public void addSpellPoint() { if (_characterStats.Player_spell_points > 0 && _spellScript.spells[spell_id].current_spell_points < _spellScript.spells[spell_id].max_spell_points) { _characterStats.Player_spell_points--; _spellScript.spells[spell_id].current_spell_points++; spell_points_text.GetComponent <Text_animation>().startAnim(_spellScript.spells[spell_id].current_spell_points + "/" + _spellScript.spells[spell_id].max_spell_points, 0.05f); GameObject.Find("spellpoints_text").GetComponent <Text_animation>().startAnim("Available skill points: " + _characterStats.Player_spell_points, 0.05f); _spellScript.setupAttributes(); if (_spellScript.spells[spell_id].type == spell_types.passive) { _spellScript.spells[spell_id].passiveActivate(); } if (GameObject.Find("Spell_preview_talent").GetComponent <Visibility_script>().isOpened) { GameObject.Find("Spell_preview_talent").GetComponent <Spell_preview_script>().showSpell(spell_id, gameObject); } /* * if ((!_characterStats.Spells.Contains(spell_id) && _spellScript.spells[spell_id].type != spell_types.passive) || GameObject.Find("Spell_preview_talent").GetComponent<Visibility_script>().isOpened) * { * GameObject.Find("Spell_preview_talent").GetComponent<Spell_preview_script>().showSpell(spell_id, gameObject); * } */ } _spellScript.checkRowAvailability(); }
public void initializeBattle(int id) { _characterStats = GameObject.Find("Game manager").GetComponent <Character_stats>(); _characterManager = GameObject.Find("Character").GetComponent <Character_manager>(); _notification = GameObject.Find("Notification").GetComponent <Ingame_notification_script>(); _enemyManagerScript = GameObject.Find("Game manager").GetComponent <Enemy_manager_script>(); _itemScript = GameObject.Find("Game manager").GetComponent <Item_script>(); _spellScript = GameObject.Find("Game manager").GetComponent <Spell_script>(); isPaused = false; _spellScript.actualizeSpells(); _spellScript.setupAttributes(); _healthBar = GameObject.Find("Health_bar").GetComponent <Bar_script>(); _resourceBar = GameObject.Find("Resource_bar").GetComponent <Bar_script>(); _spellbarAnimator = GameObject.Find("Spellbar").GetComponent <Animator>(); GameObject.Find("Item_preview").GetComponent <Animator>().Play("Item_preview_slide_out_anim"); GameObject.Find("Inventory slots").GetComponent <Animator>().Play("Inventory_slide_out_anim"); GameObject.Find("Conversation").GetComponent <Conversation_script>().closeConversation(); _spellScript.target = null; StopAllCoroutines(); isOngoing = true; if (gameObject.GetComponent <Game_manager>().current_screen.name == "Combat_screen_UI") { if (_characterStats.Player_health > _characterStats.Player_max_health || _characterStats.Player_health < 0) { _characterStats.Player_health = _characterStats.Player_max_health; _healthBar.updateHealth(); } if (_characterStats.Player_resource > _characterStats.Player_max_resource || _characterStats.Player_resource < 0) { _characterStats.Player_resource = _characterStats.Player_max_resource; _resourceBar.updateResource(); } } battle_id = id; _characterStats.Player_health = _characterStats.Player_max_health; _characterStats.Player_resource = _characterStats.Player_max_resource; _healthBar.updateHealth(); _resourceBar.updateResource(); GameObject.Find("Spell_preview").GetComponent <Visibility_script>().setInvisible(); remaining_time.GetComponent <Text_animation>().startAnim((round_time).ToString(), 0.05f); opponent_ids = battles[id].opponent_ids; opponents[0].GetComponent <Enemy_script>().enemyInitialize(battles[id].opponent_ids[0]); opponents[1].GetComponent <Enemy_script>().enemyInitialize(battles[id].opponent_ids[1]); generateSequence(); _notification.message("¤" + battles[id].battle_name, 3); battle_background.GetComponent <SpriteRenderer>().sprite = battles[id].background; round_counter = 0; timer = 0; changeRound(); }
public void Change_screen(GameObject target, bool isMenu) { current_screen.SetActive(true); if (!isMenu) { if (current_screen.GetComponent <Screen_script>().order < target.GetComponent <Screen_script>().order) { current_screen.GetComponent <Animator>().Play("Screen_to_inactive_left_anim"); } else if (current_screen.GetComponent <Screen_script>().order > target.GetComponent <Screen_script>().order) { current_screen.GetComponent <Animator>().Play("Screen_to_inactive_right_anim"); } } closeOpenedWindows(); target.SetActive(true); if (isMenu) { current_screen.GetComponent <Animator>().Play("Screen_to_inactive_left_anim"); target.GetComponent <Animator>().Play("Screen_to_active_right_anim"); } if (current_screen.GetComponent <Screen_script>().order < target.GetComponent <Screen_script>().order) { target.GetComponent <Animator>().Play("Screen_to_active_left_anim"); } else if (current_screen.GetComponent <Screen_script>().order > target.GetComponent <Screen_script>().order) { target.GetComponent <Animator>().Play("Screen_to_active_right_anim"); } current_screen = target; navigationBarVisibility(); if (current_screen == GameObject.Find("Main_screen")) { //isNewCharacter = true; } else if (current_screen == GameObject.Find("Character_customization_screen")) { //GameObject.Find("Customization_controller").GetComponent<Character_customization_script>().initializeCustomization(isNewCharacter); } else if (current_screen == GameObject.Find("Character_screen_UI")) { _characterStats.updateStats(); GameObject.Find("experience_bar").GetComponent <Bar_script>().updateXP(); gameObject.GetComponent <Spell_script>().actualizeSpells(); } else if (current_screen == GameObject.Find("Quest_screen_UI")) { gameObject.GetComponent <Quest_manager_script>().updateQuestSlots(); _characterStats.updateMoneyStat(); } else if (current_screen == GameObject.Find("Store_screen_UI")) { _characterStats.updateMoneyStat(); } else if (current_screen == GameObject.Find("Map_screen_UI")) { _characterStats.updateMoneyStat(); } else if (current_screen == GameObject.Find("Combat_screen_UI")) { GameObject.Find("Game manager").GetComponent <Combat_manager_script>().initializeBattle(UnityEngine.Random.Range(0, 6)); _characterStats.Player_health = _characterStats.Player_max_health; _characterStats.Player_resource = _characterStats.Player_max_resource; GameObject.Find("Spell_preview").GetComponent <Visibility_script>().setInvisible(); } else if (current_screen == GameObject.Find("Spell_screen_UI")) { GameObject.Find("spellpoints_text").GetComponent <Text_animation>().startAnim("Available skill points: " + _characterStats.Player_spell_points, 0.05f); GameObject.Find("Spellbar").GetComponent <Animator>().Play("Spellbar_talent_slide_in_anim"); _spellScript.setupAttributes(); _spellScript.checkRowAvailability(); ArrayList slots = new ArrayList(); slots.AddRange(_spellScript.firstRow); slots.AddRange(_spellScript.secondRow); slots.AddRange(_spellScript.thirdRow); foreach (GameObject slot in slots) { slot.GetComponent <Talent_slot_script>().spell_points_text.GetComponent <Text_animation>().startAnim(_spellScript.spells[slot.GetComponent <Talent_slot_script>().spell_id].current_spell_points + "/" + _spellScript.spells[slot.GetComponent <Talent_slot_script>().spell_id].max_spell_points, 0.05f); } _characterStats.updateMoneyStat(); } Text_animation[] allText = target.GetComponentsInChildren <Text_animation>(); foreach (Text_animation child in allText) { child.restartAnim(); } }