private void SetCurrentWavesScore(Vehicle info) { //// 이렇게 원래 빼려고 했는데, //// MaxHP를 몰라서 이러한 연산이 불가능 함. //_currentWaveHP -= info.hp // 점수 Component가 있으면 점수 추가. MyScore scoreComponent = info.gameObject.GetComponent <MyScore>(); if (scoreComponent) { GameManager.Instance.Score += scoreComponent.score; var tempGO = new GameObject("tempSource"); tempGO.transform.position = this.transform.position; var src = tempGO.AddComponent <AudioSource>(); src.PlayOneShot(scoreClip, 0.75f); Destroy(tempGO, scoreClip.length); } // hpRatio로 계산시, 적이 아직 남았는데도 승리 화면이 떠 버려서 0으로 바꿈. if (GetCurrentWaveHP() == 0f) { StartNextWave(); } leftEnemies--; VoxEventManager.Instance.PostNotifycation("UpdateEnemyCount", leftEnemies); //이전 코드 /* if (_isPreWave) * { * if (GetCurrentWaveHP() == 0f) * { * StartNextWave(); * } * } * else * { * float hpRatio = GetCurrentWaveHP() / _totalWaveHP; * Debug.Log(hpRatio); * if (hpRatio < 0.2f) * { * // 다음 웨이브 * StartNextWave(); * } * }*/ }
public bool Equals(Score other) { //Check whether the compared object is null. if (Object.ReferenceEquals(other, null)) { return(false); } //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, other)) { return(true); } //Check whether the products' properties are equal. return(UserName.Equals(other.UserName) && MyScore.Equals(other.MyScore) && DateAdded.Equals(other.DateAdded)); }
///<summary> /// Handle the end of the game. ///</summary> void ShowEnding(bool winning) { gameState = DiceGameState.GAME_ENDING; NGUITools.SetActive(UserPanel, false); NGUITools.SetActive(EndPanel, true); GrandScoreLabel.text = "Total Score: " + MyScore.ToString(); if (winning) { EndLabel.text = "Congratulations!!\n You just clear the game!! \nWant to Play again?"; } else { EndLabel.text = "Hmmm...\n You did great but did not beat the game.\nWant to Play again?"; } }
IEnumerator Post(string url) { //JsonUtilityでJsonを作成 MyScore myScore = new MyScore(inputName.userName, updateScore.score); string json = JsonUtility.ToJson(myScore); Debug.Log("json " + json); byte[] postData = System.Text.Encoding.UTF8.GetBytes(json); //リクエストの作成 var request = new UnityWebRequest(url, "POST"); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(postData); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); //送信 yield return(request.SendWebRequest()); }
/// <summary> /// Main Game Loop /// takes input, updates fields AND prints to console /// </summary> public void Loop() { playing = true; List <int> rowsToClear = new(); Thread inputThread = new Thread(Input); inputThread.Start(); //Sets up the game by using the input by player for gravity, adds a tetromino that will become the current one //and adds another tetromino that will be shown as the next one. Gravity = MyScore.SetGravity(); Grid.AddNewRandomTetrominoUpcoming(); Grid.SetCurrentTetromino(); while (playing) { //GAME TIMING================ Thread.Sleep(50); //game tick TickCounter++; //for each loop, add 1 to TickCounter. //HANDLE USER INPUT (MOVEMENT) ========== if (!HandleUserInput()) { //Console.Beep(); } InputKey = new ConsoleKeyInfo(); //GAME LOGIC =============== //Gravity dictates how often the current Tetromino will fall down. if (TickCounter == Gravity) { if (Grid.CanTetroFit(0, 1)) { //CanTetroFit is a collision check, if it returns true the current tetromino falls down one step. Grid.UpdateTetromino("gravity"); } else //If CanTetroFit returns false it means it cannot fall down anymore. { //This method turns the current tetromino into at signs in the gamefield at the position where it couldnt fall anymore. Grid.AddCurrentTetrominoToStack(); //CHECK FOR FULL ROWS ============== Grid.CheckForFullRow(rowsToClear); //out List<int> rowsToClear); //Remove if full rows if (rowsToClear.Count > 0) { CoolClearLinesEffect(rowsToClear); Grid.RemoveFullRows(rowsToClear); MyScore.UpdateScore(rowsToClear.Count); rowsToClear.Clear(); } //Add next tetro ClearUpcomingTetromino(); Grid.SetCurrentTetromino(); // Check if game lose if (!(Grid.CanTetroFit(-2, -2))) { playing = false; Console.WriteLine("GAME OVER"); Console.SetCursorPosition(20, 5); Console.WriteLine("PRESS ANY KEY TO EXIT"); Console.ReadKey(); } } //Checks currentLevel in the Score class and calls the LevelUp function //if LevelUp is true Gravity goes down and the game gets faster if (MyScore.LevelUp()) { Gravity = Gravity - 2; if (Gravity < 2) { Gravity = 2; } } TickCounter = 0; } //DRAW GAME================== DrawUpcomingTetromino(); DrawGameField(); DrawTetromino(); DrawLevelAndScore(); } }
void Start() { myscore = GameObject.FindGameObjectWithTag("TheScore").GetComponent <MyScore>(); UpdateScore(); }
// Use this for initialization void Start() { myScore = GameObject.FindGameObjectWithTag("TheScore").GetComponent <MyScore>(); FinalScoreText.text = "Your Final Score is: " + myScore.score; }