Example #1
0
    void OnHit(GameObject obj, Vector3 hitpoint, Canvas cv)
    {
        Fishing_Fish fish = obj.GetComponent <Fishing_Fish>();

        if (fish == null)
        {
            return;
        }

        Destroy(gameObject);

        GameObject prefab = (GameObject)OwnerCannon.BelongRole.GameBase.FishingAssetBundle.LoadAsset(m_szNet);

        Vector3   pos  = GameFunction.WorldToLocalPointInRectangle(hitpoint, Camera.main, cv, cv.worldCamera);
        Transform root = cv.transform.Find("Root");

        GameObject explosion = (GameObject)Instantiate(prefab, pos, Quaternion.identity);

        explosion.transform.SetParent(root, false);
        OwnerCannon.BelongRole.GameBase.m_AddItems.Add(explosion);

        prefab = (GameObject)OwnerCannon.BelongRole.GameBase.FishingAssetBundle.LoadAsset("FishHit");
        GameObject bubble = (GameObject)Instantiate(prefab, pos, Quaternion.identity);

        bubble.transform.SetParent(root, false);
        OwnerCannon.BelongRole.GameBase.m_AddItems.Add(bubble);

        GameMain.WaitForCall(1f, () =>
        {
            OwnerCannon.BelongRole.GameBase.m_AddItems.Remove(explosion);
            Destroy(explosion);

            OwnerCannon.BelongRole.GameBase.m_AddItems.Remove(bubble);
            Destroy(bubble);
        });

        bool bLocal = m_Id != 0;

        fish.OnHit(bLocal);

        if (bLocal)//local player send
        {
            UMessage msg = new UMessage((uint)GameCity.EMSG_ENUM.CCMsg_FISHING_CM_FIRERESULT);
            msg.Add(GameMain.hall_.GetPlayerId());
            msg.Add(fish.m_nOnlyId);
            msg.Add(m_Id);
            HallMain.SendMsgToRoomSer(msg);
        }
    }