コード例 #1
0
    void OnTriggerExit2D(Collider2D collider)
    {
        GameObject thing = collider.gameObject;

        if (thing.transform.parent.gameObject != tiles)
        {
            if (thing.GetComponent <Food>() != null)
            {
                GameEventManager.AddPoints(thing.GetComponent <Food>().PointValue, thing.transform.position);
            }
            else
            {
                GameEventManager.AddItem(thing.name);
                switch (thing.name)
                {
                case "sunglasses":
                    sunglasses.SetActive(true);
                    CancelInvoke("DisableSunglasses");
                    Invoke("DisableSunglasses", itemTime);
                    break;

                case "tie":
                    shirt.SetActive(true);
                    CancelInvoke("DisableTie");
                    Invoke("DisableTie", itemTime);
                    break;

                case "handcuffs":
                    harness.SetActive(true);
                    CancelInvoke("DisableHandcuffs");
                    Invoke("DisableHandcuffs", itemTime);
                    break;

                case "dog":
                    GameEventManager.MultiplyPoints(2);
                    multiplier.Show(thing.GetComponent <SpriteRenderer>().sprite, "x2");
                    break;

                case "badge":
                    multiplier.Show(thing.GetComponent <SpriteRenderer>().sprite, "x3");
                    GameEventManager.MultiplyPoints(3);
                    break;

                case "heart":
                    multiplier.Show(thing.GetComponent <SpriteRenderer>().sprite, "^2");
                    GameEventManager.MultiplyPoints(GameEventManager.points);
                    break;

                case "octopus":
                    octopus.SetActive(true);
                    CancelInvoke("DisableOctopus");
                    Invoke("DisableOctopus", itemTime);
                    break;

                case "rifle":
                    rifle.SetActive(true);
                    CancelInvoke("DisableRifle");
                    Invoke("DisableRifle", itemTime);
                    break;

                case "camera":
                    flashRenderer.SetAlpha(1);
                    flash.CrossFadeAlpha(0, 0.5f, false);
                    Vector3 position;
                    foreach (Transform food in foodObject.transform)
                    {
                        position = Camera.main.WorldToViewportPoint(food.position);
                        if (position.x > 0 && position.x < 1 && position.y > 0 && position.y < 1)
                        {
                            GameEventManager.AddPoints(food.GetComponent <Food>().PointValue, food.transform.position);
                            Object.Destroy(food.gameObject);
                        }
                    }
                    break;

                case "sass":
                    jumpSpeed = sassyJumpSpeed;
                    sass.SetActive(true);
                    Invoke("DisableSass", itemTime);
                    break;

                case "medal":
                    medal.enabled = true;
                    CancelInvoke("DisableMedal");
                    Invoke("DisableMedal", itemTime);
                    break;

                case "botox":
                    animator.runtimeAnimatorController = unicorn;
                    Invoke("DisableBotox", itemTime);
                    break;

                default:
                    break;
                }
            }
            Object.Destroy(thing);
        }
    }