Exemple #1
0
        // --------------------------------------------------------------------------------------------
        public override void Destroy()
        {
            base.Destroy();

            _owner.PlayerTurnStarted -= Player_PlayerTurnStarted;
            _owner.PlayerTurnEnded   -= Player_PlayerTurnEnded;

            BoardTile?.SetOccupant(null);
            BoardTile = null;
        }
Exemple #2
0
        // --------------------------------------------------------------------------------------------
        public void OccupyBoardTile(BoardTile newTile, bool asChild)
        {
            // do this check so that OccupyBoardTile can be called arbitrarily without re-occupying the same boardtile
            if (BoardTile != newTile)
            {
                // leave the current tile, if it exists
                BoardTile?.SetOccupant(null);

                // set the new tile, then add this unit as an occupant
                BoardTile = newTile;
                newTile.SetOccupant(this);
            }

            if (asChild)
            {
                // parent the unit to the tile and zero out its local position
                newTile.AddChild(this);
                LocalPosition = Vector3.zero;
            }
        }