コード例 #1
0
    void MoveCharacterToTile(GameObject character, GameObject tile)
    {
        GameTile      tileInstance  = tile.GetComponent <GameTile>();
        BaseCharacter baseCharacter = character.GetComponent <BaseCharacter>();

        // Unhighlight current tiles
        baseCharacter.ResetMovableTiles();

        // Move character to tile
        if (!baseCharacter.MoveToTile(tileInstance))
        {
            DeselectItems();
        }
        else
        {
            // Remake movable tiles list
            baseCharacter.MovableTiles.Clear();
            int moveThreshhold = baseCharacter.GetMoveThreshhold();
            // Reindex character movable tiles
            for (int i = (int)baseCharacter.Coordinates.x - moveThreshhold; i <= (int)baseCharacter.Coordinates.x + moveThreshhold; i++)
            {
                for (int j = (int)baseCharacter.Coordinates.z - moveThreshhold; j <= (int)baseCharacter.Coordinates.z + moveThreshhold; j++)
                {
                    if (isTileInBounds(i, j) && baseCharacter.IsTileMovable(tileInstance))
                    {
                        GameTile curTile = Board [i, j].GetComponent <GameTile> ();
                        curTile.IsSelected = true;
                        curTile.ChangeMaterial();
                        baseCharacter.MovableTiles.Add(curTile);
                    }
                }
            }
        }
    }