Ejemplo n.º 1
0
 protected virtual AMS_Health_Management AquireTarget()
 {
     AMS_Health_Management[] enemyArray = FindObjectsOfType <AMS_Health_Management>();
     if (enemyArray.Length > 0)
     {
         float minDistance = turretRange;
         AMS_Health_Management closestCont = null;
         foreach (AMS_Health_Management enemy in enemyArray)
         {
             if (enemy.tag == "Default_Enemy" && enemy.currentHealth > 0)
             {
                 var dis = Vector3.Distance(transform.position, enemy.transform.position);
                 if (dis < minDistance)
                 {
                     minDistance = dis;
                     closestCont = enemy;
                 }
             }
         }
         if (closestCont != null)
         {
             return(closestCont);
         }
         else
         {
             return(null);
         }                      // Debug.Log("no enemy in range"); }
     }//there are enemies look to see if you hit
     else
     {
         return(null);
     }                      // Debug.Log("No enemies found in scene"); }
 }
Ejemplo n.º 2
0
    private void Start()
    {
        health          = GetComponentInParent <AMS_Health_Management>();
        currentCoolDown = 0f;

        baseHealth = FindObjectOfType <BaseHealth>();
    }
Ejemplo n.º 3
0
    private void OnTriggerStay(Collider other)
    {
        AMS_Health_Management health = null;

        if (!targetEveryone)
        {
            if (other.CompareTag("Player"))
            {
                health = other.gameObject.GetComponent <AMS_Health_Management>();
                DamageSomeone(health);
            }
            else
            {
                //Debug.Log("something other than player in trigger");
            }
        }
        else
        {
            health = other.gameObject.GetComponent <AMS_Health_Management>();
            if (health == null)
            {
                health = other.gameObject.GetComponentInChildren <AMS_Health_Management>();
            }
            if (health == null)
            {
                health = other.gameObject.GetComponentInParent <AMS_Health_Management>();
            }
            DamageSomeone(health);
        }
    }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        currentbase = FindObjectOfType <BaseHealth>();
        AMS_ScoreController.rankScores      = scoreRanks;
        AMS_ScoreController.score           = 0;
        AMS_ScoreController.scoreMultiplier = 1;
        AMS_ScoreController.parTimes        = parTimes;
        timeOnStart = Time.time;

        baseAlertCurrentTime = 0f;
        alertCurrentTime     = 0f;
        var playerScript = FindObjectOfType <KE_MainPlayer_Script>();

        if (playerScript != null)
        {
            var playerObj = playerScript.gameObject;
            playerHealth = playerObj.GetComponent <AMS_Health_Management>();
            if (playerHealth == null)
            {
                Debug.Log("player health was not where expected");
            }
        }
        else
        {
            Debug.Log("does not seem to be a player in the level");
        }
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        if (targetObj == null)
        {
            targetObj = gameObject;
        }

        var oldestParent = targetObj.transform;

        while (oldestParent.parent != null)
        {
            oldestParent = oldestParent.parent;
        }

        healthScript = oldestParent.GetComponentInChildren <AMS_Health_Management>();
    }//just finds the health script to watch
Ejemplo n.º 6
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag != "Player")
     {
         if (other.GetComponent <AMS_Health_Management>())
         {
             AMS_Health_Management manager = other.GetComponent <AMS_Health_Management>();
             manager.healthWeakend--;
             if (manager.healthWeakend == 0)
             {
                 manager.maxHealth     = manager.maxHealth * 2;
                 manager.currentHealth = manager.currentHealth * 2;
             }
         }
     }
 }
Ejemplo n.º 7
0
    private void OnTriggerStay(Collider other)
    {
        if (currentCoolDown <= 0f)
        {
            if (other.transform.parent != null && other.transform.parent.CompareTag("Taunt") || other.gameObject.CompareTag("Player"))
            {
                AMS_Health_Management victimHealth;

                if (other == lastCollided)
                {
                    victimHealth = lastHealth;
                }
                else
                {
                    lastCollided = other;
                    if (other.gameObject.CompareTag("Player"))
                    {
                        victimHealth = other.GetComponent <AMS_Health_Management>();
                    }
                    else
                    {
                        victimHealth = other.transform.parent.GetComponentInChildren <AMS_Health_Management>();
                    }
                    lastHealth = victimHealth;
                }

                if (victimHealth != null)
                {
                    victimHealth.TakeDamage(damageAmount, "enemy volume");
                    currentCoolDown = coolDownMax;
                }
                else
                {
                    Debug.Log("can't find health component");
                }
            }//damage the player
            else if (baseHealth != null && baseHealth.invulnerable == false)
            {
                if (other.name == "BaseHealth")
                {
                    baseHealth.currentHP -= damageAmount;
                    currentCoolDown       = coolDownMax;
                }
            }
        }
    }
Ejemplo n.º 8
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         playerHealth = other.gameObject.GetComponent <AMS_Health_Management>();
         if (playerHealth.currentHealth != playerHealth.maxHealth)
         {
             HealthText.text = "Press E to grab Healthpack";
             collectable     = true;
         }
         else
         {
             HealthText.text = "You have full health";
             collectable     = false;
         }
         note.SetActive(true);
     }
 }
Ejemplo n.º 9
0
 private void DamageSomeone(AMS_Health_Management health)
 {
     if (health != null)
     {
         if (ignoreInvincible)
         {
             health.TakeDamageUnfair(damageAmount);
         }
         else
         {
             health.TakeDamage(damageAmount, "environment");
         }
     }
     else
     {
         //Debug.Log("cannot find health component where it is expected!!");
     }
 }
Ejemplo n.º 10
0
    protected override AMS_Health_Management AquireTarget()
    {
        AMS_Health_Management returnValue = null;

        AMS_Health_Management[] enemyArray = FindObjectsOfType <AMS_Health_Management>();
        if (enemyArray.Length > 0)
        {
            float minTurretDis = turretRange;
            float minHiveDis   = turretRange;
            AMS_Health_Management closestCont = null;
            AMS_Health_Management closestHive = null;
            foreach (AMS_Health_Management enemy in enemyArray)
            {
                if (enemy.tag == "Target" && enemy.currentHealth > 0 || enemy.tag == "Default_Enemy" && enemy.currentHealth > 0)
                {
                    var dis = Vector3.Distance(transform.position, enemy.transform.position);
                    if (dis < minTurretDis)
                    {
                        minTurretDis = dis;
                        closestCont  = enemy;
                    }
                }
                else if (enemy.gameObject.GetComponent <AMS_Hive>() != null)
                {
                    var dis = Vector3.Distance(transform.position, enemy.transform.position);
                    if (dis < minHiveDis)
                    {
                        minHiveDis  = dis;
                        closestHive = enemy;
                    }
                }
            }
            if (closestCont != null)
            {
                returnValue = closestCont;
            }
            else if (closestHive != null)
            {
                returnValue = closestHive;
            }
        }//there are enemies look to see if you hit

        return(returnValue);
    }
Ejemplo n.º 11
0
    // Use this for initialization

    private void Awake()
    {
        _Health_Management = GetComponent <AMS_Health_Management>();
    }