예제 #1
0
 // 接收到创建一条鱼的消息.
 public void AddFishInCreatList(FishParam _fp)
 {
     if (CheckIfFish2CreateIsEmpty(_fp))
     {
         return;
     }
     fish2Create.Add(_fp);
 }
예제 #2
0
        // 通过名字判断这条鱼是否在鱼池中, 有这条鱼存在, 才可以创建.
        private bool CheckIfFish2CreateIsEmpty(FishParam _fp)
        {
            int _fishCount = fish.Count;

            for (int i = 0; i < _fishCount; i++)
            {
                if (fish[i].fish.name == _fp.name)
                {
                    _fp.fishPool = i;
                    return(false);
                }
            }
            return(true);
        }
예제 #3
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);
        }
예제 #4
0
        private void CreateFishAndShadow(FishParam _fp)
        {
            // 检测是否需要旋转屏幕,如果需要,则鱼的生成位置也需要更换并且旋转
            if (CanonCtrl.Instance.turn_screen == true && CanonCtrl.Instance.turn_screen_on_of)
            {
                FishCache = FishCacheTurn;
            }
            else
            {
                FishCache = FishCacheNoTurn;
            }

            int _fishPool = _fp.fishPool;

            // fish.
            Transform _fish = Factory.Create(fish[_fishPool].fish, Vector3.zero, Quaternion.identity);

            _fish.parent        = FishCache;
            _fish.localPosition = Vector3.zero;
            _fish.rotation      = Quaternion.identity;
            _fish.localScale    = Vector3.zero;
            SingleFish _sf = _fish.GetComponent <SingleFish>();

            // shadow.
            Transform _shadow = Factory.Create(fish[_fishPool].shadow, Vector3.zero, Quaternion.identity);

            _shadow.parent        = FishCache;
            _shadow.localPosition = Vector3.zero;
            _shadow.localScale    = Vector3.zero;
            _shadow.rotation      = Quaternion.identity;
            SingleShadow _ss = _shadow.GetComponent <SingleShadow>();

            // 给fish和shadow的路径赋时间.
            _fp.navPath._time = _fp.pathTimeLength;
            _sf.InitFishParam(_fp.navPath, _fp.serverID, _ss, _fishPool);
            _ss.InitShadowParam(_fp.navPath);

            // 缓存该鱼.
            fishHaveCreated.Add(_sf);
            shadowHaveCreated.Add(_ss);
        }