//public // Start is called before the first frame update void Start() { /* int height = 18; * int width = 18; * * Matrix = new int[height, width]; * for (int i = 0; i < height; i++) * { * for (int j = 0; j < width; j++) * { * if (j == i + 1 || j == i - 1 || j == i + 3 || j == i - 3) * { * Matrix[i, j] = 1; * } * // Matrix[i, j] * } * } */ foreach (var item in ListMyNPC) { AllNPC.Add(item); } foreach (var item in ListEnemyNPC) { AllNPC.Add(item); } foreach (NPCInBattlePro item in ListMyNPC) { GameObject a = Instantiate(PreNPC, ListSlot.transform.GetChild(item.Index)); a.transform.localPosition = Vector3.zero; a.GetComponent <NPCInBattle>().NPCPro = item; a.GetComponent <NPCInBattle>().IconClass.sprite = item.Hero.Class.Pic; a.GetComponent <NPCInBattle>().BattleBody.sprite = item.Hero.BattleBody; a.GetComponent <NPCInBattle>().Filler.Value = (float)item.HP / item.MaxHP; a.GetComponent <NPCInBattle>().NPCPro.TimeSpeed = Random.Range(0, MaxSpeedTurn); } foreach (NPCInBattlePro item in ListEnemyNPC) { GameObject a = Instantiate(PreNPC, ListSlot.transform.GetChild(item.Index)); a.transform.localPosition = Vector3.zero; a.GetComponent <NPCInBattle>().NPCPro = item; a.GetComponent <NPCInBattle>().IconClass.sprite = item.Hero.Class.Pic; a.GetComponent <NPCInBattle>().BattleBody.sprite = item.Hero.BattleBody; a.GetComponent <NPCInBattle>().Filler.Value = (float)item.HP / item.MaxHP; a.GetComponent <NPCInBattle>().NPCPro.TimeSpeed = Random.Range(0, MaxSpeedTurn); a.GetComponent <NPCInBattle>().BattleBody.transform.localScale = new Vector2(-1, 1); } CheckListTempForTurn(); foreach (NPCInBattlePro item in TempForTurn) { GameObject a = Instantiate(PreTurn, ListTurn.transform); a.GetComponent <TurnCon>().NameNPC.text = item.Hero.name; } ListSlot.transform.GetChild(TempForTurn[0].Index).Find("NPCInbattle(Clone)").GetComponent <NPCInBattle>().WhiteBlink(); NPCNow = ListSlot.transform.GetChild(TempForTurn[0].Index).Find("NPCInbattle(Clone)").GetComponent <NPCInBattle>(); // CheckTurn(); // CheckTurn(); MovePreNPCNow(NPCNow.NPCPro.Hero.Class); BodyMoveIn(); }
public void SkipTurn() { for (int i = 0; i < AllNPC.Count; i++) // Xoa nhung NPC Death { if (AllNPC[i].HP <= 0) { Debug.Log(AllNPC[i].Hero.name); TempForTurn.Remove(AllNPC[i]); TempForTurn2.Remove(AllNPC[i]); Temp.Remove(AllNPC[i]); AllNPC.Remove(AllNPC[i]); } } NPCNow.Shade.gameObject.SetActive(false); TurnCount -= 1; if (AllNPC.Any(z => z.TimeSpeed >= 0)) { } else { foreach (var item in AllNPC) { item.TimeSpeed += item.Spd; } } foreach (Transform item in ListTurn.transform) { Destroy(item.gameObject); } NPCInBattlePro A = TempForTurn[0]; TempForTurn[0].TimeSpeed -= MaxSpeedTurn; TempForTurn[0].TurnCount += 1; TempForTurn.Remove(TempForTurn[0]); // Destroy(ListTurn.transform.GetChild(0).gameObject); TempForTurn2 = new List <NPCInBattlePro>(TempForTurn); CheckListTempForTurn(); int b = TempForTurn.IndexOf(TempForTurn.Find(x => x == A)); TempForTurn = new List <NPCInBattlePro>(TempForTurn2); TempForTurn.Insert(b, A); // new Turn guy foreach (NPCInBattlePro item in TempForTurn) { GameObject a = Instantiate(PreTurn, ListTurn.transform); a.GetComponent <TurnCon>().NameNPC.text = item.Hero.name; } ListSlot.transform.GetChild(TempForTurn[0].Index).Find("NPCInbattle(Clone)").GetComponent <NPCInBattle>().WhiteBlink(); NPCNow = ListSlot.transform.GetChild(TempForTurn[0].Index).Find("NPCInbattle(Clone)").GetComponent <NPCInBattle>(); MovePreNPCNow(NPCNow.NPCPro.Hero.Class); BodyMoveIn(); }