Beispiel #1
0
        public override void onMessage(Movable obj, StateMsg <Movable> msg)
        {
            MovableMsg type = (MovableMsg)msg.type;

            switch (type)
            {
            case MovableMsg.breakKinematic:
                obj.getSM().changeState(NormalState.Instance());
                break;

            case MovableMsg.moveLeft:
                obj.doMoveLeft();
                break;

            case MovableMsg.moveRight:
                obj.doMoveRight();
                break;

            case MovableMsg.moveUp:
                obj.doMoveUp();
                break;

            case MovableMsg.stopMove:
                obj.doStopMove();
                break;

            case MovableMsg.wait:
                obj.doWait();
                break;
            }
        }
Beispiel #2
0
        public override void onMessage(Movable obj, StateMsg <Movable> msg)
        {
            MovableMsg type = (MovableMsg)msg.type;

            switch (type)
            {
            case MovableMsg.onLabber:
                obj.getSM().changeState(OnLabberState.Instance());
                break;

            case MovableMsg.toNormal:
                obj.getSM().changeState(NormalState.Instance());
                break;

            case MovableMsg.moveDown:    //降落

                if (!obj.downTileIsBlock())
                {
                    obj.setFallTargetY(true);
                    obj.getSM().changeState(FallToTargetState.Instance());
                }

                break;

            case MovableMsg.moveLeft:
                obj.doMoveLeft();
                obj.adjustWhenMoveOnRope();
                break;

            case MovableMsg.moveRight:
                obj.doMoveRight();
                obj.adjustWhenMoveOnRope();
                break;

            case MovableMsg.stopMove:
                obj.doStopMove();
                break;

            case MovableMsg.wait:
                obj.doWait();
                break;

            case MovableMsg.moveUp:
                //通知發訊者此動作無效
                if (msg.sender != null)
                {
                    //從繩子移到JumpPoint會發動fall to rope,這時目標就停留在JumpPoint
                    //
                    //--J
                    //  --
                    if (Movable.Debug_do_moveUp)
                    {
                        obj.printDebugMsg("[注意!]do MoveUp on rope");
                    }
                    AIMoveController ai = msg.sender.myAI;
                    ai.getSM().handleMessage(new StateMsg <AIMoveController>((int)AIMsg.reFindPath, null));
                }
                break;
            }
        }
Beispiel #3
0
        public override void onMessage(Movable obj, StateMsg <Movable> msg)
        {
            MovableMsg type = (MovableMsg)msg.type;

            switch (type)
            {
            case MovableMsg.jumpFromRope:
                obj.getSM().changeState(OnAirState.Instance());
                break;

            case MovableMsg.fallToAlignRopeFinish:
                obj.getSM().changeState(OnRopeState.Instance());
                break;
            }
        }
Beispiel #4
0
        public override void onMessage(Movable obj, StateMsg <Movable> msg)
        {
            MovableMsg type = (MovableMsg)msg.type;

            switch (type)
            {
            case MovableMsg.onRope:
                obj.getSM().changeState(OnRopeState.Instance());
                break;

            case MovableMsg.onLabber:
                obj.getSM().changeState(OnLabberState.Instance());
                break;

            case MovableMsg.landing:
                obj.getSM().changeState(NormalState.Instance());
                break;

            case MovableMsg.toKinematic:
                obj.getSM().changeState(KinematicState.Instance());
                break;
            }
        }
Beispiel #5
0
 public DefferedMsg(MovableMsg pType, Vector2 pDiff)
 {
     type = pType;
     diff = pDiff;
 }
Beispiel #6
0
        public override void onMessage(Movable obj, StateMsg <Movable> msg)
        {
            MovableMsg type = (MovableMsg)msg.type;

            switch (type)
            {
            case MovableMsg.onLabber:
                obj.getSM().changeState(OnLabberState.Instance());
                break;

            case MovableMsg.onRope:
                obj.getSM().changeState(OnRopeState.Instance());
                break;

            case MovableMsg.onAir:
                obj.getSM().changeState(OnAirState.Instance());
                break;

            case MovableMsg.fallToAlignRope:    //站在rope上時
                obj.setFallTargetY(false);
                obj.getSM().changeState(FallToTargetState.Instance());
                break;

            case MovableMsg.moveLeft:
                obj.doMoveLeft();
                break;

            case MovableMsg.moveRight:
                obj.doMoveRight();
                break;

            case MovableMsg.stopMove:
                obj.doStopMove();
                break;

            case MovableMsg.wait:
                obj.doWait();
                break;

            case MovableMsg.moveDown:
                if (!obj.downTileIsBlock())
                {
                    obj.doMoveDown();
                }
                break;

            case MovableMsg.toKinematic:
                obj.getSM().changeState(KinematicState.Instance());
                break;

            case MovableMsg.moveUp:
                //通知發訊者此動作無效
                if (msg.sender != null)
                {
                    //解決[在梯子卡點]的問題
                    //從H往下走,但因為有其他AI檔在下面,所以進入stop;之後reFindPath,y就會低於pathNode
                    //  O
                    //口H口口
                    obj.adjustY();

                    //這是為了解決從高處落下,MoveTargetPoint還在上面的問題(在normal狀態如果執行moveUp就觸發reFindPath)
                    //   .
                    //    口口
                    //   .
                    //口口口口

                    //降落在Brick、Stone、ladder時觸發
                    if (Movable.Debug_do_moveUp)
                    {
                        obj.printDebugMsg("[注意!]do MoveUp on Normal");
                    }
                    AIMoveController ai = msg.sender.myAI;
                    ai.getSM().handleMessage(new StateMsg <AIMoveController>((int)AIMsg.reFindPath, null));
                }
                break;
            }
        }