static void Main(string[] args) { GameContainer container = new GameContainer("window", 650, 400); //constructor, creates new instance of the game Gravity gravity = new Gravity(); container.GetWorld().SetPhysics(gravity); Player player = new Player("player", 1); container.GetWorld().AddActor(player); player.SetPhysics(true); player.SetPosition(220, 100); Skeleton enemy = new Skeleton("skelton", 1, player, 5, 20, 20); container.GetWorld().AddActor(enemy); enemy.SetPhysics(true); enemy.SetPosition(300, 100); container.SetMap("resources/maps/map01.tmx"); Action <IWorld> setCamera = world => { world.CenterOn(world.GetActors().Find(a => a.GetName() == "player")); }; container.Run(); //start the game, infinite loop, no change is accepted after this until the game ends }
static void Main(string[] args) { GameContainer container = new GameContainer("window", 650, 400); //constructor, creates new instance of the game Gravity gravity = new Gravity(); container.GetWorld().SetPhysics(gravity); Kettle kettle = new Kettle(); container.GetWorld().AddActor(kettle); kettle.SetPosition(100, 100); Stove stove = new Stove(); container.GetWorld().AddActor(stove); stove.SetPosition(170, 170); stove.AddKettle(kettle); PowerSource source = new PowerSource(); container.GetWorld().AddActor(source); source.SetPosition(200, 200); Crystal crystal = new Crystal(source); container.GetWorld().AddActor(crystal); crystal.SetPosition(200, 250); CrackedCrystal crackedCrystal = new CrackedCrystal(source, 3); container.GetWorld().AddActor(crackedCrystal); crackedCrystal.SetPosition(200, 350); Player player = new Player(); container.GetWorld().AddActor(player); player.SetPhysics(true); player.SetPosition(220, 100); Enemy enemy = new Enemy(player, 5, 20, 20); container.GetWorld().AddActor(enemy); enemy.SetPhysics(true); enemy.SetPosition(300, 100); container.SetMap("resources/maps/map01.tmx"); stove.AddKettle(kettle); container.Run(); //start the game, infinite loop, no change is accepted after this until the game ends }
static void Main(string[] args) { GameContainer container = new GameContainer("MerlinCore_Game", 800, 650, true); container.AddWorld("Resources/maps/map03.tmx"); container.AddWorld("Resources/maps/map02.tmx"); Message msgWon = new Message("YOU HAVE WON", 200, 150, 50, Color.Yellow, (MessageDuration)1); Message msgLost = new Message("GAME OVER", 250, 150, 50, Color.Yellow, (MessageDuration)1); container.SetEndGameMessage(msgWon, true); container.SetEndGameMessage(msgLost, false); IWorld world = container.GetWorld(0); IWorld world1 = container.GetWorld(1); ActorFactory factory = new ActorFactory(); world.SetFactory(factory); world1.SetFactory(factory); world.SetPhysics(new Gravity()); world1.SetPhysics(new Gravity()); Action <IWorld> setSubs = world => { Switch switch1 = (Switch)world.GetActors().Find(a => a is Switch); Door door1 = (Door)world.GetActors().Find(a => a is Door); switch1.Subscribe(door1); door1.SetDoor(36, 37, 31, 34); }; world.AddInitAction(setSubs); //Action<IWorld> setCamera = world => { world.CenterOn(world.GetActors().Find(a => a.GetName() == "player")); }; //world.AddInitAction(setCamera); container.Run(); }
static void Main(string[] args) { GameContainer container = new GameContainer("Remorseless winter", 1024, 768); //code here container.SetMap("resources/maps/map01.tmx"); Gravity gravity = new Gravity(container.GetWorld()); container.GetWorld().SetPhysics(gravity); Kettle kettle = new Kettle(); kettle.SetPosition(200, 240); Stove stove = new Stove(); stove.SetPosition(200, 285); IActor player = new Player(); player.SetPosition(250, 200); ((Stove)stove).AddKettle((Kettle)kettle); stove.AddWood(); stove.AddWood(); stove.AddWood(); stove.RemoveWood(); container.GetWorld().AddActor(kettle); container.GetWorld().AddActor(stove); container.GetWorld().AddActor(player); /*Actor actor = kettle; * * if(powerSource is IObservable && Actor is IObserver) * { * (IObservable)powerSource.Subscribe((IObserver)actor); * }*/ PowerSource source = new PowerSource(); source.SetPosition(100, 150); Crystal crystal = new Crystal((PowerSource)source); crystal.SetPosition(100, 100); CrackedCrystal crackedCrystal = new CrackedCrystal((PowerSource)source, 100); crackedCrystal.SetPosition(150, 100); IActor enemy = new Enemy(player); enemy.SetPosition(250, 500); player.SetPhysics(true); enemy.SetPhysics(true); container.GetWorld().AddActor(crackedCrystal); container.GetWorld().AddActor(source); container.GetWorld().AddActor(crystal); container.GetWorld().AddActor(enemy); //((IObservable)source).Subscribe((IObserver)crystal); - pre pridavani dalsieho observera na kontrolu List <IActor> actors = new List <IActor>(); actors.Add(source); actors.Add(crystal); actors.Add(kettle); actors.Add(stove); //actor = actors.Find(a => a.GetName()); //select single entry //Console.WriteLine(actor); foreach (IActor actor in actors) { Console.WriteLine(actor.GetType()); } //run game with current settings container.Run(); }