public void SetPlayerData(PlayerObj playerObj, ChampionObj championObj) { for (int i = 0; i < sellItemSlots.Count; i++) { if (playerObj.Items.ToList().Any(x => x.SlotNum == i)) { sellItemSlots[i].gameObject.SetActive(true); CombatObj itemObj = playerObj.Items.ToList().First(x => x.SlotNum == i); sellItemSlots[i].SetData(CombatTable.Instance.GetCombatData(itemObj.Type).Sprite, network.GetItemTable(itemObj.Type).SellingPrice); } else { sellItemSlots[i].gameObject.SetActive(false); } } goldText.text = playerObj.Gold.ToString("F0") + "G"; if (playerObj.Effects.Any(x => x.Type == CombatType.OnBase)) { sellItemSlots.ForEach(x => x.SetButtonInteractable(true)); buyButton.interactable = true; } else { sellItemSlots.ForEach(x => x.SetButtonInteractable(false)); buyButton.interactable = false; } }
void Start() { network = GameObject.Find("Network").GetComponent <Network>(); List <TMP_Dropdown.OptionData> options = new List <TMP_Dropdown.OptionData>(); foreach (UnitType type in Enum.GetValues(typeof(UnitType))) { if (type >= UnitType.HatsuneMiku) { options.Add(new TMP_Dropdown.OptionData(type.ToString())); } } unitTypeDropdown.options = options; SnapshotObj snapshotObj = GameObject.Find("UnitManager").GetComponent <UnitManager>().GetSnapshotObj(); if (snapshotObj != null) { ChampionObj championObj = snapshotObj.ChampionObjs.ToList().FirstOrDefault(x => x.UnitID == snapshotObj.PlayerObj.UnitID); if (championObj != null) { teamDropdown.value = teamDropdown.options.FindIndex(x => x.text == championObj.Team.ToString()); nameInputField.text = championObj.DisplayName; unitTypeDropdown.value = unitTypeDropdown.options.FindIndex(x => x.text == championObj.Type.ToString()); } } }
public void Init(IGetUnitInfo info) { Info = info; UnitType unitType = info.GetUnitType(); Instantiate(UnitTable.Instance.GetUnitModel(unitType).Model, modelRoot); //Movement GetComponent <Movement>().Init(new Vector3(info.GetXPos(), info.GetYPos(), info.GetZPos()), info.GetRotation()); //Animation IGetAnimInfo animInfo = info as IGetAnimInfo; if (animInfo != null) { GetComponent <Animation>().Init(animInfo.GetAnimType(), animInfo.GetSpeedRate(), animInfo.GetPlayTime()); } //HealthBar if (UnitType.Core <= unitType && unitType <= UnitType.Tower) { BuildingObj obj = info as BuildingObj; healthBarInstance = Instantiate(generalHealthBar, GameObject.Find("HealthBars").transform); healthBarInstance.GetComponent <GeneralHealthBar>().SetData(new Vector3(transform.position.x, 2.6f, transform.position.z), obj.MaxHP, obj.CurHP, obj.Team); } else if (UnitType.TowerBullet <= unitType && unitType <= UnitType.PressurisedSteam) { ActorObj obj = info as ActorObj; } else if (UnitType.Minion <= unitType && unitType <= UnitType.UltraMonster) { UnitObj obj = info as UnitObj; healthBarInstance = Instantiate(generalHealthBar, GameObject.Find("HealthBars").transform); healthBarInstance.GetComponent <GeneralHealthBar>().SetData(new Vector3(transform.position.x, 2.0f, transform.position.z), obj.MaxHP, obj.CurHP, obj.Team); } else { ChampionObj obj = info as ChampionObj; healthBarInstance = Instantiate(championHealthBar, GameObject.Find("HealthBars").transform); SetChampionHealthBarData(obj); } //Minimap if (unitType < UnitType.HatsuneMiku) { dotInstance = Instantiate(generalDot, GameObject.Find("MinimapUI").transform); dotInstance.GetComponent <GeneralDot>().SetData(info.GetTeam(), new Vector2(info.GetXPos(), info.GetZPos())); } else { dotInstance = Instantiate(championDot, GameObject.Find("MinimapUI").transform); dotInstance.GetComponent <ChampionDot>().SetData(info.GetUnitType(), info.GetTeam(), new Vector2(info.GetXPos(), info.GetZPos())); } }
public void SetPlayerData(PlayerObj playerObj, ChampionObj championObj) { if (state == FrontUIState.ItemUIOpen) { itemUI.SetPlayerData(playerObj, championObj); } else if (state == FrontUIState.ClientUIOpen) { } }
public void UpdateData(IGetUnitInfo info) { Info = info; UnitType unitType = info.GetUnitType(); //Movement GetComponent <Movement>().SetPosition(new Vector3(info.GetXPos(), info.GetYPos(), info.GetZPos()), info.GetRotation(), info.GetWarped()); //Animation IGetAnimInfo animInfo = info as IGetAnimInfo; if (animInfo != null) { GetComponent <Animation>().SetAnime(animInfo.GetAnimType(), animInfo.GetSpeedRate(), animInfo.GetPlayTime()); } if (UnitType.Core <= unitType && unitType <= UnitType.Tower) { BuildingObj obj = info as BuildingObj; healthBarInstance.GetComponent <GeneralHealthBar>().SetData(new Vector3(transform.position.x, 2.6f, transform.position.z), obj.MaxHP, obj.CurHP, obj.Team); } else if (UnitType.TowerBullet <= unitType && unitType <= UnitType.PressurisedSteam) { ActorObj obj = info as ActorObj; } else if (UnitType.Minion <= unitType && unitType <= UnitType.UltraMonster) { UnitObj obj = info as UnitObj; healthBarInstance.GetComponent <GeneralHealthBar>().SetData(new Vector3(transform.position.x, 2.0f, transform.position.z), obj.MaxHP, obj.CurHP, obj.Team); } else { ChampionObj obj = info as ChampionObj; SetChampionHealthBarData(obj); } //Minimap if (unitType < UnitType.HatsuneMiku) { dotInstance.GetComponent <GeneralDot>().SetData(info.GetTeam(), new Vector2(info.GetXPos(), info.GetZPos())); } else { dotInstance.GetComponent <ChampionDot>().SetData(info.GetUnitType(), info.GetTeam(), new Vector2(info.GetXPos(), info.GetZPos())); } //Victory if (unitType == UnitType.Core && info.GetCurHP() <= 0) { GameObject.Find("VictoryUI").GetComponent <VictoryUI>().SetVictory(info.GetTeam()); } }
public void SetSnapshot(SnapshotObj snapshotObj) { this.snapshotObj = snapshotObj; Dictionary <int, GameObject> removeInstances = new Dictionary <int, GameObject>(unitInstances); UpdateData(snapshotObj.ChampionObjs, removeInstances); UpdateData(snapshotObj.BuildingObjs, removeInstances); UpdateData(snapshotObj.Vector3NoAnimObjs, removeInstances); UpdateData(snapshotObj.UnitObjs, removeInstances); foreach (var remove in removeInstances) { GameObject removeGameObject = unitInstances[remove.Key]; unitInstances.Remove(remove.Key); Destroy(removeGameObject); } if (unitInstances.ContainsKey(snapshotObj.PlayerObj.UnitID)) { GameObject playerUnitInstance = unitInstances[snapshotObj.PlayerObj.UnitID]; PlayerObj playerObj = snapshotObj.PlayerObj; ChampionObj championObj = (ChampionObj)playerUnitInstance.GetComponent <Unit>().Info; Camera.main.GetComponent <RTSCamera>().SetTarget(playerUnitInstance.transform); playerController.SetPlayerUnit(playerUnitInstance); playerController.SetPlayerObj(playerObj); playerUI.SetPlayerData(playerObj, championObj); recallUI.SetActive(championObj.AnimationNum == (byte)AnimationType.Recall); frontUI.SetPlayerData(playerObj, championObj); frontUI.SetData(snapshotObj.ClientObjs); } else { Camera.main.GetComponent <RTSCamera>().SetTarget(null); playerController.SetPlayerUnit(null); } }
public void SetPlayerData(PlayerObj playerObj, ChampionObj championObj) { switch (championObj.Team) { case Team.Blue: hpImage.color = new Color(0, 0, 1); break; case Team.Red: hpImage.color = new Color(1, 0, 0); break; default: hpImage.color = new Color(1, 1, 0); break; } hpSlider.value = championObj.CurHP / championObj.MaxHP; mpSlider.value = championObj.CurMP / championObj.MaxMP; expSlider.value = playerObj.Exp / playerObj.NextExp; hpText.text = championObj.CurHP.ToString("F0") + "/" + championObj.MaxHP.ToString("F0"); mpText.text = championObj.CurMP.ToString("F0") + "/" + championObj.MaxMP.ToString("F0"); goldText.text = playerObj.Gold.ToString("F0") + "G"; for (int i = 0; i < effectIconInstances.Count; i++) { if (i < playerObj.Effects.Length) { effectIconInstances[i].SetActive(true); effectIconInstances[i].GetComponent <Icon>().SetCombatObj(playerObj.Effects[i]); } else { effectIconInstances[i].SetActive(false); } } for (int i = 0; i < itemsInstance.Count; i++) { if (playerObj.Items.ToList().Any(x => x.SlotNum == i)) { itemsInstance[i].SetActive(true); itemsInstance[i].GetComponent <Icon>().SetCombatObj(playerObj.Items.ToList().First(x => x.SlotNum == i)); } else { itemsInstance[i].SetActive(false); } } foreach (CombatObj item in playerObj.Items) { itemsInstance[item.SlotNum].GetComponent <Icon>().SetCombatObj(item); } for (int i = 0; i < skillsInstance.Count; i++) { if (playerObj.Skills.ToList().Any(x => x.SlotNum == i)) { skillsInstance[i].SetActive(true); skillsInstance[i].GetComponent <Icon>().SetCombatObj(playerObj.Skills.ToList().First(x => x.SlotNum == i)); } else { skillsInstance[i].SetActive(false); } } }
void SetChampionHealthBarData(ChampionObj championObj) { healthBarInstance.GetComponent <ChampionHealthBar>().SetData(new Vector3(transform.position.x, 2.0f, transform.position.z), championObj.DisplayName, championObj.Level, championObj.MaxHP, championObj.CurHP, championObj.MaxMP, championObj.CurMP, championObj.Team); }