public void dealallDamage(int p) { for (int i = 0; i < Temp.instance.spawnPointBoard2.Length; i++) { if (Temp.instance.spawnPointBoard2[i] == true) { GameObject p1C0Atk = GameObject.Find("P1Card " + p); CardDisplay a = p1C0Atk.GetComponent <CardDisplay>(); //ฝ่ายโดนเวทโจมตี GameObject p2C0Def = GameObject.Find("P2Creatre " + i); CretureDisplay a2 = p2C0Def.GetComponent <CretureDisplay>(); int P2hpc0 = Convert.ToInt32(a2.healthValueText.text); //Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.nameText.text + " attack = " + P2atkc0 + " hp= " + P2hpc0); P2hpc0 = P2hpc0 - a.Amount; // โช ผล string z = "-" + a.Amount.ToString();; a2.ShowDamage(z, 1.5f); a2.healthValueText.text = P2hpc0.ToString(); if (P2hpc0 <= 0) { Destroy(p2C0Def, 2); Temp.instance.spawnPointBoard2[i] = false; } } } }
public void OnTurnStart() { MessageManager.Instance.ShowMessage("Player1 Turn", 1.5f); manaText.gameObject.SetActive(true); timeText.gameObject.SetActive(true); Temp tt = GetComponent <Temp>(); tt.attackP1Button.gameObject.SetActive(true); count = 60; count2 = 70; currentTurn++; activeManaCrystals = currentTurn; if (activeManaCrystals >= 10) { activeManaCrystals = 10; } manaText.text = activeManaCrystals.ToString(); //for (int i = 0; i < activeManaCrystals; i++) //{ // manaCrystals[i].SetActive(true); //} endTurnButton.gameObject.SetActive(true); tt.DrawP1(1); // ทำให้มีมเนียนที่ลงโจมตีได้ for (int i = 0; i < tt.spawnPointBoard1.Length; i++) { if (tt.spawnPointBoard1[i] == true) { GameObject card = GameObject.Find("P1Creatre " + i); CretureDisplay a = card.GetComponent <CretureDisplay>(); a.ischarge = true; } } }
//ลงการ์ดจากมือลงบอร์ด p2 public void spawnCardP2(Card thiscard) { for (int i = 0; i < spawnPointBoard2.Length; i++) { if (spawnPointBoard2[i] == false) { GameObject go = Instantiate(creatureP2, spawnPointP2[i].position, Quaternion.identity); CretureDisplay cDisplay = go.GetComponent <CretureDisplay>(); //ตั้งชื่อ obj go.name = "P2Creatre " + i; //Debug.Log("befor" + spawnPointBroad1[boardP1]); spawnPointBoard2[i] = true; cDisplay.CretureSetup(thiscard); //boardP2 = i; break; } } }
public void OnTurEnd() { endTurnButton.gameObject.SetActive(false); manaText.gameObject.SetActive(false); timeText.gameObject.SetActive(false); OnTurnStartP2(); activeManaCrystals = 0; Temp tt = GetComponent <Temp>(); tt.attackP1Button.gameObject.SetActive(false); for (int i = 0; i < tt.spawnPointBoard1.Length; i++) { if (tt.spawnPointBoard1[i] == true) { GameObject card = GameObject.Find("P1Creatre " + i); CretureDisplay a = card.GetComponent <CretureDisplay>(); a.ischarge = false; } } }
public void healAllFriendly(int p) { for (int i = 0; i < Temp.instance.spawnPointBoard1.Length; i++) { if (Temp.instance.spawnPointBoard1[i] == true) { GameObject p1C0Atk = GameObject.Find("P1Card " + p); CardDisplay a = p1C0Atk.GetComponent <CardDisplay>(); //เป้าหมายที่ฮิว GameObject p2C0Def = GameObject.Find("P1Creatre " + i); CretureDisplay a2 = p2C0Def.GetComponent <CretureDisplay>(); int P2hpc0 = Convert.ToInt32(a2.healthValueText.text); P2hpc0 = P2hpc0 + a.Amount; // โช ผล string z = "+" + a.Amount.ToString();; a2.ShowDamage(z, 1.5f); a2.healthValueText.text = P2hpc0.ToString(); } } }
private void Awake() { instance = this; }
public void P1attack() { for (int i = 0; i < spawnPointBoard1.Length; i++) { if (spawnPointBoard1[i] == true) { // ฝ่ายP1 GameObject p1C0Atk = GameObject.Find("P1Creatre " + i); CretureDisplay a = p1C0Atk.GetComponent <CretureDisplay>(); if (a.ischarge) { int atkc0 = Convert.ToInt32(a.attackValueText.text); int hpc0 = Convert.ToInt32(a.healthValueText.text); //ค้นหาเป้าหมาบบนboard if (spawnPointBoard2[i] == true) { GameObject p2C0Def = GameObject.Find("P2Creatre " + i); CretureDisplay a2 = p2C0Def.GetComponent <CretureDisplay>(); int P2atkc0 = Convert.ToInt32(a2.attackValueText.text); int P2hpc0 = Convert.ToInt32(a2.healthValueText.text); Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.nameText.text + " attack = " + P2atkc0 + " hp= " + P2hpc0); // ฝ่ายโจมตี P1c0 ตี P2c0 P2hpc0 = P2hpc0 - atkc0; // โช damage string z = "-" + P2atkc0.ToString();; a.ShowDamage(z, 1.5f); a2.healthValueText.text = P2hpc0.ToString(); if (P2hpc0 <= 0) { Destroy(p2C0Def, 2); spawnPointBoard2[i] = false; } // ฝ่ายป้องกัน P2c0 ตี P1c0 hpc0 = hpc0 - P2atkc0; // โช damage string zz = "-" + atkc0.ToString();; a2.ShowDamage(zz, 1.5f); a.healthValueText.text = hpc0.ToString(); if (hpc0 <= 0) { Destroy(p1C0Atk, 2); spawnPointBoard1[i] = false; } } else //ไม่เจอCreture ตี hero { GameObject p2HeroDef = GameObject.Find("Player2"); HeroDisplay a2 = p2HeroDef.GetComponent <HeroDisplay>(); int P2hpc0 = Convert.ToInt32(a2.healthText.text); Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.gameObject.name + " hp= " + P2hpc0); P2hpc0 = P2hpc0 - atkc0; countAtkHero = countAtkHero + atkc0; // โช damage string zz = "-" + countAtkHero.ToString();; a2.hDamage(zz, 1.5f); a2.healthText.text = P2hpc0.ToString(); if (P2hpc0 <= 0) { GameLevelManager.instance.endGame(2f, 1); } } } // set ว่าตีไปแล้ว a.ischarge = false; } } countAtkHero = 0; attackP1Button.gameObject.SetActive(false); }
private void OnMouseDown() { Debug.Log(gameObject.name); GameObject p1C0Atk = GameObject.Find(gameObject.name); CretureDisplay a = p1C0Atk.GetComponent <CretureDisplay>(); for (int y = 0; y < 5; y++) { if (gameObject.name == "P2Creatre " + y) { i = y; } } if (Temp.instance.spawnPointBoard2[i] == true) { // ฝ่ายP2 if (a.ischarge) { int atkc0 = Convert.ToInt32(a.attackValueText.text); int hpc0 = Convert.ToInt32(a.healthValueText.text); //ค้นหาเป้าหมาบบนboard if (Temp.instance.spawnPointBoard1[i] == true) { GameObject p2C0Def = GameObject.Find("P1Creatre " + i); CretureDisplay a2 = p2C0Def.GetComponent <CretureDisplay>(); int P2atkc0 = Convert.ToInt32(a2.attackValueText.text); int P2hpc0 = Convert.ToInt32(a2.healthValueText.text); Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.nameText.text + " attack = " + P2atkc0 + " hp= " + P2hpc0); // ฝ่ายโจมตี P2c0 ตี P1c0 P2hpc0 = P2hpc0 - atkc0; // โช damage string z = "-" + P2atkc0.ToString();; a.ShowDamage(z, 1.5f); a2.healthValueText.text = P2hpc0.ToString(); if (P2hpc0 <= 0) { Destroy(p2C0Def, 2); Temp.instance.spawnPointBoard1[i] = false; } // ฝ่ายป้องกัน P1c0 ตี P2c0 hpc0 = hpc0 - P2atkc0; // โช damage string zz = "-" + atkc0.ToString();; a2.ShowDamage(zz, 1.5f); a.healthValueText.text = hpc0.ToString(); if (hpc0 <= 0) { Destroy(p1C0Atk, 2); Temp.instance.spawnPointBoard2[i] = false; } } else //ไม่เจอCreture ตี hero { GameObject p2HeroDef = GameObject.Find("Player1"); HeroDisplay a2 = p2HeroDef.GetComponent <HeroDisplay>(); int P2hpc0 = Convert.ToInt32(a2.healthText.text); Debug.Log(a.nameText.text + " attack = " + atkc0 + " hp= " + hpc0 + " atk " + a2.gameObject.name + " hp= " + P2hpc0); P2hpc0 = P2hpc0 - atkc0; //countAtkHero = countAtkHero + atkc0; // โช damage string zz = "-" + atkc0.ToString();; a2.hDamage(zz, 1.5f); a2.healthText.text = P2hpc0.ToString(); if (P2hpc0 <= 0) { // endgame GameLevelManager.instance.endGame(2f, 2); } } } // set ว่าตีไปแล้ว a.ischarge = false; } }