/// <summary> /// Initialize the game. /// </summary> /// <note>DO NOT CHANGE INITIALIZATION ORDER</note> public override void Initialize() { //Initialize environment if (!m_Initialized) CreateSky(); if (!m_Initialized) CreateGUI(); if (!m_Initialized) CreateArrow(); if (!m_Initialized) CreateLighting(); //If has been initialized, remove old ships if (m_Initialized) foreach (Ship ship in m_Ships) ship.Remove(); //Load ships m_Ships = m_Data.LoadShipList(m_Layer); foreach (Ship ship in m_Ships) ship.Initialize(); //Create the board CreateBoard(); UpdateBoard(); //Create camera if (!m_Initialized) CreateBirdsView(); //Create and initialize actor if player if (m_Player == Player.Klotski || m_Player == Player.Storm) { if (m_Initialized) m_Actor.Remove(); m_Actor = new Actor(m_Layer); m_Controlled = m_Actor; m_ActiveCamera = m_Controlled.GetCamera(); m_Actor.Initialize(m_Ships[0], 3); Renderer.Lights.Add(m_Actor.GetLight()); } else m_ActiveCamera = m_BirdsView; //Initialize AI m_Depth = 0; m_MaxDepth = 1; m_VictoryWait = 0; m_ShipStack.Clear(); m_IteratorStack.Clear(); //Add current state m_VisitedList.Clear(); GameData Root = new GameData(); foreach (Ship ship in m_Ships) Root.AddShip(ship); m_VisitedList.Add(Root); //Start BGM Global.SoundManager.PlayBGM(Global.GAME_BGM); //Game is initialized m_Initialized = true; }
/// <summary> /// State Game class constructor. /// </summary> public StateGame(Player player, GameData data) : base(StateID.Game) { //Initialize variable m_Data = data; m_Player = player; m_Victory = false; m_Initialized = false; m_ReadyToUpdate = false; m_BoardWidth = 0; m_BoardHeight = 0; m_IteratorStack = new Stack<int>(); m_ShipStack = new Stack<Ship>(); m_VisitedList = new List<GameData>(); //Empties variables m_Depth = 0; m_MaxDepth = 0; m_Sky = null; m_Actor = null; m_King = null; m_Ships = null; m_Board = null; m_SkyLayer = null; m_BirdsView = null; m_ActiveCamera = null; m_Controlled = null; m_LifeBar = null; m_Timer = null; }