예제 #1
0
        private void Game_UpdateFrame(object sender, FrameEventArgs e)
        {
            PreviousMouseState = MouseState;
            PreviousKeyboardState = KeyboardState;

            MouseState = OpenTK.Input.Mouse.GetState();
            KeyboardState = OpenTK.Input.Keyboard.GetState();

            PreviousMousePosition = MousePosition;

            #if GRAPHMAKER
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            int x = Camera.X + MousePosition.X;
            int y = Camera.Y + MousePosition.Y;

            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released && MousePosition.X > 40) {
               doc.Element("Waypoints").Add(new XElement("Waypoint", new XAttribute("X", x), new XAttribute("Y", y)));
               minID++;
               Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/BlueMinion.png" }), new Sprite(new List<string>() { "Images/BlueMinion0.png", "Images/BlueMinion1.png" }) }, minID);
                markerMinion.Pos.X = x;
                markerMinion.Pos.Y = y;
                _player1.AddMinion(markerMinion);
              // doc.Save("TestWaypoint.xml");
            XDocument doc = new XDocument();
            doc.Add(new XElement("Waypoints"));
            if (MouseState.LeftButton == ButtonState.Pressed && PreviousMouseState.LeftButton == ButtonState.Released) {
            }

            if (MouseState.RightButton == ButtonState.Pressed && PreviousMouseState.RightButton == ButtonState.Released && MousePosition.X > 40)
            {
                switch (rightClicks)
                {
                    case 0: clicks[0] = x;
                        clicks[1] = y;
                        break;

                    case 1:
                        clicks[2] = x;
                        clicks[3] = y;
                         minID++;
                         Minion markerMinion = new Minion(new List<Sprite>() { new Sprite(new List<string>() { "Images/square.png" }), new Sprite(new List<string>() { "Images/square.png", "Images/square.png" }) }, minID);
                         WaypointNode waypoint1 = graph.GetClosestWaypoint(clicks[0], clicks[1]);
                         WaypointNode waypoint2 = graph.GetClosestWaypoint(clicks[2], clicks[3]);
                         markerMinion.Pos.X = waypoint1.X + (waypoint2.X - waypoint1.X) / 2;
                         markerMinion.Pos.Y = waypoint1.Y + (waypoint2.Y - waypoint1.Y) / 2;
                _player1.AddMinion(markerMinion);
                graph.ConnectNodes(waypoint1, waypoint2);
                        Console.Write("Added neighbor");
                        break;
                }
                rightClicks++;
                rightClicks = rightClicks % 2;
                graph.WriteGraph("TestWaypointNeighbors.xml");
            }

            _scrollBar.Update(e.Time);
            #else

            _map.Update(e.Time);

            _ui.Update(e.Time);

            #endif
            }

            private void Mouse_Move(object sender, MouseMoveEventArgs e)
            {
            MousePosition = e.Position;
            }
            }
        }
예제 #2
0
        public void Reset()
        {
            _player1TreeRoot = new Dictionary<int, StackPanel>();
            _player1TreeRoot[1] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            Button player1GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player1TreeRoot[1].Children.Add(player1GoToBase);
            _player1ParentList.Add(player1GoToBase, new Tuple<StackPanel, StackPanel>(_player1TreeRoot[1], null));
            _player1TreeRoot[1].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));
            _player1TreeRoot[2] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            player1GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player1TreeRoot[2].Children.Add(player1GoToBase);
            _player1ParentList.Add(player1GoToBase, new Tuple<StackPanel, StackPanel>(_player1TreeRoot[2], null));
            _player1TreeRoot[2].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));
            _player1TreeRoot[3] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            player1GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player1TreeRoot[3].Children.Add(player1GoToBase);
            _player1ParentList.Add(player1GoToBase, new Tuple<StackPanel, StackPanel>(_player1TreeRoot[3], null));
            _player1TreeRoot[3].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));

            _player2TreeRoot = new Dictionary<int, StackPanel>();
            _player2TreeRoot[1] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            Button player2GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player2TreeRoot[1].Children.Add(player2GoToBase);
            _player2ParentList.Add(player2GoToBase, new Tuple<StackPanel, StackPanel>(_player2TreeRoot[1], null));
            _player2TreeRoot[1].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));
            _player2TreeRoot[2] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            player2GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player2TreeRoot[2].Children.Add(player2GoToBase);
            _player2ParentList.Add(player2GoToBase, new Tuple<StackPanel, StackPanel>(_player2TreeRoot[2], null));
            _player2TreeRoot[2].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));
            _player2TreeRoot[3] = new StackPanel(0, 0, 1000, 700, false, false, new Sprite(new List<string>() { "Images/SCROLLDAGGER5000.png" }, 0), new Sprite(new List<string>() { "Images/SCROLLDAGGER3000.png" }, 0));
            player2GoToBase = new Button(0, 0, 100, 100, false, "Go To Base", new Sprite(new List<string>() { "Images/blueButton.png" }, 0));
            _player2TreeRoot[3].Children.Add(player2GoToBase);
            _player2ParentList.Add(player2GoToBase, new Tuple<StackPanel, StackPanel>(_player2TreeRoot[3], null));
            _player2TreeRoot[3].Children.Add(new Button(0, 0, 100, 100, false, "Go Back", new Sprite(new List<string>() { "Images/blueButton.png" }, 0)));

            _minionEditing = 1;

            Game.Player1 = new Player(1);
            Minion minion1Player1 = new Minion(true, 1);
            minion1Player1.IsSpecial = true;
            Game.Player1.AddMinion(minion1Player1);
            Minion minion2Player1 = new Minion(true, 2);
            Game.Player1.AddMinion(minion2Player1);
            Minion minion3Player1 = new Minion(true, 3);
            Game.Player1.AddMinion(minion3Player1);
            //_player1.Base = new Base((List<Sprite>)null, 1);
            Game.Player1.Base = new Base(null, 1);
            Game.Player1.Base.Pos.X = 499;
            Game.Player1.Base.Pos.Y = 44;

            Game.Player2 = new Player(2);
            Minion minion1Player2 = new Minion(false, 1);
            minion1Player2.IsSpecial = true;
            Game.Player2.AddMinion(minion1Player2);
            Minion minion2Player2 = new Minion(false, 2);
            Game.Player2.AddMinion(minion2Player2);
            Minion minion3Player2 = new Minion(false, 3);
            Game.Player2.AddMinion(minion3Player2);
            //_player2.Base = new Base((List<Sprite>)null, 2);
            Game.Player2.Base = new Base(null, 2);
            Game.Player2.Base.Pos.X = 495;
            Game.Player2.Base.Pos.Y = 1700;

            minion1Player1.Pos.X = 175;
            minion1Player1.Pos.Y = 100;

            minion2Player1.Pos.X = 505;
            minion2Player1.Pos.Y = 180;

            minion3Player1.Pos.X = 825;
            minion3Player1.Pos.Y = 100;

            minion1Player2.Pos.X = 340;
            minion1Player2.Pos.Y = 1750;

            minion2Player2.Pos.X = 495;
            minion2Player2.Pos.Y = 1615;

            minion3Player2.Pos.X = 575;
            minion3Player2.Pos.Y = 1615;

            Game.DeathClouds.Clear();
        }
예제 #3
0
 public void AddMinion(Minion minion)
 {
     _minions.Add(minion.ID, minion);
 }
예제 #4
0
        public DecisionNode GetNode(Minion owner, InterfaceObject obj, StackPanel parent, StackPanel parentsParent)
        {
            if (obj is Button)
            {
                switch (((Button)obj).Text)
                {
                    case "Is Enemy\nClose":
                        return new IsEnemyClose(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Is 1 \nEnemy Left":
                        return new IsEnemyNum1(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Is 2\nEnemies Left":
                        return new IsEnemyNum2(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Is Enemy\nOn My Half":
                        return new IsEnemyOnMyHalf(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Is Nearest\nEnemy Moving\nAway":
                        return new NearestEnemyMovingAway(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Is Nearest\nEnemy Moving\nTowards":
                        return new NearestEnemyMovingTowards(owner)
                        {
                            FalseChild = GetNode(owner, parentsParent.Children[parentsParent.Children.IndexOf(parent) + 1], parent, parentsParent),
                            TrueChild = GetNode(owner, parent.Children[parent.Children.IndexOf(obj) + 1], parent, parentsParent)
                        };

                    case "Attack Closest":
                        return new AttackClosest(owner);

                    case "Defend Special":
                        return new DefendSpecial(owner);

                    case "Follow Path":
                        return new FollowPath(owner, null);

                    case "Go To Base":
                        return new GotoBase(owner);

                    case "Return to Base":
                        return new ReturnHomeBase(owner);

                    case "Patrol\n Home Half":
                        return new PatrolHomeHalf(owner);

                    case "Run Away":
                        return new RunAway(owner);

                    case "Stop":
                        return new WaitForTime(owner);
                }

                return null;
            }
            else // obj is StackPanel
            {
                return GetNode(owner, (obj as StackPanel).Children[0], obj as StackPanel, parent);
            }
        }