//Character attributes public BasicGroundEnemy(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, //GameObject attributes WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, //PhysicalObject attributes double runSpeed, double maxSpeed) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed) { Stompable = true; }
public static void Main() { using (var game = new Game()) { game.Run(60); } }
public Direction SuggestMove(Game g) { Game gW = new Game(g); Game gA = new Game(g); Game gS = new Game(g); Game gD = new Game(g); bool wWorked = gW.Move(Direction.Up); bool aWorked = gA.Move(Direction.Left); bool sWorked = gS.Move(Direction.Down); bool dWorked = gD.Move(Direction.Right); int maxValue = Math.Max(gW.HeuristicValue, Math.Max(gA.HeuristicValue, Math.Max(gS.HeuristicValue, gD.HeuristicValue))); bool moveWorked = false; if (gW.HeuristicValue == maxValue && wWorked) return Direction.Up; else if (gA.HeuristicValue == maxValue && aWorked) return Direction.Left; else if (gS.HeuristicValue == maxValue && sWorked) return Direction.Down; else if (gD.HeuristicValue == maxValue && dWorked) return Direction.Right; if (wWorked) return Direction.Up; if (aWorked) return Direction.Left; if (sWorked) return Direction.Down; if (dWorked) return Direction.Right; throw new ApplicationException("No move could be found"); }
public void SetRightCell(Cell cell) { rightCell = cell; GameObject obj = rightCell.gameObject; if (rightCell.isRightCell) { this.transform.Translate(obj.transform.position.x - this.transform.position.x, obj.transform.position.y - this.transform.position.y, 0F); rightCell.isRightCell = false; obj.GetComponent <CircleCollider2D>().enabled = false; // При отпускании блока, нужно добалять соответсвующий блок в game var cellPos = rightCell.PosInGrid; var go = this.gameObject; e.Game game = GameObject.Find("GameField").GetComponent <Level>().game; switch (go.GetComponent <ControlBlock>().GetBlockType()) { case cb.BlockType.cbAction: Debug.Log("cdAction"); var new_act = new e.ColorSwitch(0, this.GetComponent <ColorSwitch>().color, rightCell.posInGridX, rightCell.posInGridY); game.AddObject(new_act); break; case cb.BlockType.cbCondition: Debug.Log("cbCondition"); var new_cond = new e.ColorCondition(go.GetComponent <ConditionBlock>().color, new e.Point(-1, 0), rightCell.posInGridX, rightCell.posInGridY); game.AddObject(new_cond); break; case cb.BlockType.cbCicle: break; } } }
private static void Main() { Debug.Log("Starting Game."); using (var game = new Game()) { EngineReferences.Game = game; var player = new Entity("Player"); Sprite sprite = new Sprite("Content/Sprites/table.png"); KeyboardController controller = new KeyboardController() { Speed = 15 }; player.AddComponent(sprite); player.AddComponent(controller); player.AddComponent(new RigidBody()); player.Transform.Position = new Vector2(50, 50); player.Transform.Size = new Vector2(100, 100); game.AddEntity(player); game.Run(); } }
public Game(Game otherGame) { for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) x[i, j] = otherGame.X[i, j]; m_PreviousStates = otherGame.m_PreviousStates; m_Score = otherGame.m_Score; }
//Just pass on the constructor stuff to base public Character(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, double runSpeed, double maxSpeed) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons) { CurrentSprite.PlayAnimation("stand", true); MaxSpeed = maxSpeed; RunSpeed = runSpeed; }
public PhysicalObject(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons) : base(game, position, velocity, sprites, defaultSprite, controller, boundingPolygons) { this.worldPhysics = worldPhysics; this.objectPhysics = objectPhysics; this.friction = objectPhysics.Friction*worldPhysics.GroundFrictionFactor; inAirTimer.Start(); }
public Mushroom(Game game, Vector position, Dictionary<string, Sprite> sprites, string defaultSprite, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> polygons, ItemType itemType) : base(game, position, new Vector(0,0), sprites, defaultSprite, new DumbGroundAI(), worldPhysics, objectPhysics, polygons) { CurrentSprite.PlayAnimation(Sprite.DEFAULT_ANIMATION, true); MushroomType = itemType; }
public Player(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, //GameObject attributes WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, //PhysicalObject attributes double runSpeed, double maxSpeed, //Character attributes PlayerState state) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed) { oldFriction = objectPhysics.Friction; PlayerState = state; invincibleTimer.Start(); }
static void Main(string[] args) { Game g = new Game(); Random r = new Random(); int gameCount = 0; int totalScore = 0; while (true) { IAi ai = new Engine.HeuristicAi(); g = new Game(); while (g.AreMovesAvailable()) { //Console.Write(g); //char move = 'x'; ////ConsoleKeyInfo keyInfo = Console.ReadKey(); ////move = keyInfo.KeyChar; //double mov = r.NextDouble(); //if (mov < 0.5) move = 'w'; //else if (mov < 0.96) move = 'a'; //else if (mov < 0.99) move = 'd'; //else move = 's'; //if (move == 'w') // g.Move(Direction.Up); //else if (move == 'a') // g.Move(Direction.Left); //else if (move == 's') // g.Move(Direction.Down); //else if (move == 'd') // g.Move(Direction.Right); Direction suggestedMove = ai.SuggestMove(g); g.Move(suggestedMove); g.AddRandomNumber(); if (g.Score > 7000) goto outOfHere; } gameCount++; totalScore += g.Score; if (gameCount % 100 == 0) Console.WriteLine(totalScore / gameCount); } outOfHere: Console.WriteLine(); Console.Write(g); Console.WriteLine("Score: " + g.Score); Console.ReadLine(); }
WorldPhysics worldPhysics = WorldPhysics.DefaultWorldPhysics; //Physics object used on this map. Attributes may be specified in the map file. #endregion Fields #region Constructors //Construct a levelstate object public LevelState(Game game, PlayerState player, string mapName) : base(game, player) { Activated += delegate { game.Display.Renderer.SetFont("verdana", 8); }; playerInfo = player; this.game = game; this.display = game.Display; this.mapName = mapName; // game.Display.CameraX = 50; //game.Display.CameraY = 100; //Load map MapDescriptor map = game.Resources.GetMapDescriptor(mapName); objectFactory = new ObjectFactory(game, this); tileMap = new TileMap(game.Display, game.Resources, map); //And set up the world physics attributes if (map.ExtraProperties.ContainsKey("gravity")) worldPhysics.Gravity = double.Parse(map.ExtraProperties["gravity"]); if (map.ExtraProperties.ContainsKey("ground-friction-factor")) worldPhysics.GroundFrictionFactor = double.Parse(map.ExtraProperties["ground-friction-factor"]); //Spawn all objects foreach (var o in map.Objects) { GameObject obj = objectFactory.Spawn(o.Name, new Vector(o.X, o.Y), new Vector(0,-100), worldPhysics); if (obj != null) { objects.Add(obj); if (o.Name == "mario") { this.player = (Player)objects[objects.Count-1]; } } } //Set the map background if (!string.IsNullOrEmpty(map.Background)) background = new ParallaxBackground(game.Resources.GetTexture(map.Background), 0.5, 0.2, game.Display); camera = new Camera(display, 0, map.Width * map.TileSize, 0, map.Height * map.TileSize); game.Audio.PlayMusic("overworld-intro", "overworld"); icons["coin"] = objectFactory.CreateIcon("coin", 0.7); //new Icon(game, Helpers. icons["mario"] = objectFactory.CreateIcon("mario-big", 0.5); //new Icon(game, marioIcon); }
public MapEditorState(Game game, EditorModel model) : base(game) { this.model = model; model.AddListener(this); display = game.Display; renderer = display.Renderer; input = game.Input; model.Display = display; model.Zoom = display.Zoom; }
public MainWindow() { InitializeComponent(); CultureInfo newCulture = new CultureInfo("ru-RU"); Thread.CurrentThread.CurrentCulture = newCulture; Thread.CurrentThread.CurrentUICulture = newCulture; _drawer = new WpfDrawer(canvas1, listBox1, heroListBox, listBoxDateTime); _game = new Engine.Game(_drawer, (uint)canvas1.Width, (uint)canvas1.Height); CompositionTarget.Rendering += DrawSnapshot; }
public static void Main(string[] args) { Game game = new Game(); game.Initialize(800, 600, false); game.PushState(new TestState()); game.MaxFPS = 60; game.Display.Zoom = 100; //game.Display.CameraX = game.Display.ViewportWidth / 2; //game.Display.CameraY = game.Display.ViewportHeight / 2; while (!game.Done) { game.Run(); } }
/// <summary> /// Run the main game loop /// </summary> public void MainLoop() { game = new Game(); game.Initialize(1024, 768, false, "HIAGE Map Editor"); game.PushState(new MapEditorState(game, model)); model.ResourceManager = game.Resources; //model.CurrentTileset = model.ResourceManager.GetTileset("grassland"); //while (!game.Done && model.Running) { game.Run(); } Application.Quit(); }
public static void Main(string[] args) { Game game = new Game(); game.Initialize(800, 600, false, "Hiage Mario"); game.MaxFPS = 60; game.Display.Zoom = 150; //Log.OutputStreamWriter = new StreamWriter("log.txt"); PlayerState initialState = new PlayerState(); initialState.HealthStatus = PlayerState.Health.Small; game.PushState(new LevelState(game, initialState, "level1")); //game.PushState(new LevelState(null, game, "minimap")); //game.PushState(new LevelState(null, game, "test_multi")); game.Run(); }
//Construct a game object. Set controller to null if the object should be static. public GameObject(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, Dictionary<string, BoundingPolygon> boundingPolygons) { this.game = game; this.boundingPolygons = boundingPolygons; Sprites = sprites; CurrentSprite = sprites[defaultSprite]; Velocity = velocity; Position = position; this.renderer = game.Display.Renderer; this.controller = controller; //boundingPolygon.MoveTo(Position.X, Position.Y); CanCollide = true; SetupStates(); }
/// <summary> /// Konstraktor /// </summary> /// <param name="gameType">tipe game (1.(player vs player) atau 2.(player vs computer))</param> public MainForm(int gameType) { InitializeComponent(); this.DoubleBuffered = true; b = new Board(); snakes = b.Snakes; ladders = b.Ladders; convert = new Converter(); game = new Game(b, new Dice(), gameType); if (gameType == 1) { playerAvatars = new Bitmap[] { new Bitmap(Properties.Resources.player1), new Bitmap(Properties.Resources.player2) }; } else { playerAvatars = new Bitmap[] { new Bitmap(Properties.Resources.player1), new Bitmap(Properties.Resources.playerComp) }; } }
void Start() { balls = new Dictionary <e.Color, int> { { e.Color.Red, redBallsCount }, { e.Color.Green, greenBallsCount }, { e.Color.Blue, blueBallsCount }, { e.Color.Purple, purpleBallsCount }, { e.Color.Yellow, yellowBallsCount } }; ballHistory = e.BallHistory.GetInstance(); ballHistory.Clear(); var basket = new e.Bascket(e.Color.Green, 3, 7); var basket2 = new e.Bascket(e.Color.Green, 1, 7); var basket3 = new e.Bascket(e.Color.Green, 2, 7); this.game = new e.Game(); game.AddObject(basket); game.AddObject(basket2); game.AddObject(basket3); }
public GameState(Game game) { this.game = game; }
public MarioGameState(Game game, PlayerState state) : base(game) { PlayerState = state; }
public ObjectFactory(Game game, MarioGameState state) { this.game = game; this.state = state; }
public About(Game game) { InitializeComponent(); DataContext = game; }
private void SetPlayerSessionGame(Game game) { _playerSession = new PlayerSession(game); DataContext = _playerSession.Game; }
public PlayerSession(Game game) { Game = game; }
//CollidableObject o1 = new CollidableObject(55, 53, new Vector(-30, -70)), o2 = new CollidableObject(-40, -30, new Vector(0, 0)); //CollidableObject o1 = new CollidableObject(-20, 25, new Vector(0, -10)), o2 = new CollidableObject(-35, -25, new Vector(0, 0)); public void Initialize(Game game) { this.game = game; tilemap = new TileMap(game.Display, game.Resources.GetTileset("grassland"), 10, 10, 10, -50, -50, 32); Log.Write("Edges: "); foreach (Edge e in tilemap.AllEdges) { Log.Write("" + e); } }
public Coin(Game game, Vector position, Dictionary<string, Sprite> sprites, string defaultSprite, Dictionary<string, BoundingPolygon> polygons) : base(game, position, new Vector(0,0), sprites, defaultSprite, null, polygons) { CurrentSprite.PlayAnimation("normal", true); }