示例#1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Fish" && !Manager.instance.drill)
        {
            if (160f * transform.localScale.x > col.gameObject.GetComponent <SpriteRenderer>().sprite.rect.xMax)
            {
                if (PlayerPrefs.GetInt("Tutorial") == 0)
                {
                    tut.obtained++;
                }

                var fish = col.gameObject;
                Manager.instance.weight += AddWeight(fish.name, fish);

                if (Manager.instance.weight <= Manager.instance.capacity)
                {
                    molest.PlayOneShot(squish);

                    fish.transform.position = new Vector3(transform.position.x, transform.position.y, -0.25f);

                    Disable(fish);
                    fish.tag = "InBubble";

                    bubblefish.Add(fish);

                    if (PlayerPrefs.GetInt("Lucky Number 6", 0) == 0)
                    {
                        List <GameObject> unique = bubblefish.GroupBy(x => x.name).Select(x => x.First()).ToList();
                        if (unique.Count() == 6)
                        {
                            Manager.instance.Achievement("Lucky Number 6", "Acquire 6 different fish in your bubble");
                        }
                    }

                    if (fish.name.Contains("Golden Fish"))
                    {
                        Manager.instance.Achievement("Ecstacy of Gold", "Catch the Golden Fish");
                    }

                    if (Manager.instance.weight == Manager.instance.capacity && PlayerPrefs.GetInt("Daredevil", 0) == 0)
                    {
                        startTime = Time.time;
                        set       = true;
                    }

                    if (Manager.instance.magnet && PlayerPrefs.GetInt("Sucker", 0) == 0)
                    {
                        counter++;
                        if (counter == 5)
                        {
                            Manager.instance.Achievement("Sucker", "Suck 5 fish with the magnet");
                        }
                    }

                    fish.GetComponent <Rigidbody2D>().mass = 0f;
                }
                else
                {
                    StartCoroutine(death.L());
                    Manager.instance.weight = Manager.instance.capacity;
                }
            }
            else
            {
                StartCoroutine(death.L());
            }
        }
    }