示例#1
0
 private void KilledBy(GameObject attacker)
 {
     if (killable != null)
     {
         killable.Kill(attacker);
     }
     Reset();
 }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Minion")
        {
            Killable minion = other.GetComponent <Killable> ();

            Health -= 1;

            minion.Kill();
        }
    }
    void CheckForKillsAndCollisions()
    {
        Vector3 avoidVector = Vector3.zero;

        foreach (GameObject agent in detector.nearbyAgents)
        {
            Killable killable = agent.GetComponent <Killable>();
            if (killable)
            {
                // Draw rays to debug
                Vector3 raystart  = transform.position + Vector3.up * 5;
                Vector3 direction = agent.transform.position + Vector3.up * 2 - raystart;
                Debug.DrawRay(raystart, direction, Color.green);
                Debug.DrawRay(raystart, direction.normalized * killDistance, Color.blue);
                //print("distance:  " + direction.magnitude);

                // Distance to target's head or thereabuots
                if (Vector3.Distance(transform.position + Vector3.up * 2, agent.transform.position) < killDistance)
                {
                    killable.Kill();
                }
            }
            else
            {
                Vector3 raystart  = transform.position + Vector3.up * 5;
                Vector3 direction = agent.transform.position + Vector3.up * 5 - raystart;
                Debug.DrawRay(raystart, direction, Color.green);
                Debug.DrawRay(raystart, direction.normalized * killDistance, Color.magenta);

                if (Vector3.Distance(transform.position + Vector3.up * 5, agent.transform.position) < killDistance)
                {
                    avoidVector += direction.normalized * avoidForceMultiplier / direction.magnitude;
                }
            }
        }

        // apply aviod force
        if (avoidVector.magnitude > maxAvoidForce)
        {
            avoidVector = avoidVector.normalized * maxAvoidForce;
        }
        body.AddForce(avoidVector);
    }
示例#4
0
    public void Kill()
    {
        if (alive)
        {
            AudioPlayer.main.PlaySound(GameEvent.BombExplodes);
            GameObject xpl = Instantiate(Explosion);
            xpl.SetActive(true);
            xpl.transform.position = transform.position - Vector3.forward;
            ParentPlane.Kill();
            lightSmoke.Play();
            darkSmoke.Play();
            fire.Play();

            foreach (GameObject obj in disableObjects)
            {
                obj.SetActive(false);
            }

            alive = false;
        }
    }
示例#5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Killable killable = (Killable)target;

        if (Application.isPlaying)
        {
            if (GUILayout.Button("Kill"))
            {
                killable.Kill();
            }
            if (GUILayout.Button("¨Destroy"))
            {
                killable.Destroy();
            }
            if (GUILayout.Button("Resurrect"))
            {
                killable.Resurrect();
            }
        }
    }
示例#6
0
 public void Attack(Killable character)
 {
     character.Kill();
 }