// Use this for initialization void Start() { terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); start_time = Time.time; completion_time = start_time - 1f; race_car.transform.position = terrain_manager.myInfo.start_pos; race_car.transform.rotation = Quaternion.identity; Random.InitState(random_seed); for (int i = 0; i < number_of_turrets; i++) { Vector3 pos = terrain_manager.myInfo.GetRandomFreePos(); pos.y = 2f; //turret_list.Add(Instantiate(turret, pos, Quaternion.identity)); turret_clone = Instantiate(turret, pos, Quaternion.identity); destructable_script = (Destructable)turret_clone.GetComponent(typeof(Destructable)); destructable_script.is_weak = weak_turrets; gatlinggun_script = (GatlingGun)turret_clone.GetComponent(typeof(GatlingGun)); gatlinggun_script.is_long_range = long_range_turrets; turret_list.Add(turret_clone); } for (int i = 0; i < number_of_extra_cars; i++) { Vector3 pos = new Vector3(185f, 0, 135 + 10 * i); pos.y = 2f; turret_list.Add(Instantiate(race_car, pos, Quaternion.identity)); } }
// Use this for initialization void Awake() { terrain_manager = terrain_manager_game_object.GetComponent <TerrainManager>(); start_time = Time.time; completion_time = start_time - 1f; //race_car.transform.position = terrain_manager.myInfo.start_pos; //race_car.transform.rotation = Quaternion.identity; Random.InitState(random_seed); for (int i = 0; i < number_of_turrets; i++) { turret_clone = Instantiate(turret, Vector3.zero, Quaternion.identity); destructable_script = (Destructable)turret_clone.GetComponent(typeof(Destructable)); destructable_script.is_weak = weak_turrets; gatlinggun_script = (GatlingGun)turret_clone.GetComponent(typeof(GatlingGun)); gatlinggun_script.is_long_range = long_range_turrets; turret_clone.layer = LayerMask.NameToLayer("Ignore Raycast"); turret_list.Add(turret_clone); } for (int i = 0; i < number_of_extra_cars; i++) { Vector3 pos = new Vector3(185f, 0, 135 + 10 * i); pos.y = 2f; turret_list.Add(Instantiate(race_car, pos, Quaternion.identity)); } try { PositionTurrets(); } catch { Debug.Log("Delayed positioning of Turrets (in Start()) needed..."); } }
public override void UpdateBeforeSimulation100() { if (setup == true) { boolRecentWanted = false; setup = false; } HashSet <IMyEntity> ships = new HashSet <IMyEntity>(); //find all of the ships Sandbox.ModAPI.MyAPIGateway.Entities.GetEntities(ships, (x) => x is Sandbox.ModAPI.IMyCubeGrid); var GatlingGuns = new List <IMySmallGatlingGun>(); // go through ships foreach (var ship in ships) { var templist = new List <Sandbox.ModAPI.IMySlimBlock>(); // find all gatling guns in the group (ship as Sandbox.ModAPI.IMyCubeGrid).GetBlocks(templist, x => x.FatBlock is IMySmallGatlingGun); foreach (var temp in templist) { GatlingGuns.Add(temp.FatBlock as IMySmallGatlingGun); } } foreach (var GatlingGun in GatlingGuns) { var tempattackplayerid = GatlingGun.OwnerId; var tempdefendplayerid = (Entity as Sandbox.ModAPI.IMyTerminalBlock).OwnerId; var tempattackfactionid = MyAPIGateway.Session.Factions.TryGetPlayerFaction(tempattackplayerid); var tempdefendfactionid = MyAPIGateway.Session.Factions.TryGetPlayerFaction(tempdefendplayerid); try { if (Entity.GetTopMostParent().EntityId != GatlingGun.GetTopMostParent().EntityId&& (GatlingGun.Enabled) && GatlingGun.OwnerId != (Entity as Sandbox.ModAPI.IMyTerminalBlock).OwnerId && VRageMath.ContainmentType.Contains == GatlingGun.GetTopMostParent().WorldAABB.Contains(MyAPIGateway.Session.Player.GetPosition()) && (GatlingGun.GetPosition() - Entity.GetPosition()).Length() < 1500 && boolRecentWanted == false) { MyAPIGateway.Session.Factions.DeclareWar(tempdefendfactionid.FactionId, tempattackfactionid.FactionId); MyAPIGateway.Utilities.ShowNotification("You have failed to depower weapons", 3000, MyFontEnum.Red); MyAPIGateway.Utilities.ShowMessage("Admiral Butts", "You fool! We will tear you to shreds..."); boolRecentWanted = true; } if (boolRecentWanted == true && (GatlingGun.GetPosition() - Entity.GetPosition()).Length() > 3000) { MyAPIGateway.Session.Factions.AcceptPeace(tempdefendfactionid.FactionId, tempattackfactionid.FactionId); MyAPIGateway.Utilities.ShowNotification("Your are now free to repower weapons", 3000, MyFontEnum.Green); MyAPIGateway.Utilities.ShowMessage("Admiral Butts", "You're lucky to be alive, SCUM"); boolRecentWanted = false; } } catch { return; } } }