void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            RespawnableObject playerRespawn = collision.GetComponent <RespawnableObject>();

            if (playerRespawn)
            {
                playerRespawn.RespawnPosition = transform.position;
            }

            if (enableOnce)
            {
                GetComponent <Collider2D>().enabled = false;
            }

            if (LastCheckpoint)
            {
                LastCheckpoint.Deactivate();
            }

            LastCheckpoint = this;

            Activate();
        }
    }
Beispiel #2
0
    void Awake()
    {
        controller  = GetComponent <CharacterController2D>();
        cursor      = GetComponent <CursorBehaviour>();
        tools       = GetComponentsInChildren <ToolBehaviour>(true);
        respawn     = GetComponent <RespawnableObject>();
        textDialogs = GetComponentInChildren <TextDialogs>();
        gameManager = GameManager.Instance;

        mainCamera = Camera.main;
    }
Beispiel #3
0
    private static void SetObjectCollidedWith(RespawnableObject obj)
    {
        if (obj == null)
        {
            return;
        }

        if (!obj.hasBeenCollidedWith)
        {
            obj.SetCollidedWith();
        }
    }
Beispiel #4
0
    void KillObject(Collider2D objectToKill)
    {
        RespawnableObject resObject = objectToKill.GetComponent <RespawnableObject>();

        if (!resObject)
        {
            // TODO: Consider destroying these objects?
            objectToKill.gameObject.SetActive(false);
            return;
        }

        resObject.StartRespawn();
    }
    void OnTriggerEnter(Collider other)
    {
        CauldronIngredient ingredient = other.attachedRigidbody.GetComponentInChildren <CauldronIngredient>();


        Vector3 contactPosition = other.attachedRigidbody.gameObject.transform.position;

        contactPosition.y = gameObject.transform.position.y;

        SplashEffect.transform.position = contactPosition;

        SFXPlayer.Instance.PlaySFX(SplashClips[Random.Range(0, SplashClips.Length)], contactPosition, new SFXPlayer.PlayParameters()
        {
            Pitch    = Random.Range(0.8f, 1.2f),
            SourceID = 17624,
            Volume   = 1.0f
        }, 0.2f, true);

        splashVFX.Play();

        RespawnableObject respawnableObject = ingredient;

        if (ingredient != null)
        {
            m_CurrentIngredientsIn.Add(ingredient.IngredientType);
        }
        else
        {
            //added an object that is not an ingredient, it will make automatically fail any recipe
            m_CurrentIngredientsIn.Add("INVALID");
            respawnableObject = other.attachedRigidbody.GetComponentInChildren <RespawnableObject>();
        }

        if (respawnableObject != null)
        {
            respawnableObject.Respawn();
        }
        else
        {
            Destroy(other.attachedRigidbody.gameObject, 0.5f);
        }
    }