Exemplo n.º 1
0
    public void TryPlacePawnOnTile(Tile tile)
    {
        if (tile.Pawn != null)
        {
            return;
        }

        Location curLoc = new Location();

        for (int i = 0; i < Location.FiveSlice.Length; i++)
        {
            curLoc = tile.Location + Location.FiveSlice[i];
            if (Map.IsInMapBounds(curLoc))
            {
                Tile placeableTile = Map.Tiles[curLoc.X, curLoc.Y];
                if (placeableTile.Pawn != null &&
                    placeableTile.Pawn.Owner == Player.CurrentTurn &&
                    placeableTile.Pawn == Player.CurrentTurn.Leader)
                {
                    PawnAssetInfo assetInfo = Player.CurrentTurn == Player1 ? GameAssets.Inst.Swordsmen[(int)Player1.Tribe] : GameAssets.Inst.Swordsmen[(int)Player1.Tribe];
                    Player.CurrentTurn.Swordsmen.Add(GameSetup.Inst.InstantiatePawnAt(tile, assetInfo, Player.CurrentTurn));
                }
            }
        }
    }
Exemplo n.º 2
0
    public Pawn InstantiatePawnAt(Tile tile, PawnAssetInfo prefab, Player owner)
    {
        Vector3 pos = tile.transform.position;

        pos.z = -1;
        Pawn newPawn = Instantiate(prefab.GetComponent <Pawn>(), pos, PawnPrefab.transform.rotation, PawnParent);

        newPawn.transform.localScale = tileSize;
        newPawn.Location.X           = tile.Location.X;
        newPawn.Location.Y           = tile.Location.Y;

        newPawn.AssetInfo = prefab;
        newPawn.Owner     = owner;

        if (prefab.Class == Class.Swordsman)
        {
            owner.Swordsmen.Add(newPawn);
        }
        else
        {
            owner.Leader = newPawn;
        }

        Map.Tiles[tile.Location.X, tile.Location.Y].Pawn = newPawn;

        return(newPawn);
    }