Ejemplo n.º 1
0
 public void StartGame()
 {
     OnGameStarted?.Invoke();
     GameStarted = true;
     cameraSetup.PreventDoubleTrigger();
     SpawnPlayer();
 }
Ejemplo n.º 2
0
    public override void OnServerAddPlayer(NetworkConnection conn)
    {
        Transform  start  = numPlayers == 0 ? startPos1.transform : startPos2.transform;
        GameObject player = Instantiate(playerPrefab, start.position, start.rotation);

        player.name = "Player" + count++;
        NetworkServer.AddPlayerForConnection(conn, player);
        foreach (var it in NetworkServer.connections)
        {
            if (it.Value != NetworkServer.localConnection)
            {
                cl = it.Value;
            }
        }

        if (numPlayers == 2)
        {
            GlobalVariables.local = false;
            OnGameStarted?.Invoke();
            menuObject.SetActive(false);
            NetworkSceneCreator nsc = new NetworkSceneCreator();
            nsc.createNetworkGameScene(cl);
            ngc.conn     = conn;
            ngc.elements = nsc.game;
            ngc.start    = true;
            FindObjectOfType <AudioManager>().Play("ingame_music");
        }
    }
Ejemplo n.º 3
0
    public void StartMainGame(bool newGame = false)
    {
        OnGameStart?.Invoke();
        AsyncOperation asop = SceneManager.LoadSceneAsync(MainGameName);

        asop.completed += _ => OnGameStarted?.Invoke();
    }
Ejemplo n.º 4
0
        public void Start()
        {
            OnGameStarting?.Invoke(this, new GameStateEventArgs(_gameState));

            _gameState.PlayerOne = new Player
            {
                Name    = "Player 1",
                Marker  = 'X',
                IsHuman = true
            };

            _gameState.PlayerTwo = new Player
            {
                Name    = "Player 2",
                Marker  = 'O',
                IsHuman = true
            };

            _gameState.CurrentPlayer = _gameState.PlayerOne;

            HandleAction(GameAction.CoinFlip);

            //get human player count
            //setup any AI

            OnGameStarted?.Invoke(this, new GameStateEventArgs(_gameState));
        }
Ejemplo n.º 5
0
        public void Start()
        {
            var data = Game.StartGame(Team.Blue);

            OnGameStarted?.Invoke(data);
            Console.WriteLine("Runner started the game!");
        }
Ejemplo n.º 6
0
 void OnCountdownFinished()
 {
     SetPageState(PageState.None);
     OnGameStarted?.Invoke();
     _score    = 0;
     _gameOver = false;
 }
Ejemplo n.º 7
0
 public void StartGame()
 {
     gameState = GameStates.Play;
     enemySpawner.CurrentWave = 0;
     enemySpawner.StartNextWave();
     OnLevelStarted?.Invoke(enemySpawner.CurrentWave, enemySpawner.MaxWave);
     OnGameStarted?.Invoke();
 }
Ejemplo n.º 8
0
    public void StartGame()
    {
        lives = PlayerDataHolder.GetLives();

        OnGameStarted?.Invoke();

        UIManager.Instance.UpdateLives(lives);
    }
Ejemplo n.º 9
0
 void OnCountdownFinished()
 {
     SetUIState(GameUIState.Playing);
     scoreText.SetActive(true);
     OnGameStarted?.Invoke();
     ;
     score_ = 0;
     potatoHorizontalPosition.Value = 0;
 }
Ejemplo n.º 10
0
 public void StartGame()
 {
     foreach (var moving in _movingObjects)
     {
         moving.ToInitialState();
         moving.Activate();
     }
     OnGameStarted?.Invoke();
 }
Ejemplo n.º 11
0
 public void StartGame()
 {
     scoreText.gameObject.SetActive(true);
     multiplierText.gameObject.SetActive(true);
     startGamePanel.SetActive(false);
     endGamePanel.SetActive(false);
     OnGameStarted?.Invoke();
     gameStarted = true;
 }
Ejemplo n.º 12
0
 private void Awake()
 {
     // Make the game run as fast as possible. Avoids setting to default frame rate on device.
     Application.targetFrameRate = 300;
     gameMode = GetComponent <GameMode>();
     PlayerData.Create();
     GameInitialized += delegate { OnGameIntialized.Invoke(); };
     GameStarted     += delegate { OnGameStarted.Invoke(); };
     GameOver        += delegate { OnGameOver.Invoke(); };
 }
Ejemplo n.º 13
0
        /// <summary>
        ///     Runs the current MAME game.
        /// </summary>
        public void RunGame()
        {
            // Don't attempt to start MAME process if we are exiting
            if (_cancellationTokenSource.IsCancellationRequested)
            {
                return;
            }

            var game = CurrentGame();

            Log.Information("Running game {description} {year} {manufacturer} on display {display}",
                            game.Description,
                            game.Year, game.Manufacturer, _screen.DeviceName);

            // Create layout and run game
            var arguments = new List <string>
            {
                game.Name,
                _settings.CommandLineOptions,
                "-screen",
                $"\"{_screen.DeviceName}\""
            };

            // Enable in-game titles if required
            if (_settings.LayoutSettings.InGameTitles.Enabled)
            {
                var artPath = _layoutBuilder.EnsureLayout(game, _screen.Bounds.Width, _screen.Bounds.Height);
                arguments.Add("-artpath");
                arguments.Add(artPath);
            }

            try
            {
                // Start MAME, verifying that we aren't in the process of shutting down
                if (_cancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }

                _mameProcess         = _invoker.Run(false, arguments.ToArray());
                _mameProcess.Exited += OnMameExited;
                _mameProcess.Start();

                Log.Debug("MAME started; pid: {pid}", _mameProcess.Id);

                OnGameStarted?.Invoke(this, null);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unable to start game");
                _cancellationTokenSource.Cancel();

                throw;
            }
        }
        private void DisableCountdownText(OnGameStarted _)
        {
            _countdownText.text = "GO GO GO GO";
            StartCoroutine(WaitForTwoSeconds());

            IEnumerator WaitForTwoSeconds()
            {
                yield return(new WaitForSeconds(2.0f));

                _countdownText.gameObject.SetActive(false);
            }
        }
        private void Start(object sender, EventArgs e)
        {
            Map map = mapSettingsControl.GetMap();

            IList <AiPlayer> aiPlayers = aiPlayerSettingsControl.GetPlayers();

            IList <Player> players = new List <Player>();

            foreach (AiPlayer aiPlayer in aiPlayers)
            {
                players.Add(aiPlayer);
            }

            players.Add(myHumanPlayerControl.GetPlayer());

            foreach (Player player in humanPlayerSettingsControl.GetPlayers())
            {
                players.Add(player);
            }

            Game game = null;

            using (UtilsDbContext db = new UtilsDbContext())
            {
                IEnumerable <HotseatSavedGameInfo> savedGamesEnum = db.HotseatSavedGameInfos.ToList();
                HotseatSavedGameInfo lastGame = savedGamesEnum.LastOrDefault();
                int gameId = 1;
                if (lastGame != null)
                {
                    gameId = lastGame.Id + 1;
                }

                var factory = new GameFactory();
                game = factory.CreateGame(gameId, GameType.MultiplayerHotseat, map, players, fogOfWar: fogOfWarCheckBox.Checked);


                // TEST

                /*NetworkObjectWrapper wrapper = new NetworkObjectWrapper<Game>() {TypedValue = game};
                 * using (var ms = new MemoryStream())
                 * {
                 *  wrapper.Serialize(ms);
                 *
                 *  ms.Position = 0;
                 *
                 *  var obj = NetworkObjectWrapper.Deserialize(ms).Value;
                 * }*/
                // END TEST
            }

            OnGameStarted?.Invoke(game);
        }
Ejemplo n.º 16
0
 private void SendInputDirection(InputDirection inputDirection)
 {
     print(inputDirection);
     if (!gameStarted)
     {
         gameStarted = true;
         OnGameStarted?.Invoke();
     }
     else
     {
         OnInput?.Invoke(inputDirection);
     }
 }
Ejemplo n.º 17
0
    public void StartGame()
    {
        Time.timeScale = 1f;

        Player      = _player;
        PlayerShips = _startingPlayerShips;

        _currentLevel = 1;

        LoadNewLevel(_currentLevel, _startingAsteroids);
        SpawnUFOs();

        OnGameStarted?.Invoke();
    }
        private void StartGame()
        {
            GameStarted = true;

            UnityMainThreadDispatcher.Instance().Enqueue(() =>
            {
                Debug.Log("Starting Game!");
                OnGameStarted?.Invoke();
                while (inboundMessages.Count > 0)
                {
                    IncommingMessageState inboundMessage = inboundMessages.Dequeue();
                    ReceiveMatchStateHandle(inboundMessage.opCode, inboundMessage.message);
                }
            });
        }
Ejemplo n.º 19
0
    private bool UpdateCooldown()
    {
        m_StartCountdownTimer -= Time.deltaTime;
        m_StartCountdownTimer  = Mathf.Max(m_StartCountdownTimer, 0.0f);

        if (m_StartCountdownTimer == 0.0f)
        {
            OnGameStarted?.Invoke();

            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 20
0
    IEnumerator StartGameCoroutine()
    {
        float countDown = 3;

        while (countDown > 0)
        {
            countDown -= Time.deltaTime;
            countDownText.SetText(countDown.ToString("f0"));
            yield return(null);
        }

        countDown = Mathf.Clamp(countDown, 0, countDown);

        gameSceneCountDownCanvas.enabled = false;
        gameUICanvas.enabled             = true;
        OnGameStarted?.Invoke();
    }
Ejemplo n.º 21
0
        private void OnStateUpdatedCallback(int state)
        {
            Logger.Debug($"OnStateUpdatedCallback - state={state}");

            if (state == 1)
            {
                _changedLamps = new int[PinMameApi.PinmameGetMaxLamps() * 2];
                _changedGIs   = new int[PinMameApi.PinmameGetMaxGIs() * 2];

                OnGameStarted?.Invoke();
            }
            else
            {
                OnGameEnded?.Invoke();
                RunningGame = null;
            }
        }
        private void Start(object sender, EventArgs e)
        {
            try
            {
                Map map = mapSettingsControl.GetMap();

                IList <AiPlayer> aiPlayers = aiPlayerSettingsControl.GetPlayers();

                IList <Player> players = new List <Player>();
                foreach (AiPlayer aiPlayer in aiPlayers)
                {
                    players.Add(aiPlayer);
                }

                players.Add(myHumanPlayerControl.GetPlayer());

                Game game = null;
                // generate id for the game
                using (UtilsDbContext db = new UtilsDbContext())
                {
                    IEnumerable <SingleplayerSavedGameInfo> savedGamesEnum =
                        db.SingleplayerSavedGameInfos.AsEnumerable();
                    SingleplayerSavedGameInfo lastGame = savedGamesEnum.LastOrDefault();
                    int gameId = 1;
                    if (lastGame != null)
                    {
                        gameId = lastGame.Id + 1;
                    }

                    var factory = new GameFactory();
                    game = factory.CreateGame(gameId, GameType.SinglePlayer, map, players, fogOfWar: fogOfWarCheckBox.Checked);
                }


                OnGameStarted?.Invoke(game);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show(
                    "One or more components required to start the game are missing! Please, reinstall the game!",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 23
0
        public async Task RunAuto()
        {
            var data = Game.StartGame(Team.Blue);

            OnGameStarted?.Invoke(data);
            Console.WriteLine("Runner started an auto game!");

            while (Game.State != GameState.GameEnded)
            {
                Point move;
                if (Game.PlayerTurn == Team.Blue)
                {
                    move = PlayerBlue.ProposeMove(data);
                    PlayerRed.UpdateState(data);
                }
                else
                {
                    move = PlayerRed.ProposeMove(data);
                    PlayerBlue.UpdateState(data);
                }
                data = Game.TryMakeMove(Game.PlayerTurn, move);
                if (data.Code == ResponseCode.OK)
                {
                    await OnMoveCompleted?.Invoke(data);
                }
                if (Game.State == GameState.GameEnded)
                {
                    await OnMoveCompleted?.Invoke(data);

                    await OnGameEnded?.Invoke(data);

                    return;
                }
                await Task.Delay(500);
            }
            //if (data.Code == ResponseCode.Draw)
            //    Console.WriteLine("Draw!");
            //else
            //    Console.WriteLine("{0} Lost! (Point {1})", data.NextPlayer, data.Updated);
        }
Ejemplo n.º 24
0
    public void Show(CharactersConfig characters, IList <string> primarySkills, IList <string> attackSkills)
    {
        base.Show();

        offScreenController.gameObject.SetActive(true);

        startButton.onClick.RemoveAllListeners();
        startButton.onClick.AddListener(() =>
                                        OnGameStarted?.Invoke(skillsPanel.CurrentSkillId, skillPanel2.CurrentSkillId, characters[offScreenController.SelectedIndex]));

        nextCharacterButton.onClick.RemoveAllListeners();
        nextCharacterButton.onClick.AddListener(() => offScreenController.Next());

        prevCharacterButton.onClick.RemoveAllListeners();
        prevCharacterButton.onClick.AddListener(() => offScreenController.Prev());

        foreach (var character in characters)
        {
            charactersPanel.Add(character.Id);
            offScreenController.AddCharacter(character);
        }

        foreach (var skillId in primarySkills)
        {
            //var sprite = contentFactory.GetSpriteById(skillId);
            skillsPanel.Add(skillId, Sprite.Create(new Texture2D(1, 1), new Rect(0, 0, 1, 1), Vector2.one * 0.5f));
        }

        skillsPanel.SetOn(0);

        foreach (var skillId in attackSkills)
        {
            //var sprite = contentFactory.GetSpriteById(skillId);
            skillPanel2.Add(skillId, Sprite.Create(new Texture2D(1, 1), new Rect(0, 0, 1, 1), Vector2.one * 0.5f), true);
        }

        skillPanel2.SetOn(0);
    }
        private void StartGame()
        {
            if (GameStarted == true)
            {
                return;
            }
            if (_allPlayersAdded == false || _matchJoined == false)
            {
                return;
            }
            GameStarted = true;

            UnityMainThreadDispatcher.Instance().Enqueue(() =>
            {
                Debug.Log("Starting game");
                OnGameStarted?.Invoke();
                while (_incommingMessages.Count > 0)
                {
                    IncommingMessageState incommingMessage = _incommingMessages.Dequeue();
                    ReceiveMatchStateHandle(incommingMessage.opCode, incommingMessage.message);
                }
            });
        }
Ejemplo n.º 26
0
    IEnumerator SpawningCoroutine()
    {
        timeRemain     = settings.playTime;
        Time.timeScale = 1;
        OnGameStarted?.Invoke(timeRemain);
        float spawnTime = 0;

        while (timeRemain > 0)
        {
            timeRemain -= Time.deltaTime;
            spawnTime  += Time.deltaTime;
            if (spawnTime > settings.ballCreatingFrequency)
            {
                spawnTime = 0;
                CreateBall();
            }

            yield return(null);
        }

        Time.timeScale = Mathf.Epsilon;
        OnGameEnded?.Invoke();
    }
Ejemplo n.º 27
0
    private void Init()
    {
        mapGenerator = new MapGenerator(tilePool, crystalPool, Vector3.zero, Vector3.one);

        IsGameOver      = false;
        tilePassedCount = 0;

        if (player != null)
        {
            Destroy(player);
        }
        player = Instantiate(playerObj, new Vector3(0, 0.75f, 0), Quaternion.identity);

        mapGenerator.randomCrystals = RandomCrystals;
        mapGenerator.GenerateStartSector();
        mapGenerator.GenerateNextSector(4);
        for (int i = 0; i < 4; i++)
        {
            mapGenerator.GenerateNextSector(CalculateSectorSize());
        }
        player.SetActive(true);
        Points = 0;
        OnGameStarted?.Invoke();
    }
Ejemplo n.º 28
0
 private void StartSystem(OnGameStarted info)
 {
     this.enabled = true;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Triggers when the game is started.
 /// </summary>
 private void TriggerGameStarted()
 {
     OnGameStarted?.Invoke(gameData);
     SetTimer(true);
 }
Ejemplo n.º 30
0
 public void EventGameStarted()
 {
     OnGameStarted?.Invoke();
 }