コード例 #1
0
 public void OnCameraChanged()
 {
     if (GameBase != null && Target != null)
     {
         SetPos(GameFunction.WorldToLocalPointInRectangle(Target.transform, GameBase.CurCam, GameBase.m_GameCanvas, GameBase.UICam));
     }
 }
コード例 #2
0
    public Vector3 GetCoinPos()
    {
        //Vector3 pos = m_InfoUI.FindChild("left/Image_coinframe/Image_Coin").position;
        Vector3 pos   = m_InfoUI.position;
        Canvas  cv    = GameBase.GameCanvas;
        Vector3 uiPos = GameFunction.WorldToLocalPointInRectangle(pos, cv.worldCamera, cv, cv.worldCamera);

        return(uiPos);
    }
コード例 #3
0
 void UpdateTalk()
 {
     if (m_TalkObj != null && m_TalkObj.activeSelf)
     {
         Canvas  cv    = m_TalkObj.GetComponentInParent <Canvas>();
         Vector3 uiPos = GameFunction.WorldToLocalPointInRectangle(m_LockPointTfm.position, Camera.main, cv, cv.worldCamera);
         m_TalkObj.transform.localPosition = uiPos;
         float dis         = Vector3.Distance(m_LockPointTfm.position, Camera.main.transform.position);
         float scaleFactor = Mathf.Clamp(80f / dis, 0.1f, 1f);
         m_TalkObj.transform.localScale = new Vector3(scaleFactor, scaleFactor, 1f);
         //DebugLog.Log("fish scale:" + scaleFactor + " dis:" + dis);
     }
 }
コード例 #4
0
    void OnFire(GameObject target, uint bulletId)
    {
        PlayAnim("fashe");

        foreach (string point in m_Data.m_szBulletPoint)
        {
            Transform      tfm   = transform.Find(point);
            Canvas         cv    = BelongRole.GameBase.GameCanvas;
            Vector3        uiPos = GameFunction.WorldToLocalPointInRectangle(tfm.position, cv.worldCamera, cv, cv.worldCamera);
            Fishing_Bullet fb    = Fishing_Bullet.Create(BelongRole.GameBase.FishingAssetBundle, uiPos, tfm.rotation, m_Data, target, bulletId);
            fb.OwnerCannon = this;
        }
    }
コード例 #5
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);
        }
    }
コード例 #6
0
    void UpdateLockState()
    {
        if (m_eLockState == LockFishState.LFS_Begin)
        {
            if (IsLocal())
            {
                if (LockFish == null)
                {
                    ChangeLockFish(GameBase.FishMgr.LockNextFish(m_nIndex));
                }
            }

            if (LockFish != null)
            {
                m_eLockState = LockFishState.LFS_Locking;
                LockUI.gameObject.SetActive(true);
            }
        }

        if (m_eLockState == LockFishState.LFS_End)
        {
            OnLockFishLost();
            LockUI.gameObject.SetActive(false);
            m_eLockState = LockFishState.LFS_None;
        }

        if (m_eLockState == LockFishState.LFS_Locking)
        {
            if (IsLocal())
            {
                if (LockFish == null || !LockFish.IsLockBySit(m_nIndex, -100f))
                {
                    //DebugLog.Log("locking->begin curfish:" + (LockFish == null ? 0 : LockFish.m_nOnlyId));

                    LockUI.gameObject.SetActive(false);
                    m_eLockState = LockFishState.LFS_Begin;
                    OnLockFishLost();
                }
            }

            if (LockFish != null)
            {
                Canvas cv = GameBase.GameCanvas;
                LockUI.localPosition = GameFunction.WorldToLocalPointInRectangle(LockFish.GetLockPoint().position, Camera.main, cv, cv.worldCamera);
            }
        }
    }
コード例 #7
0
    public void OnCatch(Fishing_Cannon cannon, bool bLocal, long reward, FishType_Enum fishType, byte getSkillId, int specialId)
    {
        if (m_CatchRole != null)
        {
            return;
        }

        m_CatchRole = cannon.BelongRole;
        m_Animator.SetTrigger("die");
        gameObject.layer = 0;//no collide
        m_SplineMove.Stop();
        m_CatchRole.GameBase.OnLockFishLost(new List <byte>(m_LockSitList));

        if (bLocal && fishType > FishType_Enum.FishType_Boss)
        {
            m_CatchRole.GameBase.StartLottery(fishType, specialId);
        }
        else
        {
            Canvas  cv  = m_CatchRole.GameBase.GameCanvas;
            Vector3 pos = GameFunction.WorldToLocalPointInRectangle(transform.position, Camera.main, cv, cv.worldCamera);
            if (fishType == FishType_Enum.FishType_Lottery)
            {
                getSkillId = RoomInfo.NoSit;
            }
            GameMain.SC(PopCoin(this, Fishing_Data.GetInstance().m_FishData[m_nTypeId],
                                bLocal, reward, pos, m_CatchRole.GetCoinPos(), getSkillId));
        }

        float deadTime = 3f;

        m_CatchRole.GameBase.m_AddItems.Add(gameObject);
        if (bLocal && m_DeadSound != null)
        {
            m_DeadSound.volume = AudioManager.Instance.SoundVolume;
            m_DeadSound.Play();
            deadTime = m_DeadSound.clip.length;
        }
        GameMain.WaitForCall(deadTime, () =>
        {
            m_CatchRole.GameBase.m_AddItems.Remove(gameObject);
            OnDeath(this);
        });
    }