示例#1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            GameControllerScript GC = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>();

            if (GC.GetCoins() >= bribeCost)
            {
                GC.DecrementCoin(bribeCost);
                GetComponent <CapsuleCollider2D>().enabled = false;
                gravityModifier = 0;
                currentState    = State.Bribed;
                guard_animator.SetBool("is_alert", false);
                guard_animator.SetBool("is_bribed", true);
                guard_animator.SetFloat("speed", 0f);
            }
            else
            {
                currentState = State.Chasing;
                chaseTimer   = maxChaseTime;
                collision.gameObject.GetComponent <PlayerPlatformerController>().Kill();
            }
        }
    }