Exemplo n.º 1
0
    /********* helper for conditions for combos *********/

    // sets the last boba of combo as selected
    void SetLastBobaAsSelected(bool selected)
    {
        BobaCharacter bobachar = GetLastBoba();

        if (bobachar != null)
        {
            bobachar.SetSelected(selected);
        }
    }
Exemplo n.º 2
0
 // gets all bobas allowed in combo that are around the currently selected boba and highlights them
 void HighlightAllowedBobas(BobaCharacter bobachar)
 {
     foreach (BobaCharacter b in bobaPlace.GetComponentsInChildren <BobaCharacter>())
     {
         if (b.Check(bobachar) && !comboList.Contains(b))
         {
             b.SetHighlight(true);
             HighlightAllowedBobas(b);
         }
     }
 }
Exemplo n.º 3
0
 public bool Check(BobaCharacter bobachar)
 {
     if (!HighlightOrNah() && BobaType == bobachar.BobaType)
     {
         Vector3 distance = transform.position - bobachar.transform.position;
         if (distance.sqrMagnitude < (1.5f * 1.5f))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // touch began
            Vector3      p   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(p, Vector2.zero);
            if (hit.collider != null)
            {
                if (hit.collider.tag == "bobacharacter")
                {
                    BobaCharacter bobachar = hit.collider.GetComponent <BobaCharacter>();
                    if (bobachar.Check(bobachar))
                    {
                        comboList.Add(bobachar);
                        bobachar.SetSelected(true);
                    }
                }
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            // touch ended
            // check if combo is more than 2... if it is...
            if (comboList.Count > 2)
            {
                // go through every boba in combo and delete them
                foreach (BobaCharacter bobachar in comboList)
                {
                    //multiply the amount in combo * 100

                    score += (comboList.Count * 100);
                    if (bobachar.gameObject != null)
                    {
                        Destroy(bobachar.gameObject);
                    }

                    scoreDisplay.text = "" + score;

                    // updates score for exit menu and pause menu
                    Exit.scoreNum      = score;
                    PauseMenu.scoreNum = score;
                }
            }
            else
            {
                // combo must be less than 2 bobas so set last boba as unselected
                SetLastBobaAsSelected(false);
            }
            // clear all bobas in list
            comboList.Clear();
        }

        if (Input.GetMouseButton(0))
        {
            Vector3      p   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(p, Vector2.zero);

            if (hit.collider != null)
            {
                if (hit.collider.tag == "bobacharacter")
                {
                    BobaCharacter bobachar = hit.collider.GetComponent <BobaCharacter>();

                    // if pet is not already inside combo
                    if (!comboList.Contains(bobachar))
                    {
                        // is it allowed to be part of combo?
                        if (GetLastBoba().Check(bobachar))
                        {
                            // make last boba in combo unselected
                            SetLastBobaAsSelected(false);

                            // add it to the combo
                            comboList.Add(bobachar);

                            // make it selected
                            bobachar.SetSelected(true);
                        }
                    }

                    else
                    {
                        // boba is inside combo
                        int index = comboList.LastIndexOf(bobachar);

                        if (index == comboList.Count - 2)
                        {
                            SetLastBobaAsSelected(false);
                            comboList.RemoveAt(comboList.Count - 1);
                            SetLastBobaAsSelected(true);
                        }
                    }

                    //if (selected != hit.collider.gameObject)
                    //{
                    //    // boba character selected
                    //    if (selected != null)
                    //    {
                    //        // not selected
                    //        selected.GetComponent<Animator>().SetBool("selected", false);
                    //    }
                    //    hit.collider.GetComponent<Animator>().SetBool("selected", true);
                    //    selected = hit.collider.gameObject;
                    //}
                }
            }
        }

        foreach (BobaCharacter b in bobaPlace.GetComponentsInChildren <BobaCharacter>())
        {
            b.SetHighlight(false);
        }


        if (comboList.Count > 0)
        {
            HighlightAllowedBobas(GetLastBoba());
        }



        /*if (outside)
         * {
         *  SceneManager.LoadScene(2);
         * }*/
    }