public void AirDropAt(Vector3 position, float speed = 50f, float height = 400f) { float worldSize = (float)(global::World.Size - (global::World.Size / 7)); Vector3 zero = Vector3.zero; BaseEntity baseEntity = GameManager.server.CreateEntity("assets/prefabs/npc/cargo plane/cargo_plane.prefab", default(Vector3), default(Quaternion)); if (baseEntity) { baseEntity.Spawn(true); } CargoPlane cp = baseEntity.GetComponent <CargoPlane>(); Vector3 startPos = zero, endPos = zero; float secsToTake; float rand = (float)(worldSize * UnityEngine.Random.Range(0.4f, 1.2f)); while (startPos.x == 0 || startPos.z == 0) { startPos = Vector3Ex.Range(-rand, rand); } startPos.y = height; endPos = position + (position - startPos); endPos.y = height; secsToTake = Vector3.Distance(startPos, endPos) / speed; cp.SetFieldValue("startPos", startPos); cp.SetFieldValue("endPos", endPos); cp.SetFieldValue("secondsToTake", secsToTake); cp.transform.rotation = Quaternion.LookRotation(endPos - startPos); baseEntity.Spawn(true); }
public void StartExample() { createPlane = GetPlane; CargoPlane plane = createPlane(); // Ковариативность info = ShowInfo; info(plane); // Ковариативность Builder <Client> clientBuilder = GetClient; Builder <Person> personBuilder1 = clientBuilder; // ковариантность Builder <Person> personBuilder2 = GetClient; // ковариантность Person p = personBuilder1("Tomson"); // вызов делегата p.Display(); GetInfo <Person> personInfo = PersonInfo; GetInfo <Client> clientInfo = personInfo; // контравариантность Client client = new Client { Name = "Tomson" }; clientInfo(client); // Client: Tomson }
void cmdConsoleAirdropMassDrop(ConsoleSystem.Arg arg) { if (arg.connection != null) { if (arg.connection.authLevel < 1) { SendReply(arg, "You are not allowed to use this command"); return; } } if (arg.Args == null || arg.Args.Length < 1) { SendReply(arg, "You must select the number of airdrops that you want"); return; } for (int i = 0; i < Convert.ToInt32(arg.Args[0]); i++) { AllowNextDrop(); Vector3 dropposition = RandomDropPoint(); BaseEntity entity = GameManager.server.CreateEntity("assets/bundled/prefabs/events/cargo_plane.prefab", new Vector3(), defaultRot); if (entity != null) { CargoPlane plane = entity.GetComponent <CargoPlane>(); plane.InitDropPosition(dropposition); entity.Spawn(true); CPsecondsToTake.SetValue(plane, Vector3.Distance((Vector3)CPendPos.GetValue(plane), (Vector3)CPstartPos.GetValue(plane)) / airdropSpeed); } } }
// log air planes spawned void OnAirdrop(CargoPlane plane, Vector3 location) { if (LogAiredrop()) { executeQuery("INSERT INTO server_log_airdrop (plane, location, time) VALUES (@0, @1, @2)", plane.ToString(), location.ToString(), getDateTime()); } }
void cmdConsoleAirdropToPos(ConsoleSystem.Arg arg) { if (arg.connection != null) { if (arg.connection.authLevel < 1) { SendReply(arg, "You are not allowed to use this command"); return; } } if (arg.Args == null || arg.Args.Length < 3) { SendReply(arg, "You must give coordinates of destination ex: airdrop.topos 124 200 -453"); return; } AllowNextDrop(); BaseEntity entity = GameManager.server.CreateEntity("assets/bundled/prefabs/events/cargo_plane.prefab", new Vector3(), defaultRot); if (entity != null) { var targetPos = new Vector3(); targetPos.x = Convert.ToSingle(arg.Args[0]); targetPos.y = Convert.ToSingle(arg.Args[1]); targetPos.z = Convert.ToSingle(arg.Args[2]); CargoPlane plane = entity.GetComponent <CargoPlane>(); plane.InitDropPosition(targetPos); entity.Spawn(true); CPsecondsToTake.SetValue(plane, Vector3.Distance((Vector3)CPendPos.GetValue(plane), (Vector3)CPstartPos.GetValue(plane)) / airdropSpeed); } }
private void Awake() { _entity = GetComponent <CargoPlane>(); _entity.dropped = true; enabled = false; }
static void Main(string[] args) { Console.WriteLine("Airplanes controller: \n"); Console.Beep(); var ABC123 = new PeoplePlane("ABC123", 50, 0, false, 350); var DDD888 = new PeoplePlane("DDD888", 35, 0, false, 450); var SSS777 = new PeoplePlane("SSS777", 70, 0, false, 250); //Operations on ABC123: Console.WriteLine($"Operations on {ABC123.PlaneId}: \n"); Console.Beep(3000, 300); ABC123.LoadPassengers(43); ABC123.TakeOff(); ABC123.Land(); ABC123.UnloadPassengers(43); //Operations on DDD888 Console.WriteLine($"Operations on {DDD888.PlaneId}: \n"); DDD888.LoadPassengers(23); DDD888.TakeOff(); DDD888.Land(); DDD888.UnloadPassengers(23); //Creating airport with airplanes var eindhovenAirport = new Airport("Eindhoven", ABC123, DDD888, SSS777); //Operations on the airport: eindhovenAirport.ListAirplanes(); eindhovenAirport.RequestPlaneDetails(); eindhovenAirport.LoadPassengersInto(ABC123, 55); //Instantiating cargo planes var FF2134 = new CargoPlane("FF2134", false, 0); var PLA166 = new CargoPlane("PLA166", false, 0); //Adding the two cargo planes to the airport Eindhoven: eindhovenAirport.AddCargoPlane(FF2134); eindhovenAirport.AddCargoPlane(PLA166); //Operations on the cargo planes eindhovenAirport.LoadCargoInto(FF2134, 17); //Calling the overriden ToString method Console.WriteLine(FF2134); Console.WriteLine(PLA166); Console.WriteLine(ABC123); Console.WriteLine(DDD888); Console.WriteLine(SSS777); Console.Beep(); //The spaceship var SPACE123 = new SpacePlane("SPACE123", false); SPACE123.LoadMissles(); SPACE123.StartStarterMotor(); }
private void callStrike(Vector3 position, int speed = -1) { if (speed == -1) { speed = planeSpeed; } if (broadcastStrikeAll) { PrintToChat(lang.GetMessage("strikeInbound", this)); } Puts(string.Format(lang.GetMessage("calledTo", this), position.ToString())); CargoPlane plane = CreatePlane(); var strikePlane = plane.gameObject.AddComponent <StrikePlane>(); if (strikePlane == null) { Puts("null plane"); } StrikePlanes.Add(strikePlane); strikePlane.SpawnPlane(plane, position, speed); float removePlane = ((Vector3.Distance((Vector3)StartPos.GetValue(plane), (Vector3)DropPos.GetValue(plane)) / speed) + 10); timer.Once(removePlane, () => DestroyPlane(strikePlane)); }
static void Main(string[] args) { Airplane a1 = new PassengerPlane(new Airbus()); a1.Fly(); Airplane a2 = new PassengerPlane(new Boeing()); a2.Fly(); Airplane a3 = new PassengerPlane(new MD()); a3.Fly(); Airplane a4 = new CargoPlane(new Airbus()); a4.Fly(); Airplane a5 = new CargoPlane(new Boeing()); a5.Fly(); Airplane a6 = new CargoPlane(new MD()); a6.Fly(); Console.ReadLine(); }
private CargoPlane GetPlane() { CargoPlane newPlane = new CargoPlane { Model = "AirBus" }; return(newPlane); }
public void HasRoomsTest() { CargoPlane airplane1 = new CargoPlane("EEE123"); airplane1.Load(10); Assert.IsTrue(airplane1.HasRooms()); }
public void UnLoadTest() { CargoPlane airplane1 = new CargoPlane("EEE123"); airplane1.Unload(); Assert.AreEqual(airplane1.CurrentAmountOfCargo, 0); }
private bool isStrikePlane(CargoPlane plane) { if (plane.GetComponent <StrikePlane>() != null && StrikePlanes.Contains(plane.GetComponent <StrikePlane>())) { return(true); } return(false); }
private void Awake() { entity = GetComponent <CargoPlane>(); rocketOptions = ins.configData.Rocket; fireDistance = ins.configData.Plane.Distance; entity.dropped = true; enabled = false; }
public void LoadTest() { CargoPlane airplane1 = new CargoPlane("EEE123"); airplane1.Load(50); Assert.AreNotEqual(airplane1.CurrentAmountOfCargo, 50); Assert.AreEqual(airplane1.CurrentAmountOfCargo, 20); }
private bool CanShowPanel(CargoPlane plane) { if (!IsStrikePlane(plane)) { return(false); } return(true); }
private void Awake() { entity = GetComponent <CargoPlane>(); rocketOptions = ins.configData.Rocket; fireDistance = ins.configData.Plane.Distance; hasDropped.SetValue(entity, true); enabled = false; }
private void SpawnPlane() { _plane = GameManager.server.CreateEntity(PLANE_PREFAB) as CargoPlane; if (_plane == null) { return; } _plane.Spawn(); _plane.gameObject.GetOrAddComponent <CargoComponent>().SetEvent(this); }
void OnAirdrop(CargoPlane plane, Vector3 location) { if (NotifyAirdrop) { string x = location.x.ToString(); string y = location.y.ToString(); string z = location.z.ToString(); string loc = x + ", " + y + ", " + z; Say(GetMsg("Incoming Airdrop").Replace("{location}", loc).Replace("{x}", x).Replace("{y}", y).Replace("{z}", z)); } }
void OnAirdrop(CargoPlane plane, Vector3 dropPosition) { if (configData.AirDropSurprise == null || configData.AirDropSurprise < 1) { return; } if (random.Next(1, 100) <= configData.AirDropSurprise) { SpawnSurprise(dropPosition); } }
/** * Spawns */ void OnAirdrop(CargoPlane plane, Vector3 location) { if (GetConfig <bool>("Across-the-board", "Enable Airdrop Notification", true)) { string Message = lang.GetMessage("Incoming Airdrop", this, null); string x = location.x.ToString(); string y = location.y.ToString(); string z = location.z.ToString(); string loc = x + ", " + y + ", " + z; Broadcast(Message.Replace("{location}", loc).Replace("{x}", x).Replace("{y}", y).Replace("{z}", z)); } }
void SpawnAirdrop(Vector3 position) { BaseEntity planeEntity = GameManager.server.CreateEntity("assets/prefabs/npc/cargo plane/cargo_plane.prefab", new Vector3(), new Quaternion(1f, 0f, 0f, 0f)); if (planeEntity != null) { CargoPlane plane = planeEntity.GetComponent <CargoPlane>(); plane.InitDropPosition(position); planeEntity.Spawn(); } }
private void OnEntitySpawned(CargoPlane plane) { NextTick(() => { if (!CanShowPanel(plane)) { return; } _activeAirdrops.Add(plane); CheckAirdrop(); }); }
private void OnEntitySpawned(CargoPlane plane) { NextTick(() => { if (!CanShowPanel(plane)) { return; } _activeStrikePlanes.Add(plane); CheckStrikePlanes(); }); }
private void OkButton_Click(object sender, EventArgs e) { if (ClassSelectComboBox.SelectedItem == null) { MessageBox.Show("Класс самолёта не выбран"); } else { try { if (ClassSelectComboBox.SelectedIndex == 0) { PassengerAirliner pasAir = new PassengerAirliner(); pasAir.Name = NameBox.Text; if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0) { pasAir.PasCap = Convert.ToInt32(PasCapBox.Text); pasAir.StaffCap = Convert.ToInt32(VarBox.Text); airline.AddPlane(pasAir); } else { MessageBox.Show("Некорректные данные"); } mainForm.Refresh(airline); Close(); } else if (ClassSelectComboBox.SelectedIndex == 1) { CargoPlane cargoAir = new CargoPlane(); cargoAir.Name = NameBox.Text; if (Convert.ToInt32(PasCapBox.Text) >= 0 && Convert.ToInt32(VarBox.Text) >= 0) { cargoAir.PasCap = Convert.ToInt32(PasCapBox.Text); cargoAir.LoadCap = Convert.ToDouble(VarBox.Text); airline.AddPlane(cargoAir); } else { MessageBox.Show("Некорректные данные"); } mainForm.Refresh(airline); Close(); } } catch (FormatException) { MessageBox.Show("Некорректные данные"); } } }
static void Main(string[] args) { /*create an airport which has 3 people plane, * 2 cargo plane and 1 space plane*/ var airport1 = new Airport("Eindhoven"); //list all the airplanes of the airport airport1.ShowAirplanes(); //request airplanes and take some actions with them try { PeoplePlane airplane1 = (PeoplePlane)airport1.RequestPlane("ABC124"); airplane1.Load(133); airplane1.TakeOff(); airplane1.Load(5); airplane1.Land(); airplane1.Unload(); airport1.ShowAvailableAirplanes(); } catch (NullReferenceException ex) { Console.WriteLine(ex); } try { CargoPlane airplane2 = (CargoPlane)airport1.RequestPlane("FF2134"); airplane2.Load(25); airplane2.TakeOff(); airplane2.Unload(); airplane2.Land(); airplane2.Unload(); } catch (NullReferenceException ex) { Console.WriteLine(ex); } try { SpacePlane spaceAirplane = (SpacePlane)airport1.RequestPlane("SPC777"); spaceAirplane.StartMotor(); spaceAirplane.TakeOff(); spaceAirplane.TakeOverMissile(5); } catch (NullReferenceException ex) { Console.WriteLine(ex); } }
private void CallStrike(Vector3 position) { CargoPlane entity = CreatePlane(); entity.Spawn(); StrikePlane plane = entity.gameObject.AddComponent <StrikePlane>(); plane.InitializeFlightPath(position); if (configData.Other.Broadcast) { PrintToChat(msg("strikeInbound")); } }
int this[int i] { get { if (arr[i] is PassangerPlane) { PassangerPlane x = arr[i] as PassangerPlane; return(x.passangerCapacity); } else { CargoPlane y = arr[i] as CargoPlane; return(y.carrying); } } }
private bool CanShowPanel(CargoPlane plane) { if (!IsCrashPlane(plane)) { return(false); } object result = Interface.Call("MagicPanelCanShow", Name, plane); if (result is bool) { return((bool)result); } return(true); }
private void MassSet(Vector3 position, Vector3 offset, int speed = -1) { if (speed == -1) { speed = planeSpeed; } CargoPlane plane = CreatePlane(); var strikePlane = plane.gameObject.AddComponent <StrikePlane>(); StrikePlanes.Add(strikePlane); strikePlane.SpawnPlane(plane, position, speed, true, offset); float removePlane = ((Vector3.Distance((Vector3)StartPos.GetValue(plane), (Vector3)DropPos.GetValue(plane)) / speed) + 10); timer.Once(removePlane, () => DestroyPlane(strikePlane)); }
int RandomCrateDrop(CargoPlane cargoplane) { return GetRandomNumber(dropMinCrates, dropMaxCrates+1); }
Vector3 FindDropPoint(CargoPlane cargoplane) { return (Vector3)dropPosition.GetValue(cargoplane); }
private void OnAirdrop(CargoPlane plane, Vector3 dropLocation) { HookCalled("OnAirdrop"); }