void ShowTeamSelectorPanel() { Builder laborCenter = BuildingManager.Instance.AllBuildings.SingleOrDefault(b => b.Type == Building.BuildingType.LaborCenter); Debug.Log($"{laborCenter.CharacterInBuilding.Count}"); Debug.Log($"{laborCenter.TeamLockState.Count}"); if (laborCenter != null) { if (laborCenter.CharacterInBuilding.Count == 1 && laborCenter.TeamLockState.Count == 0) { TeamSelectorCallback(0); CloseUpgradePanel(); return; } TeamSelectorPanel teamSelectorPanel = Resources.FindObjectsOfTypeAll <TeamSelectorPanel>()[0]; teamSelectorPanel.gameObject.SetActive(true); teamSelectorPanel.CreateTeamSelectorPanel(TeamSelectorPanel.Mode.Build, builder, LoadManager.Instance.allBuildingData[builder.Type].upgradePoint[builder.Level], TeamSelectorCallback, false); } else { Debug.Log($"No LaborCenter found. Using Default production point(5)."); BuildingManager.Instance.UpgradeBuilding(builder, 1); gameObject.GetComponent <ClosePanelHelper>().ForceClosePanel(); } }
public void OnClickReady() { TeamSelectorPanel teamSelectorPanel = Resources.FindObjectsOfTypeAll <TeamSelectorPanel>()[0]; teamSelectorPanel.gameObject.SetActive(true); teamSelectorPanel.activityName = QuestManager.Instance.selectingLevel; teamSelectorPanel.CreateTeamSelectorPanel(TeamSelectorPanel.Mode.Quest, BuildingManager.Instance.AllBuildings.SingleOrDefault(b => b.Type == Building.BuildingType.TownBase), LoadManager.Instance.allQuestData.SingleOrDefault(q => q.Value.questName == QuestManager.Instance.selectingLevel).Value.duration, QuestManager.Instance.StartQuest, true); }
void ShowTeamSelectorPanel(Builder builder, Action <int> callback) { Builder laborCenter = BuildManager.Instance.AllBuildings.SingleOrDefault(b => b.Type == Building.BuildingType.LaborCenter); if (laborCenter != null && laborCenter.Level != 0) { TeamSelectorPanel teamSelectorPanel = Resources.FindObjectsOfTypeAll <TeamSelectorPanel>()[0]; teamSelectorPanel.gameObject.SetActive(true); teamSelectorPanel.CreateTeamSelectorPanel(TeamSelectorPanel.Mode.Build, builder, LoadManager.Instance.allBuildingData[builder.Type].upgradePoint[builder.Level], callback, false); teamSelectorPanel.gameObject.GetComponent <ClosePanelHelper>().SetOnExitCallback(() => { buildPermission = false; CancleShowAvailableTiles(); }); } else { Debug.Log($"No LaborCenter found. Using Default production point(5)."); callback(0); } }
bool TryCraftItem() { Resource resourceRecipe = LoadManager.Instance.allResourceData[currentSelectedItemName]; Resource resource = LoadManager.Instance.allResourceData[currentSelectedItemName.Replace("Recipe:", "")]; if (ItemManager.Instance.IsAffordable(resourceRecipe.craftingData.craftingMaterials)) { TeamSelectorPanel teamSelectorPanel = Resources.FindObjectsOfTypeAll <TeamSelectorPanel>()[0]; teamSelectorPanel.CreateTeamSelectorPanel(TeamSelectorPanel.Mode.Craft, builder, resourceRecipe.craftingData.pointRequired, (_teamNumber) => { if (ItemManager.Instance.TryConsumeResources(resourceRecipe.craftingData.craftingMaterials)) { RefreshCraftingPanel(); } NotificationManager.Instance.AddActivity(new ActivityInformation() { activityName = ("Craft:" + resource.Name), activityType = ActivityType.Craft, startPoint = 0, requiredPoint = resourceRecipe.craftingData.pointRequired, teamNumber = _teamNumber, informationID = resource.ID, builderReferenceID = builder.ID }); builder.TeamLockState.Add(_teamNumber); GetComponent <ClosePanelHelper>().ForceClosePanel(); }, false); } else { Debug.LogError("Something happened here."); /// IsAffordable must be checked by RefreshItemInformation() before come to this function. return(false); } return(true); }
public void CreateTeamSelectableAssignSlot(GameObject container, Builder builder, int teamNumber, int point, bool isInteractable) { Building buildData = LoadManager.Instance.allBuildingData[builder.Type]; GameObject assignPanelGO = Instantiate(Resources.Load("Prefabs/UI/AssignPanelPrefab") as GameObject, container.transform); assignPanelGO.GetComponentInChildren <Text>().text = $"Team {teamNumber + 1}"; if (builder.TeamLockState.Contains(teamNumber)) { assignPanelGO.GetComponent <Image>().color = Color.red; } else { assignPanelGO.AddComponent <Button>().onClick.AddListener(() => { TeamSelectorPanel teamSelectorPanel = GameObject.FindObjectOfType <TeamSelectorPanel>(); teamSelectorPanel.OnClickConfirmTeam(teamNumber); }); } if (builder.Type == Building.BuildingType.LaborCenter) { float productionPoint = (float)(LoadManager.Instance.allBuildingData[Building.BuildingType.LaborCenter].production[builder.Level]["Production"]); if (builder.CharacterInBuilding != null) { productionPoint += builder.CharacterInBuilding[teamNumber].Characters.Sum(c => ((c.Stats.strength * 0.2f / 8) + (c.Stats.speed * 0.2f / 8) + (c.Stats.craftsmanship * 0.8f / 3))); } assignPanelGO.transform.Find("Duration").GetComponent <Text>().text = GetFormattedDuration((int)(point / productionPoint)); } else if (builder.Type == Building.BuildingType.TownBase) { assignPanelGO.transform.Find("Duration").GetComponent <Text>().text = GetFormattedDuration((int)(point)); } else if (builder.Type == Building.BuildingType.MedicalCenter || builder.Type == Building.BuildingType.Armory || builder.Type == Building.BuildingType.Kitchen) { float productionPoint = (float)(LoadManager.Instance.allBuildingData[builder.Type].production[builder.Level]["Production"]); if (builder.CharacterInBuilding != null) { productionPoint += builder.CharacterInBuilding[teamNumber].Characters.Sum(c => ((c.Stats.strength * 0.2f / 8) + (c.Stats.speed * 0.2f / 8) + (c.Stats.craftsmanship * 0.8f / 3))); } assignPanelGO.transform.Find("Duration").GetComponent <Text>().text = GetFormattedDuration((int)(point / productionPoint)); } // Debug.Log($"{point} / {productionPoint} "); List <GameObject> slotListGO = new List <GameObject>(); for (int i = 1; i <= buildData.maxCharacterStored[builder.Level].amount[teamNumber]; i++) { GameObject slotGO = new GameObject(); slotGO.transform.SetParent(assignPanelGO.transform.Find("Container")); slotGO.AddComponent <Image>().color = (teamNumber % 2 == 0 ? Color.yellow : Color.green); Slot slot = slotGO.AddComponent <Slot>(); slot.builder = builder; slot.isInteractable = isInteractable; slot.teamNumber = teamNumber; slotGO.name = "Character" + (i).ToString() + "Team" + (teamNumber); slotGO.tag = "DropSlot"; slotListGO.Add(slotGO); } for (int i = 0; i < builder.CharacterInBuilding[teamNumber].Characters.Count; i++) { slotListGO[i].GetComponent <Slot>().character = builder.CharacterInBuilding[teamNumber].Characters[i]; } }