示例#1
0
        public override void NailDownFish(int fishId, bool bIsCatch, int nLottery)
        {
            if (_hookedFishes.ContainsKey(fishId))
            {
                int         objType      = _hookedFishes[fishId].ObjType;
                int         size         = InfoManager.Instance.GetFishInfo(objType).size;
                ResSizeInfo sizeInfo     = InfoManager.Instance.GetSizeInfo(size);
                float       struggleTime = sizeInfo.struggleTime;

                if (bIsCatch)
                {
                    //Ensure that certain fish has been caught.
                    // 26 or 27 means it is a chest
                    if (objType != 26 && objType != 27)
                    {
                        player.LastDeltaLottery += nLottery - player.Lottery;
                    }
                    else
                    {
                        _nChestLottery = nLottery - player.Lottery;
                    }
                    player.Lottery = nLottery;

                    if (struggleTime > 0)
                    {
                        //Recover normal speed of swimming
                        _toEscapeFishes[0].FishAnimator.speed = 1;
                        _toEscapeFishes.RemoveAt(0);
                    }
                }
                else
                {
                    if (struggleTime > 0)
                    {
                        //Recover normal speed of swimming
                        _toEscapeFishes[0].FishAnimator.speed = 1;

                        _hookedFishes.Remove(_toEscapeFishes[0].FishID);
                        //Decouple fish and hook
                        _toEscapeFishes[0].SHook.fish = null;
                        //_toEscapeFishes [0].SetEscapePath ();
                        _toEscapeFishes[0].OnEscape();
                        _level.fishMgr.AddEscaped(_toEscapeFishes[0]);

                        //Sound
                        Utils.PlaySound(AudioNames.FishEscape);
                        if (UnityEngine.Random.Range(0, 1f) > 0.5f)
                        {
                            Utils.PlaySound(AudioNames.FishSayBye);
                        }
                        _toEscapeFishes.RemoveAt(0);
                    }
                }

                HookFsm.ChangeState <Back>();
            }
        }
示例#2
0
        public override void CalculateBackPeriod()
        {
            float fRealBackPeriod = _fEmptyBackPeriod;

            foreach (var item in _hookedFishes)
            {
                int         size     = InfoManager.Instance.GetFishInfo(item.Value.ObjType).size;
                ResSizeInfo sizeInfo = InfoManager.Instance.GetSizeInfo(size);
                float       backTime = sizeInfo.backTime;
                if (fRealBackPeriod < backTime)
                {
                    fRealBackPeriod = backTime;
                }

                if (sizeInfo.struggleTime > 0)
                {
                    if (_toEscapeFishes.Count == 0)
                    {
                        _toEscapeFishes.Add(item.Value);
                    }
                    else
                    {
                        int i;
                        for (i = 0; i < _toEscapeFishes.Count; i++)
                        {
                            if (item.Value.EscapeTime < _toEscapeFishes[i].EscapeTime)
                            {
                                _toEscapeFishes.Insert(i, item.Value);
                                break;
                            }
                        }
                        if (i == _toEscapeFishes.Count)
                        {
                            _toEscapeFishes.Add(item.Value);
                        }
                    }
                }
                else
                {
                    NetWorkManager.Instance.reqFishResult(item.Value.FishID, true, result => { });
                }
            }
            _fBackf = 1 / fRealBackPeriod;
            _fBackI = 0;
            _vec3StartBackLocalPos      = _transHook.localPosition;
            _nCountOfApplyedTouchFishes = 0;
            foreach (var item in _waitForResultFishs)
            {
                _level.fishMgr.Add(item.Key, item.Value);
            }
            _waitForResultFishs.Clear();
        }
示例#3
0
        public virtual void CalculateBackPeriod()
        {
            float fRealBackPeriod = _fEmptyBackPeriod;

            foreach (var item in _hookedFishes)
            {
                int         size     = InfoManager.Instance.GetFishInfo(item.Value.ObjType).size;
                ResSizeInfo sizeInfo = InfoManager.Instance.GetSizeInfo(size);
                float       backTime = sizeInfo.backTime;
                if (fRealBackPeriod < backTime)
                {
                    fRealBackPeriod = backTime;
                }

                if (sizeInfo.struggleTime > 0)
                {
                    if (_toEscapeFishes.Count == 0)
                    {
                        _toEscapeFishes.Add(item.Value);
                    }
                    else
                    {
                        int i;
                        for (i = 0; i < _toEscapeFishes.Count; i++)
                        {
                            if (item.Value.EscapeTime < _toEscapeFishes[i].EscapeTime)
                            {
                                _toEscapeFishes.Insert(i, item.Value);
                                break;
                            }
                        }
                        if (i == _toEscapeFishes.Count)
                        {
                            _toEscapeFishes.Add(item.Value);
                        }
                    }
                }
            }
            _fBackf = 1 / fRealBackPeriod;
            _fBackI = 0;
            _vec3StartBackLocalPos = _transHook.localPosition;
        }
示例#4
0
        public override void OnEnterStruggle()
        {
            base.OnEnterStruggle();
            _bApplyedResult = false;
            _level.raiseHookStruggleEvent(true);
            //Calculate the time limit
            int         size     = InfoManager.Instance.GetFishInfo(_toEscapeFishes[0].ObjType).size;
            ResSizeInfo sizeInfo = InfoManager.Instance.GetSizeInfo(size);

            _fEndStruggleTime = _fHookPassTime + sizeInfo.struggleTime * 1000;
            //Randomly generate how many times does player need to tap.
            _nTapTimes = UnityEngine.Random.Range(_nFloorTapTimes, _nCeilTapTimes + 1);

            //Vibration!!
#if !UNITY_STANDALONE_WIN && !UNITY_EDITOR
            if (_level.bVibration)
            {
                Handheld.Vibrate();
            }
#endif

            _raiseEnterStruggleEvent();
        }
示例#5
0
        public override void NailDownFish(int fishId, bool bIsCatch, int nLottery)
        {
            //Judge if fish in _hookedFishes
            if (_hookedFishes.ContainsKey(fishId))
            {
                int         objType      = _hookedFishes[fishId].ObjType;
                int         size         = InfoManager.Instance.GetFishInfo(objType).size;
                ResSizeInfo sizeInfo     = InfoManager.Instance.GetSizeInfo(size);
                float       struggleTime = sizeInfo.struggleTime;
                if (bIsCatch)
                {
                    //Ensure that certain fish has been caught.
                    if (objType != 27)
                    {
                        player.LastDeltaLottery += nLottery - player.Lottery;
                    }
                    else
                    {
                        _nChestLottery = nLottery - player.Lottery;
                    }
                    player.Lottery = nLottery;
                    if (struggleTime > 0)
                    {
                        if (_toEscapeFishes.Count > 0 && _toEscapeFishes[0].FishID == fishId)
                        {
                            //Recover normal speed of swimming
                            _toEscapeFishes[0].FishAnimator.speed = 1;
                            _toEscapeFishes.RemoveAt(0);
                        }
                    }
                }
                else
                {
                    //Judge whether it is a fish that can struggle
                    if (struggleTime > 0)
                    {
                        if (_toEscapeFishes.Count > 0 && _toEscapeFishes[0].FishID == fishId)
                        {
                            //Recover normal speed of swimming
                            _toEscapeFishes[0].FishAnimator.speed = 1;
                            _hookedFishes.Remove(_toEscapeFishes[0].FishID);
                            //Decouple fish and hook
                            _toEscapeFishes[0].SHook.fish = null;
                            //_toEscapeFishes[0].SetEscapePath();
                            _toEscapeFishes[0].OnEscape();
                            _level.fishMgr.AddEscaped(_toEscapeFishes[0]);
                            //Sound
                            Utils.PlaySound(AudioNames.FishEscape);
                            if (Random.Range(0, 1f) > 0.5f)
                            {
                                Utils.PlaySound(AudioNames.FishSayBye);
                            }
                            _toEscapeFishes.RemoveAt(0);
                        }
                    }
                }

                if (HookFsm.CurrentState.GetType().IsAssignableFrom(typeof(Struggle)))
                {
                    HookFsm.ChangeState <Back>();
                }
            }
        }