Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Diagnostics; // for Stopwatch timer
public class Mission : AMission
{
Stopwatch PlayerGroupIdleTimer = new Stopwatch();
const int PlayerAirgroupIdleTimeMinutes = 3; // 3 minutes for player to warm up his engine
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft airc1 = (AiAircraft)GamePlay.gpPlayer().Place();
PlayerGroupIdleTimer.Start();
if (!airc1.IsAirborne())
{
airc1.AirGroup().Idle = true;
GamePlay.gpHUDLogCenter(player.Name() + " warm up your engine");
}
}
public override void OnTickGame()
{
base.OnTickGame();
//check mission timers
if (PlayerGroupIdleTimer.Elapsed.Minutes >= PlayerAirgroupIdleTimeMinutes)
{
PlayerGroupIdleTimer.Reset(); //Set timer to 0
PlayerGroupIdleTimer.Stop();
AiAircraft airc1 = (AiAircraft)GamePlay.gpPlayer().Place();
airc1.AirGroup().Idle = false;
}
}
}