![]() |
#5
|
|||
|
|||
![]()
At the moment i about to finish a checkAirfield Routine:
Code:
using System; using System.Text; using System.Collections; using System.Collections.Generic; using maddox.game; using maddox.game.world; using maddox.GP; public class Mission : AMission { AiAirport PlayerStartAirport; AiAirport PlayerEndAirport; AiAircraft PlayerAircraft; internal AiAirport getNearestAirfield(Player player) { AiAirport NearestAirfield = null; AiAirport[] airports = GamePlay.gpAirports(); Point3d PlayerStartPos = player.Place().Pos(); if (airports != null) { foreach (AiAirport airport in airports) { if (NearestAirfield != null) { if (NearestAirfield != null) if (NearestAirfield.Pos().distance(ref PlayerStartPos) > airport.Pos().distance(ref PlayerStartPos)) NearestAirfield = airport; } else NearestAirfield = airport; } } return NearestAirfield; } internal AiAirport getNearestAirfield(AiWayPoint waypoint) { AiAirport NearestAirfield = null; AiAirport[] airports = GamePlay.gpAirports(); Point3d WaypointPos = waypoint.P; if (airports != null) { foreach (AiAirport airport in airports) { if (NearestAirfield != null) { if (NearestAirfield != null) if (NearestAirfield.Pos().distance(ref WaypointPos) > airport.Pos().distance(ref WaypointPos)) NearestAirfield = airport; } else NearestAirfield = airport; } } return NearestAirfield; } internal bool checkAirfield(Player player, AiAirport airport, double maxdistance) { Point3d PlayerPos = player.Place().Pos(); GamePlay.gpLogServer(null, "Distanz zum Flugplatz {0}", new object[] {airport.Pos().distance(ref PlayerPos)}); //test if (airport.Pos().distance(ref PlayerPos) < maxdistance) return true; else return false; } public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; } private void checkLanded(AiAircraft aircraft) { if (GamePlay.gpPlayer().Place() != aircraft) return; } public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) { if (aircraft.Player(0) != null) { if (checkAirfield(aircraft.Player(0) , PlayerStartAirport, 2000.0)) GamePlay.gpHUDLogCenter("Mission Successfull"); } } public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) { if (aircraft.Player(0) != null) { if (checkAirfield(aircraft.Player(0), PlayerStartAirport, 2000.0)) GamePlay.gpHUDLogCenter("Mission Successfull"); } } public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) { base.OnPlaceEnter(player, actor, placeIndex); if (PlayerStartAirport== null) PlayerStartAirport = getNearestAirfield(player); AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay(); int i = Wp.Length; if (i > 0) { AiWayPoint EndPoint = Wp[i - 1]; if (PlayerEndAirport == null) PlayerEndAirport = getNearestAirfield(EndPoint); } else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() }); } } This Code:
AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay(); int i = Wp.Length; if (i > 0) { AiWayPoint EndPoint = Wp[i - 1]; if (PlayerEndAirport == null) PlayerEndAirport = getNearestAirfield(EndPoint); } else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() }); Last edited by FG28_Kodiak; 10-06-2011 at 08:25 AM. |
|
|