Пример #1
0
        public MonsterPlaceMenu(MonsterData.Monster monster, AnimatedSprite texture)
            : base(0, 0, Game1.viewport.Width, Game1.viewport.Height)
        {
            if (monster != MonsterData.Monster.CursedDoll)
            {
                monsterTexture = texture;
                monsterTexture.CurrentFrame = 0;
            }

            this.monster  = monster;
            monsterData   = MonsterData.GetMonsterData(monster);
            ok            = new ClickableTextureComponent(new Rectangle(16, 16, 60, 60), Game1.mouseCursors, new Rectangle(128, 256, 63, 63), 1f, false);
            placementTile = Game1.content.Load <Texture2D>("LooseSprites\\buildingPlacementTiles");

            //Warn users
            if (monster == MonsterData.Monster.ArmoredBug)
            {
                Game1.addHUDMessage(new HUDMessage("Be aware that armored bugs are unkillable.", 2));
            }
            else if (monster == MonsterData.Monster.Duggy || monster == MonsterData.Monster.MagmaDuggy)
            {
                monsterTexture.CurrentFrame = 5;
                Game1.addHUDMessage(new HUDMessage("Duggies can only be spawned on diggable tiles.", 2));
            }

            Game1.playSound("bigSelect");
            Game1.addHUDMessage(new HUDMessage($"Click anywhere to spawn a {monsterData.Displayname}", null));
        }
Пример #2
0
        public bool SpawnMonster(MonsterData.Monster monster, Vector2 location)
        {
            //spawn monster
            if (IsOkToPlace(monster, location))
            {
                MonsterData monsterData = MonsterData.GetMonsterData(monster);
                object[]    args        = monsterData.ConstructorArgs;

                if (monster == MonsterData.Monster.BlackSlime)
                {
                    args[1] = new Color(40 + random.Next(10), 40 + random.Next(10), 40 + random.Next(10));
                }

                args[0] = location;
                Monster m = (Monster)Activator.CreateInstance(monsterData.Type, args);
                m.currentLocation = Game1.currentLocation;

                if (monster == MonsterData.Monster.GraySlime)
                {
                    int num = Game1.random.Next(120, 200);
                    (m as GreenSlime).color.Value = new Color(num, num, num);
                    while (Game1.random.NextDouble() < 0.33)
                    {
                        m.objectsToDrop.Add(380);
                    }
                    m.Speed = 1;
                }
                else if (monster == MonsterData.Monster.Duggy || monster == MonsterData.Monster.WildernessGolem)
                {
                    m.setTileLocation(location); //For Tile-Locked Monsters like Duggy
                }
                else if (monster == MonsterData.Monster.StickBug)
                {
                    (m as RockCrab).makeStickBug();
                }
                else if (monster == MonsterData.Monster.TigerSlime)
                {
                    (m as GreenSlime).makeTigerSlime();
                }
                else if (monster == MonsterData.Monster.PrismaticSlime)
                {
                    (m as GreenSlime).makePrismatic();
                }

                Game1.currentLocation.addCharacter(m);
                spawnedMonsters.Add(m);
                Monitor.Log("Spawned " + monster + " at " + location, LogLevel.Debug);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 public void SpawnMonster(MonsterData.Monster monster, Vector2 location, int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         if (!SpawnMonster(monster, location))
         {
             Monitor.Log("You may not place this monster there.", LogLevel.Info);
             break;
         }
     }
     Monitor.Log($"Spawned {amount} {MonsterData.GetMonsterData(monster).Displayname} at {location}", LogLevel.Info);
 }