public void LoadAsset(InfoFigure info) { if (info.asset != null) { skeleton.skeletonDataAsset = info.asset; skeleton.startingLoop = true; skeleton.Initialize(true); } }
List <int> GetRealFrends(InfoFigure x) { List <int> r = new List <int>(); foreach (int z in x.Frends) { if (Info[z].Owner.activeSelf) { r.Add(z); } } return(r); }
public void OnShow(InfoFigure info) { this.Show(); AudioManager1.Ins.PlaySound(SoundType.UnlockFigure); UIManager.Ins.popup.PlayComeReward(); UIManager.Ins.UpdatePlayerMasks(info.idFigure); asset.skeletonDataAsset = info.asset; asset.startingLoop = true; asset.Initialize(true); nameFigure.text = info.heroName; StartCoroutine(ShowRewardClaimed()); }
private void OnSelectItem(FigureItem figureItem, InfoFigure info) { // AudioManager.PlaySound(AudioManager.selectFigureName); AudioManager1.Ins.PlaySound(SoundType.Click); if (currentFigureItem != previousFigureItem || figureItem != previousFigureItem) { previousFigureItem = currentFigureItem; currentFigureItem = figureItem; previousFigureItem.SetActiveBox(); currentFigureItem.SetActiveBox(); currentInfoData = info; } if (!info.isBuy && info.mission != "") { missionInfo.GetComponentInChildren <Text>().text = info.mission; missionInfo.Show(); } if (info.isBuy) { HideAllButton(); listButton[0].Show(); } else if (info.costType == CostType.Coin) { HideAllButton(); costButtonTxt.text = info.cost.ToString(); listButton[1].Show(); } else if (info.costType == CostType.Video) { HideAllButton(); videoTxt.text = figureItem.videoTxt.text; listButton[2].Show(); } else { HideAllButton(); // listButton[3].Show(); } if (info.isUsing) { HideAllButton(); // listButton[3].Show(); } }
void CreateInfo(GameObject x) { if (x.tag == "Robot") { Robo.Add(x.name, new InfoRobot(x)); foreach (Transform child in x.transform) { if (child.tag == "Figure") { List <int> IdList = new List <int>(); IdList = GetJoinInfoId(child.gameObject); InfoFigure i = new InfoFigure(child.gameObject, IdList); Info.Add(child.gameObject.GetInstanceID(), i); Robo[x.name].DefoltHealth += i.DefoltHealth; Robo[x.name].Health += i.Health; } } } }
public void SetUp(InfoFigure info) { nameTxt.text = info.heroName; if (info.asset != null) { skeleton.skeletonDataAsset = info.asset; skeleton.startingLoop = true; skeleton.Initialize(true); } if (info.isUsing) { HideAllCostType(); costTypePre[1].Show(); } else if (info.isBuy) { HideAllCostType(); } else if (info.costType == CostType.Coin) { HideAllCostType(); costTypePre[0].Show(); costTxt.text = info.cost.ToString(); } else if (info.costType == CostType.Video) { HideAllCostType(); costTypePre[2].Show(); } else if (info.costType == CostType.Vip) { HideAllCostType(); costTypePre[3].GetComponent <Text>().text = "Vip"; costTypePre[3].Show(); } else { HideAllCostType(); costTypePre[3].Show(); } }
public void RetrievingData() { // var path = "Assets/Skin"; // Object[] data = Resources.LoadAll(path, typeof(Sprite)); // Debug.Log(data.Length); // foreach (var item in data) // { // Debug.Log(item); // } var sp = GameHelper.GetAllAssetAtPath <Sprite>("", "Assets/Skin"); ReadExcelOnline.Connect(); ReadExcelOnline.GetTable(ID, sheetName, d => { // foreach (var key in d.Keys) // { // var rows = d[key]; // foreach (var item in rows.Keys) // { // Debug.Log(rows[item] + " " + key + " " + item); // } // } if (data.figures.Count > 0) { int c = 0; foreach (var key in d.Keys) { if (c < data.figures.Count) { if (key < 1) { continue; } var rows = d[key]; var temp = new InfoFigure(); temp.heroName = rows[1]; temp.figureSprite = sp.Find(n => n.name.ToLower().Contains(temp.heroName.ToLower())); var dataSke = GameHelper.GetAllAssetAtPath <SkeletonDataAsset>(null, "Assets/skin-animation/" + temp.heroName + "-ani"); temp.asset = dataSke[5]; temp.idFigure = int.Parse(rows[0]) - 1; var s = rows[2]; if (s.Contains("enemy")) { temp.costType = CostType.KillEnemy; temp.mission = s; // find and convert string numericString = ""; foreach (char ch in s) { // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces. if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-') { numericString = string.Concat(numericString, ch); } } if (int.TryParse(numericString, out int j)) { temp.number = j; } } else if (s.Contains("videos")) { temp.costType = CostType.Video; // find and convert string numericString = ""; foreach (char ch in s) { // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces. if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-') { numericString = string.Concat(numericString, ch); } } if (int.TryParse(numericString, out int j)) { temp.number = j; } } else if (s.Contains("Tournament")) { temp.costType = CostType.Tournament; temp.mission = "Phần thưởng vô địch Tournament"; } else if (s.Contains("Rate")) { temp.costType = CostType.Rate; temp.mission = s; } else if (s.Contains("Free")) { temp.costType = CostType.Free; } else if (s.Contains("ngày")) { temp.costType = CostType.Day; temp.mission = s; } else if (s.Contains("Top")) { temp.costType = CostType.Top; temp.mission = s; // find and convert string numericString = ""; foreach (char ch in s) { // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces. if ((ch > '1' && ch <= '9') || ch == ' ' || ch == '-') { numericString = string.Concat(numericString, ch); } } if (int.TryParse(numericString, out int j)) { temp.number = j; } } else if (s.Contains("Chạy")) { temp.costType = CostType.Run; temp.mission = s; // find and convert string numericString = ""; foreach (char ch in s) { // Check for numeric characters (0-9), a negative sign, or leading or trailing spaces. if ((ch >= '0' && ch <= '9') || ch == ' ' || ch == '-') { numericString = string.Concat(numericString, ch); } } if (int.TryParse(numericString, out int j)) { temp.number = j; } } else if (s.Contains("VIP")) { temp.costType = CostType.Vip; temp.mission = s; } else { temp.costType = CostType.Coin; } if (temp.costType == CostType.Coin) { temp.cost = int.Parse(s); } data.figures[c] = temp; c++; } } } }); EditorUtility.SetDirty(data); AssetDatabase.SaveAssets(); }
void Damaging(GameObject x, int damage, string name) { if (!Info.ContainsKey(x.GetInstanceID())) { return; } InfoFigure w = Info[x.GetInstanceID()]; if (!x.activeSelf) { //print("Выход по пизде"); return; } if (damage < w.Health) { w.Health -= damage; Robo[name].Health -= damage; //dark figure HealthColoring(w); } else { damage -= w.Health; x.SetActive(false); if (w.Frends.Count == 0) { Robo[name].Health -= w.Health; w.Health = 0; foreach (int q in w.Frends) { Info[q].RealFrendsCount--; } return; } List <int> RealFrends = GetRealFrends(w); if (RealFrends.Count > 0) { damage /= RealFrends.Count; //проверка на огрызки и удаление их CheckIsolatedSegmentS(w, name); //new Robo[name].Health -= w.Health; w.Health = 0; foreach (int q in w.Frends) { Info[q].RealFrendsCount--; } //new foreach (int z in RealFrends) { if (Info[z].Health > 0) { Damaging(Info[z].Owner, damage, name); } } } else { Robo[name].Health -= w.Health; w.Health = 0; foreach (int q in w.Frends) { Info[q].RealFrendsCount--; } } } //print("2)Health in "+w.Owner.name+" = "+w.Health+ " Robo.Health=" + Robo[name].Health); }
void HealthColoring(InfoFigure w) { float ratio = (float)w.Health / w.DefoltHealth; Coloring(w.Owner, Setup.Figures[w.Id].GO, w.BaseColor, ratio); }
void CheckIsolatedSegmentS(InfoFigure x, string name) { List <int> RealFrends = GetRealFrends(x); List <int>[] Segment = new List <int> [RealFrends.Count]; int[] SegmentHealth = new int[RealFrends.Count]; for (int i = 0; i < RealFrends.Count; i++) { Stack = new List <int>(); GetSegment(RealFrends[i]); Segment[i] = Stack; SegmentHealth[i] = SumHealth(Segment[i]); } foreach (List <int> s in Segment) { //print("s.Count=" + s.Count + " SumHealth(s)=" + SumHealth(s)); } int maxValue = SegmentHealth.Max(); int maxIndex = SegmentHealth.ToList().IndexOf(maxValue); //print("maxValue =" + maxValue + " maxIndex =" + maxIndex); if (x.Owner.transform.parent.name == "Tower") { //print("in rotor"); if (!Segment[maxIndex].Contains(x.Owner.transform.parent.parent.gameObject.GetInstanceID())) { //print("рукав больше тела"); foreach (int z in Segment[maxIndex]) { if (Info[z].Owner.transform.parent == x.Owner.transform.parent) { Info[z].Owner.transform.parent = Info[z].Owner.transform.root; } } } ; } if (x.Owner.name == "T0 Rotor") { //print("is rotor"); Transform Tower = x.Owner.transform.Find("Tower"); if (Info[Segment[maxIndex][0]].Owner.transform.parent.gameObject.GetInstanceID() == Tower.gameObject.GetInstanceID()) //Robot2 { //print("рукав больше тела2"); List <GameObject> box = new List <GameObject>(); foreach (Transform child in Tower) { box.Add(child.gameObject); } foreach (GameObject child in box) { child.transform.parent = child.transform.root; } } } for (int i = 0; i < SegmentHealth.Length; i++) { if (i != maxIndex) { if (!Segment[maxIndex].Contains(Segment[i][0])) { Segment[i].Reverse(); foreach (int z in Segment[i]) { Info[z].Owner.SetActive(false); Robo[name].Health -= Info[z].Health; Info[z].Health = 0; foreach (int q in Info[z].Frends) { Info[q].RealFrendsCount--; } } } } } }
void ChangeReward() { dataReward = UIManager.Ins.FindByID(idFigures[currentReward]); reward.sprite = dataReward.figureSprite; reward.SetNativeSize(); }