private void Start()
    {
        // Score
        ManagerScore.I.Initialize(this);

        // A little of UI
        if (UIGameOver != null)
        {
            UIGameOver.SetActive(false);
        }
        else
        {
            Debug.LogWarning("UIGameOver is missing, please set", this);
        }

        if (TetrominoListForMatch.Count < 1)
        {
            Debug.LogError("TetraminoPrefabs for a match wasn't set", this);
        }

        if (GridData != null)
        {
            GridWidth  = GridData.GridWidth;
            GridHeight = GridData.GridHeight;
        }
        Grid = new Transform[GridWidth, GridHeight];

        if (TetrominoSpawnedTraced.Count == 0)
        {
            GameStarted?.Invoke();
            SpawnTetromino();
        }
    }
 public void GameStarted_Invoke(ServerCore server)
 {
     if (GameStarted != null)
     {
         GameStarted.Invoke(server);
     }
 }
예제 #3
0
 protected void OnGameStarted(EventArgs e)
 {
     if (GameStarted != null)
     {
         GameStarted.Invoke(this, e);
     }
 }
예제 #4
0
    IEnumerator GameStart()
    {
        yield return(StartCoroutine(LoadLevel()));

        yield return(StartCoroutine(BattlePrepare()));

        yield return(StartCoroutine(FocusTeamMember()));

        gameEnded = false;
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }
        //角色加入忽略层
        Units.ForEach(u => u.gameObject.layer = 2);
        yield return(new WaitForSeconds(gameStartTime));

        foreach (var unit in Units)
        {
            unit.UnitClicked   += OnUnitClicked;
            unit.UnitDestroyed += OnUnitDestroyed;
            //设置同盟列表。
        }

        Units.ForEach(u => { u.Initialize(); }); //战斗场景角色初始化。

        StartCoroutine(RoundStart());
    }
예제 #5
0
        /// <summary>
        /// Handles the notification.
        /// </summary>
        /// <param name="n">The n.</param>
        private void HandleNotification(Notification n)
        {
            switch (n.NotificationType)
            {
            case Notification.Type.GameStarted:
                // if game already started
                if (Maze != null)
                {
                    return;
                }
                Maze = Maze.FromJSON(n.Data);
                GameStarted?.Invoke();
                break;

            case Notification.Type.GameOver:
                GameOver?.Invoke(n.Data);
                break;

            case Notification.Type.PlayerMoved:
                MoveUpdate mu = MoveUpdate.FromJSON(n.Data);
                OtherPosition = GetEstimatedPosition(OtherPosition, mu.Direction);
                break;

            default:
                break;
            }
        }
예제 #6
0
 void GameListPanel_Inputed(IFocusable sender, InputEventArgs args)
 {
     if (args.InputInfo.IsPressed(ButtonType.Circle))
     {
         if (GameStarted != null)
         {
             sound.Play(PPDSetting.DefaultSounds[1], -1000);
             GameStarted.Invoke(this, new GameEventArgs(gameList.List[currentIndex]));
         }
     }
     else if (args.InputInfo.IsPressed(ButtonType.Down))
     {
         currentIndex++;
         if (currentIndex >= gameList.List.Length)
         {
             currentIndex = 0;
         }
         sound.Play(PPDSetting.DefaultSounds[0], -1000);
     }
     else if (args.InputInfo.IsPressed(ButtonType.Up))
     {
         currentIndex--;
         if (currentIndex < 0)
         {
             currentIndex = gameList.List.Length - 1;
         }
         sound.Play(PPDSetting.DefaultSounds[0], -1000);
     }
     scrollIndex = currentIndex - scrollIndex >= 5 ? scrollIndex + 1 : scrollIndex;
     scrollIndex = scrollIndex > currentIndex ? currentIndex : scrollIndex;
 }
예제 #7
0
        private void OnPlayerPressed()
        {
            player.Pressed -= OnPlayerPressed;

            ScoreManager.StartCount();
            GameStarted?.Invoke();
        }
예제 #8
0
        private void StartGameProcessMonitoring()
        {
            var dispatcher = Dispatcher.CurrentDispatcher;

            ThreadPool.QueueUserWorkItem(_ =>
            {
                while (gameProcessMonitoring.Wait(1000) == false)
                {
                    bool localIsRunGameLocked = dispatcher.Invoke(() => IsRunGameLocked);

                    var processes = Process.GetProcessesByName(Constants.ProcessName);

                    if (processes.Length > 0 && IsRunGameLocked == false)
                    {
                        dispatcher.Invoke(() =>
                        {
                            IsRunGameLocked = true;
                            Status          = "Dark Souls 3 is running...";
                            GameStarted?.Invoke(this, EventArgs.Empty);
                        });
                    }
                    else if (processes.Length == 0 && IsRunGameLocked)
                    {
                        dispatcher.Invoke(() =>
                        {
                            IsRunGameLocked = false;
                            Status          = "Dark Souls 3 has stopped...";
                            GameStopped?.Invoke(this, EventArgs.Empty);
                        });
                    }
                }

                gameProcessMonitoring.Reset();
            });
        }
예제 #9
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Jump"))
     {
         GameStarted?.Invoke();
         this.enabled = false;
     }
 }
예제 #10
0
        /// <summary>
        /// Method is called once, at the beggining of the game.
        /// </summary>
        public void StartGame()
        {
            GameStarted?.Invoke(this);

            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => u.OnTurnStart());
            Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
            Debug.Log("Game started");
        }
예제 #11
0
        private void StartGame()
        {
            gameStartedTime = Time.time;
            UpdateAsteroidEventTime();
            StartNextWave();

            isGameInProgress = true;
            GameStarted?.Invoke();
        }
예제 #12
0
 public void Start()
 {
     Clear();
     NextPolyomino = new Tetromono();
     Place(currentPolyomino);
     scoreBoard.Reset();
     IsStarted = true;
     GameStarted?.Invoke();
 }
예제 #13
0
        public void StartGame()
        {
            if (_isPlaying == false)
            {
                _isPlaying = true;
            }

            GameStarted?.Invoke();
        }
예제 #14
0
        private void Start()
        {
            GameStarted?.Invoke(this, EventArgs.Empty);

            IList <string> letterPairs = _letterPairGenerator.GetLetterPairList(4); // TODO: use numPairs from settings

            LetterPairsGenerated?.Invoke(this, new LetterPairsEventArgs(letterPairs));
            _timer.StartAsync(45 * letterPairs.Count); // TODO: use time from settings
        }
예제 #15
0
 internal void StartGame()
 {
     if (Players.Count >= MinPlayerCount)
     {
         _gameStarted = true;
         InitRoom();
         GameStarted.Invoke(this);
     }
 }
예제 #16
0
 public void StartGame()
 {
     if (GameStarted != null)
     {
         GameStarted.Invoke(this, new EventArgs());
     }
     Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
     Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
     Debug.Log("Game Started");
 }
예제 #17
0
        public void StartGame(CellState firstPlayerColor)
        {
            this.firstPlayerColor = firstPlayerColor;
            currentPlayerColor    = firstPlayerColor;
            secondPlayerColor     = Field.GetOppositeColor(firstPlayerColor);

            GameStarted?.Invoke(field.Cells);

            GetAvailableCells();
        }
예제 #18
0
        private void TriggerEvents(bool recursive)
        {
            int originalCount = eventQueue.Count;

            // Do not use foreach as eventQueue might change
            for (int i = 0; i < (recursive ? eventQueue.Count : originalCount); i++)
            {
                // Performance is not a problem since events are rare!
                var arg = eventQueue[i];
                if (arg is GamerJoinedEventArgs)
                {
                    if (GamerJoined != null)
                    {
                        GamerJoined.Invoke(this, arg as GamerJoinedEventArgs);
                    }
                }
                else if (arg is GamerLeftEventArgs)
                {
                    if (GamerLeft != null)
                    {
                        GamerLeft.Invoke(this, arg as GamerLeftEventArgs);
                    }
                }
                else if (arg is GameStartedEventArgs)
                {
                    if (GameStarted != null)
                    {
                        GameStarted.Invoke(this, arg as GameStartedEventArgs);
                    }
                }
                else if (arg is GameEndedEventArgs)
                {
                    if (GameEnded != null)
                    {
                        GameEnded.Invoke(this, arg as GameEndedEventArgs);
                    }
                }
                else if (arg is NetworkSessionEndedEventArgs)
                {
                    if (SessionEnded != null)
                    {
                        SessionEnded.Invoke(this, arg as NetworkSessionEndedEventArgs);
                    }
                }
            }

            if (recursive)
            {
                eventQueue.Clear();
            }
            else
            {
                eventQueue.RemoveRange(0, originalCount);
            }
        }
 private void Update()
 {
     if (!_gameStarted)
     {
         if (Input.GetMouseButtonDown(0))
         {
             GameStarted?.Invoke();
             _gameStarted = true;
         }
     }
 }
예제 #20
0
        public void StartGame(Tuple <int, int> blackHoleCoords)
        {
            currentPlayerColor = firstPlayerColor;

            board.SetBlackHole(blackHoleCoords);

            GameStarted?.Invoke(board.Points);

            var availablePoints = GetAvailablePoints();

            AvailablePointsCalculated?.Invoke(availablePoints);
        }
예제 #21
0
        public void Connect(string endpoint, int port)
        {
            if (manager != null)
            {
                throw new InvalidOperationException();
            }

            var listener = new EventBasedNetListener();

            manager = new NetManager(listener);
            manager.Start();
            manager.Connect(endpoint, port, nameof(MultiplayerTest));

            listener.PeerConnectedEvent += peer => server = peer;

            var processor = new NetPacketProcessor();

            processor.RegisterNestedType <Order>(() => new Order());
            processor.SubscribeReusable <OrderPacket>(packet =>
            {
                foreach (var order in packet.Orders)
                {
                    OrderReceived?.Invoke(order);
                }
            });

            listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) =>
            {
                var type = (PacketType)dataReader.GetByte();
                switch (type)
                {
                case PacketType.StartGame:
                    var players = dataReader.GetInt();
                    GameStarted?.Invoke(players);
                    break;

                case PacketType.Orders:
                    processor.ReadAllPackets(dataReader);
                    break;
                }

                dataReader.Recycle();
            };

            writer = new NetDataWriter();

            thread = new Thread(Run)
            {
                IsBackground = true
            };

            thread.Start();
        }
예제 #22
0
    // Method is called once, at the beginning of the game.
    public void StartGame()
    {
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }

        InitTracker[0].OnTurnStart();
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
        // Select unit with a short delay
        StartCoroutine(StartGameSelect());
    }
예제 #23
0
파일: RoundManager.cs 프로젝트: gczxcyd/XDD
    public float turnStartTime  = 2f;                //状态持续时间。

    IEnumerator GameStart()
    {
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }
        //角色加入忽略层
        Units.ForEach(u => u.gameObject.layer = 2);
        yield return(new WaitForSeconds(gameStartTime));

        StartCoroutine(RoundStart());
    }
예제 #24
0
        public void StartGame()
        {
            CurrentPlayerColor = _firstPlayerColor;

            _board.SetBlackHole(GenerateBlackHoleCoords());

            GameStarted?.Invoke(_board.Cells);

            var availableCells = GetAvailableCells();

            AvailableCellsCalculated?.Invoke(availableCells);
        }
예제 #25
0
    /// <summary>
    /// Method is called once, at the beggining of the game.
    /// </summary>
    public void StartGame()
    {
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }

        UnitNumber = 0;
        ClockTick();
        //Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        //Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
예제 #26
0
        private void OnLobbyNetworkReceived(NetPeer peer, NetDataReader dataReader)
        {
            NetMessage instruction = (NetMessage)dataReader.GetInt();

            switch (instruction)
            {
            case NetMessage.ServerClosed:
                OnServerClosed();
                break;

            case NetMessage.ClientsCount:
                int count = dataReader.GetInt();
                OnClientsCount(count);
                break;

            case NetMessage.AddPlayer:
                PlayerAdded?.Invoke(this, new LobbyPlayerEventArgs()
                {
                    PlayerID        = dataReader.GetString(),
                    ControllerIndex = (PlayerControllerIndex)dataReader.GetInt()
                });
                break;

            case NetMessage.RemovePlayer:
                PlayerRemoved?.Invoke(this, new LobbyPlayerEventArgs()
                {
                    PlayerID = dataReader.GetString()
                });
                break;

            case NetMessage.PrepareToStartGame:
                PreparingGameToStart?.Invoke(this, new LobbyOptionsArgs {
                    PlayersCount = dataReader.GetInt(),
                    Map          = dataReader.GetInt(),
                    Biome        = dataReader.GetInt(),
                });
                break;

            case NetMessage.InstantiateCharacter:
                InstantiateCharacter?.Invoke(this, new LobbyPlayerEventArgs {
                    PlayerID        = dataReader.GetString(),
                    ControllerIndex = (PlayerControllerIndex)dataReader.GetInt(),
                    Type            = (Pj.Type)dataReader.GetInt(),
                    X = dataReader.GetFloat(), Y = dataReader.GetFloat()
                });
                break;

            case NetMessage.StartGame:
                this.SetGameplay();
                GameStarted?.Invoke(this, EventArgs.Empty);
                break;
            }
        }
예제 #27
0
    /// <summary>
    /// Method is called once, at the beggining of the game.
    /// </summary>
    public void StartGame()
    {
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }

        // Added Skill event so the skills can turn themselves off when a turn starts.
        Skills.ForEach(u => { u.OnTurnStart(); });

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
예제 #28
0
        private void PrepareLevel()
        {
            CurrentLevel = new GameObject("TileMap").AddComponent <HexagonLevelBehaviour>();

            CurrentLevel.Initiliaze(_gridSizeX, _gridSizeY);

            GameStarted?.Invoke();

            ViewController.Instance.InGameView.Open(new InGameViewParameters());

            TileMapSystem.HexagonBlowed   += OnHexagonBlowed;
            TileMapSystem.OutOfMove       += OnOutOfMove;
            BombHexagonBehaviour.Exploded += OnBombExploded;
        }
예제 #29
0
    /// <summary>
    /// Method is called once, at the beggining of the game.
    /// </summary>
    public void StartGame()
    {
        if (GameStarted != null)
        {
            GameStarted.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);

        if (NetManager.playerCount == 1)
        {
        }
    }
예제 #30
0
    public void SwapMap()
    {
        menuMap.SetActive(false);
        gameMap.SetActive(true);
        GameStarted?.Invoke();

        /*
         * StartCoroutine(_fm.FadeOut(callback =>
         * {
         *  if(callback.Equals(true))
         *      LoadLevel(sceneName);
         * }));
         */
    }