Beispiel #1
0
    void LocalFire(GameObject target)
    {
        if (BelongRole == null || BelongRole.m_nTotalCoin < m_nBulletCost)
        {
            LocalFireFail();
            return;
        }

        UMessage msg = new UMessage((uint)GameCity.EMSG_ENUM.CCMsg_FISHING_CM_APPLYFIRE);

        msg.Add(GameMain.hall_.GetPlayerId());
        msg.Add(transform.eulerAngles.z);
        msg.Add((byte)m_Data.m_szBulletPoint.Length);
        msg.Add(++m_nBulletId);
        HallMain.SendMsgToRoomSer(msg);

        OnFire(target, m_nBulletId);

        if (m_FireSound != null)
        {
            m_FireSound.volume = AudioManager.Instance.SoundVolume;
            m_FireSound.loop   = false;
            m_FireSound.Play();
        }

        BelongRole.UpdateInfoUI(BelongRole.m_nTotalCoin - m_nBulletCost);
    }
Beispiel #2
0
    void UpdateLocked()
    {
        if (BelongRole.LockFish != null && !BelongRole.LockFish.Caught())
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit rayhit;
                if (Physics.Raycast(ray, out rayhit, 500f, CGame_Fishing.FishLayer))
                {
                    BelongRole.ChangeLockFish(rayhit.collider.gameObject.GetComponent <Fishing_Fish>());
                }
            }

            m_bFire = true;
            Canvas  cv = BelongRole.GameBase.GameCanvas;
            Vector3 ms = RectTransformUtility.WorldToScreenPoint(cv.worldCamera, BelongRole.LockUI.transform.position);
            UpdateFire(ms, BelongRole.LockFish.gameObject);
            UpdateLockLine();
        }
        else
        {
            m_bFire = false;
            m_LineImg.fillAmount = 0f;
        }
    }
Beispiel #3
0
    public void OtherFire(float angle, byte num, GameObject lockObj)
    {
        if (BelongRole.IsLocal())
        {
            return;
        }

        transform.eulerAngles = new Vector3(0f, 0f, angle);
        OnFire(lockObj, 0);
    }
Beispiel #4
0
    void UpdateLockLine()
    {
        if (!BelongRole.IsLockFish() || BelongRole.LockFish == null || BelongRole.LockFish.Caught())
        {
            m_LineImg.fillAmount = 0f;
            return;
        }

        Canvas  cv      = BelongRole.GameBase.GameCanvas;
        Vector3 ms      = RectTransformUtility.WorldToScreenPoint(cv.worldCamera, BelongRole.LockUI.transform.position);
        Vector3 linePos = RectTransformUtility.WorldToScreenPoint(cv.worldCamera, m_LineImg.transform.position);

        Vector2 targetDir = ms - linePos;
        float   len       = targetDir.magnitude;
        float   uiLen     = m_LineImg.rectTransform.rect.width;

        m_LineImg.fillAmount = len / uiLen;
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (BelongRole.IsLocal())
        {
            m_shootTimer -= Time.deltaTime;

            if (!BelongRole.IsLockFish())
            {
                UpdateInput();
            }
            else
            {
                UpdateLocked();
            }
        }
        else
        {
            UpdateLockLine();
        }
    }