コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (dead)
        {
            return;
        }
        var fat = collision.GetComponent <FatScript>();

        if (fat.Fat == 4)
        {
            Kill();
            return;
        }
        var  deltay = collision.transform.position.y - transform.position.y;
        var  player = collision.GetComponent <PlatformingCharacter>();
        bool onTop  = deltay > .1f && player.VMomentum < 0f;

        if (onTop)
        {
            ScreenFreeze.Freeze(6);
            if (fat.Fat < 3)
            {
                player.VMomentum = player.jumpForce;
            }
            if (fat.Fat == 3)
            {
                player.VMomentum = player.jumpForce * .5f;
            }
            if (fat.Fat > 1)
            {
                Kill();
            }
            else
            {
                Flinch();
            }
        }
        else
        {
            MySceneManager.Kill();
            // Debug.Log("Kill!");
        }
    }