예제 #1
0
    private void CheckInRange()
    {
        if (null != _dropIfRanges && _dropIfRanges.Length > 0)
        {
            _xRotate = Mathf.Abs(_offsetRotate.x);
            _zRotate = Mathf.Abs(_offsetRotate.z);
            for (int i = 0; i < _dropIfRanges.Length; i++)
            {
                if (i >= 1)
                {
                    _preRangeTemp = _dropIfRanges[i - 1];
                }
                _curRangeTemp = _dropIfRanges[i];

                if (_curRangeTemp.InRange && _curRangeTemp.AllowStayTime != -1)
                {
                    _curRangeTemp.CurAddupTime += Time.deltaTime;
                    if (_curRangeTemp.CurAddupTime >= _curRangeTemp.AllowStayTime)
                    {
                        _curRangeTemp.InRange = false;
                        float v = UnityEngine.Random.Range(0f, (1f - float.Epsilon));
                        if (v <= _curRangeTemp.DropOutRandomPercent)
                        {
                            PlayerDrop();
                            Debug.LogFormat("TameMonsterManager.PlayerDrop Succeed: RandomValue:{0} DropOutRandomPercent:{1}", v, _curRangeTemp.DropOutRandomPercent);
                        }
                        else
                        {
                            Debug.LogFormat("TameMonsterManager.PlayerDrop Failing: RandomValue:{0} DropOutRandomPercent:{1}", v, _curRangeTemp.DropOutRandomPercent);
                        }
                    }
                }

                if (_curRangeTemp.AllowStayTime != -1)
                {
                    //lz-2017.01.13 大于前一个范围,小于等于当前范围
                    if (
                        ((_preRangeTemp == null || _zRotate > _preRangeTemp.AngleRadius) && _zRotate <= _curRangeTemp.AngleRadius) ||
                        ((_preRangeTemp == null || _xRotate > _preRangeTemp.AngleRadius) && _xRotate <= _curRangeTemp.AngleRadius)
                        )
                    {
                        _curRangeTemp.InRange = true;
                    }
                    else
                    {
                        _curRangeTemp.InRange = false;
                    }
                }

                _preRangeTemp = null;
                _curRangeTemp = null;
            }
        }
    }
예제 #2
0
    private void InitDropIsRanges()
    {
        if (TameMonsterConfig.instance.IfRangeList.Count > 0)
        {
            TameMonsterConfig.instance.IfRangeList = TameMonsterConfig.instance.IfRangeList.OrderBy(a => (a.AngleRadius)).ToList();

            _dropIfRanges = new DropIfRange[TameMonsterConfig.instance.IfRangeList.Count];
            for (int i = 0; i < TameMonsterConfig.instance.IfRangeList.Count; i++)
            {
                _dropIfRanges[i] = new DropIfRange(TameMonsterConfig.instance.IfRangeList[i]);
            }
        }
    }