public static GameObject CreateGoblinArcher(Coord pos, Timeline timeline, GoalMapStore goalMapStore, MessageBus mainBus) { GameObject goblin = new UpdatingGameObject(pos, Layers.Main, null, timeline, isWalkable: true); Item mainWeapon = new ProjectileWeapon(new Damage(1), 5); Being goblinBeing = new Being(new SelectedAttributes(new AttributeSet(4, 5, 4, 4, 3)), goblins, new EquipmentSlotSet(), 2, "goblin"); goblinBeing.Equipment.Equip(mainWeapon, EquipmentSlot.RightHandEquip); goblinBeing.Inventory.Add(gold, 10); Actor goblinActor = new Actor(goblinBeing, new BasicAgent(goalMapStore), mainBus); goblin.AddComponent(goblinActor); goblin.AddComponent(new GlyphComponent(new Glyph(Characters.g, Color.GreenYellow))); goblin.AddComponent(new NameComponent(new Title("a", "goblin"))); EffectTargetComponent effectTarget = new EffectTargetComponent(); effectTarget.EffectTarget.AddEffectReceiver(goblinActor); goblin.AddComponent(effectTarget); timeline.OnAdvance += goblinActor.Update; return(goblin); }
public Floor(int index, Timeline timeline, MapInfo mapInfo, Spawner spawner, GoalMapStore goalMapStore, MessageBus messageBus) { Index = index; Timeline = timeline; MapInfo = mapInfo; Spawner = spawner; GoalMapStore = goalMapStore; MessageBus = messageBus; }
public BasicAgent(GoalMapStore goalMapStore) { _goalMapStore = goalMapStore; }
private static void StartGame() { //Dungeon dungeon = new Dungeon(); // dungeon.Enter(); MessageBus mainBus = new MessageBus(); Timeline timeline = new Timeline(); MapInfo mapInfo = new MapGenerator(timeline, mainBus).Generate(120, 40, "helloseed"); Map map = mapInfo.Map; LightMap lightMap = mapInfo.LightMap; Spawner spawner = new Spawner(map); mainBus.RegisterSubscriber(spawner); JoystickConfig joystickConfig = new JoystickConfig { DownCode = Terminal.TK_S, LeftCode = Terminal.TK_A, RightCode = Terminal.TK_D, UpCode = Terminal.TK_W, MapUp = Terminal.TK_UP, MapDown = Terminal.TK_DOWN, MapRight = Terminal.TK_RIGHT, MapLeft = Terminal.TK_LEFT, Inventory = Terminal.TK_I, Equip = Terminal.TK_E }; //lightMap.AddLight(new Light(Color.AntiqueWhite, new Coord(1, 1), 15, 5)); lightMap.AddLight(new Light(Color.Wheat, new Coord(8, 8), 20, 10000)); // Creating Player GameObject player = new UpdatingGameObject(new Coord(20, 20), Layers.Main, null, timeline); Being playerBeing = new Being(new SelectedAttributes(new AttributeSet(10, 10, 10, 10, 10)), Alignment.PlayerAlignment, new EquipmentSlotSet(), 5, "You"); playerBeing.Equipment.Equip(new MeleeWeapon(new Damage(10)), EquipmentSlot.RightHandEquip); UserControlAgent control = new UserControlAgent(joystickConfig); mainBus.RegisterSubscriber <MouseMoveEvent>(control); mainBus.RegisterSubscriber <KeyEvent>(control); Actor playerActor = new Actor(playerBeing, control, mainBus); player.AddComponent(playerActor); player.AddComponent(new GlyphComponent(new Glyph(Characters.AT, Color.Aqua))); player.AddComponent(new LightSourceComponent(lightMap, new Light(Color.Aqua, Coord.NONE, 4, 8))); player.AddComponent(new FOVExplorerComponent()); player.AddComponent(new NameComponent(new Title("the", "Hero"))); EffectTargetComponent playerEffectTarget = new EffectTargetComponent(); playerEffectTarget.EffectTarget.AddEffectReceiver(playerActor); player.AddComponent(playerEffectTarget); playerEffectTarget.EffectTarget.ApplyEffect(new StaminaEffect(1, EffectKind.Repeating, new EventTimerTiming(25, 25))); Logger logger = new Logger(); mainBus.RegisterSubscriber(logger); MapViewPane viewPane = new MapViewPane(mainBus, joystickConfig, new InventoryDisplayPane(playerBeing.Equipment, playerBeing.Inventory, joystickConfig, mainBus)); viewPane.Map = map; viewPane.LightMap = lightMap; map.ObjectRemoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectMoved += (sender, eventArgs) => viewPane.SetDirty(); map.ObjectAdded += (sender, eventArgs) => viewPane.SetDirty(); TextPane descriptionPane = new TextPane("TEST TEXT"); Describer describer = new Describer(descriptionPane); describer.Map = map; mainBus.RegisterSubscriber(describer); LogPane logPane = new LogPane(logger); StackPane mapAndConsole = new StackPane(StackPane.StackDirection.Vertical); mapAndConsole.AddChild(descriptionPane, 1); mapAndConsole.AddChild(viewPane, 5); mapAndConsole.AddChild(logPane, 1); StackPane statusBars = new StackPane(StackPane.StackDirection.Vertical); statusBars.AddChild(new FillBarPane(playerBeing.Health, "Health", Color.Red, Color.DarkRed), 1); statusBars.AddChild(new FillBarPane(playerBeing.Mana, "Mana", Color.Aqua, Color.DarkBlue), 1); statusBars.AddChild(new FillBarPane(playerBeing.Stamina, "Stamina", Color.Yellow, Color.DarkGoldenrod), 1); StackPane root = new StackPane(StackPane.StackDirection.Horizontal); root.AddChild(mapAndConsole, 4); root.AddChild(statusBars, 1); Window rootWindow = new Window(root, new Rectangle(0, 0, 160, 50), 0); BearTermRenderer renderer = new BearTermRenderer(rootWindow, "window.title='Spell Sword'; window.size=160x50; window.resizeable=true; input.filter=[keyboard+, mouse+, arrows+]"); mainBus.RegisterSubscriber <ParticleEvent>(renderer); mainBus.RegisterSubscriber <WindowEvent>(renderer); //WindowRouter windowRouter = new WindowRouter(); //windowRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); //mainBus.RegisterSubscriber(windowRouter); GameControlConsumer gameControlConsumer = new GameControlConsumer(joystickConfig, mainBus, viewPane); BearTermInputRouter inputRouter = new BearTermInputRouter(gameControlConsumer); mainBus.RegisterSubscriber(inputRouter); inputRouter.Handle(WindowEvent.Open(root, new Rectangle(0, 0, 160, 50))); GoalMapStore goalMapStore = new GoalMapStore(map); for (int i = 1; i < 5; i++) { //GameObject goblin = TestUtil.CreateGoblin((5 + i, 5 + i % 2 + 1), playerActor, timeline, goalMapStore, mainBus); //map.AddEntity(goblin); } map.AddEntity(player); Terminal.Refresh(); int lastFrame = Environment.TickCount; while (true) { inputRouter.HandleInput(); //control.VisualizeAim(playerActor); if (!control.WaitingForInput) { timeline.Advance(1); goalMapStore.UpdateMaps(); } if (Environment.TickCount - lastFrame > 20) { renderer.Refresh(); lastFrame = Environment.TickCount; } } }