/// <summary> Creates a random Monster entity </summary> private Monster RandomMonster() { // Array of Creatures enum Creatures[] creatures = Enum.GetValues(typeof(Creatures)).Cast <Creatures>().ToArray(); int maxVal = creatures.Sum(x => (int)x); int randNum = random.Next(0, maxVal); int totalRarity = 0; // Loop until monster selected foreach (Creatures creature in creatures) { int rarity = (int)creature; // Return Monster entity if selected if (randNum < rarity + totalRarity) { return(MonsterFactory.Create(creature)); } totalRarity += rarity; } return(null); }
public static void MonsterOnMap(Location location, ushort monsterId) { var monster = MonsterFactory.Create(monsterId); if (monster != null) { IThing monsterAsThing = monster; var tile = Game.Instance.GetTileAt(location); if (tile == null) { Console.WriteLine($"Unable to place monster at {location}, no tile there."); return; } // place the monster. tile.AddThing(ref monsterAsThing); if (!Game.Instance.Creatures.TryAdd(monster.CreatureId, monster)) { Console.WriteLine($"WARNING: Failed to add {monster.Article} {monster.Name} to the global dictionary."); } Game.Instance.NotifySpectatingPlayers(conn => new CreatureAddedNotification(conn, monster, EffectT.BubbleBlue), monster.Location); } }
public string Execute(string[] inputArgs) { string monsterType = inputArgs[2]; MonsterFactory monsterFactory = new MonsterFactory(); var monster = monsterFactory.Create(monsterType); LoadUtilities.LoadMonsterRepository().Add(monster); return($"Successful create new Monster {monsterType}"); }
static void Main(string[] args) { var playerFactory = new PlayerFactory(); var monsterFactory = new MonsterFactory(); var knight = playerFactory.Create(PlayerType.Knight); var wizard = playerFactory.Create(PlayerType.Wizard); Console.WriteLine("{0}:", knight.GetType().Name); Console.WriteLine("{0} = {1}", nameof(knight.ExperiencePoints), knight.ExperiencePoints); Console.WriteLine("{0} = {1}", nameof(knight.HitPoints), knight.HitPoints); Console.WriteLine("{0} = {1}", nameof(knight.Gold), knight.Gold); Console.WriteLine(); Console.WriteLine("{0}:", wizard.GetType().Name); Console.WriteLine("{0} = {1}", nameof(wizard.ExperiencePoints), wizard.ExperiencePoints); Console.WriteLine("{0} = {1}", nameof(wizard.HitPoints), wizard.HitPoints); Console.WriteLine("{0} = {1}", nameof(wizard.Gold), wizard.Gold); Console.WriteLine(); var aerialMonster = monsterFactory.Create(MonsterType.Aerial); var terrestrialMonster = monsterFactory.Create(MonsterType.Terrestrial); var aquaticMonster = monsterFactory.Create(MonsterType.Aquatic); Console.WriteLine("{0}:", aerialMonster.GetType().Name); Console.WriteLine("{0} = {1}", nameof(aerialMonster.HitPoints), aerialMonster.HitPoints); Console.WriteLine(); Console.WriteLine("{0}:", terrestrialMonster.GetType().Name); Console.WriteLine("{0} = {1}", nameof(terrestrialMonster.HitPoints), terrestrialMonster.HitPoints); Console.WriteLine(); Console.WriteLine("{0}:", aquaticMonster.GetType().Name); Console.WriteLine("{0} = {1}", nameof(aquaticMonster.HitPoints), aquaticMonster.HitPoints); Console.WriteLine(); Console.ReadKey(); }
public void Execute() { foreach (var gameEntity in _attackGroup) { if (!(gameEntity.calldown.Value < 0.001f)) { continue; } _factory.Create(gameEntity.creator.Value, _grid.WorldToCell(gameEntity.target.Entity.view.Value.transform.position)); if (gameEntity.target.Entity.creatureType.Value == CreatureType.Position) { gameEntity.target.Entity.ReplaceCell(_randomPositionGenerator.RandomPosition()); } gameEntity.ReplaceCalldown(gameEntity.initialCalldown.Value); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. this.spriteBatch = new SpriteBatch(this.GraphicsDevice); this.background = new BackgroundObject(this.Content, "bg1"); this.startMenu.LoadContent(this.Content); this.font = this.Content.Load <SpriteFont>("MyFont"); IDrawableGameObject barbarian = CharacterFactory.Create("Barbarian", this.Content, 100, 400); IDrawableGameObject goblin = MonsterFactory.Create("Goblin", this.Content, 500, 400); IDrawableGameObject blackDragon = MonsterFactory.Create("BlackDragon", this.Content, 1200, 450); this.player = (ICharacter)barbarian; this.gameObjects.Add(barbarian); this.gameObjects.Add(goblin); this.gameObjects.Add(blackDragon); }
private static void CreateMonsters(Scene scene) { try { Log.Debug("CreateMonsters"); var comp = scene.GetComponent <MonsterComponent>(); var monster1 = MonsterFactory.Create(scene); monster1.Position = new UnityEngine.Vector3(0, 0, 0); monster1.GetComponent <MoveComponent>().Speed = 1f; comp.Add(monster1); var monster2 = MonsterFactory.Create(scene); monster2.GetComponent <MoveComponent>().Speed = 1f; monster2.Position = new UnityEngine.Vector3(4, 0, 0); comp.Add(monster2); //monster1.GetComponent<MoveComponent>().MoveTo(monster2.Position).Coroutine(); monster2.GetComponent <MoveComponent>().MoveTo(new UnityEngine.Vector3(-2, 0, 0)).Coroutine(); } catch (System.Exception e) { Log.Error(e); } }