Exemplo n.º 1
0
 void Start()
 {
     lr = GetComponent <LineRenderer> ();
     dg = GetComponent <DamageGiver> ();
     lr.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero });
     CheckRaycast(transform.position);
     //		transform.forward = Camera.main.transform.forward;
 }
Exemplo n.º 2
0
        void OnCollisionEnter(Collision hit)
        {
            DamageGiver dg = hit.collider.GetComponent <DamageGiver> ();

            if (dg)
            {
                Destroy(dg);
            }
        }
Exemplo n.º 3
0
 public void TryTakeDamage(DamageGiver dg)
 {
     //		Debug.Log ("dg.rig:" + dg.GetComponent<Rigidbody> ().velocity);
     if (directional)
     {
         //			Vector3 dirToDamageGiver = (dg.transform.position - this.transform.position).normalized;
         //			Vector3 dirToDamageGiver = dg.GetComponent<Rigidbody>().velocity;
         Vector3 dirToDamageGiver = Camera.main.transform.position - transform.position;
         if (!DirectionValid(dirToDamageGiver))
         {
             return;
         }
     }
     TakeDamage(dg.damageAmount);
     DamageFx(dg);
 }
Exemplo n.º 4
0
 public void DamageFx(DamageGiver dg)
 {
     GameObject x = (GameObject)Instantiate(smallExplosion, dg.transform.position, dg.transform.rotation);
 }