Ejemplo n.º 1
0
 public override void OnChangeScene()
 {
     if (!HookFsm.CurrentState.GetType().IsAssignableFrom(typeof(Idle)))
     {
         _toEscapeFishes.Clear();
         foreach (var item in _waitForResultFishs)
         {
             if (item.Value.SHook != null)
             {
                 item.Value.SHook.fish = null;
             }
             //item.Value.SetEscapePath();
             item.Value.OnEscape();
             _level.fishMgr.AddEscaped(item.Value);
         }
         _waitForResultFishs.Clear();
         foreach (var item in _hookedFishes)
         {
             item.Value.SHook.fish = null;
             //item.Value.SetEscapePath();
             item.Value.OnEscape();
             _level.fishMgr.AddEscaped(item.Value);
         }
         _hookedFishes.Clear();
         float bakcPeriod = (Vector3.Distance(transform.position, _transHook.position) - _fOriginalDistance) / _fSpeedWhenChangeScene;
         _fBackf = 1 / bakcPeriod;
         _fBackI = 0;
         _vec3StartBackLocalPos = _transHook.localPosition;
         HookFsm.ChangeState <Back>();
         NetWorkManager.Instance.ntfBackScore();
     }
 }
Ejemplo n.º 2
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>();
            }
        }
Ejemplo n.º 3
0
 public override void LaunchHook(int nAngle)
 {
     if (!HookFsm.CurrentState.GetType().IsAssignableFrom(typeof(Idle)))
     {
         _transHook.localPosition = _vec3OriginalHookLocalPos;
         HookFsm.ChangeState <Idle>();
     }
     base.LaunchHook(nAngle);
 }
Ejemplo n.º 4
0
 public void ChangeHooks(int number)
 {
     if (!HookFsm.CurrentState.GetType().IsAssignableFrom(typeof(Idle)))
     {
         _transHook.localPosition = _vec3OriginalHookLocalPos;
         HookFsm.ChangeState <Idle>();
     }
     _changeHooks(number);
 }
Ejemplo n.º 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>();
                }
            }
        }