Esempio n. 1
0
 public void recvDamage(int dmg, CharMotor src)
 {
     //if(this == null) return;
     if((Health -= dmg) <= 0) {
         WavMn.enemyDied();
         Destroy(gameObject);
     }  else if(src != null) spotted(src);
 }
Esempio n. 2
0
 public void setTarget( Vector2 at )
 {
     Target = null;
     var n = NavMsh.findNode(at, TargetNode);
     if(n == null) return;
     TargetNode = n;
     TargetP = at;
 }
Esempio n. 3
0
 public void spotted(CharMotor mtr)
 {
     if(mtr == Target) return;
     if(Target != null) {
         if((Target.Trnsfrm.position - Trnsfrm.position).sqrMagnitude < (mtr.Trnsfrm.position - Trnsfrm.position).sqrMagnitude)
             return;
     }
     Target = mtr;
     //Vis.enabled = false;
     //if( CurAttack ==null ) Speed = SpeedChase;
 }
Esempio n. 4
0
    /*
      public static T Cast<T>(object o)
        {
            return (T)o;
        }

    Then invoke this using reflection:

        MethodInfo castMethod = this.GetType().GetMethod("Cast").MakeGenericMethod(t);
        object castedObject = castMethod.Invoke(null, new object[] { ob
     *

    public static Receiver cast<T>(object o) {
        return (Receiver)(T)o;
    }*/
    void Awake()
    {
        if(Motor == null) {
            Motor = GetComponent<CharMotor>();
            if(Motor == null) GetComponentInParent<CharMotor>();
        }
        Timer = Freq;

        /*
               foreach( Component c in Recv.GetComponents<Component>() ) {
            var t = c.GetType();
            if(typeof(Receiver).IsAssignableFrom(t) ) {
                MethodInfo castMethod = this.GetType().GetMethod("cast").MakeGenericMethod(t);
                object castedObject = castMethod.Invoke(null, new object[] { c });
                _Recv = (Receiver)castedObject;
                //Debug.Log(" castedObject " + castedObject + "  " + castedObject.GetType() + " t " + t + "   " + typeof(Receiver).IsAssignableFrom(t));
                break;
            }
        */
        //_Recv.spotted(Motor);
           // Debug.Log(" _Recv " + _Recv);
    }
Esempio n. 5
0
 public void applyDamage(int dmg, CharMotor src)
 {
     //if(DamRecv != null)
     if (!isInvincible) { isInvincible = true; DamRecv.recvDamage(dmg, src); }
 }
Esempio n. 6
0
 public void recvDamage(int dmg, CharMotor src)
 {
     IncreaseHP(-dmg);
 }
Esempio n. 7
0
 void Awake()
 {
     Motor = GetComponent<CharMotor>();
     Timer = Freq;
 }