View Single Post
  #2  
Old 08-16-2011, 08:19 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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;
        }
    }
}

Last edited by FG28_Kodiak; 08-16-2011 at 09:09 AM.
Reply With Quote