Beispiel #1
0
    void Update()
    {
        if (idle)
        {
            transform.position = Vector3.MoveTowards(transform.position, moveTarget.position, walkSpeed * Time.deltaTime);
            transform.LookAt(moveTarget);
        }

        if (attackingPlayer && Vector3.Distance(transform.position, playerPosition.position) > beginHitDistance)
        {
            transform.position = Vector3.MoveTowards(transform.position, new Vector3(playerPosition.position.x, transform.position.y, playerPosition.position.z), walkSpeed * Time.deltaTime);
            transform.LookAt(new Vector3(playerPosition.position.x, transform.position.y, playerPosition.position.z));
        }
        if (attackingPlayer && Vector3.Distance(transform.position, playerPosition.position) < beginHitDistance)
        {
            //Begin hitting the player
            animator.SetTrigger("attack");
            idle            = false;
            attackingPlayer = false;
            transform.LookAt(new Vector3(playerPosition.position.x, transform.position.y, playerPosition.position.z));

            timeCounter += Time.deltaTime;
            if (timeCounter > secondsBetweenHits)
            {
                timeCounter = 0f;
                playerHealth.DecreaseHealth(damage);
            }
        }
        else if (attackingPlayer == false && idle == false && playerWasAttacked == true)
        {
            Attack();
        }
    }
Beispiel #2
0
    void Update()
    {
        if (Vector3.Distance(gameObject.transform.position, playerHealth.transform.position) < attackDistance)
        {
            if (!running && !hitting)
            {
                Run();
            }
            else if (Vector3.Distance(gameObject.transform.position, playerHealth.gameObject.transform.position) < startKickingDistance && !hitting)
            {
                Attack();
            }
            else
            {
                Run();
            }
        }

        if (hitting)
        {
            transform.LookAt(target);
            timeCounter += Time.deltaTime;
            if (timeCounter > secondsBetweenHits)
            {
                timeCounter = 0f;
                playerHealth.DecreaseHealth(damage);
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        timeCounter += Time.deltaTime;
        if (timeCounter > secondsBeforeExplode)
        {
            playerHealth.DecreaseHealth(Convert.ToInt32(CalculateDamage(playerHealth.transform.position)));
            Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);

            for (int i = 0; i < colliders.Length; i++)
            {
                Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();
                if (!targetRigidbody)
                {
                    continue;
                }
                targetRigidbody.AddExplosionForce(explosionForce, transform.position, explosionRadius);

                EnemyHealth enemyHealth = targetRigidbody.GetComponent <EnemyHealth>();
                if (!enemyHealth)
                {
                    continue;
                }
                enemyHealth.DecreaseHealth(Convert.ToInt32(CalculateDamage(targetRigidbody.position)));
            }

            explosionSound.gameObject.transform.parent = null;
            explosionSound.Play();
            Instantiate(explosion, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
    }
Beispiel #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <NVRHead>())
     {
         playerhealth.DecreaseHealth(damage);
     }
 }
Beispiel #5
0
    private void OnTriggerEnter(Collider other)
    {
        NVRHead playerHead = other.GetComponent <NVRHead>();

        if (playerHead)
        {
            playerHealth.DecreaseHealth(penaltyAmount);
        }
    }
Beispiel #6
0
    // Main response logic to audience input
    private void AudienceInput(bool redInput, int audienceMemberNumber)
    {
        // Create Laser
        CreateAudienceLaser(audienceMemberNumber, redInput);

        // Subtract from health
        healthBar.DecreaseHealth();

        // Decrease Health, includes cool text
        Messenger.Broadcast(GameEvent.BOSS_DECREASE_HP);
    }
    void OnTriggerEnter2D(Collider2D collider)
    {
        Projectile bullet = collider.gameObject.GetComponent <Projectile> ();

        if (bullet)
        {
            bullet.Hit();
            healthBar.DecreaseHealth(bullet.GetDamage());
            health -= bullet.GetDamage();
            if (health <= 0)
            {
                Die();
            }
        }
    }
Beispiel #8
0
    void Update()
    {
        if (!isHitting && Vector3.Distance(Target.position, transform.position) < hitLimit)
        {
            Hit();
            timeCounter += Time.deltaTime;
            if (timeCounter > 2)
            {
                timeCounter = 0f;
                playerHealth.DecreaseHealth(damage);
            }
        }
        else if (isHitting && Vector3.Distance(Target.position, transform.position) >= hitLimit)
        {
            isHitting = false;
            WalkTo(Target);
        }

        //if (isImmune && health.enabled)
        //{
        //    health.enabled = false;
        //}
        //else if (!isImmune && !health.enabled)
        //{
        //    health.enabled = true;
        //}
        if (move)
        {
            transform.position = Vector3.MoveTowards(transform.position, new Vector3(Target.position.x, transform.position.y, Target.position.z), walkSpeed * Time.deltaTime);
            transform.LookAt(new Vector3(Target.position.x, transform.position.y, Target.position.z));
        }
        if (turn)
        {
            Vector3 to = new Vector3(0, 180, 0);
            if (Vector3.Distance(transform.eulerAngles, to) > 0.01f)
            {
                transform.eulerAngles = Vector3.Lerp(transform.rotation.eulerAngles, to, Time.deltaTime);
            }
            else
            {
                transform.eulerAngles = to;
                turn = false;
            }
        }
    }
Beispiel #9
0
 void OnTriggerEnter(Collider other)
 {
     Debug.Log("Trigger");
     smashSound.Play();
     if (other.tag.Equals("Box"))
     {
         isDeactivated = true;
     }
     else if (other.tag.Equals("MainCamera"))
     {
         health.DecreaseHealth(110);
         Debug.Log("Die M**********r!!");
     }
     else
     {
         moveToEndPos = true;
     }
 }