Пример #1
0
    public override void Awake()
    {
        base.Awake();
        stats = GameStatistics.Instance;

        DebugCommands.Instance.AddCommand(new ConsoleCommand("PrintStats", "Prints the game statistics", Debug_PrintStatistics));
    }
Пример #2
0
    public override void Awake()
    {
        base.Awake();

        level = LevelManager.Instance;
        stats = GameStatistics.Instance;
    }
Пример #3
0
    public override void Awake()
    {
        base.Awake();

        myCount = DynamicText.GetTextMesh(this);
        stats = GameStatistics.Instance;
        level = LevelManager.Instance;
    }
Пример #4
0
    public static GameStatistics Get()
    {
        if (instance == null)
        {
            instance = new GameStatistics();
        }

        return instance;
    }
Пример #5
0
    public override void Awake()
    {
        base.Awake();
        delay = 5;
        tick = 0;

        frame = Frame.Instance;
        timer = ZombieTimer.Instance;
        stats = GameStatistics.Instance;
        level = LevelManager.Instance;
        navigate = MenuNavigator.Instance;
        //[Player status injection site: load player stats here for which weapons they had saved]
    }
Пример #6
0
    public void save()
    {
        GameStatistics stats = GameStatistics.load();
        LevelStatistic found = stats.levelStats.Find(p => p.level == level);

        if (found != null)
        {
            stats.levelStats.Remove(found);
        }
        stats.levelStats.Add(this);

        stats.collectedCoins = collectedCoins;
        stats.save();
    }
Пример #7
0
 public override void Potted(PocketIndexes pocketIndex)
 {
     if (m_rigidbody)
     {
         m_state = State.POTTED;
         m_rigidbody.velocity        = Vector3.zero;
         m_rigidbody.angularVelocity = Vector3.zero;
         CloseDrag();
         CloseRenderer();
         enabled = false;
         RemovePhysicalMaterial();
         GameStatistics.MarkPottedJiangyouBallCount(1);
     }
 }
Пример #8
0
    void init()
    {
        if (inited)
        {
            return;
        }

        float tmp = pb_line.GetComponent <RectTransform>().sizeDelta.y;

        if (!init_phase_one)
        {
            OneSignalController.Create();
            GameStatistics.Create();

            TextManager.Init(Application.systemLanguage);

            if (Application.systemLanguage == SystemLanguage.Russian)
            {
                logo.sprite = Resources.Load <Sprite>("logo/Russian");
            }
            else
            {
                logo.sprite = Resources.Load <Sprite>("logo/English");
            }

            play_btn_text.text = TextManager.getText("initializer_btn_play");
            loading_text.text  = TextManager.getText("initializer_loading");

            Helper.DeviceNameHelper.Init();
            DataController.Create();
            pb_line.GetComponent <RectTransform>().sizeDelta = new Vector2(25 * max_pb_with / 100.0f, tmp);
            init_phase_one = true;
            //AppodealController.Create();
            return;
        }

        if (!init_phase_two)
        {
            pb_line.GetComponent <RectTransform>().sizeDelta = new Vector2(70 * max_pb_with / 100.0f, tmp);
            StarTasksController.Create();
            init_phase_two = true;
            return;
        }

        pb.SetActive(false);
        btn.SetActive(true);

        inited = true;
    }
Пример #9
0
    public void SignalDefeat()
    {
        GameStatistics gs = GameObject.Find("GAMESTATS").GetComponent <GameStatistics>();

        Debug.Log("Lives :" + gs.GetPlayerLives().ToString());
        gs.DecPlayerLife();
        if (gs.GetPlayerLives() > 0)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }
        else
        {
            SceneManager.LoadScene(0);
        }
    }
Пример #10
0
    public void save()
    {
        Debug.Log("Level stats = " + JsonUtility.ToJson(this));
        GameStatistics   stats = GameStatistics.load();
        LevelStatsistics found = stats.levelStats.Find(p => p.level == level);

        if (found != null)
        {
            stats.levelStats.Remove(found);
        }
        stats.levelStats.Add(this);

        stats.collectedCoins = collectedCoins;
        stats.save();
    }
Пример #11
0
    public static GameStatistics LoadStatistics()
    {
        GameStatistics gs = null;

        if (PlayerPrefs.HasKey("Save"))
        {
            string jsonData = PlayerPrefs.GetString("Save");
            gs = JsonHelper.StatisticsFromJson <GameStatistics>(jsonData);
        }
        else
        {
            Debug.Log("Não existe");
        }
        return(gs);
    }
Пример #12
0
    void Awake()
    {
        musicSource      = gameObject.AddComponent <AudioSource>();
        musicSource.clip = music;
        musicSource.loop = true;

        if (PlayerPrefs.GetInt("music", 1) == 1)
        {
            musicSource.Play();
        }
        GameStatistics gameStats = GameStatistics.load();

        coins   = gameStats.collectedCoins;
        current = this;
    }
Пример #13
0
    public void Fire()
    {
        //lets set the balls target and the target position. When the white ball hits the first ball we will set the ball to point at the target.
        Pools.CueBall.setTarget(m_targetBall, m_targetPos);
        float powerScalar = m_powerScalar;

        if (GameManager.Rules.firstRound && GameManager.GType != GameType.Mission)
        {
            powerScalar *= Random.Range(.8f, 1.5f);
        }
        Pools.CueBall.fireBall(powerScalar, m_FirePoint.forward, GetHitPoint());
        m_state           = State.ROLL;
        m_CueTrans.parent = null;
        GameStatistics.MarkShot(1);
    }
Пример #14
0
        public async Task <IActionResult> Post(int SelectedOptionUser)
        {
            if (SelectedOptionUser < 1 || SelectedOptionUser > 3)
            {
                return(BadRequest("Option not supported."));
            }

            var currentUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            var gameResults = new GameStatistics(currentUserId, (GameOption)SelectedOptionUser);

            _gameRepository.Add(gameResults);
            await _gameRepository.SaveAll();

            return(Ok(_mapper.Map <GameResultDto>(gameResults)));
        }
Пример #15
0
 public int InsertStatistics(GameStatistics gameStatistics)
 {
     try
     {
         gameStatistics.TimeStamp = DateTime.Now;
         unitOfWork.GameStatistics.Insert(gameStatistics);
         unitOfWork.Commit();
         return(1);
     }
     catch (Exception exc)
     {
         log.Error(exc.Message);
         log.Error(exc.InnerException.Message);
         throw exc;
     }
 }
    public Task LoadDataManager(string activityName, string activityLevel)
    {
        return(databaseReference.Child(usrEmail + "_" + activityName + "_" + activityLevel).GetValueAsync().ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);
            }
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                string playerData = snapshot.GetRawJsonValue();

                foreach (var child in snapshot.Children)
                {
                    string t = child.GetRawJsonValue();

                    GameStatistics extractedData = JsonUtility.FromJson <GameStatistics>(t);

                    LevelPassedList.Add(extractedData.levelPassed);
                }

                //If the level is not passed, hide next levels (buttons).
                int times_passed = countOccurences(LevelPassedList, "yes");
                if (times_passed == 0)
                {
                    levelPassedFlag = false;
                }
                else
                {
                    levelPassedFlag = true;
                }
            }
        })));
    }
Пример #17
0
    public Task LoadData_ReturnTask(string level)
    {
        return(databaseReference.Child(usrEmail + "_" + level).GetValueAsync().ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);

                return;
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);

                return;
            }
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                string playerData = snapshot.GetRawJsonValue();

                foreach (var child in snapshot.Children)
                {
                    string t = child.GetRawJsonValue();

                    GameStatistics extractedData = JsonUtility.FromJson <GameStatistics>(t);


                    AttemptsList.Add(extractedData.gameAttempts);
                    DurationList.Add(extractedData.gameDuration);
                    LevelPassedList.Add(extractedData.levelPassed);
                }


                print("Data loaded successfully!");
                loadSuccessful = true;
            }
        })));
    }
Пример #18
0
        private Game GetSubject(IRules rules = default, IBoardBuilder boardBuilder = default, IGameStatistics gameStatistics = default)
        {
            if (rules == default)
            {
                rules = new EnglishDraughtsRules();
            }
            if (boardBuilder == default)
            {
                boardBuilder = new DraughtsBoardBuilder();
            }
            if (gameStatistics == default)
            {
                gameStatistics = new GameStatistics();
            }

            return(new Game(rules, boardBuilder, gameStatistics));
        }
Пример #19
0
        public GameStatistics GetGameStatistics(int gameId)
        {
            GameStatistics gameStatistics = new GameStatistics();

            var bestEntry = gameEntries.OrderBy(x => x.LinkCount)
                            .FirstOrDefault();

            var worstEntry = gameEntries.OrderByDescending(x => x.LinkCount)
                             .FirstOrDefault();

            gameStatistics.BestEntry         = bestEntry.LinkCount;
            gameStatistics.WorstEntry        = worstEntry.LinkCount;
            gameStatistics.BestEntryMessage  = bestEntry.RawText;
            gameStatistics.WorstEntryMessage = worstEntry.RawText;
            gameStatistics.CurrentWinner     = bestEntry.UserName;

            return(gameStatistics);
        }
Пример #20
0
        /// <summary>
        /// Event handler for GameWindws close event
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="gameStatistics">Game statistics</param>
        private void GameWindow_OnGameOver(object sender, GameStatistics gameStatistics)
        {
            ScoreRecord scoreRecord = new ScoreRecord();

            scoreRecord.Score = gameStatistics.Score;

            // Add score into HighScore table
            int scoreIndex = parentApp.HighScore.AddRecord(scoreRecord);

            // Show high score window
            HighScoreWindow scoreWindow = new HighScoreWindow(parentApp);

            // if high score has been reached then edit name
            if (scoreIndex > -1)
            {
                scoreWindow.EditItem(scoreIndex);
            }
        }
        public void SaveCurrentGame(GameStats currentGameStats)
        {
            var currentGame = new GameStatistics
            {
                player1         = currentGameStats.Player1,
                player2         = currentGameStats.Player2,
                BestOf          = currentGameStats.BestOf,
                scorePlayer1    = currentGameStats.ScorePlayer1,
                scorePlayer2    = currentGameStats.ScorePlayer2,
                topBreakPlayer1 = currentGameStats.TopBreakPlayer1,
                topBreakPlayer2 = currentGameStats.TopBreakPlayer2,
                winningPlayer   = currentGameStats.WinningPlayer,
                gameNumber      = currentGameStats.GameNumber,
                gameDate        = currentGameStats.GameDate
            };

            snookerEnt.GameStatistics.Add(currentGame);
            snookerEnt.SaveChanges();
        }
Пример #22
0
    // Use this for initialization
    void Start()
    {
        //Only create them if they dont exist.
        playerStatistics = new Dictionary <int, PlayerStatistics>();
        gameStatistics   = new GameStatistics();

        for (int i = 1; i <= 4; ++i)
        {
            var ps = new PlayerStatistics();
            ps.enemyKills   = new Dictionary <EnemyType, int>();
            ps.powerupsUsed = new Dictionary <Powerups, int>();

            ps.deaths         = new Dictionary <Death, int>();
            ps.totalHits      = new Dictionary <Targets, float>();
            ps.weaponTimeUsed = new Dictionary <Weapon, float>();
            playerStatistics.Add(i, ps);
        }
        init();
    }
Пример #23
0
        public void Get_Game_Results()
        {
            var game          = new GameStatistics("usr-1", GameOption.PAPER);
            var machineOption = game.SelectedOptionMachine;

            if (machineOption == GameOption.PAPER)
            {
                Assert.True(game.Tie);
            }

            if (machineOption == GameOption.ROCK)
            {
                Assert.True(game.Win);
            }

            if (machineOption == GameOption.SCISSORS)
            {
                Assert.False(game.Win);
            }
        }
Пример #24
0
        public IEnumerator Init(FightResult endResult, GameStatistics gameStatistics, int fightTime)
        {
            switch (endResult)
            {
            case FightResult.Victory:
                m_victoryText.get_gameObject().SetActive(true);
                m_defeatText.get_gameObject().SetActive(false);
                m_winAudio.get_gameObject().SetActive(true);
                break;

            case FightResult.Draw:
            case FightResult.Defeat:
                m_victoryText.get_gameObject().SetActive(false);
                m_defeatText.get_gameObject().SetActive(true);
                m_looseAudio.get_gameObject().SetActive(true);
                break;
            }
            TimeSpan timeSpan = TimeSpan.FromSeconds(fightTime);

            m_gameTimeText.SetText("Temps de jeu : " + ((timeSpan.Hours > 0) ? timeSpan.ToString("hh\\:mm\\:ss") : timeSpan.ToString("mm\\:ss")));
            yield return(m_statBoard.Init(gameStatistics));
        }
Пример #25
0
    protected void GameOver(IPlayer player)
    {
        string name = LevelDataIndex.CurrentLevel.FileName;

        m_PlayerData.HitRate = m_PlayerData.ShotCount == 0 ? 0 : (float)m_PlayerData.PottedCount / (float)m_PlayerData.ShotCount;
        int star = 0;

        if (player != null && player.playerID == playerID)
        {
            AddScore(ShotsRemain * 200, null);
            m_PlayerData.Star = LayoutConfiguration.instance[name].GetStarWithScore(m_PlayerData.Score);
            int starRecord = ConstantData.missionRecords.GetStar(name);
            GameStatistics.MarkMissionStars(Mathf.Max(0, m_PlayerData.Star - starRecord));
            star = Mathf.Max(starRecord, m_PlayerData.Star);
            ConstantData.missionRecords.Record(name, star, m_PlayerData.HighScore);
            StreamTools.SerializeObject(ConstantData.missionRecords, ConstantData.missionLevelDataRecordPath);
            BaseUIController.MSettlement.MissionComplete(m_PlayerData);
            string nextMission = ConstantData.LevelDatas.Next(LevelDataIndex.CurrentLevel).FileName;
            if (ConstantData.LevelDatas.Comp(PlayerPrefs.GetString(ConstantData.MissionProgressKeyName), nextMission) == -1)
            {
                PlayerPrefs.SetString(ConstantData.MissionProgressKeyName, nextMission);
            }

            //about achieve
            if (GameManager.Rules.firstRound)
            {
                ConstantData.achieveRecords.Mark(name, AchieveType.FinishWithTriangularPole);
            }
            else
            {
                ConstantData.achieveRecords.Mark(name, AchieveType.Finish);
            }
        }
        else
        {
            BaseUIController.MSettlement.MissionFail(m_PlayerData);
        }
        //BaseUIController.MSettlement.SetMissionData(m_PlayerData);
    }
Пример #26
0
 protected virtual void TurnBegin()
 {
     m_Turn++;
     //
     //reset game state
     //
     if (m_WhiteBallPotted)
     {
         Pools.CueBall.Reset();
     }
     if (m_WhiteHitBall)
     {
         GameStatistics.MarkCueballHitNoBall(1);
     }
     m_WhiteHitBall    = false;
     m_WhiteBallPotted = false;
     m_TimeOut         = false;
     if (onNewTurn != null)
     {
         onNewTurn(m_Turn);
     }
 }
Пример #27
0
        public GameStatistics GetGameStatistics(int gameId)
        {
            var bestEntry  = _context.GameEntries.Where(x => x.GameId == gameId).OrderBy(x => x.LinkCount).FirstOrDefault();
            var worstEntry = _context.GameEntries.Where(x => x.GameId == gameId).OrderByDescending(x => x.LinkCount).FirstOrDefault();

            GameStatistics gameStatistics = new GameStatistics();

            if (bestEntry != null)
            {
                gameStatistics.BestEntry         = bestEntry.LinkCount;
                gameStatistics.BestEntryMessage  = bestEntry.RawText;
                gameStatistics.WorstEntry        = worstEntry.LinkCount;
                gameStatistics.WorstEntryMessage = worstEntry.RawText;
                gameStatistics.CurrentWinner     = bestEntry.UserName;
            }
            else
            {
                gameStatistics = null;
            }

            return(gameStatistics);
        }
Пример #28
0
    public void RegisterScore(Profile profile, GameStatistics gameStatistics, bool isLocal)
    {
        bool scoreInserted = false;
        NamedGameStatistics namedGameStatistics = null;

        for (int index = 0; index < this.highScores.Count; ++index)
        {
            if (this.highScores[index].Score >= gameStatistics.Score)
            {
                continue;
            }

            scoreInserted = true;

            namedGameStatistics = new NamedGameStatistics(profile.Name, gameStatistics, isLocal);
            this.highScores.Insert(index, namedGameStatistics);
            break;
        }

        if (this.highScores.Count > HighScoreCount)
        {
            this.highScores.RemoveAt(this.highScores.Count - 1);
        }
        else if (!scoreInserted && this.highScores.Count < HighScoreCount)
        {
            namedGameStatistics = new NamedGameStatistics(profile.Name, gameStatistics, isLocal);
            this.highScores.Add(namedGameStatistics);
        }

        Debug.Log(string.Format("RegisterScore {0}", namedGameStatistics != null ? namedGameStatistics.ToString() : "null"));

        this.Save();

        if (this.HighScoresChange != null)
        {
            this.HighScoresChange.Invoke(null, new EventArgs());
        }
    }
Пример #29
0
        static void GameOver(GameStatistics lossStatistics)
        {
            EndedGame = true;
            EnabledSwitch(Form1.RightField.CellField, false);

            GameStatistics winStatistics;

            if (lossStatistics.Equals(rightStatistics))
            {
                winStatistics = leftStatistics;
                countWin++;
                MessageBox.Show("You are winner!! Congratulations!!");
            }
            else
            {
                winStatistics = rightStatistics;
                countDefeat++;
                MessageBox.Show("You are loser!! Sorry!!");
            }
            SaveResult();

            EndGame(null, EventArgs.Empty);
        }
Пример #30
0
        public GameStatistics GetStats()
        {
            GameStatistics gameStat = null;

            try
            {
                var resp    = NetworkActions.GET(Server + "/task/game/stats", Auth_key);
                var sr      = new StreamReader(resp.GetResponseStream());
                var content = sr.ReadToEnd();

                if (resp.StatusCode == HttpStatusCode.OK)
                {
                    var parsed = JsonConvert.DeserializeObject <Dictionary <string, int> >(content);
                    gameStat = new GameStatistics(parsed["points"], parsed["moves"], parsed["words"]);
                    Console.WriteLine(content);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: " + ex.Message);
            }
            return(gameStat);
        }
        private void CheckStats(object sender)
        {
            GameStatistics stats = new GameStatistics();

            stats.potsSuccessPlayer1 = potsSuccessPlayer1;
            stats.totalTriesPlayer1  = totalTriesPlayer1;
            stats.potsSuccessPlayer2 = potsSuccessPlayer2;
            stats.totalTriesPlayer2  = totalTriesPlayer2;
            stats.longSuccess1       = longSuccess1;
            stats.longTotal1         = longTotal1;
            stats.longSuccess2       = longSuccess2;
            stats.longTotal2         = longTotal2;
            stats.restSuccess1       = restSuccess1;
            stats.restTotal1         = restTotal1;
            stats.restSuccess2       = restSuccess2;
            stats.restTotal2         = restTotal2;
            stats.player1total       = player1Score;
            stats.player1break       = player1Break;
            stats.player2total       = player2Score;
            stats.player2break       = player2Score;

            _navigation.PushAsync(new StatisticPage(stats));
        }
Пример #32
0
    public void LoadProfile(string prefix)
    {
        this.Name = PlayerPrefs.GetString(string.Format("{0}.Name", prefix));
        this.ID = PlayerPrefs.GetInt(string.Format("{0}.ID", prefix));
        this.Password = PlayerPrefs.GetString(string.Format("{0}.Password", prefix));
        this.BestScore = new GameStatistics();
        this.BestScore.Load(string.Format("{0}.BestScore", prefix));

        int unsynchronizedScoresCount = PlayerPrefs.GetInt(string.Format("{0}.UnsynchronizedScoresCount", prefix));
        for (int index = 0; index < unsynchronizedScoresCount; index++)
        {
            GameStatistics gameStatistics = new GameStatistics();
            gameStatistics.Load(string.Format("{0}.UnsynchronizedScore{1}", prefix, index));
            this.UnsynchronizedScores.Add(gameStatistics);
        }
    }
 public StatisticViewModel(GameStatistics gameStatistics)
 {
     GameStatistics = gameStatistics;
 }
Пример #34
0
 private void OnGameFinished(GameStatistics statistics)
 {
     IsGameNotStarted = true;
 }
 public void OnGameFinished(GameStatistics statistics)
 {
     throw new NotImplementedException();
 }
Пример #36
0
    public void Awake()
    {
        GameDebug.Assert(game == null);
        DontDestroyOnLoad(gameObject);
        game = this;

        m_StopwatchFrequency = System.Diagnostics.Stopwatch.Frequency;
        m_Clock = new System.Diagnostics.Stopwatch();
        m_Clock.Start();

        var buildInfo = FindObjectOfType <BuildInfo>();

        if (buildInfo != null)
        {
            _buildId = buildInfo.buildId;
        }

        var commandLineArgs = new List <string>(System.Environment.GetCommandLineArgs());

#if UNITY_STANDALONE_LINUX
        m_isHeadless = true;
#else
        m_isHeadless = commandLineArgs.Contains("-batchmode");
#endif
        var consoleRestoreFocus = commandLineArgs.Contains("-consolerestorefocus");

        if (m_isHeadless)
        {
#if UNITY_STANDALONE_WIN
            string consoleTitle;

            var overrideTitle = ArgumentForOption(commandLineArgs, "-title");
            if (overrideTitle != null)
            {
                consoleTitle = overrideTitle;
            }
            else
            {
                consoleTitle = Application.productName + " Console";
            }

            consoleTitle += " [" + System.Diagnostics.Process.GetCurrentProcess().Id + "]";

            var consoleUI = new ConsoleTextWin(consoleTitle, consoleRestoreFocus);
#elif UNITY_STANDALONE_LINUX
            var consoleUI = new ConsoleTextLinux();
#else
            UnityEngine.Debug.Log("WARNING: starting without a console");
            var consoleUI = new ConsoleNullUI();
#endif
            Console.Init(consoleUI);
        }
        else
        {
            var consoleUI = Instantiate(Resources.Load <ConsoleGUI>("Prefabs/ConsoleGUI"));
            DontDestroyOnLoad(consoleUI);
            Console.Init(consoleUI);

            m_DebugOverlay = Instantiate(Resources.Load <DebugOverlay>("DebugOverlay"));
            DontDestroyOnLoad(m_DebugOverlay);
            m_DebugOverlay.Init();

            var hdpipe = RenderPipelineManager.currentPipeline as HDRenderPipeline;
            if (hdpipe != null)
            {
//                hdpipe.DebugLayer2DCallback = DebugOverlay.Render;
//                hdpipe.DebugLayer3DCallback = DebugOverlay.Render3D;
            }

            m_GameStatistics = new GameStatistics();
        }

        // If -logfile was passed, we try to put our own logs next to the engine's logfile
        var engineLogFileLocation = "./logs";
        var logfileArgIdx         = commandLineArgs.IndexOf("-logfile");
        if (logfileArgIdx >= 0 && commandLineArgs.Count >= logfileArgIdx)
        {
            engineLogFileLocation = System.IO.Path.GetDirectoryName(commandLineArgs[logfileArgIdx + 1]);
        }

        var logName = m_isHeadless ? "game_" + DateTime.UtcNow.ToString("yyyyMMdd_HHmmss_fff") : "game";
        GameDebug.Init(engineLogFileLocation, logName);

        ConfigVar.Init();

        Console.EnqueueCommandNoHistory("exec -s " + k_UserConfigFilename);

        // Default is to allow no frame cap, i.e. as fast as possible if vsync is disabled
        Application.targetFrameRate = -1;

        if (m_isHeadless)
        {
            Application.targetFrameRate = serverTickRate.IntValue;
            QualitySettings.vSyncCount  = 0; // Needed to make targetFramerate work; even in headless mode

#if !UNITY_STANDALONE_LINUX
            if (!commandLineArgs.Contains("-nographics"))
            {
                GameDebug.Log("WARNING: running -batchmod without -nographics");
            }
#endif
        }
        else
        {
            RenderSettings.Init();
        }

        // Out of the box game behaviour is driven by boot.cfg unless you ask it not to
        if (!commandLineArgs.Contains("-noboot"))
        {
            Console.EnqueueCommandNoHistory("exec -s " + k_BootConfigFilename);
        }

        var forceClientSystem = commandLineArgs.Contains("-forceclientsystems");
        if (!m_isHeadless || forceClientSystem)
        {
            m_SoundSystem = new SoundSystem();
            m_SoundSystem.Init(audioMixer);
            m_SoundSystem.MountBank(defaultBank);

            GameObject go = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/ClientFrontend", typeof(GameObject)));
            UnityEngine.Object.DontDestroyOnLoad(go);
            clientFrontend = go.GetComponentInChildren <ClientFrontend>();
        }

        sqpClient = new SQP.SQPClient();

        GameDebug.Log("FPS Sample initialized");
#if UNITY_EDITOR
        GameDebug.Log("Build type: editor");
#elif DEVELOPMENT_BUILD
        GameDebug.Log("Build type: development");
#else
        GameDebug.Log("Build type: release");
#endif
        GameDebug.Log("BuildID: " + buildId);
        GameDebug.Log("Cwd: " + System.IO.Directory.GetCurrentDirectory());

        SimpleBundleManager.Init();
        GameDebug.Log("SimpleBundleManager initialized");

        levelManager = new LevelManager();
        levelManager.Init();
        GameDebug.Log("LevelManager initialized");

        inputSystem = new InputSystem();
        GameDebug.Log("InputSystem initialized");
        inputSystem.SetVRInput();

        // TODO (petera) added Instantiate here to avoid making changes to asset file.
        // Feels like maybe SO is not really the right tool here.
        config = Instantiate((GameConfiguration)Resources.Load("GameConfiguration"));
        GameDebug.Log("Loaded game config");

        // Game loops
        Console.AddCommand("preview", CmdPreview, "Start preview mode");
        Console.AddCommand("serve", CmdServe, "Start server listening");
        Console.AddCommand("client", CmdClient, "client: Enter client mode. Looking for servers");
        Console.AddCommand("boot", CmdBoot, "Go back to boot loop");
        Console.AddCommand("connect", CmdConnect, "connect <ip>: Connect to server on ip (default: localhost)");

        Console.AddCommand("menu", CmdMenu, "show the main menu");
        Console.AddCommand("load", CmdLoad, "Load level");
        Console.AddCommand("quit", CmdQuit, "Quits");
        Console.AddCommand("screenshot", CmdScreenshot, "Capture screenshot. Optional argument is destination folder or filename.");
        Console.AddCommand("crashme", (string[] args) => { GameDebug.Assert(false); }, "Crashes the game next frame ");
        Console.AddCommand("saveconfig", CmdSaveConfig, "Save the user config variables");
        Console.AddCommand("loadconfig", CmdLoadConfig, "Load the user config variables");

#if UNITY_STANDALONE_WIN
        Console.AddCommand("windowpos", CmdWindowPosition, "Position of window. e.g. windowpos 100,100");
#endif

        Console.SetOpen(true);
        Console.ProcessCommandLineArguments(commandLineArgs.ToArray());

        PushCamera(bootCamera);
    }
Пример #37
0
 public NamedGameStatistics(string profileName, GameStatistics gameStatistics, bool isLocal)
     : base(gameStatistics.Score, gameStatistics.Lines, gameStatistics.StartLevel)
 {
     this.ProfileName = profileName;
     this.IsLocal = isLocal;
 }
Пример #38
0
    public void StopAttraction()
    {
        if (running)
        {
            running = false;
            StopAnimation();

            bool aborted = false;

            // Abort or regular stop?
            if (timeLeft > 0)
            {
                aborted = true;
            }

            PlaySound(aborted);

            // Unlock player
            PlayerMovement player = FindObjectOfType <PlayerMovement>();
            if (player)
            {
                player.UnlockMovement();
            }

            if (!aborted)
            {
                if (game.happinessPopupTextPrefab != null)
                {
                    float      gainedHappiness = npcsActive.Count * game.rewardSatisfiedRide;
                    GameObject popup           = (GameObject)Instantiate(game.happinessPopupTextPrefab);
                    popup.transform.position = entrancePosition.transform.position + (Vector3.up);
                    popup.transform.SetParent(entrancePosition.transform);
                    popup.GetComponent <TMPro.TextMeshPro>().text = "+" + gainedHappiness.ToString("N0");
                }
                completedRides++;
                GameStatistics.AddTotalNumberOfSatisfiedVisitors(npcsActive.Count);
                GameStatistics.AddTotalNumberOfDrivenAttractions(1);
            }
            else
            {
                GameStatistics.AddTotalNumberOfStoppedAttractions(1);
            }

            while (npcsActive.Count > 0)
            {
                GameObject npc = npcsActive[0];
                npcsActive.Remove(npc);
                NPC npcScript = npc.GetComponent <NPC>();

                npcScript.SetStatus(NPC.status.IDLE);
                if (aborted)
                {
                    npcScript.UpdateHappiness(game.penaltyUnsatisfiedRide);
                }
                else
                {
                    npcScript.UpdateHappiness(game.rewardSatisfiedRide);
                    Debug.Log("AttractionController::Done Attraction, giving visitors happiness");
                }
                if (timeLeft <= 0)
                {
                    npcScript.DoneAttraction();
                }
            }

            visitorMangager.CalculateHappiness();
        }
    }
Пример #39
0
 public void SetBestStats(GameStatistics newStats)
 {
     WaveIndex = Mathf.Max(WaveIndex, newStats.WaveIndex);
     KilledMobs = Mathf.Max(KilledMobs, newStats.KilledMobs);
 }
Пример #40
0
 public Task WriteAsync(string entity, GameStatistics statistics)
 {
     throw new NotImplementedException();
 }
Пример #41
0
    public void RegisterScore(GameStatistics gameStatistics)
    {
        this.UnsynchronizedScores.Add(gameStatistics);

        float lastScore = this.BestScore != null ? this.BestScore.Score : 0f;
        if (gameStatistics.Score > lastScore)
        {
            this.BestScore = gameStatistics;
        }

        gameStatistics.Registered = true;

        HighScoresManager.Instance.RegisterScore(this, gameStatistics, true);

        ProfileManager.Instance.SynchronizeProfile(this);

        if (this.ProfileChange != null)
        {
            this.ProfileChange.Invoke(this, null);
        }
    }
Пример #42
0
    public void StartGame(int startLevel = 0)
    {
        this.Clear();

        this.startLevel = startLevel;

        this.Statistics = new GameStatistics();
        this.Statistics.StartLevel = startLevel;
        this.SetSpeed(this.GetSpeed(this.Statistics.StartLevel));
        this.tetrominoGenerator.Reset();
        this.NewTetromino();
        this.IsGameStarted = true;
    }