The player and hamsa health was going below 0, so to get around this I added an if statement.
Add an attack script for the Hamsa’s
This attack is similar to the pulse.
I attached it to the gameObject Hamsas which stores all the Hamsa’s.
On the enemy script add a TakeDamage script which listens for the attack.timeUp.
I added in an update to check when the enemies health = 0 as this will end the game.
Now I need the attack to start only when all the Hamsa’s have some health. I created a hamsaManager which contains a list of hamsa’s by tagging all the Hamsa – “Hamsa”.
Then for the length of the list I check if any of the Hamsa’s have 0 health, if they do, the manage sends a message of died = true.
In my Attack script:
- I added the OnEnable/OnDisable, for the HamsaManager died.
- Then StopAttacking, which takes a bool of dead.
- When a Hamsa has died it sends a message here to say that one is dead
- But I need to add, the tell it to stop attacking.
- In order for this all to work, the healing mechanics needs to be in.
Creating a Tile Manager, the tile manager will look after the colour of the tiles, and is attached to the tile GameObject (which holds all the individual tiles)
In the script I make a private GameObject list to store all my tiles, I then fill this list with all the GameObjects with the tag “Tile”
Actually maybe it would be better to put this type of information into a level manager… I am going to make a new script. I make a new script and new empty GameObject in the hierarchy and call it level, attaching the level manager to it.
In the Level Manager, I actually want lists of the:
- tiles on the floor
- hamsas on the floor
- colours available?
Back to the Hamsa Manager, I just call in the list made by the LevelManager
I do the same for the tileManager
Assign initial Colours in the tileManager: