Exemplo n.º 1
0
    // Check collision with fish.
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other.tag);
        if (other.tag == "Wall" && !IsBack)
        {
            IsMove = false;
            IsBack = true;
            PlayerAnimator.SetBool("IsUp", true);
            PlayerAnimator.SetBool("IsCatch", false);
            return;
        }
        if (other.tag == "Explose")
        {
            Destroy(other.gameObject);
        }

        if (other.tag == "Mouth")
        {
            if (GameManager.Instance.gameMode.catchFish)
            {
                GameObject fishObj = other.transform.parent.gameObject;
                if (!fishObj.GetComponent <Move2>().isCatch)
                {
                    IsMove = false;
                    IsBack = true;
                    GetComponent <BoxCollider2D>().enabled = false;
                    PlayerAnimator.SetBool("IsUp", true);
                    PlayerAnimator.SetBool("IsCatch", false);


                    if (GameManager.Instance.gameModeConfig == GameModeConfig.GAME_OFFLINE)
                    {
                        fishObj.GetComponent <Move2>().isCatch = true;
                        boatMan.CatchFish(fishObj);
                    }
                    else
                    {
                        //fishObj.GetComponent<Move2>().CatchByBoat(boatMan.photonView.viewID);
                    }
                }
            }
            else
            {
                //Destroy Fish TODO: despawn fish
            }
        }

        if (other.tag == "Trash")
        {
            boatMan.CatchTrash(other.gameObject);
        }

        //play sound

        Audio.Instance.StopHookSound();

        Audio.Instance.PlayEffect(SoundType.SWIRLING, true, 0);
    }