void Init() { this.ChangeGameStatu(GameStatu.Init); level = GameGlobalValue.s_CurrentScene; subLevel = GameGlobalValue.s_CurrentLevel; gameType = GameGlobalValue.s_CurrentGameType; gameDifficulty = GameGlobalValue.s_CurrentDifficulty; currentWeaponId = GameGlobalValue.s_currentWeaponId; currentWave = 1; currentTurns = 1; if (records == null) { records = new GameRecords(level, (int)gameDifficulty, gameType); } records.SubLevel = subLevel; //初始化游戏数据 InitGameData(); //初始化UI InitUI(); //初始化武器 InitWeapon(); //初始 emenyController InitEmenyController(); //播放开始音效 SoundManager.Instance.PlaySound(SoundManager.SoundType.GameStart); //PlayerPrefs.DeleteAll(); Player player = Player.CurrentPlayer; }
/// <summary> /// 增加游戏纪录 /// </summary> /// <param name="level">游戏场景</param> /// <param name="score">分数</param> /// <param name="weight">权重</param> public void AddPlayRecord(GameRecords record) { if (record == null) { return; } LevelScore score = GetScoreByLevel(record.Level); if (score == null) { return; } score.PlayCount += 1; score.MaxHits = record.MaxCombos; if (score.SetScore(record.Scores)) { //重新计算总分 this.ReportScore(score.LeardBoardID, score.BestScore, (ok) => { score.NeedReported = !ok; }); } Save2File(); }
public void Init(GameData gameData) { _gameRecords = GameUtility.Instance.GetGameRecords(); _gameData = gameData; _maxRecordCount = _gameData.ConstantData.MAX_RECORD_COUNT; _recordDisplayView.Init(gameData); }
public GameStateManager() { GameStats = new GameRecords(); SpawnManager = new SpawnManager(); CoM.Profile = new UserProfile(); _loaded = false; }
void subSubInit() { play = new GameRecords(); tskSetsSpetial = new List <TTskSet> { { new TTskSet("Spetial", "||●", "", 0, false, Colors.White, 0, 0) }, { new TTskSet("Delimiter", " ", "||||||||\n", 3, false, Colors.Yellow, 1, 1) } }; }
public void Save() { if (_gameRecords == null) { _gameRecords = new GameRecords(); } AssetModel.Instance.SaveObjecToJsonFile(_gameRecords, GAMERECORD_JSON_FILE_PATH); }
public GameRecords GetGameRecords() { var records = AssetModel.Instance.LoadJsonFileToObject <GameRecords>(GAMERECORD_JSON_FILE_PATH); if (records == null) { records = new GameRecords(); } else { records.Init(); } _gameRecords = records; return(records); }
void OnGameFinish(LTEvent evt) { if (evt.data != null) { GameRecords record = evt.data as GameRecords; if (record != null) { if (record.FinishType == GameFinishType.Failed) { //hide gun for (int i = 0; i < Guns.Length; i++) { Guns[GunIndex].SetActive(false); } } } } }
/** Restores game from save file. */ public void Load() { Util.Assert(CoM.GameDataLoaded, "Data must be loaded before loading a save file."); DateTime startTime = DateTime.Now; GameStats = loadFromStoreDefault <GameRecords>("GameStats"); Store = loadFromStoreDefault <MDRStore>("Store"); ExploredDungeon = loadFromStoreDefault <MDRDungeon>("ExploredDungeon"); CharacterList = loadFromStoreDefault <MDRCharacterLibrary>("Characters"); PartyList = loadFromStoreDefault <MDRPartyLibrary>("Parties"); SpawnManager = loadFromStoreDefault <SpawnManager>("SpawnData"); Trace.Log("Save file loading completed in " + (DateTime.Now - startTime).TotalMilliseconds.ToString("0.0") + "ms."); _loaded = true; UpdateCharacterRecords(true); }
public static int GetMoneyFromRecord(GameRecords record, bool success = false) { int money = Mathf.CeilToInt(s_moneyRate * record.Scores); if (record.gameType == GameType.Story) { if (success) { if (Player.CurrentPlayer.GetSceneCurrentLevel(record.Level) > record.SubLevel) { money += s_MoneyPerLevel / 10; } else { money += s_MoneyPerLevel; } } } return(money); }
public override void ExtendedStart() { //Init(); coins_games_panel.SetActive(DataController.instance.minigames_screen_data.ShowCoinsGame); btn_stars.transform.GetChild(0).gameObject.GetComponent <Text>().text = TextManager.getText("mm_minigames_play_btn_text"); btn_coins.transform.GetChild(0).gameObject.GetComponent <Text>().text = TextManager.getText("mm_minigames_play_btn_text"); //var task = StarTasksController.instance.get_cur_task(); string text = TextManager.getText("mm_minigames_aims_text"); //!!! //ToDo add aims //!!! //text += TextManager.getText("mm_minigames_" + task.task_info[0].type.ToString() + "_text") // + " " + task.task_info[0].value.ToString(); //if(task.task_info.Count == 2) //{ // if(task.task_info[1].type == TaskType.TIME_OUT) // { // text += " " + TextManager.getText("mm_minigames_in_seconds_text").Replace("%N%", task.task_info[1].value.ToString()); // } //} star_body.text = text; star_header.text = TextManager.getText("mm_minigames_level_text") + " " + (StarTasksController.instance.get_cur_index() + 1); coins_header.text = TextManager.getText("mm_minigames_best_text"); GameRecords rec = DataController.instance.gamesRecords.Record(GameName.zigzag.ToString()); coins_body.text = "Best: " + rec.best_value + "\n" + "Last: " + rec.last_value;; }
void subSubInit() { play = new GameRecords(); tskSetsSpetial = new List<TTskSet>{ {new TTskSet("Spetial","||●", "", 0, false, Colors.White, 0, 0)}, {new TTskSet("Delimiter"," " ,"||||||||\n", 3, false, Colors.Yellow, 1, 1)} }; }
protected virtual void Start() { gr = FindObjectOfType <GameRecords>(); health = startingHealth; }
/// <summary> /// 显示结束UI /// </summary> /// <param name="success"></param> /// <param name="record"></param> void ShowFinishUI(bool success, GameRecords record) { if (uiFinish) { uiFinish.SetActive(true); RectTransform bgRect = uiFinish.GetComponent<RectTransform>().FindChild("Background").GetComponent<RectTransform>(); if (bgRect) { Vector3 bgScale = bgRect.localScale; bgRect.localScale = Vector3.zero; LeanTween.scale(bgRect, bgScale, 0.2f); if (GameType != 2) { //显示title GameObject tltSucc = bgRect.FindChild("TitleSuccess").gameObject; GameObject tltFail = bgRect.FindChild("TitleFailed").gameObject; if (tltSucc) { tltSucc.SetActive(success); } if (tltFail) { tltFail.SetActive(!success); } } //更新数据显示 //杀敌数 CommonUtils.SetChildText(bgRect, "Infos/Kills/TextCount", record.EnemyKills.ToString()); //最大连击数 CommonUtils.SetChildText(bgRect, "Infos/MaxHits/TextCount", record.MaxCombos.ToString()); //爆头数 CommonUtils.SetChildText(bgRect, "Infos/HeadShot/TextCount", record.HeadShotCount.ToString()); //分数 //CommonUtils.SetChildText(bgRect, "Infos/ScoreText", record.Scores.ToString()); Text txtScore = bgRect.FindChild("Infos/ScoreText").GetComponent<Text>(); if (txtScore) { //txtScore.text = record.Scores.ToString(); StartCoroutine(DigitalDisplay(txtScore, record.Scores, 0, 1000)); } Text txtMoneyEarn = bgRect.FindChild("Infos/MoenyEarn/TextCount").GetComponent<Text>(); if (txtMoneyEarn) { int moneyEarned = GameGlobalValue.GetMoneyFromRecord(record,success); Player.CurrentPlayer.EarnMoney(moneyEarned); StartCoroutine(DigitalDisplay(txtMoneyEarn, moneyEarned)); } //重新开始按钮 Button btnRestart = bgRect.FindChild("BtnRestart").GetComponent<Button>(); if (btnRestart) { btnRestart.onClick.AddListener(OnRestartClicked); } //回主页按钮 Button btnMainMenu = bgRect.FindChild("BtnMainMenu").GetComponent<Button>(); if (btnMainMenu) { btnMainMenu.onClick.AddListener(OnMenuClicked); } Button btnNext = bgRect.FindChild("BtnNext").GetComponent<Button>(); if(btnNext) { btnNext.onClick.AddListener(OnBtnNextClicked); } if(record.gameType == global::GameType.Story) { if(success) { CommonUtils.SetChildText(bgRect, "Title", "Level Success"); btnRestart.gameObject.SetActive(false); btnNext.gameObject.SetActive(true); } else { CommonUtils.SetChildText(bgRect, "Title", "Level Failed"); btnRestart.gameObject.SetActive(true); btnNext.gameObject.SetActive(false); } } else { btnRestart.gameObject.SetActive(true); btnNext.gameObject.SetActive(false); } } } }
public static int GetMoneyFromRecord(GameRecords record, bool success = false) { int money = Mathf.CeilToInt(s_moneyRate * record.Scores); if (record.gameType == GameType.Story) { if (success) { if (Player.CurrentPlayer.GetSceneCurrentLevel(record.Level) > record.SubLevel) { money += s_MoneyPerLevel / 10; } else { money += s_MoneyPerLevel; } } } return money; }
void Init() { this.ChangeGameStatu(GameStatu.Init); level = GameGlobalValue.s_CurrentScene; subLevel = GameGlobalValue.s_CurrentLevel; gameType = GameGlobalValue.s_CurrentGameType; gameDifficulty = GameGlobalValue.s_CurrentDifficulty; currentWeaponId = GameGlobalValue.s_currentWeaponId; currentWave = 1; currentTurns = 1; if (records == null) { records = new GameRecords(level, (int)gameDifficulty,gameType); } records.SubLevel = subLevel; //初始化游戏数据 InitGameData(); //初始化UI InitUI(); //初始化武器 InitWeapon(); //初始 emenyController InitEmenyController(); //播放开始音效 SoundManager.Instance.PlaySound(SoundManager.SoundType.GameStart); //PlayerPrefs.DeleteAll(); Player player = Player.CurrentPlayer; }
void _create() { tskSets = new List <int>(); record = new GameRecords(); ghostCount = 4; }
/// <summary> /// 显示结束UI /// </summary> /// <param name="success"></param> /// <param name="record"></param> void ShowFinishUI(bool success, GameRecords record) { if (uiFinish) { uiFinish.SetActive(true); RectTransform bgRect = uiFinish.GetComponent <RectTransform>().FindChild("Background").GetComponent <RectTransform>(); if (bgRect) { Vector3 bgScale = bgRect.localScale; bgRect.localScale = Vector3.zero; LeanTween.scale(bgRect, bgScale, 0.2f); if (GameType != 2) { //显示title GameObject tltSucc = bgRect.FindChild("TitleSuccess").gameObject; GameObject tltFail = bgRect.FindChild("TitleFailed").gameObject; if (tltSucc) { tltSucc.SetActive(success); } if (tltFail) { tltFail.SetActive(!success); } } //更新数据显示 //杀敌数 CommonUtils.SetChildText(bgRect, "Infos/Kills/TextCount", record.EnemyKills.ToString()); //最大连击数 CommonUtils.SetChildText(bgRect, "Infos/MaxHits/TextCount", record.MaxCombos.ToString()); //爆头数 CommonUtils.SetChildText(bgRect, "Infos/HeadShot/TextCount", record.HeadShotCount.ToString()); //分数 //CommonUtils.SetChildText(bgRect, "Infos/ScoreText", record.Scores.ToString()); Text txtScore = bgRect.FindChild("Infos/ScoreText").GetComponent <Text>(); if (txtScore) { //txtScore.text = record.Scores.ToString(); StartCoroutine(DigitalDisplay(txtScore, record.Scores, 0, 1000)); } Text txtMoneyEarn = bgRect.FindChild("Infos/MoenyEarn/TextCount").GetComponent <Text>(); if (txtMoneyEarn) { int moneyEarned = GameGlobalValue.GetMoneyFromRecord(record, success); Player.CurrentPlayer.EarnMoney(moneyEarned); StartCoroutine(DigitalDisplay(txtMoneyEarn, moneyEarned)); } //重新开始按钮 Button btnRestart = bgRect.FindChild("BtnRestart").GetComponent <Button>(); if (btnRestart) { btnRestart.onClick.AddListener(OnRestartClicked); } //回主页按钮 Button btnMainMenu = bgRect.FindChild("BtnMainMenu").GetComponent <Button>(); if (btnMainMenu) { btnMainMenu.onClick.AddListener(OnMenuClicked); } Button btnNext = bgRect.FindChild("BtnNext").GetComponent <Button>(); if (btnNext) { btnNext.onClick.AddListener(OnBtnNextClicked); } if (record.gameType == global::GameType.Story) { if (success) { CommonUtils.SetChildText(bgRect, "Title", "Level Success"); btnRestart.gameObject.SetActive(false); btnNext.gameObject.SetActive(true); } else { CommonUtils.SetChildText(bgRect, "Title", "Level Failed"); btnRestart.gameObject.SetActive(true); btnNext.gameObject.SetActive(false); } } else { btnRestart.gameObject.SetActive(true); btnNext.gameObject.SetActive(false); } } } }
void _create() { tskSets = new List<int>(); record = new GameRecords(); ghostCount = 4; }
private void Start() { gr = FindObjectOfType <GameRecords>(); Destroy(gameObject, 3f); }
/// <summary> /// 增加游戏纪录 /// </summary> /// <param name="level">游戏场景</param> /// <param name="score">分数</param> /// <param name="weight">权重</param> public void AddPlayRecord(GameRecords record) { if (record == null) return; LevelScore score = GetScoreByLevel(record.Level); if (score == null) { return; } score.PlayCount += 1; score.MaxHits = record.MaxCombos; if (score.SetScore(record.Scores)) { //重新计算总分 this.ReportScore(score.LeardBoardID, score.BestScore, (ok) => { score.NeedReported = !ok; }); } Save2File(); }