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); }
public void setTarget( Vector2 at ) { Target = null; var n = NavMsh.findNode(at, TargetNode); if(n == null) return; TargetNode = n; TargetP = at; }
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; }
/* 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); }
public void applyDamage(int dmg, CharMotor src) { //if(DamRecv != null) if (!isInvincible) { isInvincible = true; DamRecv.recvDamage(dmg, src); } }
public void recvDamage(int dmg, CharMotor src) { IncreaseHP(-dmg); }
void Awake() { Motor = GetComponent<CharMotor>(); Timer = Freq; }