Exemple #1
0
        public void EndGame()
        {
            isPlaying = false;
            s2ai.Dispose();
            stateChangeListener.GameEnded();
            var winner = FindWinner();

            RpcEndGame(winner);
            var result = new MatchResult {
                winner  = sPlayerData[winner].leaderboardPlayerId,
                players = sPlayerData.Select(d => new PlayerMatchInfo {
                    id     = d.leaderboardPlayerId,
                    kills  = d.player.sKills,
                    deaths = d.player.sDeaths,
                }).ToArray(),
            };

            foreach (var d in sPlayerData)
            {
                Destroy(d.playerGo);
            }
            StartCoroutine(TransitionToGameOver());
#if !UNITY_EDITOR
            if (TransitionParams.gameType == GameType.Multi)
            {
#endif
            StartCoroutine(ReportMatchResult(result));
#if !UNITY_EDITOR
        }
#endif
        }
Exemple #2
0
        public void TestStayOnStage()
        {
            var ai          = new S2AI(2, 1);
            var inp         = new AIInputManager();
            var keepWalking = new KeepWalking(0, inp);

            Strategy[] strategies =
            {
                new StayOnStage(0, inp),
                keepWalking
            };
            var player = new DummyPlayerSnapshotProvider();
            var env    = new AIEnvironment(
                new [] { 0 },
                new DummyGameSnapshotProvider(),
                new DummyStageSnapshotProvider(20),
                new [] { player }
                );

            ai.Ready(env, strategies);
            ai.BeginEvaluate();
            float min = 0, max = 0;

            for (int i = 0; i < 30; i++)
            {
                ai.ExecAndMoveNext();
                if (inp.IsControlActive(Control.Left))
                {
                    player.Move(-1);
                    keepWalking.direction = Control.Left;
                }
                else if (inp.IsControlActive(Control.Right))
                {
                    player.Move(1);
                    keepWalking.direction = Control.Right;
                }
                if (player.x < min)
                {
                    min = player.x;
                }
                if (player.x > max)
                {
                    max = player.x;
                }
                Thread.Sleep(25);
            }
            ai.Dispose();
            Debug.Assert(min <-7f && max> 7f);
        }