コード例 #1
0
ファイル: Bot.cs プロジェクト: bytinggames/LD48
        public Bot(int botID, PathTrack path) : base(path.GetStartPos(), path.GetStartOrientation())
        {
            this.path  = path;
            this.botID = botID;

            if (botID != 0)
            {
                carColor = Colors.botColors[botID - 1];
            }
        }
コード例 #2
0
ファイル: Friend.cs プロジェクト: bytinggames/LD48
        public Friend(PathTrack path) : base(0, path)
        {
            playerTexOrientation = orientation;

            //dialog = new FriendDialogue();
            //dialogEnumerator = dialog.

            carColor = Colors.friend;

            Texture    = Textures.car2Color;
            noColorTex = Textures.car2NoColor;

            InitLowered();
        }
コード例 #3
0
ファイル: Race.cs プロジェクト: bytinggames/LD48
        public override bool Update(GameTime gameTime)
        {
            camera.UpdateBegin();

            if (!gameState.Update(gameTime))
            {
                return(false);
            }

            if (!pauseGame)
            {
                for (int i = 0; i < Entities.Count; i++)
                {
                    Entities[i].Update(gameTime);
                }
            }
#if DEBUG
            else
            {
                player.Update(gameTime);
            }
#endif

#if DEBUG
            #region Editor

            if (Input.e.pressed)
            {
                editorTool++;
                if ((int)editorTool >= Enum.GetNames(editorTool.GetType()).Length)
                {
                    editorTool = 0;
                }
            }
            else if (Input.q.pressed)
            {
                editorTool--;
                if ((int)editorTool < 0)
                {
                    editorTool = (EditorTool)(Enum.GetNames(editorTool.GetType()).Length - 1);
                }
            }

            //if (editorTool != EditorTool.None)
            {
                if (Input.mbLeft.pressed || Input.mbRight.pressed)
                {
                    pressedX  = (int)Math.Floor(camera.mousePos.X / Tile.size);
                    pressedY  = (int)Math.Floor(camera.mousePos.Y / Tile.size);
                    mouseDown = Input.mbLeft.pressed ? Input.mbLeft : Input.mbRight;
                }
                if (mouseDown != null && mouseDown.released)
                {
                    switch (editorTool)
                    {
                        #region Tile
                    case EditorTool.Tile:
                    case EditorTool.Goal:

                        int x = (int)Math.Floor(camera.mousePos.X / Tile.size);
                        int y = (int)Math.Floor(camera.mousePos.Y / Tile.size);

                        int xStart = Math.Min(x, pressedX);
                        int xEnd   = Math.Max(x, pressedX);
                        int yStart = Math.Min(y, pressedY);
                        int yEnd   = Math.Max(y, pressedY);

                        bool setStreet = mouseDown == Input.mbLeft;

                        if (xStart < 0)
                        {
                            xStart = 0;
                        }
                        if (yStart < 0)
                        {
                            yStart = 0;
                        }
                        if (xStart >= width)
                        {
                            xStart = width - 1;
                        }
                        if (yStart >= height)
                        {
                            yStart = height - 1;
                        }

                        if (editorTool == EditorTool.Tile)
                        {
                            for (int y1 = yStart; y1 <= yEnd; y1++)
                            {
                                for (int x1 = xStart; x1 <= xEnd; x1++)
                                {
                                    street[x1, y1] = setStreet;
                                }
                            }
                            UpdateTiles(xStart - 1, xEnd + 1, yStart - 1, yEnd + 1);
                        }
                        else if (editorTool == EditorTool.Goal)
                        {
                            for (int y1 = yStart; y1 <= yEnd; y1++)
                            {
                                for (int x1 = xStart; x1 <= xEnd; x1++)
                                {
                                    AddEntity(new Goal(new Vector2(x1, y1) * Tile.size));
                                }
                            }
                        }
                        break;

                        #endregion
                    case EditorTool.House:
                        if (mouseDown == Input.mbLeft)
                        {
                            House house = new House(GetDragRectangle());
                            AddEntity(house);
                        }
                        break;
                    }

                    mouseDown = null;
                }

                if (mouseDown == Input.mbRight)
                {
                    if (editorTool != EditorTool.Tile)
                    {
                        for (int i = Entities.Count - 1; i >= 0; i--)
                        {
                            if (Entities[i] is E_Mask m && m.Mask.ColVector(camera.mousePos))
                            {
                                RemoveEntity(Entities[i]);
                            }
                        }
                    }
                }
                else
                {
                    switch (editorTool)
                    {
                    case EditorTool.Tile:
                        break;

                    case EditorTool.House:
                        break;

                    case EditorTool.Car:

                        if (Input.mbLeft.pressed)
                        {
                            if (carIndex == 0)
                            {
                                carBuild = new PlayerCar(camera.mousePos, 0f);
                            }
                            else
                            {
                                carBuild = new Car(camera.mousePos, 0f);
                            }
                            AddEntity(carBuild);
                        }

                        if (Input.mbLeft.down)
                        {
                            Vector2 dir = camera.mousePos - carBuild.Pos;
                            carBuild.orientation = (float)Math.Atan2(dir.Y, dir.X);
                        }
                        break;

                    case EditorTool.Bot:

                        if (Input.mbLeft.pressed)
                        {
                            Bot bot = Entities.Find(f => f is Bot b && b.botID == carIndex) as Bot;
                            if (bot == null)
                            {
                                PathTrack path = new PathTrack(new List <Vector2>()
                                {
                                    camera.mousePos
                                });

                                if (carIndex == 0)
                                {
                                    bot = new Friend(path);
                                }
                                else
                                {
                                    bot = new Bot(carIndex, path);
                                }
                                AddEntity(bot);
                            }
                            else
                            {
                                bot.path.nodes.Add(camera.mousePos);
                            }
                        }
                        break;
                    }
                }

                if (Input.plusNum.pressed)
                {
                    carIndex++;
                }
                else if (Input.minusNum.pressed)
                {
                    carIndex--;
                }
            }
            #endregion
#endif

            camera.targetPos = player.Pos;

            camera.UpdateEnd(G.ResX, G.ResY);

#if DEBUG
            if (Input.f.pressed)
            {
                Win();
            }
#endif

            return(true);
        }