private void PaintGame() { gp.Clear(Color.FromKnownColor(KnownColor.Control)); if (GameConfig.GameOver == false) { if (food.IfEaten()) { Console.WriteLine("food eaten"); score += GameConfig.GamePoint; ScoreChange?.Invoke(score); } food.MakeFood().Paint(gp); foreach (var body in snake.Move()) { body.Paint(gp); } } else { Console.WriteLine("game over!!"); t.Enabled = false; //重置snake snake.Reset(); //使得下局重置food位置 Food.Eaten = true; } }
private void OnClearLines(int linesCount) { int an = 10 + (linesCount - 1) * 10; int sum = (10 + an) / 2 * linesCount; _score += sum; _textScore.text = _score.ToString(); ScoreChange?.Invoke(_score); }
public void ResetScore() { score = 0; up = 0; medium = 0; down = 0; timer = 0; spawnCount = 0; caught = false; lives = 3; played = false; consecutive = 0; ScoreChange?.Invoke(-1, ChangeType.Reset); }
private void OnCollisionEnter(Collision collision) { if (collision.collider.tag == "Ball") { score++; caught = true; float floorHeight = Playspace.Instance.FloorCenter.y; float collisionHeight = collision.contacts[0].point.y; // check ball collision position to categorize exercise float height = collisionHeight - floorHeight; ChangeType type; if (height > upLimit) { up += 1; type = ChangeType.Up; } else if (height < downLimit) { down += 1; type = ChangeType.Down; } else { medium += 1; type = ChangeType.Middle; } // Notify all event handler of ScoreChange ScoreChange?.Invoke(1, type); // catch 3 balls in a row: lives++ with limit 3 consecutive++; if (consecutive >= 3) { lives = Mathf.Min(3, lives + 1); consecutive = 0; } // destroy is handled in explosion script } if (collision.collider.tag == "Bomb") { Instantiate(GameObject.Find("AudioManager").GetComponent <AudioManager>().bombExplode, collision.collider.transform.position, Quaternion.identity); lives = 0; } }
public void AddScore(int deletedLinesAmount) { _scoreData.Score += _lineCost * deletedLinesAmount; ScoreChange?.Invoke(_scoreData.Score); }
protected virtual void OnScoreChange() { ScoreChange?.Invoke(this); }
private void OnBlockAdded(int scoreCount) { _score += scoreCount; _textScore.text = _score.ToString(); ScoreChange?.Invoke(_score); }
public void OnScoreChange(GameScore gameScore) { ScoreChange?.Invoke(this, new ScoreChangeEventArgs(gameScore)); }
//plaatjes draaien (lars) private void CardClick(object sender, MouseButtonEventArgs e) { Image terug = new Image(); Image card = (Image)sender; int index = (int)card.Tag; alleKaarten[index].clicked(); if (ClickCards < 2) { ClickCards++; if (ClickCards == 2) { ShowCards(); card.Source = null; ImageSource kaart1 = alleKaarten[Vorigekaart].Show(); ImageSource kaart2 = alleKaarten[index].Show(); if (kaart1.ToString() == kaart2.ToString()) { if (player1 == true) { punten.Add(punten1); punten1++; ScoreChange?.Invoke(); MessageBox.Show("2 gelijken!"); } if (player1 == false) { punten.Add(punten2); punten2++; ScoreChange?.Invoke(); MessageBox.Show("2 gelijken!"); } alleKaarten[Vorigekaart].Onzichtbaar(); alleKaarten[index].Onzichtbaar(); bool alleKaartenOnzichtbaar = true; foreach (Kaart kaart in alleKaarten) { if (kaart.IsZichtbaar()) { alleKaartenOnzichtbaar = false; } } if (alleKaartenOnzichtbaar) { if (punten1 > punten2) { MessageBox.Show("De winnaar is: " + playernames[0]); } else if (punten1 < punten2) { MessageBox.Show("De winnaar is: " + playernames[1]); } else { MessageBox.Show("Gefeliciteerd, jullie zijn beide toppers"); } } } else { MessageBox.Show("Niet gelijk"); alleKaarten[Vorigekaart].Terugdraaien(); alleKaarten[index].Terugdraaien(); } if (player1 == true) { player1 = false; } else { player1 = true; } ClickCards = 0; } else { Vorigekaart = index; } } ShowCards(); }
void Start() { ScoreAmount.Score = PlayerPrefs.GetInt("Score"); ScoreChange?.Invoke(ScoreAmount.Score); }
public void ChangeScore(int amount) { ScoreAmount.Score += amount; ScoreChange?.Invoke(ScoreAmount.Score); }
public void ChangeScore() { ScoreAmount.Score += UpgradeStats.ClickPower; ScoreChange?.Invoke(ScoreAmount.Score); }