public void RemoveCDToDuel(int CD) { List <GameObject> tmp_rm = new List <GameObject>(); for (int sts = 0; sts < DuelList.Count; sts++) { if (DuelList[sts] != null) { var stmp = (DuelList[sts]).GetComponent <StatusEffectViewSetting>(); if (stmp.Turns - CD <= 0) { tmp_rm.Add(DuelList[sts]); } else { stmp.Turns -= CD; } } } foreach (var d in tmp_rm) { d.GetComponent <StatusEffectViewSetting>().Remove(); DuelList.Remove(d); } }
public bool InsertStatusToDuel(int status_id, int CD) { foreach (var t in DuelList) { if (t != null) { var y = t.GetComponent <StatusEffectViewSetting>(); if (y.st_id == status_id) { y.Turns += CD; return(true); } } } var targ = new ULZAsset.StatusObject(); foreach (var sobj in StatusOpt) { if (sobj.id == status_id) { targ = sobj; } } GameObject ff = (GameObject)Instantiate(StatusPrefab, new Vector3(0, 0, 0), Quaternion.identity); var t2d = MainEffectAB.LoadAsset(targ.img) as Texture2D; ff.name = "status_ins" + this.DuelList.Count.ToString(); ff.transform.SetParent(DuelStatusViewList.transform); ff.GetComponent <StatusEffectViewSetting>().st_id = status_id; ff.GetComponent <StatusEffectViewSetting>().Icon.sprite = Sprite.Create( t2d, new Rect(-0.2f, 0, t2d.width, t2d.height), new Vector2(0.5f, 0.5f) ); ff.GetComponent <StatusEffectViewSetting>().Turns = CD; var r = DuelStatusViewList.transform.position; r.y -= DuelList.Count * 0.3f; ff.transform.position = r; DuelList.Add(ff); return(true); }