public void ActivateEquipment(string equipmentId) { CurrentPlayer currentPlayer = Service.CurrentPlayer; EquipmentVO currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(equipmentId); if (currentEquipmentDataByID == null) { Service.Logger.Warn("Invalid EquipmentID: " + equipmentId); return; } if (currentPlayer.ActiveArmory.Equipment.Contains(currentEquipmentDataByID.Uid)) { return; } if (ArmoryUtils.GetCurrentActiveEquipmentCapacity(currentPlayer.ActiveArmory) + currentEquipmentDataByID.Size > currentPlayer.ActiveArmory.MaxCapacity) { string instructions = Service.Lang.Get("ARMORY_FULL", new object[0]); Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions); return; } if (!ArmoryUtils.IsEquipmentOnValidPlanet(currentPlayer, currentEquipmentDataByID)) { string instructions2 = Service.Lang.Get("BASE_ON_INCORRECT_PLANET", new object[0]); Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions2); return; } currentPlayer.ActiveArmory.Equipment.Add(currentEquipmentDataByID.Uid); Service.EventManager.SendEvent(EventId.EquipmentActivated, currentEquipmentDataByID); EquipmentIdRequest request = new EquipmentIdRequest(equipmentId); ActivateEquipmentCommand activateEquipmentCommand = new ActivateEquipmentCommand(request); activateEquipmentCommand.Context = equipmentId; activateEquipmentCommand.AddFailureCallback(new AbstractCommand <EquipmentIdRequest, DefaultResponse> .OnFailureCallback(this.OnActivateEquipmentFailure)); Service.ServerAPI.Enqueue(activateEquipmentCommand); }
private void SetDimmerBasedOnRequirements(CurrentPlayer player, EquipmentVO equipment) { UXSprite subElement = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteDim"); UXSprite subElement2 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteDimFull"); UXLabel subElement3 = this.inactiveGrid.GetSubElement <UXLabel>(equipment.Uid, "LabelEquipmentRequirement"); UXSprite subElement4 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteLockIcon"); UXElement subElement5 = this.inactiveGrid.GetSubElement <UXElement>(equipment.Uid, "PlanetLocked"); subElement2.Visible = false; subElement4.Visible = false; subElement5.Visible = false; bool flag = ArmoryUtils.IsEquipmentOwned(player, equipment); if (ArmoryUtils.IsBuildingRequirementMet(equipment) && flag && ArmoryUtils.IsEquipmentValidForPlanet(equipment, player.PlanetId)) { subElement3.Text = string.Empty; if (ArmoryUtils.HasEnoughCapacityToActivateEquipment(player.ActiveArmory, equipment)) { this.UpdateMinimumInactiveSize(equipment.Size); subElement.Visible = false; return; } subElement3.Text = this.lang.Get("ARMORY_INACTIVE_CAPACITY_REACHED", new object[0]); subElement.Visible = true; return; } else { if (!ArmoryUtils.IsBuildingRequirementMet(equipment)) { StaticDataController staticDataController = Service.StaticDataController; BuildingTypeVO buildingTypeVO = staticDataController.Get <BuildingTypeVO>(equipment.BuildingRequirement); subElement3.Text = this.lang.Get("BUILDING_REQUIREMENT", new object[] { buildingTypeVO.Lvl, LangUtils.GetBuildingDisplayName(buildingTypeVO) }); subElement2.Visible = true; subElement.Visible = false; return; } UXButton subElement6 = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentItemCard"); subElement6.Enabled = false; if (!ArmoryUtils.IsEquipmentOnValidPlanet(player, equipment) && flag) { subElement.Visible = false; subElement2.Visible = true; string planetDisplayName = LangUtils.GetPlanetDisplayName(player.PlanetId); subElement3.Text = this.lang.Get("BASE_ON_INCORRECT_PLANET", new object[] { planetDisplayName }); subElement5.Visible = true; return; } subElement.Visible = false; subElement2.Visible = true; subElement4.Visible = true; if (player.Shards.ContainsKey(equipment.EquipmentID)) { subElement3.Text = this.lang.Get("EQUIPMENT_LOCKED", new object[] { equipment.UpgradeShards - player.Shards[equipment.EquipmentID] }); } else { subElement3.Text = this.lang.Get("EQUIPMENT_LOCKED", new object[] { equipment.UpgradeShards }); } return; } }