示例#1
0
 // Update is called once per frame
 void Update()
 {
     if (health.GetHealth() < 1000)
     {
         transform.parent.parent.parent.parent.parent.parent.parent.parent.GetComponent <HealthScript>().DoDamage((1000 - health.GetHealth()) / 2, health.invulFrames);
         health.SetHealth(1000, 1000);
     }
 }
    // Update is called once per frame
    void Update()
    {
        health        = _health.GetHealth();
        healthUI.text = "Health: " + health + "/100";

        if (health <= 0)
        {
            player.interactable = false;
            dead = Color.Lerp(Color.white, color, Mathf.PingPong(Time.deltaTime, 1));
        }
    }
示例#3
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        //print( "onTriggerEnterEvent: " + otherCollider.gameObject.name );

        if (isInvincible == false)
        {
            Hitbox GotHitBox = otherCollider.GetComponent <Hitbox>();

            if (GotHitBox != null)
            {
                Health.TakeDamage(1, GotHitBox.transform.position);
                Anim.SetTrigger("TakeDamage");
            }

            if (Health.GetHealth() == 1)
            {
                Anim.SetTrigger("Dissolve");
            }
        }
    }
    private void StateLogic()
    {
        var distance = Vector3.Distance(selfPos, playerPos);

        anim.SetInteger("ActionIndex", 0);
        if (distance >= chaseDist)
        {
            //rush at the player untl we walk
            curState = aiState.chasing;
            anim.SetBool("Action", true);
            anim.SetInteger("ActionIndex", 5);
            anim.SetBool("Moving", false);
        }
        else if (distance < chaseDist && distance >= maxAtkRange)
        {
            //walk until we're in range to max range atk
            curState = aiState.walking;
            anim.SetBool("Action", false);
            anim.SetBool("Moving", true);
        }
        else if (distance < maxAtkRange && distance >= medAtkRange) //do the max range atk
        {
            curState = aiState.maxAtk;
        }
        else if (distance < medAtkRange && distance >= closeAtkRange) //do the med range atks
        {
            curState = aiState.medAtk;
        }
        else if (distance < closeAtkRange) //do the close range atk
        {
            curState = aiState.closeAtk;
        }
        else
        {
            anim.SetBool("Action", false);
        }
        if (bossHealth.GetHealth() <= 0)
        {
            curState = aiState.dead;
        }
    }
示例#5
0
    void OnTriggerEnter(Collider item)
    {
        if (item.tag == "Asteroid")         // if the gameobject name is _astriod//using tags is better marcus-15/06/2015
        {
            anim.SetBool("Idel", false);
            anim.SetTrigger("Impact");            //set of the Impact anim on collision with asteroid - marcus - 15/06/2015
            //doDamage();
            health.ApplyDamage(asteroidDamage);
            Invoke("startAnimation", 1.5f);

            // Debug.Log(health.GetHealth);

            if (health.GetHealth() <= 0)             // if the health is 0
            {
                Debug.Log("Game Over");
            }
        }

        //Had to comment this section out has it dose nothing at the moment are you working on this
        // cause at the moment there is no health variable to refrence
        // I changed all the PickUps variables to pickups to match the varible I created -Marcus: 09/06/15
    }
    // Update is called once per frame
    void Update()
    {
        // check for ESC input
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            FullReset();
        }

        // check for R input
        if (Input.GetKeyDown(KeyCode.R))
        {
            NewRound();
        }

        // Round timer
        if (fightActive)
        {
            roundTime -= Time.deltaTime;
        }

        //
        if (p1won || p2won)
        {
            return;
        }

        // Countdown timer at start of round
        if (timeUntilNextSec > -1)
        {
            timeUntilNextSec -= Time.deltaTime;
        }
        if (timeUntilNextSec <= 0 && secondsOnCountdown >= 0)
        {
            secondsOnCountdown--;
            timeUntilNextSec += 1;
        }
        // Display text for countdown timer
        if (secondsOnCountdown > 0)
        {
            mainText.text  = "" + secondsOnCountdown;
            clockText.text = "";
        }
        else if (secondsOnCountdown == 0)
        {
            mainText.text  = "FIGHT!";
            clockText.text = "" + (int)roundTime;
            fightActive    = true;
        }
        else
        {
            mainText.text  = "";
            clockText.text = "" + (int)roundTime;
        }


        var players = GameObject.FindGameObjectsWithTag("Player");

        // Time ran out
        if (roundTime < 0)
        {
            fightActive = false;
            timeExpired = true;

            foreach (var p in players)
            {
                PlayerController pc = p.GetComponent <PlayerController>();
                pc.IdleAnim();
            }
        }

        // Player ran out of HP or fell off the level
        foreach (var p in players)
        {
            HealthScript     hs = p.GetComponent <HealthScript>();
            PlayerController pc = p.GetComponent <PlayerController>();
            if (hs.GetHealth() <= 0 || p.transform.position.y < -20)
            {
                fightActive = false;
                pc.IdleAnim();

                if (hs.GetHealth() <= 0)
                {
                    healthKO = true;
                }
                if (p.transform.position.y < -20)
                {
                    offMapKO = true;
                }
            }
        }

        // Determine which PlayerController is player 1
        PlayerController playerOne = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <PlayerController>();
        PlayerController playerTwo = GameObject.FindGameObjectsWithTag("Player")[1].GetComponent <PlayerController>();

        if (playerOne.GetPlayerNumber() != 1)
        {
            PlayerController temp = playerOne;
            playerOne = playerTwo;
            playerTwo = temp;
        }

        // Win conditions
        if (timeExpired || healthKO) // Time or health ran out
        {
            if (playerOne.GetHealth() > playerTwo.GetHealth())
            {
                p1won = true;
            }
            else if (playerOne.GetHealth() < playerTwo.GetHealth())
            {
                p2won = true;
            }
            else
            {
                p1won = true;
                p2won = true;
                Debug.Log("1");
            }
        }
        else if (offMapKO) // Fell off map
        {
            if (playerOne.GetY() > playerTwo.GetY())
            {
                p1won = true;
            }
            else if (playerOne.GetY() < playerTwo.GetY())
            {
                p2won = true;
            }
            else
            {
                p1won = true;
                p2won = true;
                Debug.Log("2");
            }
        }

        if (p1won)
        {
            p1wins++;
        }
        if (p2won)
        {
            p2wins++;
        }

        if (p1won && !p2won)
        {
            mainText.text = "PLAYER 1 WON!\n";
        }
        if (!p1won && p2won)
        {
            mainText.text = "PLAYER 2 WON!\n";
        }
        if (p1won && p2won)
        {
            mainText.text = "IT'S A DRAW!\n";
        }

        if (p1won || p2won)
        {
            mainText.text += "Score:  " + p1wins + " - " + p2wins;
        }
    }
 //public event Action<Health> HealthDepleted;
 void Start()
 {
     health = healthH.GetHealth();
 }
示例#8
0
    IEnumerator BasicAttack(float resetTime, int currentComboIndex) //Attack Ability
    {
        playerController.isBusy = true;
        playerController.movementScript.canMove = false;
        playerController.movementScript.RotateToClickLocation();

        if (detectAttackable(attackRange, attackArc, 8))
        {
            lastAttackTime = Time.time;

            switch (currentComboIndex)
            {
            case 0:     //Initial Attack
                comboIndex++;
                //Debug.Log("Combo 1");
                playerController.anim.Play("Attack1");
                //sound 1
                break;

            case 1:     //Second Attack
                comboIndex++;
                //Debug.Log("Combo 2");
                playerController.anim.Play("Attack1");
                //sound 2
                break;

            case 2:     //Third Attack
                comboIndex++;
                //Debug.Log("Combo 3");

                //attackDamageMultiplier += 2;
                playerController.anim.Play("Attack1");
                //sound3
                break;
            }

            foreach (GameObject target in targetList)
            {
                HealthScript enemyHealth = (HealthScript)target.GetComponent <HealthScript>();

                if (enemyHealth.GetHealth() > 0)
                {
                    /**if (Vector3.Dot(TargetFacing(enemyHealth.transform.forward, transform.position), transform.forward) < 0.05f) //Sneak modifier added
                     * {
                     *  attackDamageMultiplier += 2;
                     *  Debug.Log("Sneak Attack Multiplier Added");
                     * }*/

                    enemyHealth.Damage(attackDamage);

                    /**if (currentComboIndex == 3)
                     * {
                     *  StartCoroutine(KnockbackTarget(transform.position, target));
                     *  comboIndex = 0; //Reset Combo Indexer
                     * }*/
                }
            }
        }
        else
        {
            playerController.anim.Play("Attack1");
            comboIndex = 0;
        }

        if (comboIndex == 3)
        {
            comboIndex = 0;
        }

        playerController.isBusy = false;
        playerController.movementScript.canMove = true;
        yield return(new WaitForSeconds(resetTime));
    }
 //
 public float GetHealth()
 {
     return(healthScript.GetHealth());
 }