Beispiel #1
0
 // =============================================================================================================
 /// <summary>
 /// Check if the selected building can really train a unit
 /// </summary>
 /// <param name="building"></param>
 /// <param name="unit"></param>
 /// <param name="showErrorMsgs"></param>
 /// <returns></returns>
 private void BuildingTryToTrainUnit(BuildingBehaviour building, CharacterData unit, bool showErrorMsgs)
 {
     if (building.GetActionTimer > 0)
     {
         if (showErrorMsgs)
         {
             ShowWarningText(CoreManager.Instance.Language_GetTextById("msg_alreadyTraining"));
         }
         return;
     }
     if (levelGold < unit.goldCost)
     {
         if (showErrorMsgs)
         {
             ShowWarningText(CoreManager.Instance.Language_GetTextById("msg_noGold"));
         }
         return;
     }
     if (building.GetActionTimer > 0)
     {
         return;
     }
     building.TrainUnit();
     GoldAdd(-unit.goldCost);
     UpdateBuildingUi();
 }
Beispiel #2
0
 // =============================================================================================================
 /// <summary>
 /// Cancel the selection of a building in game.
 /// </summary>
 private void CancelSelection()
 {
     if (buildingSelected != null)
     {
         buildingSelected.BuildingSelectedToggle(false);
     }
     buildingSelected = null;
     uiBuildingDetails.SetActive(false);
     uiMoveModeDetails.SetActive(true);
 }
Beispiel #3
0
        // =============================================================================================================
        /// <summary>
        /// Select a building from the scene (already built).
        /// </summary>
        private void BuildingSelFromScene(BuildingBehaviour building)
        {
            if (buildingSelected != null)
            {
                buildingSelected.BuildingSelectedToggle(false);
            }

            buildingSelected = building;
            buildingSelected.BuildingSelectedToggle(true);
            unitToBuild = buildingSelected.GetUnitDataType;
            uiBuildingDetails.SetActive(true);
            uiMoveModeDetails.SetActive(false);
            uiBuildSelIcon.sprite = buildingSelected.GetPropType.picture;
            uiBuildSelName.text   = buildingSelected.GetPropType.propName;
            if (buildingSelected.GetPropType.objectType == ObjectType.BuildingFarm)
            {
                uiBuildSelUnitName.text = CoreManager.Instance.Language_GetTextById("goldIncome");
                uiBuildSelField1.text   = "<color=yellow>+" + buildingSelected.GetPropType.goldGenerate + " / " +
                                          buildingSelected.GetPropType.timerForGoldIncome + "s";
                uiBuildSelField2.text           = "<color=yellow>Bonus: +" + buildingSelected.GetGoldBonusPerTree;
                uiBuildSelUnitImg.sprite        = uiGoldIcon;
                uiBuildSelTrainBtn.interactable = false;
            }
            else if (buildingSelected.GetPropType.objectType == ObjectType.BuildingBarracks ||
                     buildingSelected.GetPropType.objectType == ObjectType.BuildingDefenseTw ||
                     buildingSelected.GetPropType.objectType == ObjectType.BuildingMagicTw)
            {
                uiBuildSelUnitName.text = CoreManager.Instance.Language_GetCharacterName(unitToBuild.unitName) +
                                          " (" + unitToBuild.goldCost + " G)";
                uiBuildSelField1.text           = "<color=red>ATK: " + unitToBuild.damage;
                uiBuildSelField2.text           = "<color=blue>DEF: " + unitToBuild.defense;
                uiBuildSelUnitImg.sprite        = unitToBuild.picture;
                uiBuildSelTrainBtn.interactable = true;
            }
            UpdateBuildingUi();
        }
 // =============================================================================================================
 private void Start()
 {
     buildingMain         = GetComponent <BuildingBehaviour>();
     currentTimerToShoot  = buildingMain.GetPropType.defenseAttackRate;
     currentTimerToSearch = timerToSearchForTarget;
 }