コード例 #1
0
        public ActionResult GenerateRoom()
        {
            Room[] possibleRooms = new Room[1];

            #region forestRoom

            List<Terrain> terrainObjects = new List<Terrain>();
            terrainObjects.Add(new Terrain(586, 626, 709, 801, @"/content/GameContent/Images/trees01.png"));
            terrainObjects.Add(new Terrain(2268, 1868, 903, 597, @"/content/GameContent/Images/trees02.png"));
            terrainObjects.Add(new Terrain(1884, 216, 709, 801, @"/content/GameContent/Images/trees01.png"));
            terrainObjects.Add(new Terrain(608, 2096, 406, 332, @"/content/GameContent/Images/rock01.png"));

            Room forestRoom = new Room(3200, 3200, @"/content/GameContent/Images/map3_v3.jpg", terrainObjects);

            #endregion

            User u = dal.GetUser(User.Identity.Name);
            u.CurrentHealth = 100;
            //u.MonstersKilled = 10;
            //u.RoomsTraveled = 10;
            dal.UpdateUser(u);

            possibleRooms[0] = forestRoom;
            //Room room = new Room() {Height = 3200, Width = 3200 };
            possibleRooms[0].monsters = GenerateMonsters(possibleRooms[0]);
            return Json(possibleRooms[0], JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
        public Monster(int characterLevel, Room room, Random rand)
        {
            Name = "Scary Monster";
            MaxHealth = characterLevel / 3;
            Attack = characterLevel / 3;
            MoveSpeed = 300;

            StartPosition = new Position(rand.Next(room.Width), rand.Next(room.Height));
        }
コード例 #3
0
ファイル: Monster.cs プロジェクト: Siryu/MathewsMages
        public Monster(int characterLevel, Room room, Random rand)
        {
            Name = "Slime";
            MaxHealth = characterLevel + 2;
            Attack = characterLevel + 7;
            MoveSpeed = rand.Next(95, 220);
            AnimationSpeed = 12;
            DropItem = GetDropItem(rand);

            Width = 155;
            Height = 155;
            CollisionWidth = 188;
            CollisionHeight = 52;
            CollisionX = 62;
            CollisionY = 120;

            //boss monster!
            if (characterLevel > 5 && rand.Next(16) == 3)
            {
                Image = @"../Content/GameContent/Images/slime_sprite_green.png";
                MoveSpeed = 220;
                AnimationSpeed = 14;
                Attack = Attack * 2;
                Name = "Boss";
                DropItem = GetBossDropItem(rand);
            }
            else
            {
                if (MoveSpeed < 145)
                {
                    Image = @"../Content/GameContent/Images/slime_sprite4.png";
                    Attack += (int)(Attack * 1.5);
                    AnimationSpeed -= rand.Next(1, 4);
                }
                if (MoveSpeed >= 145)
                {
                    Image = @"../Content/GameContent/Images/slime_sprite_red.png";
                }
                if (MoveSpeed >= 170)
                {
                    AnimationSpeed += rand.Next(1, 4);
                }
            }
            StartPosition = new Position(rand.Next(room.Width - Width), rand.Next(room.Height - Height));
            while (StartPosition.X < 300 || StartPosition.Y < 300)
            {
                StartPosition.X = rand.Next(room.Width - Width);
                StartPosition.Y = rand.Next(room.Height - Height);
            }
        }
コード例 #4
0
        private List<Monster> GenerateMonsters(Room room2)
        {
            User user = dal.GetUser(User.Identity.Name);

            Random rand = new Random();

            int maxMonsters = rand.Next((user.GetComputedLevel() * 2) - (user.GetComputedLevel() / 2), (user.GetComputedLevel() * 2));

            Monster[] monsters = new Monster[maxMonsters];

            for (int i = 0; i < maxMonsters; i++)
            {
                monsters[i] = new Monster(user.GetComputedLevel(), room2, rand);
            }

            return monsters.ToList();
        }
コード例 #5
0
        public Monster(int characterLevel, Room room, Random rand)
        {
            Name = "Scary Monster";
            MaxHealth = characterLevel / 3;
            Attack = characterLevel / 3;
            MoveSpeed = 300;
            DropItem = GetDropItem(rand);

            Image = @"/Content/GameContent/Images/monster_small.png";
            Width = 250;
            Height = 172;
            CollisionWidth = 188;
            CollisionHeight = 52;
            CollisionX = 62;
            CollisionY = 120;

            StartPosition = new Position(rand.Next(room.Width), rand.Next(room.Height));
        }
コード例 #6
0
ファイル: GameController.cs プロジェクト: Siryu/MathewsMages
        public ActionResult GenerateRoom()
        {
            Room[] possibleRooms = new Room[2];

            #region forestRoom

            List<Terrain> terrainObjects = new List<Terrain>();
            terrainObjects.Add(new Terrain(586, 626, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            terrainObjects.Add(new Terrain(2268, 1868, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            terrainObjects.Add(new Terrain(1884, 216, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects.Add(new Terrain(2268, 1868, 903, 597, @"/content/GameContent/Images/trees02.png"));
            //terrainObjects.Add(new Terrain(1884, 216, 709, 801, @"/content/GameContent/Images/trees01.png"));
            terrainObjects.Add(new Terrain(608, 2096, 406, 332, 0, 192, 406, 140, @"../Content/GameContent/Images/rock01.png"));

            Room forestRoom = new Room(3200, 3200, @"/content/GameContent/Images/map3_v3.jpg", terrainObjects);
            possibleRooms[0] = forestRoom;

            #endregion

            #region forestRoomVariation
            List<Terrain> terrainObjects1 = new List<Terrain>();
            //terrainObjects1.Add(new Terrain(586, 626, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects1.Add(new Terrain(2268, 1868, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects1.Add(new Terrain(1884, 216, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects1.Add(new Terrain(2000, 400, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects1.Add(new Terrain(2798, 2790, 709, 801, 319, 752, 77, 49, @"../Content/GameContent/Images/tree01.png"));
            //terrainObjects1.Add(new Terrain(608, 2096, 406, 332, 0, 192, 406, 140, @"../Content/GameContent/Images/rock01.png"));
            //terrainObjects1.Add(new Terrain(900, 2296, 406, 332, 0, 192, 406, 140, @"../Content/GameContent/Images/rock01.png"));

            ////Room forestRoom2 = new Room(3200, 3200, @"/content/GameContent/Images/map3_v3.jpg", terrainObjects1);
            //List<Terrain> terrainObjects2 = new List<Terrain>();
            //terrainObjects2.Add(new Terrain(2200, 0, 13605, 1600, 2200, 0, 13605, 1600, @"../Content/GameContent/Images/fireball.png"));
            ////terrainObjects2.Add(new Terrain(5439, 2054, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(5439, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(5639, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(5839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(6039, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(6239, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(6439, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(6639, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(6839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(7039, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(7239, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(7439, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(7639, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(7839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8039, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8239, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8439, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8639, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(8839, 2054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));

            //terrainObjects2.Add(new Terrain(9039, 2454, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(9439, 2854, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(9839, 3254, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(12239, 3654, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(16639, 4054, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(20039, 4454, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(24439, 4854, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(28039, 5254, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            //terrainObjects2.Add(new Terrain(32039, 5654, 934, 746, 0, 0, 934, 746, @"../Content/GameContent/Images/red_tree.gif"));
            #endregion

            #region alt forest room

            //mini room
            List<Terrain> terrainObjects2 = new List<Terrain>();

            terrainObjects2.Add(new Terrain(484, 179, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/green_tree.png"));
            terrainObjects2.Add(new Terrain(1288, 788, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/green_tree.png"));
            terrainObjects2.Add(new Terrain(2228, 44, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/green_tree.png"));
            terrainObjects2.Add(new Terrain(200, 1920, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/red_tree.png"));
            terrainObjects2.Add(new Terrain(948, 2284, 934, 746, 349, 694, 268, 53, @"../Content/GameContent/Images/red_tree.png"));

            terrainObjects2.Add(new Terrain(584, 879, 407, 320, 0, 175, 407, 131, @"../Content/GameContent/Images/wayne_rock.png"));
            terrainObjects2.Add(new Terrain(2088, 2116, 407, 320, 0, 175, 407, 131, @"../Content/GameContent/Images/wayne_rock.png"));
            terrainObjects2.Add(new Terrain(2420, 1920, 407, 320, 0, 175, 407, 131, @"../Content/GameContent/Images/wayne_rock.png"));
            terrainObjects2.Add(new Terrain(2548, 2860, 407, 320, 0, 175, 407, 131, @"../Content/GameContent/Images/wayne_rock.png"));

            Room forestRoom2 = new Room(3200, 3200, @"/content/GameContent/Images/map4_v2.jpg", terrainObjects2);
            possibleRooms[1] = forestRoom2;

            #endregion

            User u = dal.GetUser(User.Identity.Name);
            u.CurrentHealth = 100;
            dal.UpdateUser(u);

            Random rand = new Random();
            Room winner = possibleRooms[rand.Next(possibleRooms.Length)];
            winner.monsters = GenerateMonsters(winner);
            return Json(winner, JsonRequestBehavior.AllowGet);
        }