Exemplo n.º 1
0
        public static void pushHeader(InputHdr iHdr)
        {
            QueueHdr hdr;
            hdr.type = HeaderType.Input;
            hdr.pHdr = iHdr;

            Instance.outQueue.Enqueue(hdr);
        }
Exemplo n.º 2
0
 // Used to push a new input to manager
 public static void pushInput(ref InputHdr hdr)
 {
     Instance.hdrQueue.Enqueue(hdr);
 }
Exemplo n.º 3
0
        private void processInput(ref InputHdr hdr)
        {
            Player p = PlayerManager.Instance().getPlayer(hdr.player);
            Ship ship = p.playerShip;
            PhysicsObj pObj = ship.physicsObj;

            switch (hdr.input)
            {
                case InputType.Forward:
                    Vector2 direction = new Vector2((float)(Math.Cos(pObj.body.GetAngle())), (float)(Math.Sin(pObj.body.GetAngle())));
                    direction.Normalize();
                    direction *= shipSpeed;
                    pObj.body.ApplyLinearImpulse(direction, pObj.body.GetWorldCenter());
                    break;
                case InputType.RotateLeft:
                    pObj.body.Rotation -= 0.1f;
                    break;
                case InputType.RotateRight:
                    pObj.body.Rotation += 0.1f;
                    break;
                case InputType.FireMissile:
                    p.createMissile();
                    break;
                case InputType.DropBomb:
                    if (p.state == PlayerState.alive)
                    {
                        GameObjManager.Instance().createBomb(hdr.player);
                    }
                    break;
                case InputType.Collision:
                    ColHdr cHdr = (ColHdr)hdr.colInfo;
                    GameObject go1 = GameObjManager.Instance().findFromIndex(cHdr.goID1);
                    GameObject go2 = GameObjManager.Instance().findFromIndex(cHdr.goID2);
                    if (go1 != null && go2 != null)
                    {
                        go1.Accept(go2, cHdr.pos);
                    }
                    break;
                default:
                    break;
            }
        }