示例#1
0
    // Respawns a new NPC
    public IEnumerator KnockedOut()
    {
        // Find the current NPC Fighter in the scene
        GameObject CurrentNPC = GameObject.FindGameObjectWithTag("NPC_Fighter");
        // Make a local variable for the animator attached to the NPC in scene
        // We cant access the base class Anim variable so we need a new one
        Animator anim = CurrentNPC.GetComponent <Animator>();

        // Make the animation play so the NPC is knocked out
        anim.SetBool("KnockedOut", true);
        // Wait some time so the aniimation can play and end
        yield return(new WaitForSeconds(4));

        // Make a local variable for the NPC fighter Derived class.
        DB_NPC_Fighter script = CurrentNPC.GetComponent <DB_NPC_Fighter>();

        // Turn on the Health script so when the fighter spawns the GameObject has all the relevant data to acess for its variables
        script.healthSlider.gameObject.SetActive(true);
        script.staminaSlider.gameObject.SetActive(true);
        // Spawn the New NPC
        SpawnNPC();
        // Increase Round
        roundIncreaser++;
        // Remove the old one
        Destroy(CurrentNPC);
        // End solution
        yield break;
    }
示例#2
0
    private void FixedUpdate()
    {
        // if this gameObject has not been ht with a bottle and the boolean hasnt ticked to true
        if (!stunned)
        {
            Regenerate_Stamina();                                      // Call regerate stamina Function
            if (DB_RefereeAI.NPC_Saw_Elbow == false & imDead == false) // IF ref didnt see the illegal elbow and this GameObject has not got 0 HP
            {
                Movement();                                            // We can move
            }

            // if the pc isnt dead then he can fight
            if (!imDead && DB_RefereeAI.PC_Saw_Elbow == false)
            {
                Melee_Combat(); // Call combat
            }
            // Set the stamina and health values to there slider health bars
            pcStamina.value = currentStamina;
            pcHealth.value  = coreHealth;
            // when there is no stamina
            if (currentStamina <= 0)
            {
                pcHealth.gameObject.SetActive(true); // we need the players real health to turn on
                pcStamina.gameObject.SetActive(false);
            }
            else if (currentStamina > 0)              // however if the stamina has some value that is over 0
            {
                pcHealth.gameObject.SetActive(false); // Turn the real health back off
                pcStamina.gameObject.SetActive(true);
            }

            // Functions to be called
            Regenerate_Stamina();
            if (coreHealth <= 0)
            {
                KnockedOut();
            }
            // Always havce a reference for the current NPC Fighter Script
            DB_NPC_Fighter currentNPC = GameObject.FindGameObjectWithTag("NPC_Fighter").GetComponent <DB_NPC_Fighter>();
            if (currentNPC.knockedOut == true)
            {
                currentStamina = maxStamina;
                coreHealth     = maxCore_Health;
            }

            base.Stamina_Montior();
            // For now this will work
            // This timer will be a monitor for our players hand colliders
            // we want it to tick down all the time because we dont want our players colliders to be punching the NPC in a none fight state
            turnOff_colliders -= Time.deltaTime;
            // So each time the monitor reacvhes 0 and beyond
            if (turnOff_colliders <= 0)
            {
                // Just turn off the colliders
                leftHand_SC.enabled  = false;
                rightHand_SC.enabled = false;
                elbow_SC.enabled     = false;

                if (elbow_SC == null)
                {
                    return;
                }
            }
            // Turn off irrelevant colliders turn on relevant 1 when we press left mouse button
            if (Input.GetButton("Fire1"))
            {
                turnOff_colliders    = 1;
                rightHand_SC.enabled = true;
                leftHand_SC.enabled  = false;
                elbow_SC.enabled     = false;
            }
            // Turn off irrelevant colliders turn on relevant 1 when we press right mouse button
            if (Input.GetButton("Fire2"))
            {
                turnOff_colliders    = 1;
                elbow_SC.enabled     = true;
                leftHand_SC.enabled  = false;
                rightHand_SC.enabled = false;
                illegalElbow         = true;
            }
            // Turn off irrelevant colliders turn on relevant 1 when we press space bar
            if (Input.GetButton("Jump"))
            {
                turnOff_colliders    = 1;
                leftHand_SC.enabled  = true;
                rightHand_SC.enabled = false;
                elbow_SC.enabled     = false;
            }
        }
        else if (stunned)                // if the gameObject has been hit with a bottle and is stunned
        {
            anim.SetFloat("Speed", 0);   // We cant move
            stunTimer -= Time.deltaTime; // Start a timer
            if (stunTimer <= 0)          // When the timer is 0 or more
            {
                stunned   = false;       // we are free to move again
                stunTimer = 4f;          // reset that timer
            }
        }
    }