Ejemplo n.º 1
0
        public void InitShadowParam(NavPath _nav)
        {
            iTween.ScaleTo(gameObject, localScale, 1f);
            NavPath _path = PathCtrl.Instance.GetShadowPath(_nav, offset);

            navigation.init(transform, _path);
        }
Ejemplo n.º 2
0
 public void init(Transform objTrans, NavPath _path, float _dealyTimeLength)
 {
     _time     = _dealyTimeLength;
     _objTrans = objTrans;
     _objTween = _objTrans.GetComponent <TweenRotation>();
     ApplyPath(_path);
     start(_pathCfg, objTrans.eulerAngles);
 }
Ejemplo n.º 3
0
        // 转换路径.
        private NavPath ShiftPath(NavPath _np, Vector3 _basePos, float _rotX)
        {
            int _num = _np._path.Length;

            for (int i = 0; i < _num; i++)
            {
                // 1, rotate.
                _np._path[i] = Quaternion.Euler(0f, 0f, _rotX) * _np._path[i];
                // 2, group local position.
                _np._path[i] += _basePos;
            }
            return(_np);
        }
Ejemplo n.º 4
0
        // shadow的路径.
        public NavPath GetShadowPath(NavPath _np, Vector3 _shadowShift)
        {
            // we need to create a new one NavPath and return it.
            NavPath np   = new NavPath();
            int     _num = _np._path.Length;

            np._path = new Vector3[_num];
            for (int i = 0; i < _num; i++)
            {
                // 1, rotate.
                np._path[i]  = _np._path[i];
                np._path[i] += _shadowShift;
            }
            np._time = _np._time;
            return(np);
        }
Ejemplo n.º 5
0
 // 初始化鱼的参数.
 public void InitFishParam(NavPath _nav, int _fishServerID, SingleShadow _ss, int _fishPool)
 {
     // 变大.
     iTween.ScaleTo(gameObject, localScale, 1f);
     // 这条鱼所对应的影子.
     singleShadow = _ss;
     // 鱼的id.
     fishServerID = _fishServerID;
     // 鱼所在的池,方便同类炸弹使用.
     fishPool = _fishPool;
     // 初始化路径.
     navigation.init(cur_Transform, _nav);
     if (fishType == FishType.likui)
     {
         multi = LikuiBeginBeilv;
     }
 }
Ejemplo n.º 6
0
        // 从服务器接收到创建一条鱼的消息.
        public void S_C_NPC_Generator(UInt32 _serverTime, UInt32 _serverID, string _actorName, Vector3 [] _path, float _timeLength, float _rotX, float _x, float _y)
        {
            Vector3 [] tranPos = Utility.S_C_TransformPath(_path);
            FishParam  _fp     = new FishParam();
            NavPath    _np     = new NavPath();

            _fp.serverTime     = _serverTime;
            _fp.serverID       = (int)_serverID;
            _np._path          = tranPos;
            _fp.pathTimeLength = _timeLength;
            _fp.name           = _actorName;
            // 从 server 接收到的角度和 unity 的角度是相反的.
            _fp.rotX    = -_rotX;
            _fp.pos     = Utility.S_C_Transform_V3(new Vector3(_x, _y, 0f));
            _fp.navPath = ShiftPath(_np, _fp.pos, _fp.rotX);

            FishCtrl.Instance.AddFishInCreatList(_fp);
        }
Ejemplo n.º 7
0
        public void start(NavPath pathCfg, Vector3 rotAngle)
        {
            if (pathCfg != null)
            {
                _pathCfg = pathCfg;
            }

            if (rotAngle != Vector3.zero)
            {
                _pathRot = Quaternion.Euler(rotAngle);
            }

            if (_pathCfg == null)
            {
                return;
            }

            init();
            _startPos = _objTrans.localPosition;
            _lastPos  = _objTrans.localPosition;

            if (_pathCfg._time <= 0f)
            {
                _totalTimeFactor = 1f / 0.01f;
            }
            else
            {
                _totalTimeFactor = 1f / _pathCfg._time;
            }

            //设置初始朝向.
            Vector3 off = interpolate(0.05f);

            Vector3 targetPos = _startPos + off;

            // Vector3 dir = targetPos - _objTrans.localPosition;
            _objTrans.right = targetPos - _objTrans.localPosition;
            _isPathEnd      = false;
        }
Ejemplo n.º 8
0
 public void ApplyPath(NavPath _path)
 {
     _pathCfg = _path;
 }