void damagingExplode(Collider col) { if(col.rigidbody.isKinematic) { if(script = col.rigidbody.GetComponent<TankMinionMobility>()) { script.usePhysics(); } script = null; if(F_script = col.rigidbody.GetComponent<F_ControlMode>()) { F_script.usePhysics(); } F_script = null; } }
void OnCollisionEnter(Collision hit) { GameObject expl = Instantiate(explosion, transform.position, Quaternion.identity) as GameObject; Collider[] collidersInRange = Physics.OverlapSphere (transform.position, explosionRadius); foreach (Collider col in collidersInRange) { if (col.rigidbody) { //Debug.Log("Hit Layer" + col.gameObject.layer); switch (col.gameObject.layer){ //swith case 12: if(script = col.rigidbody.GetComponent("TankMinionMobility") as TankMinionMobility) { script.usePhysics(); } simpleExplode(col); script = null; deductHealth(col); break; //framework case 13: if(F_script = col.rigidbody.GetComponent<F_ControlMode>()) { F_script.usePhysics(); } simpleExplode(col); F_script = null; deductHealth(col); break; //RAIN case 14: deductHealth(col); break; default: simpleExplode(col); break; } /* if(col.rigidbody.isKinematic) { if(script = col.rigidbody.GetComponent("TankMinionMobility") as TankMinionMobility) { script.usePhysics(); } script = null; if(F_script = col.rigidbody.GetComponent<F_ControlMode>()) { F_script.usePhysics(); } F_script = null; } col.rigidbody.AddExplosionForce (explosionPower, transform.position, explosionRadius, 1f, ForceMode.Impulse); if (healthManager = col.GetComponent(typeof(Health)) as Health){ healthManager.takeDamage(20f); } tRig = col.rigidbody.GetComponentInChildren<AIRig>(); Debug.Log (tRig); if (tRig != null) { Debug.Log (tRig); float currentHelath = tRig.AI.WorkingMemory.GetItem<float>("health"); tRig.AI.WorkingMemory.SetItem<float>("health", currentHelath - 20f); } if (NPCStats = col.GetComponent(typeof(F_Stats)) as F_Stats){ NPCStats.takeDamage(20f); } */ } } Destroy(gameObject); // destroy the grenade Destroy(expl, 3); // delete the explosion after 3 seconds }
public PatrollingState(F_TankController NPC) { myController = NPC; patrolWaypoints = myController.patrolWaypoints; stateID = StateID.Patroling; mySensor = myController.GetComponentInChildren<F_PasiveSensor>(); myNav = myController.GetComponent<NavMeshAgent>(); myControlMode = myController.GetComponent<F_ControlMode>(); }
// private Transform closestWaypoint; public StartPatrolState(F_TankController NPC) { stateID = StateID.StartPatrol; patrolWaypoints = NPC.patrolWaypoints; myController = NPC; myNav = NPC.GetComponent<NavMeshAgent>(); myControlMode = NPC.GetComponent<F_ControlMode>(); }
public DestroyedState(F_TankController NPC) { stateID = StateID.Destroyed; myController = NPC; mySensor = myController.GetComponentInChildren<F_PasiveSensor>(); myNav = myController.GetComponent<NavMeshAgent>(); myTargetting = myController.GetComponent<F_Targetting>(); myAttack = myController.GetComponent<TankMinionAttack>(); myStats = myController.GetComponent<F_Stats>(); myControlMode = myController.GetComponent<F_ControlMode>(); }