Пример #1
0
    public IEnumerator UnitReproduce(GridTileInfo targetTile)
    {
        yield return(new WaitForSeconds(moveAnimationInterval));

        GameObject newClone     = Instantiate(gameObject);
        PlayerUnit newCloneUnit = newClone.GetComponent <PlayerUnit>();

        newCloneUnit.GetComponent <MapObjectInfo>().currentOccupyingTile = null; // Reset new clone's MapObjectInfo's occupying tile info, because it has not been placed on the map yet

        // Place new clone on target tile
        MapManager.PlaceObject(newClone.transform, targetTile.xCoord, targetTile.zCoord);

        newCloneUnit.InitiateClone();

        // Add new clone to new clone list
        TurnManager.newCloneReproduced.Add(newCloneUnit);

        // Clear selected tile in TurnManager;
        TurnManager.currentSelectedUnitTile = null;

        yield return(new WaitForSeconds(moveAnimationInterval));

        // If new clone meet the win requirement
        if (GameManager.sGameManager.CheckWinCondition(newCloneUnit))
        {
            //GameManager.playerUnits.Add(newCloneUnit);
            GameManager.sGameManager.PlayerWin();
        }

        // Finish reproduction
        TurnManager.playerUnitReproducing = false;
        isReproducing = false;

        // Finish animation
        TurnManager.inPlayerUnitAnimation = false;
    }