#region Copyright /* -------------------------------------------------------------------------------- This source file is part of Xenocide by Project Xenocide Team For the latest info on Xenocide, see http://www.projectxenocide.com/ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. -------------------------------------------------------------------------------- */ /* * @file BattlescapeScreenStates.cs * @date Created: 2008/02/03 * @author File creator: David Teviotdale * @author Credits: none */ #endregion #region Using Statements using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Drawing; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using ProjectXenocide.Utils; using ProjectXenocide.Model; using ProjectXenocide.UI.Dialogs; using System.Threading; using ProjectXenocide.Model.Battlescape.Combatants; using ProjectXenocide.Model.Battlescape; using ProjectXenocide.UI.Scenes.Battlescape; #endregion namespace ProjectXenocide.UI.Screens { /* This file holds the Battlescape's nested ScreenState classes */ public partial class BattlescapeScreen { /// /// Control behaviour, based on state screen is in. /// private abstract class ScreenState { /// /// Constructor /// /// The parent battlescape protected ScreenState(BattlescapeScreen battlescapeScreen) { this.battlescapeScreen = battlescapeScreen; } /// Update any model data /// Time since last update() call public virtual void Update(GameTime gameTime){ /* default behaviour is do nothing */ } /// React to user clicking left mouse button in the 3D battlescape scene /// Cell in battlescape where mouse was clicked public virtual void OnLeftMouseDownInScene(Vector3 pos) { /* default behaviour is do nothing */ } /// React to user clicking right mouse button in the 3D battlescape scene /// Cell in battlescape where mouse was clicked public virtual void OnRightMouseDownInScene(Vector3 pos) { /* default behaviour is do nothing */ } /// React to user moving cursor to new cell of battlescape /// Cell in battlescape mouse was moved to public virtual void OnMouseMoveInScene(Vector3 pos) { /* default behaviour is do nothing */ } /// Called when Screen enters a state public virtual void OnEnterState() { /* default behaviour is do nothing */ } /// Called when Screen exits a state public virtual void OnExitState() { /* default behaviour is do nothing */ } #region buttons being clicked /// User has clicked the Equipment button public virtual void OnEquipmentButton() { /* default behaviour is do nothing */ } /// User has clicked the either Right or Left hand button /// true if it was the "right hand" button public virtual void OnHandButton(bool right) { /* default behaviour is do nothing */ } /// User has clicked the "Finish Turn" button public virtual void OnFinishTurnButton() { /* default behaviour is do nothing */ } /// User has clicked the "Abort Mission" button public virtual void OnAbortButton() { /* default behaviour is do nothing */ } #endregion buttons being clicked #region Fields /// The parent BattlescapeScreen public BattlescapeScreen BattlescapeScreen { get { return battlescapeScreen; } } /// The Battlescape public Battle Battlescape { get { return battlescapeScreen.battlescape; } } /// The parent BattlescapeScreen private BattlescapeScreen battlescapeScreen; #endregion Fields } /// /// Screen behaviour, when battlescape is starting a turn /// private class StartTurnScreenState : ScreenState { /// /// Constructor /// /// The parent battlescapeScreen public StartTurnScreenState(BattlescapeScreen battlescapeScreen) : base(battlescapeScreen) { } /// Update any model data /// Time since last update() call public override void Update(GameTime gameTime) { // ToDo: implement pumping state machine owned by Battlescape until it reports aliens // and civilians have finished the actions they do before the X-Corp soldiers do anything // then let player start giving orders to the X-Corp soldiers //... start with to first soldier in X-Corp list Combatant combatant = Battlescape.Teams[Team.XCorp].Combatants[0]; BattlescapeScreen.ChangeState(new MoveOrderCombatantScreenState(BattlescapeScreen, combatant)); } /// Called when Screen enters this state public override void OnEnterState() { Battlescape.OnStartTurn(); } } /// /// Screen behaviour, when combatant is processing order /// private class CombatantActivityScreenState : ScreenState { /// /// Constructor /// /// The parent battlescapeScreen /// Combatant that is performing action public CombatantActivityScreenState(BattlescapeScreen battlescapeScreen, Combatant combatant) : base(battlescapeScreen) { this.combatant = combatant; } /// Update any model data /// Time since last update() call public override void Update(GameTime gameTime) { // ToDo: this code is just a temp hack to get MoveAction working. // This logic needs to be moved into a state machine owned by the Battlescape. if (combatant.BattlescapeUpdate(gameTime.ElapsedRealTime.TotalMilliseconds / 1000.0f)) { // action finished, wait for another order BattlescapeScreen.ChangeState(new MoveOrderCombatantScreenState(BattlescapeScreen, combatant)); } } #region Fields /// Combatant player is giving order to private Combatant combatant; #endregion Fields } } }