Пример #1
0
    void Update()
    {
        currentSpell = spells[spellIndex];
        orientEffects(); // Needs to be done for non-local clients

        if (!isLocalPlayer)
        {
            return;
        }

        base.Update(); // Checks when attack related keys are pressed

        // Ends the shield if no energy remaining
        if (!resourceManager.hasEnergy() && shieldManager.isShielding)
        {
            endSecondaryAttack();
        }


        if (currentSpell.isActive && resourceManager.hasEnergy()) // Damages if has energy
        {
            if (timePassed < waitTime)
            {
                timePassed += Time.deltaTime;
                return;
            }

            currentSpell.attack();
            timePassed = 0;
        }
        else if (currentSpell.isActive) // Ends attack if no energy left
        {
            currentSpell.endAttack();
            timePassed = 0;
        }

        energyUser();
        cycleWeapons();

        // Throw grenade
        if (Input.GetKeyDown(KeyCode.G))
        {
            StartCoroutine(throwMagicGrenade());
        }

        //Animation
        Animation(currentSpell);
        //Sounds
        spellSounds();

        setUpCam();

        // For shield debugging
        if (Input.GetKey(KeyCode.L))
        {
            Debug.LogWarning("Debug damaging shield");
            CmdShieldHit(shieldManager.currentShield.gameObject, 50);
        }
    }