private void OnTriggerEnter2D(Collider2D collision) { //Check if shark collided with fish if (collision.tag == "Fish") { NPC_Fish fishRef = collision.GetComponent <NPC_Fish>(); //Add point if correct fish was eaten if (fishRef.GetFishType() == _fish_desired) { _scoreboard.AddScore(); ChangeDesiredFish(); } else//Otherwise end the game { _gameOver = true; transform.localScale = Vector3.one; foreach (GameObject g in _bubbles) { g.SetActive(false); } _scoreboard.DisplayEndScreen(); _col_self.enabled = false; } //Remove the fish fishRef.ClearFish(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { PlayerController player = other.GetComponent <PlayerController>(); if (player != null) { switch (pointType) { case PointType.Normal: Scoreboard.AddScore(player.Player, points); Destroy(gameObject); break; case PointType.Split: pointPlayers.Add(player.Player); break; default: break; } } } }
private void OnParticleCollision(GameObject other) { _scoreboard.AddScore(scorePerHit); hitsRemaining--; if (hitsRemaining <= 0) { KillEnemy(); } }
private void PlayDeathScence() { if (isLast) { NextLevelLoader.LoadNextLevel(); } Instantiate(DeathFX, gameObject.transform.position, Quaternion.identity); Scoreboard.AddScore(enemyScoreCost); Destroy(gameObject); }
private void LateUpdate() { if (pointType == PointType.Split && pointPlayers.Count > 0) { foreach (Player p in pointPlayers) { Scoreboard.AddScore(p, points / pointPlayers.Count); } Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { PlayerController player = other.GetComponent <PlayerController>(); if (score != 0) { Scoreboard.AddScore(player.Player, score); } Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.name == "Cage") { gameObject.SetActive(false); } else if (collider.gameObject.name == "Asteroid") { Asteroid roid = collider.gameObject.GetComponent <Asteroid>(); roid.Reset(); scoreboard.AddScore(); gameObject.SetActive(false); } }
private static void ExecuteAddScoreCommand(string[] commandParams) { string username = commandParams[1]; string userPassword = commandParams[2]; string gameName = commandParams[3]; string gamePassword = commandParams[4]; int score = int.Parse(commandParams[5]); bool scoreAdded = scoreData.AddScore( username, userPassword, gameName, gamePassword, score); Console.WriteLine(scoreAdded ? "Score added" : "Cannot add score"); }
public void HitCard(PlayerController controller) { if (!CanHit) { return; } CanHit = false; bool isSame = IsSameCards(); Debug.Log(controller.Player.playerName + " hit the table!"); if (isSame) { controller.HybridModel.AnimationHandler.PlayAnimation("Headbutt"); Scoreboard.AddScore(controller.Player, 1); } else { controller.HybridModel.AnimationHandler.PlayAnimation("Stunned"); } StopAllCoroutines(); StartCoroutine(IEHitCard(isSame)); }
private IEnumerator StartGame() { audioSource.Stop(); audioSource.Play(); gameInProgress = true; score = 0; milk.transform.position = milkStartPos; timer = 0; gameCodeText.text = scoreboard.currentGameCode; while (timer <= countDownTime) { timer += Time.deltaTime; timerText.text = ((int)timer).ToString(); yield return(null); } timer = milkingTime; milkingAllowed = true; while (timer > 0.0f) { timer -= Time.deltaTime; timerText.text = Mathf.Clamp(timer, 0.0f, milkingTime).ToString("F2"); yield return(null); } timerText.text = Mathf.Clamp(timer, 0.0f, milkingTime).ToString("F2"); scoreboard.AddScore(score); SaveScores(); milkingAllowed = false; gameInProgress = false; }
public void TestWithSampleData() { var sampleData = GetTestData(); foreach (var item in sampleData) { try { var sb = new Scoreboard(); foreach (var frame in item.Frames) { foreach (var score in frame.Scores) { sb.AddScore(score); } } Assert.AreEqual(true, sb.IsCompleted); Assert.AreEqual(item.TotalScore, sb.Score); foreach (var frame in sb.Frames) { if (!frame.IsExtension) { Assert.AreEqual(FrameState.End, frame.State); Assert.AreEqual(true, frame.IsEnded); } Assert.AreEqual(item.Frames[sb.Frames.IndexOf(frame)].TotalScore, frame.Score); } } catch (Exception) { return; } } Assert.Fail("No exception thrown"); }
public void ChangeState(int state) { if (state == -1) { this.state = state; if (GetServer().firstGame) { fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.architectTutorial.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.driverTutorial.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); } SwitchAudio("game"); } else if (state == 0) { this.state = state; startTime = Time.time; GameScene.Instance.waitingUI.GetComponent <TextMeshProUGUI>().SetText("(client)"); countdownCoroutine = StartCoroutine(StartCountdown()); } else if (state == 1) { this.state = state; GameScene.Instance.countdownEndSound.Play(); GameScene.Instance.countdownLabel.GetComponent <TextMeshProUGUI>().SetText("GO"); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.score.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.speed.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.currentStack.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.nextTile.GetComponent <CanvasGroup>(), 0f, 1f, 0.5f)); if (GetServer().firstGame) { fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.architectTutorial.GetComponent <CanvasGroup>(), 1f, 0f, 1f)); fadeUI = StartCoroutine(FadeCanvas(GameScene.Instance.driverTutorial.GetComponent <CanvasGroup>(), 1f, 0f, 1f)); } } else if (state == 2) { this.state = state; GetServer().firstGame = false; //StartCoroutine(FadeOutAudio(gameMusics[currentMusicId])); if (paused) { Pause(); } GameObject.FindGameObjectsWithTag("Driver")[0].GetComponent <Driver>().engineSound.pitch = -0.8f; if (GameObject.FindGameObjectsWithTag("Driver")[0].GetComponentInChildren <AudioListener>()) { GameObject.FindGameObjectsWithTag("Driver")[0].GetComponentInChildren <AudioListener>().enabled = false; } if (GameObject.FindGameObjectsWithTag("Architect")[0].GetComponentInChildren <AudioListener>()) { GameObject.FindGameObjectsWithTag("Architect")[0].GetComponentInChildren <AudioListener>().enabled = false; } if (GameObject.FindGameObjectsWithTag("Architect")[0].GetComponent <Goals>()) { GameObject.FindGameObjectsWithTag("Architect")[0].GetComponent <Goals>().Reset(); } // Rewind GameObject driver = GameObject.FindGameObjectsWithTag("Driver")[0]; List <Vector3> lastPositions = driver.GetComponent <Driver>().lastPositions; List <Quaternion> lastRotations = driver.GetComponent <Driver>().lastRotations; Destroy(driver.GetComponent <Driver>().vehicle); GameObject vehicle = Instantiate(vehicles[driver.GetComponent <Driver>().vehicleId], lastPositions[0], lastRotations[0]); vehicle.GetComponent <Vehicle>().rewind = true; vehicle.AddComponent <ReproduceMovements>(); vehicle.GetComponent <ReproduceMovements>().positions = lastPositions; vehicle.GetComponent <ReproduceMovements>().rotations = lastRotations; vehicle.GetComponent <ReproduceMovements>().vehicleId = driver.GetComponent <Driver>().vehicleId; vehicle.GetComponent <ReproduceMovements>().fallInWater = driver.GetComponent <Driver>().gameoverFallInWater; // GameOver UI GameScene.Instance.score.SetActive(false); GameScene.Instance.speed.SetActive(false); GameScene.Instance.currentStack.SetActive(false); GameScene.Instance.nextTile.SetActive(false); GameScene.Instance.warningLabel.SetActive(false); GameScene.Instance.camera.SetActive(true); GameScene.Instance.camera.GetComponent <DeathCamera>().target = vehicle; GameScene.Instance.gameoverScoreLabel.GetComponent <TextMeshProUGUI>().SetText("Score: " + score); GameScene.Instance.gameoverTimeLabel.GetComponent <TextMeshProUGUI>().SetText("Time: " + Mathf.Floor(Time.time - startTime)); GameScene.Instance.gameoverUI.SetActive(true); // Highscore if (score > PlayerPrefs.GetInt("scoreboard_highscore")) { GameScene.Instance.gameoverHighscore.SetActive(true); PlayerPrefs.SetInt("scoreboard_highscore", score); if (PlayerPrefs.HasKey("scoreboard_username")) { StartCoroutine(Scoreboard.AddScore(score)); } } } }
public void AddRecipeBonusScore(int recipePoints) { scoreboard.AddScore(playerSide, recipePoints); }
protected virtual void Update() { // Use escape to pause if (Input.GetKeyDown(KeyCode.Escape)) { this.Pause(); } if (Menu.InPlay) { // Remove the speedMultiplier when the timer expires if (this.speedCounter > 0) { this.speedCounter -= Time.deltaTime; if (this.speedCounter <= 0) { this.speedMultiplier = 1.0f; this.speedCounter = 0; } } // Use space bar to jump if (Input.GetKeyDown(KeyCode.Space)) { this.JumpEnter(); } if (Input.GetKeyUp(KeyCode.Space)) { this.JumpExit(); } // The player loses if they fall outside of the camera if (!God.InCamera(this.transform.position)) { LossMenu.HandleLoss(this.score); Scoreboard.AddScore(new HighScore { Score = this.score, Distance = (int)this.transform.position.x, Date = DateTime.Now, Difficulty = Settings.Difficulty }); } // Tell the camera to skip ahead if the player surpasses maxScreenX if (God.CameraCoords(this.transform.position).x > maxScreenX) { God.Skip(1 / (1 - God.CameraCoords(this.transform.position).x)); } // Apply upward jetpack force if the player is currently jetpacking if (this.isJetpacking) { this.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, jumpJetpackForce * Time.deltaTime * Settings.JumpPower)); } // Move forward with the current speed multiplier and update the HUD distance int lastX = (int)this.transform.position.x; this.transform.Translate(new Vector3(God.ScrollSpeed * this.SpeedMultiplier * Time.deltaTime, 0, 0)); if ((int)this.transform.position.x > lastX) { HUD.UpdateDistance((int)this.transform.position.x); } } // Set the player to static when not in play and dynamic when in play if (this.GetComponent <Rigidbody2D>().bodyType == RigidbodyType2D.Static && Menu.InPlay) { this.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; // Upon exiting pause, restore the previous velocity this.GetComponent <Rigidbody2D>().velocity = this.lastVelocity; } else if (this.GetComponent <Rigidbody2D>().bodyType == RigidbodyType2D.Dynamic && !Menu.InPlay) { this.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Static; } }
public void Kill() { gameObject.SetActive(false); DeathParticle.PlayEffect(transform.position, color); Scoreboard.AddScore(1); }
void Update() { switch (stageState) { case StageState.Intro: if (Input.GetKeyDown(KeyCode.Space) || getSendTrigger()) { int similarityPercent = SimilarityCheck(); //show result feedback if (similarityPercent < 40) { //miss //Pisca imagem de overlap e resetta session StartCoroutine(SessionTransition(1.2f)); } else { StartCoroutine(SetStageTimer(startingStageTimeValue)); SetSession(); StartCoroutine(IntroScreenAnimation()); } } break; case StageState.Playing: /* * Input de teste, aperte Y para ver como o jogo está gerando o HandicapMap (RegionMap) (ProximityMap) (THICCmap) */ if (Input.GetKeyDown(KeyCode.Y)) { Texture2D _aux = paintedImage.sharedMaterial.mainTexture as Texture2D; _aux = ImageComparator.CreateTextureMap(originalSprite.sprite.texture, Color.black); paintedImage.material.mainTexture = _aux; _aux.Apply(); } if (Input.GetKeyDown(KeyCode.Space) || getSendTrigger()) { int similarityPercent = SimilarityCheck(); //Adiciona pontiação ao score da fase scoreboard.AddScore(similarityPercent / 2, bonusBar.getValue()); //adiciona tempo int timeAdd = (int)(similarityPercent * 0.01f * timeForHundredPercent); timeValue += timeAdd; StartCoroutine(MoreTime(timeAdd)); //Pisca imagem de overlap e resetta session StartCoroutine(SessionTransition(1.2f)); stageState = StageState.Transition; } break; default: break; } }