示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (playerHitted)
        {
            if (hittedCounter < hittedTime)
            {
                hittedCounter += Time.deltaTime;
            }
            else
            {
                hittedCounter = 0.0f;
                playerHitted  = false;
            }
        }

        if (isDead)
        {
            if (deadAnimationCounter < deadAnimationTime)
            {
                deadAnimationCounter += Time.deltaTime;
            }
            else
            {
                deadAnimationCounter = 0.0f;
                isDead = false;
            }
        }

        bool isTooLittleMana = false;

        if (slowZone.manualUpdate(manaBar.Value, ref isTooLittleMana))
        {
            useMana((int)GameVariables.Abilities.Time);
        }
        if (GameVariables.GameMode == GameVariables.GameModes.God && GameVariables.Ability == GameVariables.Abilities.Thunder &&
            Input.GetButtonDown("Fire1"))
        {
            if (manaBar.Value >= (int)GameVariables.Abilities.Thunder)
            {
                useMana((int)GameVariables.Abilities.Thunder);
                lightningBolt.setPositions(GameVariables.getPos());
                lightningBolt.Trigger();
                GameObject objectHit = GameVariables.getObjectHit();
                if (objectHit != null)
                {
                    LightningHitable hitableObject = objectHit.GetComponent <LightningHitable>();
                    if (hitableObject != null)
                    {
                        hitableObject.afterHit();
                    }
                }
            }
            else
            {
                //not enough mana!!!oneoneone
                Debug.Log("Too little mana for thunder");
                isTooLittleMana = true;
            }
        }
        if (isTooLittleMana)
        {
            manaBar.blink();
        }

        if (Input.GetKey(KeyCode.H))
        {
            manaToHealth();
        }
        if (Input.GetKey(KeyCode.M))
        {
            healthToMana();
        }


        //***********************************
        //for debug only!

        /*if (Input.GetKeyDown(KeyCode.I))
         * {
         *      takeDamage(-10);
         * }
         * if (Input.GetKeyDown(KeyCode.O))
         * {
         *      takeDamage(10);
         * }*/
        //***********************************
    }