Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making inventory grid "any" shaped #1

Open
PR3CL1K opened this issue Feb 13, 2018 · 1 comment
Open

Making inventory grid "any" shaped #1

PR3CL1K opened this issue Feb 13, 2018 · 1 comment

Comments

@PR3CL1K
Copy link

PR3CL1K commented Feb 13, 2018

I'm trying to build game that is similar to building ships in StarDrive 2

stardrive2

it's mean that grid is not square but triangle or any wierd shape like ship.

Anyway, i manage to implement this into your code (i'm not programer but just learning hobbist), so it would be great if you implement it to your code so more people can acess it

"My" method is creating grid with pixel image like this https://www.youtube.com/watch?v=B_Xp9pt8nRY. After that, i just do some corection to your code so it doesn't show eror that you try acess tiles that are dont exist

  1. InvenGritScript

In CreateSlots function, inside iner for cycle i add this

if (color == map.GetPixel (x, y))
{...
..}

so it generate tile just when color (like black pixel) match your pixel map

  1. InvenGridManager

In SlotCheck function, inside iner for cycle i add this

if (slotGrid [checkStartPos.x + x, checkStartPos.y + y] != null)
{.....
...}
else return 2;

In both ColorChangeLoop, inde iner for cycle i add this

if (slotGrid[startPos.x + x, startPos.y + y] != null )
{...
...}

And this is result of future ship
result

@Not-Steve1
Copy link
Owner

Not-Steve1 commented Feb 14, 2018

This was actually the next step for the mini project of mine. An irregularly shaped grid. My plan back then was to store the ship layout with a pixel image (same with what you suggested). But It would still spawn all slots. My plan was to add a bool property to each slot that if a slot is placable(part of the ship slots). Then render a background only on the slots that are part of the ship. After, there would be lines on InvenManager that checks if the slots highlighted is all part of the ship.

You basically guessed what I was planning to do. A spaceship that you can put equipment in like a grid inventory. I was using this project to practice and learn unity. The only difference was that you can buy equipment that you can put outside the ship and some that can only be equipped if some part of it is outside(like a gun/cannon, barrel outside/rest of the parts inside). That is why my plans were different from yours.

I don't think I will update/work on this anytime soon. I had to table this project. Did not have much time between work and school. And I am already working on another project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants