コード例 #1
0
ファイル: OHook.cs プロジェクト: swiftliang/NewGame
        //Remember to reset rotation and position
        public override void OnEnter(int enterTime, Player player, AllStuffNeeded allStuff)
        {
            base.OnEnter(enterTime, player, allStuff);
            _transHook.localPosition = _vec3OriginalHookLocalPos;
            int i;

            for (i = 0; i < 5; i++)
            {
                if (i == 2)
                {
                    _allHooks[i].transHookTopEnd.SetActive(true);
                }
                else
                {
                    _allHooks[i].transHookTopEnd.SetActive(false);
                }
            }
        }
コード例 #2
0
        public virtual void OnEnter(int enterTime, Player player, AllStuffNeeded allStuff)
        {
            //active hook list
            _activatedHooks = new List <SingleHook>();
            _activatedHooks.Add(_allHooks[2]);

            //hook pass time
            _fP            = _level.PassTime - enterTime;
            _fHookPassTime = 0;

            //player
            this.player = player;

            //allstuff
            this.transFakePoleEnd = allStuff.transFakePoleEnd;
            this.animatorCh       = allStuff.animatorCh;
            this._vec3ChestPos    = allStuff.vec3ChestPos;

            RaiseLotteryChangeEvent();
            HookFsm.ChangeState <Idle>();
        }
コード例 #3
0
ファイル: SceneMgr.cs プロジェクト: swiftliang/NewGame
        private void _loadAllStuff()
        {
            AllStuffNeeded leftStuff = new AllStuffNeeded();

            leftStuff.gmObjRealPoleEnd = leftRealPoleEnd;
            leftStuff.gmObjRealPoleEnd.SetActive(false);
            leftStuff.gmObjBoat = leftBoat;
            leftStuff.gmObjBoat.SetActive(false);
            leftStuff.transFakePoleEnd = leftFakePoleEnd;
            leftStuff.animatorCh       = leftAnimatorCh;
            leftStuff.vec3ChestPos     = transLeftChestPos.position;
            hookPosAllStuffMap.Add(HookPos.left, leftStuff);
            AllStuffNeeded rightStuff = new AllStuffNeeded();

            rightStuff.gmObjRealPoleEnd = rightRealPoleEnd;
            rightStuff.gmObjRealPoleEnd.SetActive(false);
            rightStuff.gmObjBoat = rightBoat;
            rightStuff.gmObjBoat.SetActive(false);
            rightStuff.transFakePoleEnd = rightFakePoleEnd;
            rightStuff.animatorCh       = rightAnimatorCh;
            rightStuff.vec3ChestPos     = transRightChestPos.position;
            hookPosAllStuffMap.Add(HookPos.right, rightStuff);
        }
コード例 #4
0
        //1. get hook gameObject
        //2. add component
        //3. activate
        //4. Init
        //5. OnEnter
        //6. Add it into Map
        public void NewEnter(Message msg)
        {
            MessageSycHook allhookInfo = JsonReader.Deserialize <MessageSycHook>(msg.rawString);
            int            iCount      = allhookInfo.playerList.Count;

            if (iCount == 1)
            {
                HookInfo info = allhookInfo.playerList[0];
                this.PassTime = info.enterTime;
                HookPos        hookPos  = (HookPos)Enum.Parse(typeof(HookPos), info.chairId);
                AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos];
                hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>();

                allStuff.gmObjBoat.SetActive(true);
                FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>();
                floatEffect.Init();
                floatEffect.StartEffect();

                hook.gameObject.SetActive(true);
                hook.Init(hookPos);
                hook.OnEnter(info.enterTime, _player, allStuff);
                uIDHookMap.Add(info.uid, hook);

                _raisePlayerInitCompleteEvent(hook.hookPos);
                _raisePlayerChangeEvent(hook.hookPos, true);
                _raiseScoreChangeEvent(hook.hookPos, _player.Score);
                raiseLotteryChangeEvent(hook.hookPos, _player.Lottery);
                raiseHookPowerEvent(1);
            }
            else if (iCount == 2)
            {
                this.PassTime = Mathf.Max(allhookInfo.playerList[0].enterTime, allhookInfo.playerList[1].enterTime);
                for (int i = 0; i < iCount; i++)
                {
                    HookInfo info = allhookInfo.playerList[i];
                    if (info.uid == Game.Instance.player.UID)
                    {
                        if (hook == null)
                        {
                            this.PassTime = info.enterTime;
                            HookPos        hookPos  = (HookPos)Enum.Parse(typeof(HookPos), info.chairId);
                            AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos];
                            hook = allStuff.gmObjRealPoleEnd.AddComponent <Hook>();

                            allStuff.gmObjBoat.SetActive(true);
                            FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>();
                            floatEffect.Init();
                            floatEffect.StartEffect();

                            hook.gameObject.SetActive(true);
                            hook.Init(hookPos);
                            hook.OnEnter(info.enterTime, _player, allStuff);
                            uIDHookMap.Add(info.uid, hook);

                            _raisePlayerInitCompleteEvent(hook.hookPos);
                            _raisePlayerChangeEvent(hook.hookPos, true);
                            _raiseScoreChangeEvent(hook.hookPos, _player.Score);
                            raiseLotteryChangeEvent(hook.hookPos, _player.Lottery);
                            raiseHookPowerEvent(1);
                        }
                    }
                    else if (info.uid != Game.Instance.player.UID)
                    {
                        HookPos        hookPos  = (HookPos)Enum.Parse(typeof(HookPos), info.chairId);
                        AllStuffNeeded allStuff = SceneMgr.Instance.hookPosAllStuffMap[hookPos];
                        if (oHook == null)
                        {
                            oHook = allStuff.gmObjRealPoleEnd.AddComponent <OHook>();
                            //Assume that player can't change position in level
                            oHook.Init(hookPos);

                            FloatEffect floatEffect = allStuff.gmObjBoat.AddComponent <FloatEffect>();
                            floatEffect.Init();
                            floatEffect.StartEffect();
                        }
                        allStuff.gmObjBoat.SetActive(true);
                        oHook.gameObject.SetActive(true);
                        uIDHookMap.Add(info.uid, oHook);

                        //Init oPlayer(no definition, just intialize it)
                        _oPlayer.UID     = info.uid;
                        _oPlayer.Score   = info.score;
                        _oPlayer.Lottery = info.lottery;
                        uIDPlayerMap.Add(info.uid, _oPlayer);

                        oHook.OnEnter(info.enterTime, _oPlayer, allStuff);


                        oHook.ChangeHooks(info.hook);
                        _raisePlayerChangeEvent(oHook.hookPos, true);
                        _raiseScoreChangeEvent(oHook.hookPos, _oPlayer.Score);
                        raiseLotteryChangeEvent(oHook.hookPos, _oPlayer.Lottery);
                    }
                }
            }
            else
            {
                DebugLogger.LogWarning(eLogType.LT_LOGIC, iCount + " hooks, out of bound!");
            }
        }