Example #1
0
 void CommandHandler(object source, NetworkEventArgs n)
 {
     if (n.GetInfo() == NetworkMessageType.TankControl)
     {
         NetIncomingMessage msg = n.GetData();
         if (msg.PositionInBytes == 8)
             return;
         //only if this tank is actually meant...
         if (msg.ReadInt32(32) == Tank.NetworkId)
         {
             NetworkAction a = (NetworkAction) msg.ReadByte();
             switch (a)
             {
                 case NetworkAction.Left:
                     Tank.move_turn_left();
                     break;
                 case NetworkAction.Right:
                     Tank.move_turn_right();
                     break;
                 case NetworkAction.Forward:
                     Tank.move_forward();
                     break;
                 case NetworkAction.Reward:
                     Tank.move_backwards();
                     break;
                 case NetworkAction.Fire:
                     Tank.FireBullet();
                     break;
                 default:
                     throw new ArgumentOutOfRangeException();
             }
         }
     }
 }
Example #2
0
        void IncomingHandler(object source, NetworkEventArgs n)
        {
            switch (n.GetInfo())
            {
            case NetworkMessageType.WhichTankCanIControl:
                int id = n.GetData().ReadInt32(32);
                NetUtil.GetTankByNetworkId(Scene, id).AddDecorator(Decorators.ControlWasd);
                NetUtil.GetTankByNetworkId(Scene, id).AddDecorator(Decorators.ControlNetworkHook);
                AddNetworkControl(id);
                break;

            case NetworkMessageType.PauseControl:
                if (NetworkPauseControl.Play == (NetworkPauseControl)n.GetData().ReadByte())
                {
                    Scene.Resume();
                }
                else
                {
                    Scene.Pause();
                }
                break;
            }
        }
Example #3
0
        void CommandHandler(object source, NetworkEventArgs n)
        {
            if (n.GetInfo() == NetworkMessageType.TankControl)
            {
                NetIncomingMessage msg = n.GetData();
                if (msg.PositionInBytes == 8)
                {
                    return;
                }
                //only if this tank is actually meant...
                if (msg.ReadInt32(32) == Tank.NetworkId)
                {
                    NetworkAction a = (NetworkAction)msg.ReadByte();
                    switch (a)
                    {
                    case NetworkAction.Left:
                        Tank.move_turn_left();
                        break;

                    case NetworkAction.Right:
                        Tank.move_turn_right();
                        break;

                    case NetworkAction.Forward:
                        Tank.move_forward();
                        break;

                    case NetworkAction.Reward:
                        Tank.move_backwards();
                        break;

                    case NetworkAction.Fire:
                        Tank.FireBullet();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }
Example #4
0
 void IncomingHandler(object source, NetworkEventArgs n)
 {
     switch (n.GetInfo())
     {
         case NetworkMessageType.WhichTankCanIControl:
             int id = n.GetData().ReadInt32(32);
             NetUtil.GetTankByNetworkId(Scene, id).AddDecorator(Decorators.ControlWasd);
             NetUtil.GetTankByNetworkId(Scene, id).AddDecorator(Decorators.ControlNetworkHook);
             AddNetworkControl(id);
             break;
         case NetworkMessageType.PauseControl:
             if (NetworkPauseControl.Play == (NetworkPauseControl) n.GetData().ReadByte())
                 Scene.Resume();
             else
                 Scene.Pause();
             break;
     }
 }