Ejemplo n.º 1
0
 public void InvokeGameWonEvent()
 {
     gameIsOver = true;
     if (GameWonEvent != null)
     {
         GameWonEvent.Invoke();
     }
 }
 public void AddFinishedItem()
 {
     finishedItems++;
     if (finishedItems == items.Count)
     {
         gameWonEvent.Invoke(0);
     }
 }
Ejemplo n.º 3
0
 public void RotateCell(int row, int col)
 {
     PlayingBoard.Cells[row, col] = Board.Rotate(PlayingBoard.Cells[row, col]);
     if (!_won && CheckForWin())
     {
         GameWonEvent?.Invoke(this, new GameWonEventArgs(DateTime.UtcNow - StartTime));
         _won = true;
     }
 }
Ejemplo n.º 4
0
 private void SetLineRendererPoint(Vector3 point)
 {
     lineRenderer.SetPosition(lineRenderer.positionCount - 1, new Vector3(point.x, point.y, 0f));
     if (lineRenderer.positionCount > drawingPoints.Count + 1)
     {
         lineRenderer.startColor = Color.green;
         lineRenderer.endColor   = Color.green;
         gameWonEvent.Invoke(0);
         enabled = false;
     }
 }
Ejemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     if (!endGame)
     {
         finishedGame = true;
         foreach (Transform child in transform)
         {
             if (child.GetComponent <DirtManager>().hasDirt)
             {
                 finishedGame = false;
             }
         }
     }
     if (finishedGame)
     {
         gameWonEvent.Invoke(0);
         Cursor.visible = true;
         finishedGame   = false;
         endGame        = true;
     }
 }
Ejemplo n.º 6
0
    public void CollectItem(string itemName)
    {
        int completedItems = 0;

        for (int j = 0; j < txtItems.Length; j++)
        {
            Text currentItemText = txtItems[j];

            string text = currentItemText.text;
            int    currentAmountCollected = (int)char.GetNumericValue(text[0]);
            int    amountToCollect        = (int)char.GetNumericValue(text[text.Length - 1]);

            if (currentItemText.name == itemName)
            {
                currentAmountCollected += 1;

                if (currentAmountCollected <= amountToCollect)
                {
                    currentItemText.text = $"{currentAmountCollected}{text.Substring(1)}";
                }

                if (currentAmountCollected == amountToCollect)
                {
                    fallingItemSpawner.RemoveItemFromPool(itemName);
                }
            }

            if (currentAmountCollected == amountToCollect)
            {
                completedItems++;
            }
        }

        if (completedItems == txtItems.Length)
        {
            AudioManager.Play(AudioClipName.Lvl1GameWon);
            gameWonEvent.Invoke(0);
            Instantiate(gameWonMenu);
        }
    }
Ejemplo n.º 7
0
        public static void IsGameWon()
        {
            int clicked = 0, bombs = 0;

            for (int i = 0; i < Box.GetLength(0); i++)
            {
                for (int j = 0; j < Box.GetLength(1); j++)
                {
                    if (Box[i, j].IsClicked)
                    {
                        clicked++;
                    }
                    if (Box[i, j].HasBomb)
                    {
                        bombs++;
                    }
                }
            }
            if (clicked == (Box.Length - bombs))
            {
                RevealAllMines(true);
                GameWonEvent.Invoke();
            }
        }
Ejemplo n.º 8
0
 public static void PublishGameWonEvent()
 {
     GameWonEvent?.Invoke();
 }