Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
        {
            cameraScripts.toggleLock();
        }
        if (Input.GetKeyDown(KeyCode.V))
        {
            HealthBar[] healthBars = FindObjectsOfType(typeof(HealthBar)) as HealthBar[];
            foreach (HealthBar bar in healthBars)
            {
                bar.toggleVisibility();
            }
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            if (lichMana >= Tuner.LICH_ABILITY_HEAL_COST)
            {
                bool healed = false;
                foreach (GameObject c in partySystem.aliveCharacters)
                {
                    if (c != null && c.GetComponent <UnitCombat>() != null)
                    {
                        if (c.GetComponent <UnitCombat>().getHealth() != c.GetComponent <UnitCombat>().getMaxHealth())
                        {
                            foreach (GameObject b in partySystem.aliveCharacters)
                            {
                                if (b != null && b.GetComponent <UnitCombat>() != null)
                                {
                                    b.GetComponent <UnitCombat>().takeDamage(-(b.GetComponent <UnitCombat>().getMaxHealth() * Tuner.LICH_ABILITY_HEAL_AMOUNT), null);
                                }
                            }
                            healed = true;
                            break;
                        }
                    }
                }
                if (healed)
                {
                    lichMana -= Tuner.LICH_ABILITY_HEAL_COST;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.F1))
        {
            keyboardHelp.SetActive(!keyboardHelp.activeSelf);
        }

        /////////////////////////////////////
        /// LICH ABILITIES
        /////////////////////////////////////
        float manaScale = lichMana / 100f;

        manaScale = Mathf.Clamp(manaScale, 0, 1f);
        lichManaBar.localScale = new Vector3(lichManaBarScaleX * manaScale, lichManaBar.localScale.y, lichManaBar.localScale.z);
        /////////////////////////////////////
        /// CHARACTER ABILITIES
        /////////////////////////////////////
        for (int i = 0; i < 8; i++)
        {
            wasTargeting[i] = targeting[i];
        }

        GameObject character = null;

        for (int i = 0; i < 8; i++)
        {
            int        characterID = Mathf.FloorToInt((i * 0.5f) + 1);
            int        abilityID   = (i % 2);
            UnitCombat unitCombat  = partySystem.getCharacter(characterID).GetComponent <UnitCombat>();

            if ((Input.GetKeyDown(Tuner.KEYS_CHARACTER_ABILITY[i]) || HUDCast[i] == true) && !Input.GetKey(KeyCode.LeftShift) && unitCombat.isAlive())
            {
                if (unitCombat.canCastAbility(abilityID, Vector2.zero, false))
                {
                    targeting[i] = true;
                    //shift = false;
                }
            }
            if (targeting[i] && (Input.GetMouseButtonDown(1) || !Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i])) && HUDCast[i] == false)
            {
                if (!Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i]))
                {
                    unitCombat.castAbilityInSlot(abilityID, CameraScripts.getCurrentMousePos());
                }
                targeting[i] = false;
                //shift = false;
            }
        }

        /*
         *  if (i < 4)
         *  {
         *      if (targeting[i] && (Input.GetMouseButtonDown(1) || !Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i])) && HUDCast[i] == false)
         *      {
         *          if (!Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i]))
         *          {
         *              unitCombat.castSpellInSlot(spellID);
         *          }
         *          targeting[i] = false;
         *          shift = false;
         *      }
         *  }
         *  else
         *  {
         *      if (Input.GetKeyDown(Tuner.KEYS_CHARACTER_ABILITY[i - 4]) && Input.GetKey(KeyCode.LeftShift) && unitCombat.isAlive())
         *      {
         *          if (unitCombat.canCastSpell(spellID))
         *          {
         *              targeting[i] = true;
         *              shift = true;
         *          }
         *      }
         *      if (targeting[i] && (Input.GetMouseButtonDown(1) || (!shift && !Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i])) || (shift && !Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i - 4]))) && HUDCast[i] == false)
         *      {
         *          if (!Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i]) || (shift && !Input.GetKey(Tuner.KEYS_CHARACTER_ABILITY[i - 4])))
         *          {
         *              unitCombat.castSpellInSlot(spellID);
         *          }
         *          targeting[i] = false;
         *          shift = false;
         *      }
         *  }
         */
        for (int i = 0; i < 8; i++)
        {
            int characterID = Mathf.FloorToInt((i * 0.5f) + 1);
            int abilityID   = (i % 2);
            character = partySystem.getCharacter(characterID);
            Ability ability = character.GetComponent <UnitCombat>().getAbilityList()[abilityID];

            if (targeting[i])
            {
                targetedAbilityIndicator.showIndicator(character, ability, CameraScripts.getCurrentMousePos());
            }
            else
            {
                targetedAbilityIndicator.hideIndicator(character, ability);
            }
        }
        if (isTargetingFromHUD() && !playerHUD.isMouseOverHUD())
        {
            if (Input.GetMouseButtonDown(0))
            {
                for (int i = 0; i < 8; i++)
                {
                    setHUDCast(i, false);
                }
            }
        }
    }