public void _collisionEvent_MissileToMissile(MG_ClassMissile hitter, MG_ClassMissile hitted) { switch (hitter.type) { // Classic missile-to-missile collision default: bool isHit = false; if (MG_ControlPlayer.I._getIsEnemy(hitter.playerOwner, hitted.playerOwner)) { isHit = _collisionCondition_MissileToMissile_Enemies(hitter, hitted); } if (isHit) { if (hitter.mB_blockValue > hitted.mB_blockValue) { MG_ControlMissile.I._addToDestroyList(hitted); } else if (hitter.mB_blockValue < hitted.mB_blockValue) { MG_ControlMissile.I._addToDestroyList(hitter); } else { MG_ControlMissile.I._addToDestroyList(hitted); MG_ControlMissile.I._addToDestroyList(hitter); } } break; } }
public void _collisionHandler_UnitToMissile(GameObject unitObj, GameObject missileObj) { // Check the MG_ClassUnit owner of the GameObjects MG_ClassUnit unit = MG_Globals.I.units[0]; bool hasUnit = false; MG_ClassMissile missile = MG_Globals.I.missiles[0]; bool hasMissile = false; foreach (MG_ClassUnit cL in MG_Globals.I.units) { if (cL.sprite == unitObj) { unit = cL; hasUnit = true; if (debug) { Debug.Log("Unit found..."); } break; } } foreach (MG_ClassMissile cL in MG_Globals.I.missiles) { if (cL.sprite == missileObj) { missile = cL; hasMissile = true; if (debug) { Debug.Log("Missile found..."); } break; } } // If one of the class does not exist, cancel the collision if (!hasUnit || !hasMissile) { if (!hasUnit) { if (debug) { Debug.Log("Unit not found, returning..."); } } if (!hasMissile) { if (debug) { Debug.Log("Missile not found, returning..."); } } return; } // Mark this collision as already handled string[] hC = new string[] { unitObj.name, missileObj.name }; handledCollisions.Add(hC); if (debug) { Debug.Log("Collision between unit and missile success!" + Time.frameCount.ToString()); } _collisionEvent_UnitToMissile(unit, missile); }
public void _collisionEvent_MissileToTerrain(MG_ClassMissile missile, GameObject terrain) { switch (missile.type) { case "test": MG_ControlMissile.I._addToDestroyList(missile); break; } }
/// <summary> /// Returns true if collision can occur. /// </summary> public bool _collisionCondition_UnitToMissile_Enemies(MG_ClassUnit unit, MG_ClassMissile missile) { bool retVal = true; // Confirm the existence of missile's owner if (!MG_GetUnit.I._doesUnitExist(missile.ownerID)) { return(false); } return(retVal); }
public void _collisionHandler_MissileToMissile(GameObject hitterObj, GameObject hittedObj) { // Check the MG_ClassUnit owner of the GameObjects MG_ClassMissile hitter = MG_Globals.I.missiles[0]; bool hasHitter = false; MG_ClassMissile hitted = MG_Globals.I.missiles[0]; bool hasHitted = false; foreach (MG_ClassMissile cL in MG_Globals.I.missiles) { if (cL.sprite == hittedObj) { hitted = cL; hasHitted = true; } else if (cL.sprite == hitterObj) { hitter = cL; hasHitter = true; } if (hasHitter && hasHitted) { break; } } // If one of the class does not exist, cancel the collision if (!hasHitter || !hasHitted) { return; } if (!(hitted.mB_blockMissile || hitter.mB_blockMissile)) { return; // Missile block condition check } // Mark this collision as already handled string[] hC = new string[] { hitterObj.name, hittedObj.name }; handledCollisions.Add(hC); if (debug) { Debug.Log("Collision between missiles success!"); } _collisionEvent_MissileToMissile(hitter, hitted); }
public void _collisionEvent_UnitToMissile(MG_ClassUnit unit, MG_ClassMissile missile) { switch (missile.type) { case "test": bool isHit = false; if (MG_ControlPlayer.I._getIsEnemy(missile.playerOwner, unit.owner)) { isHit = _collisionCondition_UnitToMissile_Enemies(unit, missile); } if (isHit) { MG_ClassUnit missileOwner = MG_GetUnit.I._getUnitFromID(missile.ownerID); MG_CalcDamage.I._damageUnit(missileOwner, unit, 1); MG_ControlMissile.I._addToDestroyList(missile); } break; } }
public void _collisionHandler_MissileToDoodad(GameObject missileObj, GameObject doodadObj) { // Check the MG_ClassUnit owner of the GameObjects MG_ClassMissile missile = MG_Globals.I.missiles[0]; bool hasMissile = false, collidesToWalls = false; foreach (MG_ClassMissile cL in MG_Globals.I.missiles) { if (cL.sprite == missileObj) { collidesToWalls = cL.collideToWalls; if (!collidesToWalls) { break; } missile = cL; hasMissile = true; break; } } if (!collidesToWalls) { return; } // If one of the class does not exist, cancel the collision if (!hasMissile) { return; } // Mark this collision as already handled string[] hC = new string[] { missileObj.name, doodadObj.name }; handledCollisions.Add(hC); if (debug) { Debug.Log("Collision between missile and doodad success!"); } _collisionEvent_MissileToTerrain(missile, doodadObj); }
public void _addToDestroyList(MG_ClassMissile targetMissile) { toDestroy.Add(targetMissile.id); }
/// <summary> /// Returns true if collision can occur. /// </summary> public bool _collisionCondition_MissileToMissile_Enemies(MG_ClassMissile hitter, MG_ClassMissile hitted) { bool retVal = true; return(retVal); }