Пример #1
0
        /// <summary>
        /// Need to unify this method with players one.
        /// </summary>
        /// <param name="race"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool isAffordable(Storage.Races race, Storage.BuildingTypes type)
        {
            Storage.BuildingInfo i = Storage.Info.get.of(race, type);

            return(ResourcesPlacer.get(BasePlayer.ia).enoughResources(WorldResources.Type.FOOD, i.resources.food) &&
                   ResourcesPlacer.get(BasePlayer.ia).enoughResources(WorldResources.Type.WOOD, i.resources.wood) &&
                   ResourcesPlacer.get(BasePlayer.ia).enoughResources(WorldResources.Type.METAL, i.resources.metal));
        }
Пример #2
0
    /// <summary>
    /// Initializes a player for a battle.
    /// </summary>
    /// <returns>The player.</returns>
    /// <param name="race">The player's race.</param>
    /// <param name="strongholdGameObject">Name of the game object placed where
    /// the player's stronghold should be.</param>
    private Battle.PlayerInformation initializePlayer(Storage.Races race, string strongholdGameObject)
    {
        GameObject stronghold;

        Battle.PlayerInformation player = new Battle.PlayerInformation(race);
        stronghold = GameObject.Find(strongholdGameObject);
        player.AddBuilding(BuildingTypes.STRONGHOLD, stronghold.transform.position.x, stronghold.transform.position.z, EntityStatus.IDLE);
        player.AddUnit(UnitTypes.HERO, stronghold.transform.position.x - 50, stronghold.transform.position.z);
        player.SetInitialResources(2000, 2000, 2000, 2000);
        return(player);
    }
Пример #3
0
    public static List <Unit> getVisibleUnitsNotOfRaceNearPosition(Vector3 position, float radius, Storage.Races race)
    {
        GameObject[] foundGameObjects = getObjectsNearPosition(position, radius);
        List <Unit>  unitsOfRace      = new List <Unit>();

        for (int i = 0; i < foundGameObjects.Length; i++)
        {
            GameObject obj       = foundGameObjects[i];
            Unit       objUnit   = obj.GetComponent <Unit>();
            FOWEntity  fowEntity = obj.GetComponent <FOWEntity>();

            if (objUnit == null || fowEntity == null)
            {
                continue;
            }

            if (objUnit.race != race && objUnit.status != EntityStatus.DEAD && fowEntity.IsRevealed)
            {
                unitsOfRace.Add(objUnit);
            }
        }
        return(unitsOfRace);
    }