Exemple #1
0
        private Vector3 fishLocalPosition;                      ///记录鱼的当前位置


        public void StartCreateParticle(SingleFish _sf, List <EffParam> _deadEffList, Transform _effCache)
        {
            fish = _sf.transform;
            fishLocalPosition = fish.localPosition;
            deadEffList       = _deadEffList;
            effCache          = _effCache;

            createdNum   = 0;
            startPlayPar = true;

            deadEffListCount = deadEffList.Count;

            for (int i = 0; i < deadEffListCount; i++)
            {
                deadEffList[i].haveCreatedPar     = false;
                deadEffList[i].targetTime2PlayEff = Time.time + deadEffList[i].time2CreateEff;

                /*
                 * deadEffList[i].haveCreatedAudio = false;
                 * if(deadEffList[i].audioLoopUntilRecycle)
                 * {
                 *      deadEffList[i].fishDeadAudioTimeLength	= Time.time + _sf.deadTimeLength;
                 * }
                 */
            }
        }
Exemple #2
0
        void OnTriggerEnter2D(Collider2D _collider)
        {
            SingleFish _sf = _collider.GetComponent <SingleFish>();

            // 9 是鱼在场景中所在的层(layers).
            if (_collider.gameObject.layer == 9)
            {
                if (_sf != null && _sf != blackHall && _sf.fishType != BaseFish.FishType.blackHall && _sf.fishType != BaseFish.FishType.quanping)
                {
                    // 如果黑洞死了.
                    if (!blackHall.dead)
                    {
                        // can be absorbed. wont absorb deading fish(including the fish killed by quanping).
                        if (_sf.beAbsorbed && _sf.cur_Collider.enabled)
                        {
                            _sf.AbosorbByBlackHall(blackHall.dead, transform, blackHall.canonID);
                        }
                    }
                    else
                    {
                        // 如果黑洞已经吸够分数了,开始回收这个黑洞, 就不要吸鱼了.
                        if (blackHall.specialFishDeadState != BaseFish.SpecialFishDeadState.recycle)
                        {
                            _sf.AbosorbByBlackHall(blackHall.dead, transform, blackHall.canonID);

                            blackHall.bh_AbosorbOneFish(blackHall.power, blackHall.blackHallAbsorbMulti, _sf.transform.position);
                        }
                    }
                }
            }
        }
        // 创建一网打尽的线.
        public static void Show_YWDJ_Lines(SingleFish _sf, Transform _ywdjLine, int _canonID, int _killFishPool, int _bulletCost, Vector3 _ywdjFishPos, float _timeLength)
        {
            if (_ywdjLine == null)
            {
                return;
            }

            int        maxCoinNum     = 0;
            SingleFish maxCoinNumFish = null;

            SingleFish [] sfArray = FishCtrl.Instance.fishHaveCreated.ToArray();
            for (int i = 0; i < sfArray.Length; i++)
            {
                if (sfArray[i] != null && sfArray[i] != _sf && sfArray[i].fishPool == _killFishPool && !sfArray[i].dead && Utility.CheckIfPosInViewport(sfArray[i].transform.position))
                {
                    // 创建线.
                    Transform _item = Factory.Create(_ywdjLine, Vector3.zero, Quaternion.identity);

                    //线会自动回收.
                    AutoRecycle _ar = _item.gameObject.GetComponent <AutoRecycle>();
                    if (_ar == null)
                    {
                        _ar = _item.gameObject.AddComponent <AutoRecycle>();
                    }
                    _ar.SetLifeTime(_timeLength);


                    _item.parent = LockCtrl.Instance.transform;
                    LineRenderer _lineRend = _item.GetComponent <LineRenderer>();
//					Vector3 _pos0_InLockCam = LockCtrl.Instance.uiCamPos_to_LockCamPos(_ywdjFishPos);
//					Vector3 _pos1_InLockCam = LockCtrl.Instance.uiCamPos_to_LockCamPos(sfArray[i].transform.position);
                    Vector3 temp = _ywdjFishPos;
                    temp.z = 0.1f;
                    Vector3 _pos0_InLockCam = temp;
                    Vector3 _pos1_InLockCam = sfArray[i].transform.position;

                    _lineRend.SetPosition(0, _pos1_InLockCam);
                    _lineRend.SetPosition(1, _pos0_InLockCam);

                    // play fish dead eff.
                    int _npcType = -1;
                    sfArray[i].KillByBullet(_canonID, -1, -1, _npcType);

                    if (sfArray[i].coinNum > maxCoinNum)
                    {
                        maxCoinNum     = sfArray[i].coinNum;
                        maxCoinNumFish = sfArray[i];
                    }

                    // show value eff.
                    NumCtrl.Instance.CreateFishDeadNum(_bulletCost * sfArray[i].multi, sfArray[i].transform.position, Quaternion.identity);
                }
            }

            if (maxCoinNumFish != null)
            {
                maxCoinNumFish.PlayCoinAudio(true);
            }
        }
Exemple #4
0
 void Awake()
 {
     rigid2D = GetComponent <Rigidbody2D>();
     if (rigid2D != null)
     {
         rigid2D.gravityScale = 0f;
         rigid2D.isKinematic  = true;
     }
     blackHall = transform.parent.GetComponent <SingleFish>();
 }
Exemple #5
0
        // 处理一条鱼死亡后要播放的特效.
        public static void CreatedFishDeadEffCtrlItem(SingleFish _sf, List <EffParam> _effList)
        {
            GameObject _effCtrlItem = new GameObject();

            _effCtrlItem.name             = "EffCtrlItem";
            _effCtrlItem.transform.parent = CreateCache();
            FishDeadEffectItemCtrl _eff = _effCtrlItem.AddComponent <FishDeadEffectItemCtrl>();

            _eff.StartCreateParticle(_sf, _effList, CreateCache());
        }
Exemple #6
0
 // 通过 serverID 获取 fish.
 public SingleFish HaveSingleFishInList(int _serverID)
 {
     for (int i = 0; i < fishHaveCreated.Count; i++)
     {
         SingleFish sf = fishHaveCreated[i];
         if (_serverID == sf.fishServerID)
         {
             return(sf);
         }
     }
     return(null);
 }
        // 子弹初始化.
        public void Init(int _canonID, int _bulletCost, int _bulletPower, Transform _lockedFish, int _robotBulletMonitorCanonID)
        {
            canonID = _canonID;
            if (_lockedFish != null)
            {
                lockSingleFish = _lockedFish.GetComponent <SingleFish>();
            }

            bulletPower = _bulletPower;
            bulletCost  = _bulletCost;
            robotBulletMonitorCanonID = _robotBulletMonitorCanonID;
        }
        // 停止锁定.
        public void StopLock()
        {
            startLock = false;

            lockFish       = null;
            lockFishScript = null;

            lineRend.enabled = false;
            number.GetComponent <UISprite>().enabled = false;

            if (audios.clip != null)
            {
                audios.Stop();
            }
        }
        public static void Record_quanPing_KillFish(SingleFish _mySelf)
        {
            SingleFish [] sfArray = FishCtrl.Instance.fishHaveCreated.ToArray();
            for (int i = 0; i < sfArray.Length; i++)
            {
                if (sfArray[i].fishType == BaseFish.FishType.normal)
                {
                    if (!_mySelf.killNorml)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.ywdj)
                {
                    if (!_mySelf.killYWDJ)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.quanping)
                {
                    if (!_mySelf.killQuanPing)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.blackHall)
                {
                    if (!_mySelf.killBlackHall)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.likui)
                {
                    if (!_mySelf.killLikui)
                    {
                        continue;
                    }
                }

                if (sfArray[i] != null && sfArray[i] != _mySelf && !sfArray[i].dead)
                {
                    sfArray[i].KillByQuanping();
                    quanPing_KillFish_List.Add(sfArray[i]);
                }
            }
        }
Exemple #10
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);
        }
        // 2-1 不是普通鱼,是缓存击杀,那么把这条缓存击杀的鱼添加到 list 中.
        public static void NPC_Kill_AddCacheInList(int _canonID, int _multi, int _power, int _serverID, int _npcType)
        {
            SingleFish _sf      = FishCtrl.Instance.HaveSingleFishInList(_serverID);
            Vector3    _fishPos = Vector3.zero;

            // 如果这条鱼还在.
            if (_sf != null)
            {
                _fishPos = _sf.transform.position;
                _sf.KillByBullet(_canonID, _multi, _power, _npcType);
            }

            CacheFishParam _cache = new CacheFishParam();

            // 记录这条缓存的鱼.
            _cache.sf        = _sf;
            _cache.pos       = _fishPos;
            _cache.value     = _multi * _power;
            _cache._serverID = _serverID;
            cacheFish.Add(_cache);
        }
        // 显示锁定线.
        public void ShowLockRend(Transform _lockFish)
        {
            // 标志锁定状态.
            startLock = true;

            // 获取锁定的鱼.
            lockFish       = _lockFish;
            lockFishScript = lockFish.GetComponent <SingleFish>();

            // 显示锁定线.
            lineRend.enabled = true;

            // 显示数字.
            number.GetComponent <UISprite>().enabled = true;

            // 播放音效.
            if (audios.clip != null)
            {
                audios.Play();
            }
        }
Exemple #13
0
        // 服务器通知机器人需要发泡.
        public void S_C_RobotGunFireNotify(int _serverID)
        {
            // 是否不许发泡.
            if (!allowFire)
            {
                return;
            }
            // 是否在切换场景.
            if (WaveCtrl.Instance.changingWave)
            {
                return;
            }

            SingleFish _sf      = FishCtrl.Instance.GetRobotFireFish(_serverID);
            Vector3    _fishPos = Vector3.zero;

            if (_sf == null)
            {
                // 鱼不见了,那就只能打中间了.
                _fishPos = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
            }
            else
            {
                // 鱼还在就获取位置.
                _fishPos = _sf.transform.localPosition;
            }

            // 一下是模拟并获取炮管要打这条鱼的角度.
            Vector3 _robot2FireDir = UICam.ScreenToWorldPoint(_fishPos) - canonBarrelTrans_robot.position;

            _robot2FireDir = new Vector3(_robot2FireDir.x, _robot2FireDir.y, 0f);
            canonBarrelTrans_robot.rotation = Quaternion.LookRotation(Vector3.forward, _robot2FireDir);

            // 转换服务器认识的发泡位置和角度.
            Vector2 _firePos_robot = Utility.C_S_TransformFirePos(bulletShowUpPos_robot.position);
            float   euelrZ_robot   = Utility.C_S_TranformFireEulerZ(canonBarrelTrans_robot.localEulerAngles.z);

            MessageHandler.Instance.C_S_RobotGunFire(canonID, euelrZ_robot, _firePos_robot, _serverID, curBulletParam.bulletCost, TimeCtrl.Instance.serverTime);
        }
        // 1 普通 npc kill.
        public static void NPC_Kill(int _canonID, int _multi, int _power, int _serverID, int _npcType)
        {
            int         _value       = _multi * _power;
            SingleCanon _singleCanon = CanonCtrl.Instance.singleCanonList[_canonID];
            SingleFish  _sf          = FishCtrl.Instance.HaveSingleFishInList(_serverID);

            // 如果这条鱼不在了,直接给分.
            if (_sf == null)
            {
                _singleCanon.AddValueList(_value, 0);
                return;
            }

            // 如果还在,那就跳到子弹击中的逻辑.
            _sf.KillByBullet(_canonID, _multi, _power, _npcType);

            // 如果是全屏炸弹,就不要显示数字,bubble, 金币柱.
            if (_sf.fishType == BaseFish.FishType.quanping)
            {
                return;
            }

            // 鱼死亡后在身上出现的数字.
            NumCtrl.Instance.CreateFishDeadNum(_value, _sf.transform.position, Quaternion.identity);

            // bubble.
            NumCtrl.Instance.AdddBubble2List(_multi, _value, _singleCanon.bubbleShowUpPos.position, Quaternion.identity, _singleCanon.upsideDown);

            // 金币柱子.
            if (TotalCylinderCtrl.Instance.showCylider)
            {
                TotalCylinderCtrl.Instance.singleCylinderList[_canonID].Add2Need2CreateList(_multi, _value, _singleCanon.cylinderShowUpPos.position);
            }

            // 给分.
            _singleCanon.AddValueList(_value, 0f);
        }
Exemple #15
0
 void OnEnable()
 {
     lockSingleFish            = null;
     robotBulletMonitorCanonID = -1;
     curDir = dir.none;
 }
Exemple #16
0
        // unity 自带的碰撞检测方法.
        void OnTriggerEnter2D(Collider2D _collider)
        {
            // 如果有锁定的鱼 && 锁定的这条鱼还在锁定状态.         have a locking fish, the locking fish is not dead or move out viewport yet.
            if (lockSingleFish != null && lockSingleFish.locking)
            {
                // 如果碰到的鱼不是锁定的鱼.
                if (lockSingleFish != _collider.GetComponent <SingleFish>())
                {
                    return;
                }
            }
            // 避免子弹互相碰撞
            if (_collider.GetComponent <SingleFish>() == null)
            {
                return;
            }

            // 创建网格.
            if (CanonCtrl.Instance.singleCanonList[canonID] != null)
            {
                CanonCtrl.Instance.singleCanonList[canonID].CreateOneNet(curTrans.position, curTrans.rotation);
            }

            SingleFish _sf = _collider.GetComponent <SingleFish>();

            _sf.ChangeColor();

            // 1, no real canon bullet(fake canon, robot canon)
            // 2, not robot Bullet(fake canon, real canon)
            // so it is a fake canon.

            // 1, 如果不是真实的玩家 && 也不是机器人.(其他玩家).
            if (canonID != CanonCtrl.Instance.realCanonID && robotBulletMonitorCanonID < 0)
            {
                // 那么仅仅只是回收子弹就可以了.
                Factory.Recycle(curTrans);
                return;
            }
            else
            {
                // 鱼还没死.
                if (!_sf.dead)
                {
                    // 2, 如果是机器人发出的子弹.
                    if (robotBulletMonitorCanonID >= 0)
                    {
                        MessageHandler.Instance.C_S_RobotBulletAttack(canonID, _sf.fishServerID, bulletCost, bulletPower, _sf.multi);
                    }
                    // 3, 如果是真实玩家发出的子弹.
                    else
                    {
                        MessageHandler.Instance.C_S_BulletAttack(_sf.fishServerID, bulletCost, bulletPower, _sf.multi);
                        // 玩家在场景中的子弹数目减少一个.
                        CanonCtrl.Instance.singleCanonList[canonID].RealGunAddBulletNumInScene(-1);
                    }

                    // 告诉这条鱼,打中它的子弹的bulletcost为多少.
                    _sf.bulletCost = bulletCost;
                }

                // 回收子弹.
                Factory.Recycle(curTrans);
            }
        }
Exemple #17
0
 // 回收fish的时候(打死或者游完路径),就从缓存 list 中 remove 该条鱼和它的影子.
 public void RemoveFishAndShadowInList(SingleFish _sf)
 {
     fishHaveCreated.Remove(_sf);
     shadowHaveCreated.Remove(_sf.singleShadow);
 }
Exemple #18
0
        public Transform GetALockFish()
        {
            int _fishNum = fishHaveCreated.Count;

            if (fishHaveCreated.Count == 0)
            {
                return(null);
            }
            else if (fishHaveCreated.Count == 1)
            {
                //判断鱼的倍率是否满足锁定条件
                if (fishHaveCreated[0].multi >= CanonCtrl.Instance.minLockMulti)
                {
                    return(fishHaveCreated[0].transform);;
                }
                else
                {
                    return(null);
                }
            }

            // 获取可以锁定的鱼.
            List <SingleFish> usefulFishList = new List <SingleFish>();

            for (int i = 0; i < _fishNum; i++)
            {
                // 鱼存是否为空					鱼碰撞体没有关闭(1,鱼没死, 2,没有正在被全屏炸弹炸死中)					鱼是否在屏幕内.
                if (fishHaveCreated[i] != null && fishHaveCreated[i].cur_Collider.enabled && Utility.CheckIfPosInViewport(fishHaveCreated[i].transform.position))
                {
                    //判断鱼的倍率是否满足锁定条件
                    if (fishHaveCreated[i].multi >= CanonCtrl.Instance.minLockMulti)
                    {
                        usefulFishList.Add(fishHaveCreated[i]);
                    }
//					continue;
                }
            }

            _fishNum = usefulFishList.Count;

            //如果获取到的满足条件的鱼为空,返回
            if (_fishNum == 0)
            {
                return(null);
            }

            //将可以锁定的鱼排序
            for (int i = 0; i < _fishNum - 1; i++)
            {
                for (int j = 0; j < _fishNum - 1 - i; j++)
                {
                    if (usefulFishList[j].multi < usefulFishList[j + 1].multi)
                    {
                        SingleFish temp = usefulFishList[j];
                        usefulFishList[j]     = usefulFishList[j + 1];
                        usefulFishList[j + 1] = temp;
                    }
                }
            }

            if (lastLockIndex > _fishNum - 1)
            {
                lastLockIndex = 0;
            }

            if (usefulFishList[lastLockIndex] != lastLockFish)
            {
                lastLockFish = usefulFishList[lastLockIndex];

                lastLockIndex++;
                //如果连续切换4个后,返回第一个
                if (lastLockIndex >= 4)
                {
                    lastLockIndex = 0;
                }
                return(lastLockFish.transform);
            }
            else
            {
                lastLockIndex++;
                if (_fishNum >= lastLockIndex)
                {
                    lastLockIndex = 0;
                }
                return(usefulFishList[lastLockIndex].transform);
            }
        }
        // 告诉这些鱼,它们被全屏炸弹杀死了.
        public static void QuanPing_Kill_Fish(SingleFish _mySelf, int _canonID, int _bulletCost)
        {
            int        maxCoinNum     = 0;
            SingleFish maxCoinNumFish = null;

            SingleFish [] sfArray = quanPing_KillFish_List.ToArray();
            for (int i = 0; i < sfArray.Length; i++)
            {
                if (sfArray[i].fishType == BaseFish.FishType.normal)
                {
                    if (!_mySelf.killNorml)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.ywdj)
                {
                    if (!_mySelf.killYWDJ)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.quanping)
                {
                    if (!_mySelf.killQuanPing)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.blackHall)
                {
                    if (!_mySelf.killBlackHall)
                    {
                        continue;
                    }
                }
                else if (sfArray[i].fishType == BaseFish.FishType.likui)
                {
                    if (!_mySelf.killLikui)
                    {
                        continue;
                    }
                }

                // no recycle by the wave.
                // if(sfArray[i]!=null && !sfArray[i].dead && sfArray[i].gameObject.activeSelf)
                if (sfArray[i] != null && !sfArray[i].dead && sfArray[i].gameObject.activeSelf)
                {
                    // play fish dead eff.
                    int _npcType = -1;
                    sfArray[i].KillByBullet(_canonID, -1, -1, _npcType);
                    sfArray[i].PlayCoinAudio(false);

                    if (sfArray[i].coinNum > maxCoinNum)
                    {
                        maxCoinNum     = sfArray[i].coinNum;
                        maxCoinNumFish = sfArray[i];
                    }

                    // show value eff.
                    NumCtrl.Instance.CreateFishDeadNum(_bulletCost * sfArray[i].multi, sfArray[i].transform.position, Quaternion.identity);
                }
            }

            if (maxCoinNumFish != null)
            {
                maxCoinNumFish.PlayCoinAudio(true);
            }

            quanPing_KillFish_List.Clear();
        }
 void OnEnable()
 {
     _target = target as SingleFish;
 }