// Update is called once per frame
    void Update()
    {
        charDirect = gameObject.GetComponent <PlayerMovementDash>();

        direction = charDirect.faceDir;

        // print("FIRST DIRECTION " + direction);

        bool coolDownComplete = (Time.time > nextReadyTime);  // Check to see if cooldown is available or not.

        if (coolDownComplete)
        {
            AbilityReady();  // Ability is ready once cooldown is completed.

            if (!attackLock)
            {
                if (Input.GetButtonDown(abilityButtonAxisName)) // Check for button input to trigger associated ability.
                {
                    charDirect.dashLocked = true;

                    ButtonTriggered();    // Once button is triggered perform scripted actions.
                }
            }
        }
        else
        {
            CoolDown();     // If cooldown is not complete then run CoolDown function.
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        meleeLocker  = gameObject.GetComponent <MeleeCoolDown>();
        rangedLocker = gameObject.GetComponent <RangedCoolDown>();
        charDirect   = gameObject.GetComponent <PlayerMovementDash>();

        print("Start state of Melee Lock " + meleeLocker.attackLock);
        print("Start state of Ranged Lock " + rangedLocker.attackLock);
        print("Dash Locker State " + charDirect.dashLocked);


        direction = charDirect.faceDir;


        bool firstCoolDownComplete  = (Time.time > firstNextReadyTime);  // Check to see if cooldown is available or not.
        bool secondCoolDownComplete = (Time.time > secondNextReadyTime); // Check to see if cooldown is available or not.

        if (firstCoolDownComplete && !summonActive)
        {
            // print("First Summon Cooldown Complete");
            if (Input.GetKeyDown("q"))          // Checks for pressing the Q key to start casting for first summon. Look into possibly changing this so it pulls the string from a variable for more flexbility.
            {
                castActive = true;

                sumChosen = 1;

                print("First summon ready");

                meleeLocker.attackLock  = true;
                rangedLocker.attackLock = true;
                //charDirect.dashLocked = true;
                print("Dash Locker State " + charDirect.dashLocked);
            }

            if (Input.GetKeyDown(KeyCode.Tab))      // Checks for pressing the Space key to deactivate the casting state. NOTE: This and the left/right clicks still need locks on abilities in other functions.
            {
                castActive = false;
                sumChosen  = 0;

                print("Summon Deactivated");

                meleeLocker.attackLock  = false;
                rangedLocker.attackLock = false;
            }

            /*
             * if (Input.GetKeyUp("space"))
             * {
             *  //charDirect.dashLocked = false;
             * StartCoroutine("DashUnlockDelay");
             * }
             */
        }
        else
        {
            print("FIRST SUMMON COOLING DOWN");
            FirstCoolDown();                         // If cooldown is not complete then run CoolDown function to update the display for the ui. CURRENTLY NOT USED FULLY.
        }



        if (secondCoolDownComplete && !summonActive)
        {
            // print("Second Summon Cooldown Complete");
            if (Input.GetKeyDown("e"))          // Checks for pressing the E key to start casting for second summon.
            {
                castActive = true;
                sumChosen  = 2;
                print("Second summon ready");

                meleeLocker.attackLock  = true;
                rangedLocker.attackLock = true;
                //charDirect.dashLocked = true;
            }

            if (Input.GetKeyDown(KeyCode.Tab))      // Checks for pressing the Space key to deactivate the casting state. NOTE: This and the left/right clicks still need locks on abilities in other functions.
            {
                castActive = false;
                sumChosen  = 0;
                print("Summon Deactivated");

                meleeLocker.attackLock  = false;
                rangedLocker.attackLock = false;
            }

            /* if (Input.GetKeyUp(KeyCode.Tab))
             * {
             *   StartCoroutine("DashUnlockDelay");
             *
             * } */
        }
        else
        {
            print("SECOND SUMMON COOLING DOWN");
            SecondCoolDown();                         // If cooldown is not complete then run CoolDown function to update the display for the ui. CURRENTLY NOT USED FULLY.
        }


        if (castActive && sumChosen == 1)     // If the player has pressed the Q key to activate casting, pull from the two abilities assigned to the given first summon.
        {
            if (Input.GetButtonDown("Fire1")) // If assigned button is pressed then perform proper actions for the given ability. NOTE: Take another look at this, the process seems wrong, might not need clone yet.
            {
                selectedSummon = firstSummon;

                selectedSummon.attacker = attackingChar;

                selectedSummon.selectedSprite = selectedSummon.sumChar;

                selectedSummon.summonSlot = sumChosen;

                selectedAbility = selectedSummon.ability1;

                selectedSummon.selectedAbility = selectedAbility;

                SetTargetPosition();

                selectedSummon.Initialize(summonHolder);           // Sets the spawn point of the ability as the object weaponholder.

                castActive = false;

                summonActive = true;


                print("cast deactivated");

                // firstNextReadyTime = firstSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown. This value is what handles the checking for the cooldown.
                firstCoolDownTimeLeft = firstSumCooldown;  // Updated to update the display for the player.



                selectedSummon.TriggerAbility();           // Runs TriggerAbility of the summon to then run the given ability.

                StartCoroutine(AbilityUnlockerBuffer(unlockBuffer));

                //meleeLocker.attackLock = false;
                //rangedLocker.attackLock = false;
            }

            if (Input.GetButtonDown("Fire2"))
            {
                selectedSummon = firstSummon;

                selectedSummon.attacker = attackingChar;

                selectedSummon.summonSlot = sumChosen;

                selectedSummon.selectedSprite = selectedSummon.sumChar2;

                selectedAbility = selectedSummon.ability2;

                selectedSummon.selectedAbility = selectedAbility;

                SetTargetPosition();

                selectedSummon.Initialize(summonHolder);           // Sets the spawn point of the ability as the object weaponholder.

                castActive = false;
                print("cast deactivated");

                firstNextReadyTime    = firstSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown.
                firstCoolDownTimeLeft = firstSumCooldown;



                selectedSummon.TriggerAbility();

                meleeLocker.attackLock  = false;
                rangedLocker.attackLock = false;
                // charDirect.dashLocked = false;
            }
        }


        if (castActive && sumChosen == 2)   // If the player has pressed the E key to activate casting, pull from the two abilities assigned to the given second summon.
        {
            if (Input.GetButtonDown("Fire1"))
            {
                selectedSummon = secondSummon;

                selectedSummon.attacker = attackingChar;

                selectedSummon.summonSlot = sumChosen;

                selectedSummon.selectedSprite = selectedSummon.sumChar;

                selectedAbility = selectedSummon.ability1;  // This might be a thing that leads nowhere GIVE IT ANOTHER LOOK

                selectedSummon.selectedAbility = selectedAbility;

                SetTargetPosition();

                selectedSummon.Initialize(summonHolder);           // Sets the spawn point of the ability as the object weaponholder.

                castActive = false;


                summonActive = true;

                print("cast deactivated");

                //secondNextReadyTime = secondSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown.
                secondCoolDownTimeLeft = secondSumCooldown;

                selectedSummon.TriggerAbility();

                StartCoroutine(AbilityUnlockerBuffer(unlockBuffer));
            }

            if (Input.GetButtonDown("Fire2"))
            {
                selectedSummon = secondSummon;

                selectedSummon.attacker = attackingChar;

                selectedSummon.summonSlot = sumChosen;

                selectedSummon.selectedSprite = selectedSummon.sumChar2;

                selectedAbility = selectedSummon.ability2;  // This might be a thing that leads nowhere GIVE IT ANOTHER LOOK

                selectedSummon.selectedAbility = selectedAbility;

                SetTargetPosition();

                selectedSummon.Initialize(summonHolder);           // Sets the spawn point of the ability as the object weaponholder.

                castActive = false;


                summonActive = true;

                print("cast deactivated");

                //secondNextReadyTime = secondSumCooldown + Time.time; // Sets the ready time for the summon based off cooldown.
                secondCoolDownTimeLeft = secondSumCooldown;

                selectedSummon.TriggerAbility();

                StartCoroutine(AbilityUnlockerBuffer(unlockBuffer));
            }
        }
    }