Exemplo n.º 1
0
    void OnAddPoints(int pointsCount)
    {
        if (IsGameOver)
        {
            return;
        }
        D.Log("Ball_OnBallInBasket");
        _isNextLevel = true;

        _points.AddPoint(pointsCount);
//		_poinsBmScript.AddPoints (pointsCount);
    }
    private void Ball_OnGoal(int pointsCount)
    {
        if (IsGameOver)
        {
            return;
        }
        D.Log("Ball_OnBallInBasket");
        _isNextLevel = true;
        //int _pointsCount = DefsGame.bubbleMaxSize - _bubble.GetStartSize () + 1;

        _points.AddPoint(pointsCount);
        _poinsBmScript.AddPoints(pointsCount);
    }
Exemplo n.º 3
0
    public void UpdateWinner()
    {
        //Time.timeScale = 0.001f;
        resultsUI.SetActive(true);
        winnertext.text = PlayerSelect.GetWinner() + " wins!";

        Debug.Log(PlayerSelect.GetWinnerID());
        Points.AddPoint(PlayerSelect.GetWinnerID());
        Debug.Log(Points.p1);
        Debug.Log(Points.p2);

        pointstext.text = "WINS\nP1: " + Points.p1 + "\nP2: " + Points.p2 + "\nP3: " + Points.p3 + "\nP4: " + Points.p4;

        StartCoroutine(Timer(5));
    }
Exemplo n.º 4
0
    public void UpdateWinner()
    {
        //Time.timeScale = 0.001f;
        resultsUI.SetActive(true);
        winnertext.text = PlayerSelect.GetWinner() + " (P" + PlayerSelect.GetWinnerID() + ") wins!";

        Points.AddPoint(PlayerSelect.GetWinnerID());

        pointstext.text = "WINS\nP1: " + Points.p1 + "\nP2: " + Points.p2 + "\nP3: " + Points.p3 + "\nP4: " + Points.p4;

        if (Points.p1 >= 3 || Points.p2 >= 3 || Points.p3 >= 3 || Points.p4 >= 3)
        {
            winnertext.text = PlayerSelect.GetWinner() + " (P" + PlayerSelect.GetWinnerID() + ") is the ultimate winner!";
            StartCoroutine(Timer(starttimer));
            SceneManager.LoadScene("MenuScene");
        }

        StartCoroutine(Timer(starttimer));
    }
Exemplo n.º 5
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (isShot == true)
     {
         return;
     }
     else
     {
         if (desiredSpray == shooter.SodaType)
         {
             //Reward player for correct drink
             Debug.Log("yay!");
             //change faces to reward
             yum.SetActive(true);
             yuck.SetActive(false);
             //disables the parent sprite
             this.gameObject.GetComponent <SpriteRenderer>().enabled = false;
             //Create Thanks bubble and sets parent to face
             thanksBubble = GameObject.Instantiate(thanksBubble, speechBubbleObject.transform.position, speechBubbleObject.transform.rotation);
             thanksBubble.transform.parent = this.transform;
             //disactivate original speech bubble with order
             speechBubbleObject.SetActive(false);
             // add a point to the score
             points.AddPoint();
             //cannot be shot again
             isShot = true;
         }
         else
         {
             //Changes face to "yuck"
             Debug.Log("boo!");
             //enable lose face, disable win face
             yuck.SetActive(true);
             yum.SetActive(false);
             //disables the parent sprite
             this.gameObject.GetComponent <SpriteRenderer>().enabled = false;
             //removes order speech bubble
             speechBubbleObject.SetActive(false);
         }
     }
 }
Exemplo n.º 6
0
    private void Input(Event e, Vector3 mouse)
    {
        Points points = (Points)target;
        Rect   rect   = new Rect(5, 5, width + 10, height + 10);

        #region Input while over point
        if (!rect.Contains(e.mousePosition) && mouseOverPoint != null)
        {
            if (mouseOverPoint != null)
            {
                if (dragging)
                {
                    Undo.RecordObject(points, "Point Moved");
                    points.paths[currentPath].points[(int)mouseOverPoint] = mouse;
                    if (autoBuild)
                    {
                        points.BuildCollider();
                    }
                }

                if (e.type == EventType.MouseDown && e.button == 0 && e.modifiers != EventModifiers.Shift)
                {
                    if (e.modifiers != EventModifiers.Control)
                    {
                        dragging = true;
                    }
                }

                if (e.type == EventType.MouseUp && e.button == 0)
                {
                    dragging = false;
                }

                if (e.type == EventType.MouseDown && e.button == 0 && e.modifiers == EventModifiers.Control)
                {
                    Undo.RecordObject(points, "Point Removed");
                    points.paths[currentPath].points.RemoveAt((int)mouseOverPoint);
                    if (autoBuild)
                    {
                        points.BuildCollider();
                    }
                }

                if (e.type == EventType.MouseDown && e.button == 1 && e.modifiers != EventModifiers.Control)
                {
                    positionSettingStart = e.mousePosition;

                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Set Position"), false, Callback, 1);

                    string str = showPositionSetting ? "Close" : "Cancel";
                    menu.AddItem(new GUIContent(str), false, Callback, 2);
                    menu.ShowAsContext();
                }

                if (e.type == EventType.MouseDown && e.button == 1 && e.modifiers == EventModifiers.Control)
                {
                    Undo.RecordObject(points, "Remove Path");
                    points.RemovePath(currentPath);
                    if (autoBuild)
                    {
                        points.BuildCollider();
                    }
                }

                if (e.type == EventType.MouseDown)
                {
                    if ((int)mouseOverPoint != rightClickPoint)
                    {
                        showPositionSetting = false;
                    }
                }
            }
        }
        #endregion

        #region Input while not over point
        if (!rect.Contains(e.mousePosition) && mouseOverPoint == null)
        {
            if (e.type == EventType.MouseDown && e.button == 0 && e.modifiers == EventModifiers.Shift)
            {
                handleSize = points.useGlobal ? points.settings.handleSize : points.handleSize;

                float   closestLine = handleSize;
                int     index       = -1;
                Vector2 m2          = new Vector2(mouse.x, mouse.y);
                for (int i = 0; i < points.paths.Count; i++)
                {
                    for (int j = 0; j < points.paths[i].points.Count; j++)
                    {
                        Vector2 p1 = new Vector2(points.paths[i].points[j].x, points.paths[i].points[j].y);
                        Vector2 p2 = Vector2.zero;
                        if (j > 0)
                        {
                            p2 = new Vector2(points.paths[i].points[j - 1].x, points.paths[i].points[j - 1].y);
                        }
                        else
                        {
                            p2 = new Vector2(points.paths[i].points[points.paths[i].points.Count - 1].x, points.paths[i].points[points.paths[i].points.Count - 1].y);
                        }

                        float dist = HandleUtility.DistancePointToLineSegment(m2, p1, p2);

                        if (dist < closestLine)
                        {
                            closestLine = dist;
                            index       = j;
                        }
                    }
                }

                Undo.RecordObject(points, "Add Point");

                if (index > -1)
                {
                    points.InsertPoint(m2, index, currentPath);
                }
                else
                {
                    points.AddPoint(m2, currentPath);
                }

                SceneView.RepaintAll();
                if (autoBuild)
                {
                    points.BuildCollider();
                }
            }

            if (e.type == EventType.MouseDown && e.button == 1 && e.modifiers == EventModifiers.Shift)
            {
                Undo.RecordObject(points, "Add Path");
                points.AddPath();
                currentPath = points.paths.Count - 1;
                points.AddPoint(mouse, currentPath);
                if (autoBuild)
                {
                    points.BuildCollider();
                }
            }
        }
        #endregion
    }