public void ProcessCollisionInfo(GameObject collidedObject, GameObject objectCollidedWith) { string collidedObjectTag = collidedObject.tag; string objectCollidedWithTag = objectCollidedWith.tag; if (collidedObjectTag == CollisionConstants.BulletTag) { BulletController bullet = collidedObject.GetComponent <BulletController>(); // bullet hits any object except other bullet and owner if (objectCollidedWithTag == CollisionConstants.WallTag) { bullet.Destroy(); } // player's bullet hits an enemy or enemy bullet hits player if (objectCollidedWithTag == CollisionConstants.PlayerTag && bullet.Owner == Tank.UnitType.Enemy || objectCollidedWithTag == CollisionConstants.EnemyTag && bullet.Owner == Tank.UnitType.Player) { bullet.Destroy(); SpawnableUnit unit = objectCollidedWith.GetComponent <SpawnableUnit>(); unit.Despawn(); } } // player tank hits an enemy tank if (collidedObjectTag == CollisionConstants.PlayerTag && objectCollidedWithTag == CollisionConstants.EnemyTag) { SpawnableUnit unit = collidedObject.GetComponent <SpawnableUnit>(); unit.Despawn(); } }
static void Prefix(ref SpawnableUnit __instance, PilotDef pilotDef) { try { if (!string.IsNullOrEmpty(pilotDef.Voice)) { string text2 = string.Format("vo_{0}", pilotDef.Voice); AudioBankList bankId2 = (AudioBankList)Enum.Parse(typeof(AudioBankList), text2, true); SceneSingletonBehavior <WwiseManager> .Instance.LoadBank(bankId2); SceneSingletonBehavior <WwiseManager> .Instance.voBanks.Add(text2); } } catch (Exception e) { Logger.LogError(e); } }
protected void Spawn(int unitIndex) { SpawnableUnit unit = spawnableUnits[unitIndex]; if (ownerResources == null) { Debug.Log("owner resources = null"); } if (ownerResources.Food >= unit.cost) { ownerResources.removeFood(unit.cost); GameObject tempGO = Instantiate(unit.prefab, transform); tempGO.GetComponent <Renderer>().material = gameController.CurrentPlayerMaterial(); tempGO.transform.position = transform.position + Vector3.up * 1.5f; tempGO.GetComponent <UnitController>().MoveTo(DefaultTileToSpawn, DefaultPositionToSpawn); } }
public static bool Prefix(UnitSpawnPointGameLogic __instance, SpawnableUnit spawnableUnit, MechDef ___mechDefOverride, ref PilotDef ___pilotDefOverride, VehicleDef ___vehicleDefOverride, TurretDef ___turretDefOverride) { if (ModState.PlayerGetsAIMechs && __instance.team == TeamDefinition.Player1TeamDefinitionGuid && spawnableUnit.unitType == UnitType.Mech) { ModInit.modLog.LogMessage( $"PLAYER UNIT: First mech in AIMechVariants was {ModState.AIMechs.First().mechDef.Name} with count {ModState.AIMechs.First().count}"); var AIMechVariants = ModState.AIMechs.OrderBy(x => x.count).ToList(); ModInit.modLog.LogMessage( $"PLAYER UNIT: Filtered to match mechdef IDs and reordered! First mech in AIMechVariants is now {AIMechVariants.First().mechDef.Name} with count {AIMechVariants.First().count}"); ModState.AIMechs.First().count += 1; var newMechDef = AIMechVariants.FirstOrDefault()?.mechDef; newMechDef.DependenciesLoaded(1000U); ___mechDefOverride = newMechDef; ModInit.modLog.LogMessage( $"PLAYER UNIT: mechDefOverride set to {___mechDefOverride.Description.Id}"); ___pilotDefOverride = spawnableUnit.Pilot; ModInit.modLog.LogMessage( $"PLAYER UNIT: pilotDefOverride set to {___pilotDefOverride.Description.Id}"); __instance.pilotDefId = spawnableUnit.PilotId; ModInit.modLog.LogMessage( $"PLAYER UNIT: __instance.pilotDefId is {__instance.pilotDefId}, should be {___pilotDefOverride.Description.Id}"); __instance.mechDefId = newMechDef.Description.Id; ModInit.modLog.LogMessage( $"PLAYER UNIT: __instance.mechDefId is {__instance.mechDefId}, should be {___mechDefOverride.Description.Id}"); __instance.unitType = spawnableUnit.unitType; ___vehicleDefOverride = spawnableUnit.VUnit; ___turretDefOverride = spawnableUnit.TUnit; __instance.vehicleDefId = spawnableUnit.UnitId; __instance.turretDefId = spawnableUnit.UnitId; return(false); } return(true); }