Пример #1
0
        public void MoveObject(LaneType from, LaneType to, GameObject obj)
        {
            if (gameObjects.ContainsKey(from) && gameObjects[from].Contains(obj))
            {
                gameObjects[from].Remove(obj);
            }

            AddObjectToLane(to, obj);
        }
Пример #2
0
        private void HandleMouse()
        {
            MouseState ms = Mouse.GetState();

            GameObject go = new GameObject();
            go.Type = currentType;
            go.Texture = textures[go.Type];
            go.Rect = new Rectangle(ms.X, LanePositionY[3], go.Texture.Width, go.Texture.Height);
            go.Lane = LaneType.F_F;

            scenes[currentScene].AddObjectToLane(go.Lane, go);
        }
Пример #3
0
        public void AddObjectToLane(LaneType lane, GameObject obj)
        {
            List<GameObject> objs = null;

            if (gameObjects.ContainsKey(lane))
            {
                objs = gameObjects[lane];
            }
            else
            {
                objs = new List<GameObject>();
                gameObjects.Add(lane, objs);
            }

            objs.Add(obj);
        }
Пример #4
0
        protected override void LoadContent()
        {
            int i = 0;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            backGround = new GameObject();
            backGround.Texture = this.Content.Load<Texture2D>("black");
            backGround.Rect = new Rectangle((this.graphics.PreferredBackBufferWidth - backGround.Texture.Width) / 2, TOP_OFFSET,
                backGround.Texture.Width, backGround.Texture.Height);

            roadObjects = new GameObject[4];

            smallFont = this.Content.Load<SpriteFont>("smallFont");

            Texture2D roadTexture = this.Content.Load<Texture2D>("road");

            for(i = 0; i < roadObjects.Length;i++)
            {
                roadObjects[i] = new GameObject();
                roadObjects[i].Texture = roadTexture;
                roadObjects[i].Rect = new Rectangle(i * roadObjects[i].Texture.Width, 480 - roadObjects[i].Texture.Height / 2 - 100 - TOP_OFFSET,
                    roadObjects[i].Texture.Width, roadObjects[i].Texture.Height);
            }

            LanePositionY = new Dictionary<int, int>();

            LanePositionY.Add(0, 270);
            LanePositionY.Add(1, 290);
            LanePositionY.Add(2, 315);
            LanePositionY.Add(3, 340);

            scenes.Add(CreateScene());

            textures = new Dictionary<ObjectType, Texture2D>();
            textures.Add(ObjectType.ROAD_BLOCK_T, this.Content.Load<Texture2D>("road_block"));
            textures.Add(ObjectType.BARRICADE, this.Content.Load<Texture2D>("barricade"));

            buildHelpText();
        }