public void Attack() { if (player.GetActionUI() > 0) { if (Input.GetButtonUp("Attack") || buttonClicked == true) { isAttacking = true; cells = new List <Tile> (); cells.Add(gameboard.WhatTile(player)); Vector3 coor = gameboard.WhatTile(player).GetCoor(); range = player.GetRange(); if (range >= 0) { for (int i = 0; i <= range; i++) { cells.Add(gameboard.GetTile((int)coor.x + i, (int)coor.z)); cells.Add(gameboard.GetTile((int)coor.x - i, (int)coor.z)); } for (int j = 0; j <= range; j++) { cells.Add(gameboard.GetTile((int)coor.x, (int)coor.z + j)); cells.Add(gameboard.GetTile((int)coor.x, (int)coor.z - j)); } } foreach (Tile t in cells) { if (t != null) { t.GetComponent <Renderer> ().material.color = endColor; } } StartCoroutine(Attacking(player)); } } if (isAttacking) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100)) { foreach (Tile t in cells) { if (t != null) { if (t.name == hit.transform.gameObject.name) { t.GetComponent <Renderer> ().material.color = Color.green; attackedTile = t; } else { t.GetComponent <Renderer> ().material.color = endColor; } } } } if (Input.GetMouseButtonDown(0)) { isAttacking = false; buttonClicked = false; foreach (Tile t in cells) { if (t != null) { t.GetComponent <Renderer> ().material.color = startColor; } } //attack function foreach (Character chara in gameboard.GetCharacters()) { if (player != chara) { if (IsCharacterHit(chara, attackedTile)) { if (range == 0) { player.GetAnimator().SetTrigger("Attack"); } else { player.GetAnimator().SetTrigger("RangedAttack"); } chara.SetHealth(-player.GetAttack()); player.SetActionUI(-1); } } } } } }
public void ActivateHap(Character p) { if (idH == 0) { string stat = null; int diceRoll2 = Random.Range(0, 6); if (diceRoll2 == 0) { stat = "Mouvement"; p.SetMouvement(diceRoll - p.GetMouvement()); } else if (diceRoll2 == 1) { stat = "Maximum Health"; p.SetMaxHealth(diceRoll - p.GetMaxHealth()); if (p.GetMaxHealth() < p.GetHealth()) { p.SetHealth(p.GetMaxHealth() - p.GetHealth()); } } else if (diceRoll2 == 2) { stat = "Strength"; p.SetStrength(diceRoll - p.GetStrength()); } else if (diceRoll2 == 3) { stat = "Agility"; p.SetAgility(diceRoll - p.GetAgility()); } else if (diceRoll2 == 4) { stat = "Intelligence"; p.SetIntelligence(diceRoll - p.GetIntelligence()); } else { stat = "Wisdom"; p.SetWisdom(diceRoll - p.GetWisdom()); } description = "Your " + stat + " has been set to " + diceRoll + "."; } else if (idH == 1) { if (diceRoll < 4) { p.SetHealth(diceRoll); if (p.GetHealth() > p.GetMaxHealth()) { p.SetHealth(p.GetMaxHealth() - p.GetHealth()); } description = "You won the bet, you gain " + diceRoll + " HP."; } else { int d = diceRoll - 2; p.SetHealth(-d); description = "You lost the bet, you lost " + d + " HP."; } } else if (idH == 2) { if (diceRoll < 4) { p.SetHealth(-diceRoll); description = "You lost the bet, you lost " + diceRoll + " HP."; } else { GameboardControl gb = GameObject.FindWithTag("GameBoard").GetComponent <GameboardControl> (); foreach (Character c in gb.GetCharacters()) { if (c.GetId() != p.GetId()) { c.SetHealth(-1); } } description = "You won the bet, everyone else loses 1 Hp."; } } else if (idH == 3) { UIController uiC = GameObject.Find("Canvas").GetComponent <UIController> (); uiC.SetLevelUpButtons(); description = "You gain a level."; } }
public void LevelUp(int stat) { gameBoard.GetCharacters() [gameBoard.GetIdc() - 1].LevelUp(stat); statsUI.GetComponent <StatsUI> ().SetLevelUpButtons(false); }