/// <summary> /// Gets the states in the start of the game. /// </summary> /// <param name="context">The concrete game context.</param> /// <returns>Object that implements the IGameState interface.</returns> public IGameState GetStartMenuState(Game context) { var startMenu = new StartMenuState(); startMenu.Context = context; return(startMenu); }
public BuildingBoardState(Game game) : base(game) { game.Services.AddService(typeof(IBuildingBoardState), this); scrollingBackgroundManager = new ScrollingBackgroundManager(game, "Textures\\"); game.Components.Add(scrollingBackgroundManager); scrollingBackgroundManager.ScrollRate = -1f; celAnimationManager = (ICelAnimationManager)game.Services.GetService(typeof(ICelAnimationManager)); startMenuState = (StartMenuState)game.Services.GetService(typeof(IStartMenuState)); allHidenPoints = SetHidenTiles(); // set all the allHidenPoints player = new Player(game) { myTurn = true }; enemy = new Player(game); player.pawns = new Pawn[player.army_size]; enemy.pawns = new Pawn[player.army_size]; remainShapesToPutOnBigEmptyBoard = 5; // set the number of shapes we exepted on board as 5 soundEffect = (ISoundManager)game.Services.GetService(typeof(ISoundManager)); isPlayBadPlaceSoundEffect = true; // for the algorithm about activate the badPlace sound // we dont see any shape: dragingShape = null; hideShape = true; }
bool checkButtons() { if (createButton.Triggered) { cleanup(); returnControl("create"); return(true); } else if (joinLanButton.Triggered) { NetPeerConfiguration config = new NetPeerConfiguration("rts"); config.Port = 14243; client = new NetClient(config); client.Start(); if (Game1.DEBUG) { client.Configuration.SimulatedMinimumLatency = .08f; client.Configuration.SimulatedRandomLatency = .01f; } client.DiscoverLocalPeers(14242); state = StartMenuState.Joining; } else if (joinIPButton.Triggered) { if (!File.Exists("C:\\rts hosts.txt")) { File.Create("C:\\rts hosts.txt"); } string[] hosts = File.ReadAllLines("C:\\rts hosts.txt"); NetPeerConfiguration config = new NetPeerConfiguration("rts"); config.Port = 14243; client = new NetClient(config); client.Start(); //client.Configuration.SimulatedMinimumLatency = .5f; //client.Configuration.SimulatedRandomLatency = .01f; foreach (string host in hosts) { client.DiscoverKnownPeer(host, 14242); } state = StartMenuState.Joining; } else if (exitButton.Triggered) { cleanup(); returnControl("exit"); return(true); } return(false); }
public FadeStartMenu(StartMenuState state, float gapTime = .5f) { stateContext = state; this.uim = state.Context; this.startMenuItems = uim._startMenu; gapBetweenFades = gapTime; }
void InitStateMachine() { _stateMachine = new StateMachine(); var menu = new StartMenuState(_startMenu, _gameUI, this); var p1 = new PlayerMoveState(_player1); var p2 = new PlayerMoveState(_player2); var checkEndGame = new CheckEndGameState(_checkEndGameProcessor); var endGame = new EndGameState(_endGameMenu, _gameUI, _checkEndGameProcessor, _grid, _player1, _player2); _stateMachine.AddTransition(menu, p1, TimeToPlay()); _stateMachine.AddTransition(p1, p2, SwitchToPlayer2()); _stateMachine.AddTransition(p2, checkEndGame, SwitchToCheckEnd()); _stateMachine.AddTransition(checkEndGame, p1, SwitchToPlayer1()); _stateMachine.AddTransition(checkEndGame, endGame, EndGame()); _stateMachine.AddTransition(endGame, p1, Restart()); _stateMachine.AddTransition(endGame, menu, ToStartMenu()); _stateMachine.AddAnyTransition(menu, ExitGame()); _stateMachine.SetState(menu); //условия перехода Func <bool> TimeToPlay() => () => _startMenu._startGame;//начинаем игру из стартового меню Func <bool> SwitchToPlayer2() => () => _player1._endMove; Func <bool> SwitchToCheckEnd() => () => _player2._endMove; Func <bool> SwitchToPlayer1() => () => _checkEndGameProcessor.ContinueGame(); Func <bool> EndGame() => () => !_checkEndGameProcessor.ContinueGame();; //ничья или ктото победил Func <bool> Restart() => () => _endGameMenu._restartGame; //рестарт игры из экрана конца игры Func <bool> ToStartMenu() => () => _endGameMenu._mainMenu; //переходим в стартовое меню из экрана конца игры Func <bool> ExitGame() => () => false; //выход в стартовое меню из любого состояния }
public ChooseFlagState(Game game) : base(game) { game.Services.AddService(typeof(IChooseFlagState), this); startMenuState = (StartMenuState)game.Services.GetService(typeof(IStartMenuState)); celAnimationManager = (ICelAnimationManager)game.Services.GetService(typeof(ICelAnimationManager)); color = Color.White; }
public override void Initialize() { LoadingState loadingState = new LoadingState(); StartMenuState startMenuState = new StartMenuState(); AddState(loadingState); AddState(startMenuState); }
void Awake() { frame = FindObjectOfType<Frame>(); if (!frame) throw new Exception("Couldn't find UPF Frame"); currentState = StartMenuState.InitialMenu; }
private void Start() { // Initialize states StartMenuState = new StartMenuState(this); BeginBattleState = new BeginBattleState(this); BattleState = new BattleState(this); BattleVictoryState = new BattleVictoryState(this); BattleLoseState = new BattleLoseState(this); // Initial state TransitionToState(StartMenuState); }
bool checkButtons() { if (createButton.Triggered) { cleanup(); returnControl("create"); return true; } else if (joinLanButton.Triggered) { NetPeerConfiguration config = new NetPeerConfiguration("rts"); config.Port = 14243; client = new NetClient(config); client.Start(); //client.Configuration.SimulatedMinimumLatency = .5f; //client.Configuration.SimulatedRandomLatency = .01f; client.DiscoverLocalPeers(14242); state = StartMenuState.Joining; } else if (joinIPButton.Triggered) { if (!File.Exists("C:\\rts hosts.txt")) File.Create("C:\\rts hosts.txt"); string[] hosts = File.ReadAllLines("C:\\rts hosts.txt"); NetPeerConfiguration config = new NetPeerConfiguration("rts"); config.Port = 14243; client = new NetClient(config); client.Start(); //client.Configuration.SimulatedMinimumLatency = .5f; //client.Configuration.SimulatedRandomLatency = .01f; foreach (string host in hosts) client.DiscoverKnownPeer(host, 14242); state = StartMenuState.Joining; } else if (exitButton.Triggered) { cleanup(); returnControl("exit"); return true; } return false; }
public FadeOutStartMenu(StartMenuState state) : base(state, .25f) { Logger.Debug("Fade out start"); curStage = StageToFadeInAtEndEnum.Quit; }
public FadeInStartMenu(StartMenuState state) : base(state, .5f) { curStage = StageToFadeInAtEndEnum.Title; stateContext.introInProgress = true; }
private void LoadExistingGame() { currentState = StartMenuState.ContinueMenu; SetupContinueMenu(); }
void Update() { if (InputManager.Instance.KeyReleased("Cancel") && currentState == StartMenuState.ContinueMenu) { currentState = StartMenuState.InitialMenu; SetupInitialMenu(); } }