public void fillAttackMenu() { //Vector3 v3 = new Vector3(6.2f, 136.6f); foreach (Transform child in action_content.transform) { GameObject.Destroy(child.gameObject); } for (var i = 0; i < state_machine.getCurrCharac().skills.Count; i++) { GameObject skillButton = Instantiate(skill_select, action_content.transform, false) as GameObject; skillButton.AddComponent <Skill>(); skillButton.GetComponent <Skill>().copy(state_machine.getCurrCharac().skills[i]); skillButton.GetComponent <Button>().onClick.AddListener(delegate { attackSelected(skillButton.GetComponent <Skill>()); }); skillButton.GetComponent <Transform>().localPosition = new Vector3(skillButton.transform.localPosition.x, skillButton.transform.localPosition.y - (i * 19), skillButton.transform.localPosition.z); skillButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = state_machine.getCurrCharac().skills[i].abilityName; skillButton.transform.GetChild(1).gameObject.GetComponent <Text>().text = state_machine.getCurrCharac().skills[i].manaCost.ToString(); } }
void OnMouseDown() { if (state_machine.getState() == 2) { if (gameObject.CompareTag("EnemyTile") && state_machine.getAbility().manaCost <= state_machine.getCurrCharac().curr_mana) { attack(gameObject.GetComponent <Monster>()); state_machine.setState(0); bmm.closeAttackMenu(); } else { if (!gameObject.CompareTag("EnemyTile")) { Debug.Log("Wrong target!"); } else { Debug.Log("Not enough Mana!"); } } } else if (state_machine.getState() == 4) { if (gameObject.CompareTag("EnemyTile") && state_machine.getAbility().manaCost <= state_machine.getCurrCharac().curr_mana) { cast(gameObject.GetComponent <Monster>()); state_machine.setState(0); bmm.closeSpellMenu(); } else { if (!gameObject.CompareTag("EnemyTile")) { Debug.Log("Wrong target!"); } else { Debug.Log("Not enough Mana!"); } } } else if (state_machine.getState() == 5) { if (gameObject.CompareTag("PlayerTile") && state_machine.getAbility().manaCost <= state_machine.getCurrCharac().curr_mana) { castSupport(gameObject.GetComponent <Character>()); state_machine.setState(0); bmm.closeSpellMenu(); } else { if (!gameObject.CompareTag("PlayerTile")) { Debug.Log("Wrong target!"); } else { Debug.Log("Not enough Mana!"); } } } else if (state_machine.getState() == 7) { if (gameObject.CompareTag("PlayerTile")) { useItem(gameObject.GetComponent <Character>()); state_machine.setState(0); bmm.closeItemMenu(); } else { Debug.Log("Wrong target!"); } } }