Exemple #1
0
        /// <summary>
        /// Adds a building with the given type and position to this player's information.
        /// </summary>
        /// <param name="type">Type of building.</param>
        /// <param name="x">The x coordinate in the grid.</param>
        /// <param name="y">The y coordinate in the grid.</param>
        /// <param name="status">The status of the entity.</param>
        public void AddBuilding(Storage.BuildingTypes type, float x, float y, EntityStatus status)
        {
            PlayableEntity e = new PlayableEntity();

            e.type.building = type;
            e.position.X    = x;
            e.position.Y    = y;
            e.hasStatus     = true;
            e.status        = status;
            buildings.Add(e);
        }
Exemple #2
0
        /// <summary>
        /// Adds a building with the given type and position to this player's information.
        /// </summary>
        /// <param name="type">Type of building.</param>
        /// <param name="x">The x coordinate in the grid.</param>
        /// <param name="y">The y coordinate in the grid.</param>
        public void AddBuilding(Storage.BuildingTypes type, float x, float y)
        {
            PlayableEntity e = new PlayableEntity();

            e.type.building = type;
            e.entityType    = Storage.EntityType.BUILDING;
            e.position.X    = x;
            e.position.Y    = y;
            e.hasStatus     = false;
            buildings.Add(e);
        }
Exemple #3
0
 /// <summary>
 /// Some buildings need a different rotation, not the default. In order to be shown properly
 /// </summary>
 /// <param name="race"></param>
 /// <param name="type"></param>
 private void CheckBuildingDefaultRotation(Storage.Races race, Storage.BuildingTypes type)
 {
     if (type == Storage.BuildingTypes.SAWMILL)
     {
         Debug.Log("Applying rotation to " + type);
         ApplyRotation();
     }
     else if (race == Storage.Races.MEN && type == Storage.BuildingTypes.ARCHERY)
     {
         Debug.Log("Applying rotation to " + race + " " + type);
         ApplyRotation();
     }
 }
Exemple #4
0
 /// <summary>
 /// Starts creating a building, required the name of the building ex: 'elf-farm'
 /// </summary>
 /// <param name="name"></param>
 public void createBuilding(Storage.Races race, Storage.BuildingTypes type, bool continuousConstruction = false)
 {
     if (!_newBuilding.placing && isAffordable(race, type))
     {
         _newBuilding.race     = race;
         _newBuilding.type     = type;
         _newBuilding.ghost    = CreateGhostBuilding(race, type);
         _newBuilding.material = _newBuilding.ghost.GetComponent <Renderer>().material;
         _newBuilding.placing  = true;
         _newBuilding.continuousConstruction = continuousConstruction;
         BasePlayer.player.setCurrently(Player.status.PLACING_BUILDING);
         CheckBuildingDefaultRotation(race, type);
     }
 }
Exemple #5
0
 public void OnBuildingDestroyed(Storage.BuildingTypes type)
 {
     uint[] missionTargets;
     if (buildings.TryGetValue(type, out missionTargets))
     {
         if (missionTargets[0] > 0)   // There are targets in the "to be destroyed" slot
         {
             missionTargets[0]--;
             if (missionTargets[0] == 0)
             {
                 controller.notifyBuildingDestroyed(type, owner);
             }
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// Creates a building in the given position.
        /// </summary>
        /// <returns>The building, if the position is available for
        /// construction, or <code>null</code>.</returns>
        ///
        /// <param name="position">The position of the building.</param>
        /// <param name="rotation">The rotation of the building.</param>
        /// <param name="type">The type of building.</param>
        /// <param name="race">The race this building belongs to.</param>
        public GameObject createBuilding(Vector3 position, Quaternion rotation,
                                         Storage.BuildingTypes type, Storage.Races race, bool checkFow, float yOffset = 0)
        {
            GameObject obj = null;

            position.y += yOffset;
            position    = grid.discretizeMapCoords(position);
            if (grid.isNewPositionAbleForConstrucction(position, checkFow))
            {
                position.y -= yOffset - 0.1f;
                obj         = Storage.Info.get.createBuilding(race, type, position, rotation);
                if (type == Storage.BuildingTypes.STRONGHOLD)
                {
                    grid.reservePositionForStronghold(position);
                }
                grid.reservePosition(position);
            }
            return(obj);
        }
    public void notifyBuildingDestroyed(Storage.BuildingTypes type, int caller)
    {
        bool notify = false;
        int  winner;

        if (destroyedBuildingsWinners.TryGetValue(type, out winner))
        {
            if (winner == 0)
            {
                notify = true;
                destroyedBuildingsWinners[type] = caller;
                missionsToComplete--;
            }
        }
        if (notify)
        {
            // TODO for each player, indicate winner
        }
    }
Exemple #8
0
 /// <summary>
 /// Returns the building of the spcedified type
 /// </summary>
 /// <param name="race"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 private GameObject CreateFinalBuilding(Storage.Races race, Storage.BuildingTypes type)
 {
     return(Storage.Info.get.createBuilding(race, type));
 }
Exemple #9
0
        /// <summary>
        /// Returns the ghost building of the specified type
        /// </summary>
        /// <param name="race"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private GameObject CreateGhostBuilding(Storage.Races race, Storage.BuildingTypes type)
        {
            GameObject ghost = Storage.Info.get.createBuilding(race, type, new Vector3(0, 0, 0), Quaternion.identity, Storage.Info.BuildingVariant.GHOST);

            return(ghost);
        }
Exemple #10
0
        public bool isAffordable(Storage.Races race, Storage.BuildingTypes type)
        {
            Storage.BuildingInfo i = Storage.Info.get.of(race, type);

            return(ResourcesPlacer.get(BasePlayer.player).enoughResources(i.resources));
        }
Exemple #11
0
 public void notifyBuildingCreated(Storage.BuildingTypes type, int caller)
 {
 }
Exemple #12
0
    private void DisplayBuildingDestroyed(Storage.BuildingTypes type)
    {
        switch (type)
        {
        case Storage.BuildingTypes.STRONGHOLD:
            AppendMessage(STRONGHOLD_LOST);
            break;

        case Storage.BuildingTypes.ARCHERY:
            AppendMessage(SHOOTING_RANGE_LOST);
            break;

        case Storage.BuildingTypes.BARRACK:
            AppendMessage(BARRACK_LOST);
            break;

        case Storage.BuildingTypes.FARM:
            AppendMessage(FARM_LOST);
            break;

        case Storage.BuildingTypes.MINE:
            AppendMessage(MINE_LOST);
            break;

        case Storage.BuildingTypes.SAWMILL:
            AppendMessage(SAWMILL_LOST);
            break;

        case Storage.BuildingTypes.STABLE:
            AppendMessage(STABLE_LOST);
            break;

        case Storage.BuildingTypes.WATCHTOWER:
            AppendMessage(WATCHTOWER_LOST);
            break;

        case Storage.BuildingTypes.WALLCORNER:
        case Storage.BuildingTypes.WALL:
            AppendMessage(WALL_LOST);
            break;

        case Storage.BuildingTypes.WALLGATE:
            AppendMessage(WALL_GATE_LOST);
            break;

        case Storage.BuildingTypes.ARTILLERY:
            AppendMessage(ARTILLERY_BUILDING_LOST);
            break;

        case Storage.BuildingTypes.ENT:
            AppendMessage(ENT_BUILDING_LOST);
            break;

        case Storage.BuildingTypes.GRYPHON:
            AppendMessage(GRYPHON_BUILDING_LOST);
            break;

        case Storage.BuildingTypes.SPECIAL:
            AppendMessage(SPECIAL_UNITS_BUILDING_LOST);
            break;

        case Storage.BuildingTypes.WORKSHOP:
            AppendMessage(WORKSHOP_LOST);
            break;
        }
        sounds.onBuildingDestroyed();
    }