public HealthPowerUp(DecimalPoint location, GameWorld gameWorld) : base(location, gameWorld) { Image = Properties.Resources.heart; health = 500; DropChance = 50; }
public Player(Image image, GameWorld gameWorld) { double speed = 0.000001; this.MotionBehavior = new NormalMotionBehavior(this, gameWorld); MotionBehavior.CanMoveThroughWall = false; Location = new DecimalPoint(300, 150); Image = image; Angle = 0; ActualSpeed = 0; Acceleration = 0.3; TargetSpeed = 0; Inertia = new DecimalPoint(0.5, 0.5); DrawBehavior = new TopDownRotationDrawBehavior(this); //((GrowingImageDrawBehavior)DrawBehavior).SpeedX = 10; //((GrowingImageDrawBehavior)DrawBehavior).SpeedY = 10; //((GrowingImageDrawBehavior) DrawBehavior).SizeChanged += (Size) => //{ // if (Size.Width > 400) // { // ((GrowingImageDrawBehavior)DrawBehavior).SpeedX = -2; // ((GrowingImageDrawBehavior)DrawBehavior).SpeedY = -2; // } // if (((GrowingImageDrawBehavior) DrawBehavior).SpeedY < 0) // { // ((GrowingImageDrawBehavior)DrawBehavior).SpeedX = 0 - (int)speed; // ((GrowingImageDrawBehavior)DrawBehavior).SpeedY = 0 - (int)speed; // speed += speed; // } //}; Paralax = Paralax.Middleground; IsPhysicalObject = true; }
/// <summary> /// Checks if object is within the spcified range /// </summary> /// <param name="range">The range to check</param> /// <returns>Returns true if the object is within range</returns> public static bool IsInRange(DecimalPoint source, DecimalPoint destination, int range) { bool x = Math.Abs(source.X - destination.X) < range; bool y = Math.Abs(source.Y - destination.Y) < range; return(x && y); }
public CircleMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint center) : base(gameObject, gw) { Center = center; Range = 200; angle = 0; }
public CircleMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint center) : base(gameObject, gw) { Center = center; range = gw.GetDistance(center, gameObject.Location); Range = 180; angle = GameWorld.CalcAngle(GameObject.Location.ToPoint(), Center.ToPoint()); }
private void Init() { Energy = new Mana(300); Health = new Health(1000); DrawBehavior = new TopDownRotationDrawBehavior(this); Level = 1; Experience = new NormalExperience(); Inertia = new DecimalPoint(0.5, 0.5); Acceleration = 5; IsPhysicalObject = true; Paralax = Paralax.Middleground; SpellHandler = new SpellHandler(GameWorld, this); AttackMap = new Dictionary <ActionSlot, Func <Spell> >(); ExperienceWhenKilled = 300; Loot = new Loot(); Loot.Items.Add(new HealthPowerUp(Location, GameWorld)); Experience.LevelUp += Experience_LevelUp; Killed += Character_Killed; }
protected Character(GameWorld gameWorld, DecimalPoint location) { Location = location; GameWorld = gameWorld; MotionBehavior = new NormalMotionBehavior(this, gameWorld); Targets = new List <Type>(); Init(); }
/// <summary> /// MotionBehavior contructor /// </summary> /// <param name="gameObject">GameObject</param> /// <param name="gw">GameWorld</param> protected MotionBehavior(IGameObject gameObject, GameWorld gw) { this.GameObject = gameObject; this.gw = gw; Speed = new DecimalPoint(0, 0); NewSpeed = new DecimalPoint(0, 0); CanMoveThroughWall = false; }
public EvasiveMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint targetLocation) : base(gameObject, gw) { TargetLocation = targetLocation; MinRange = 200; MidRange = 400; MaxRange = 1000; this.targetSpeed = gameObject.TargetSpeed; }
/// <summary> /// MotionBehavior contructor /// </summary> /// <param name="gameObject">GameObject</param> /// <param name="gw">GameWorld</param> protected MotionBehavior(IGameObject gameObject, GameWorld gw) { this.GameObject = gameObject; this.Gw = gw; Speed = new DecimalPoint(0, 0); NewSpeed = new DecimalPoint(0, 0); CanMoveThroughWall = false; }
protected Character(GameWorld gameWorld, DecimalPoint location) { Location = location; GameWorld = gameWorld; MotionBehavior = new NormalMotionBehavior(this, gameWorld); Targets = new List<Type>(); Init(); }
public Monster(GameWorld gameWorld, DecimalPoint location) : base(gameWorld, location) { Image = Properties.Resources.MonsterSmall; Inertia.X = 2; Inertia.Y = 2; TargetSpeed = 7; DrawBehavior.IsCircle = true; MotionBehavior = new WanderingMotionBehavior(this, gameWorld); CreateAttackMap(); }
/// <summary> /// Checks if the object is within two ranges /// </summary> /// <param name="minRange">Minimum range</param> /// <param name="maxRange">Maximum range</param> /// <returns>Returns true if the object is within the two ranges</returns> public static bool IsInRange(DecimalPoint source, DecimalPoint destination, int minRange, int maxRange) { double x = Math.Abs(source.X - destination.X); double y = Math.Abs(source.Y - destination.Y); bool inX = x > minRange && x < maxRange; bool inY = y > minRange && x < maxRange; return(inX || inY); }
public Player(GameWorld gameWorld, DecimalPoint location) : base(gameWorld, location) { Image = Properties.Resources.Player; Acceleration = 2; Inertia.X = 2; Inertia.Y = 2; DrawBehavior.IsCircle = true; Health.Max = 5000; Health.Current = Health.Max; Targets.Add(typeof(Enemy)); CreateAttackMap(); }
protected PowerUp(DecimalPoint location, GameWorld gameWorld) { Location = location; GameWorld = gameWorld; GameWorld.Collision += gameWorld_Collision; Inertia = new DecimalPoint(0, 0); MotionBehavior = new StationaryMotionBehavior(this, gameWorld); Paralax = Paralax.Middleground; DrawBehavior = new TopDownRotationDrawBehavior(this); IsPhysicalObject = false; }
private void Init() { gw.Collision += gw_Collision; Acceleration = 2; Inertia = new DecimalPoint(5, 5); TargetSpeed = 30; MotionBehavior = new NormalMotionBehavior(this, gw); MotionBehavior.WallCollision += MotionBehavior_WallCollision; gw.GameObjects.Add(this); DrawBehavior = new TopDownRotationDrawBehavior(this); Paralax = Paralax.Foreground; IsPhysicalObject = false; }
public Enemy(Image image, GameWorld gameWorld) { Image = image; this.MotionBehavior = new NormalMotionBehavior(this, gameWorld); Location = new DecimalPoint(300, 150); Image = image; Angle = 0; ActualSpeed = 0; Acceleration = 0.3; TargetSpeed = 0; Inertia = new DecimalPoint(0.5, 0.5); DrawBehavior = new TopDownRotationDrawBehavior(this); Paralax = Paralax.Middleground; IsPhysicalObject = true; }
private void Init() { Tile t = new Tile(Resources.Grass, 0); TileRepository.Add(t); t = new Tile(Resources.Rock, 1); t.IsSolid = true; TileRepository.Add(t); Tile brick = new Tile(Properties.Resources.BrickWall, 2); brick.IsSolid = true; TileRepository.Add(brick); Tile grassstone = new Tile(Properties.Resources.FloorsMedieval, 3); grassstone.IsSolid = false; TileRepository.Add(grassstone); Player = CreatePlayer(); gameWorld.Player = Player; gameWorld.GameObjects.Add(Player); Random r = new Random(); for (int i = 0; i < 5; i++) { DecimalPoint loc; int x; int y; do { x = r.Next(2000); y = r.Next(2000); loc = new DecimalPoint(x, y); } while (gameWorld.GetTile(x / Tile.Width, y / Tile.Height).IsSolid); Enemy monster = new Monster(gameWorld, loc); gameWorld.GameObjects.Add(monster); } if (Loaded != null) { Loaded(this, EventArgs.Empty); } }
private void Init() { Acceleration = 5; Angle = Source.Target != null ? (int)GameWorld.CalcAngle(Source.Location.ToPoint(), Source.Target.Location.ToPoint()) : Source.Angle; Cost = 20; Damage = 200; DamageBehavior = new NormalDamageBehavior(Source, Source.Targets, (int)Damage); DrawBehavior = new TopDownRotationDrawBehavior(this); Inertia = new DecimalPoint(5, 5); ActualSpeed = Source.ActualSpeed; Location = new DecimalPoint(Source.Location.X, Source.Location.Y); MotionBehavior = new NormalMotionBehavior(this, GameWorld); Paralax = Paralax.Middleground; TargetSpeed = 20; IsPhysicalObject = false; MotionBehavior.CanMoveThroughObjects = true; SpellHandler = Source.SpellHandler; SpellHandler.Spells.Add(this); AttackBehaviors = new List <IAttackBehavior>(); GameWorld.Collision += GameWorld_Collision; GameWorld.Split += GameWorld_Split; }
protected override DecimalPoint VisitDecimalPoint(DecimalPoint node) { visitedDecimalPoint = true; Assert.IsTrue(node.Value == "."); return(base.VisitDecimalPoint(node)); }
private void Init() { Acceleration = 5; Angle = Source.Target != null ? (int)GameWorld.CalcAngle(Source.Location.ToPoint(), Source.Target.Location.ToPoint()) : Source.Angle; Cost = 20; Damage = 200; DamageBehavior = new NormalDamageBehavior(Source, Source.Targets, (int)Damage); DrawBehavior = new TopDownRotationDrawBehavior(this); Inertia = new DecimalPoint(5, 5); ActualSpeed = Source.ActualSpeed; Location = new DecimalPoint(Source.Location.X, Source.Location.Y); MotionBehavior = new NormalMotionBehavior(this, GameWorld); Paralax = Paralax.Middleground; TargetSpeed = 20; IsPhysicalObject = false; MotionBehavior.CanMoveThroughObjects = true; SpellHandler = Source.SpellHandler; SpellHandler.Spells.Add(this); AttackBehaviors = new List<IAttackBehavior>(); GameWorld.Collision += GameWorld_Collision; GameWorld.Split += GameWorld_Split; }
public OffensiveMotionBehavior(IGameObject gameObject, GameWorld gameWorld, DecimalPoint targetLocation) : base(gameObject, gameWorld) { this.TargetLocation = targetLocation; }
protected Enemy(GameWorld gameWorld, DecimalPoint location) : base(gameWorld, location) { Targets.Add(typeof(Player)); Target = gameWorld.Player; }
public MotionEventArgs(DecimalPoint distanceMoved, double totalDistanceMoved) { DistanceMoved = distanceMoved; TotalDistanceMoved = totalDistanceMoved; }
/// <summary> /// Checks if object is within the spcified range /// </summary> /// <param name="range">The range to check</param> /// <returns>Returns true if the object is within range</returns> public static bool IsInRange(DecimalPoint source, DecimalPoint destination, int range) { bool x = Math.Abs(source.X - destination.X) < range; bool y = Math.Abs(source.Y - destination.Y) < range; return x && y; }
private void Init() { Tile t = new Tile(Resources.Grass, 0); TileRepository.Add(t); t = new Tile(Resources.Rock, 1); t.IsSolid = true; TileRepository.Add(t); Tile brick = new Tile(Properties.Resources.BrickWall, 2); brick.IsSolid = true; TileRepository.Add(brick); Tile grassstone = new Tile(Properties.Resources.FloorsMedieval, 3); grassstone.IsSolid = false; TileRepository.Add(grassstone); Player = CreatePlayer(); gameWorld.Player = Player; gameWorld.GameObjects.Add(Player); Random r = new Random(); for (int i = 0; i < 5; i++) { DecimalPoint loc; int x; int y; do { x = r.Next(2000); y = r.Next(2000); loc = new DecimalPoint(x, y); } while (gameWorld.GetTile(x / Tile.Width, y / Tile.Height).IsSolid); Enemy monster = new Monster(gameWorld, loc); gameWorld.GameObjects.Add(monster); } if(Loaded != null) Loaded(this, EventArgs.Empty); }
public DecimalPoint GetDistance(DecimalPoint location, DecimalPoint destination) { return(new DecimalPoint(Math.Abs(location.X - destination.X), Math.Abs(location.Y - destination.Y))); }
public double GetDistance(DecimalPoint location, DecimalPoint destination) { return Math.Sqrt(Math.Pow(location.X - destination.X, 2) + Math.Pow(location.Y - destination.Y, 2)); }
public IEnumerable<IGameObject> GetClosestGameObjects(DecimalPoint location, int range) { return GameObjects.Where(x => GetDistance(location, x.Location) < range && x.IsPhysicalObject); }
/// <summary> /// Checks if the object is within two ranges /// </summary> /// <param name="minRange">Minimum range</param> /// <param name="maxRange">Maximum range</param> /// <returns>Returns true if the object is within the two ranges</returns> public static bool IsInRange(DecimalPoint source, DecimalPoint destination, int minRange, int maxRange) { double x = Math.Abs(source.X - destination.X); double y = Math.Abs(source.Y - destination.Y); bool inX = x > minRange && x < maxRange; bool inY = y > minRange && x < maxRange; return inX || inY; }
protected virtual DecimalPoint VisitDecimalPoint(DecimalPoint node) { return(VisitSyntaxNode(node) as DecimalPoint); }
private void Init() { Energy = new Mana(300); Health = new Health(1000); DrawBehavior = new TopDownRotationDrawBehavior(this); Level = 1; Experience = new NormalExperience(); Inertia = new DecimalPoint(0.5, 0.5); Acceleration = 5; IsPhysicalObject = true; Paralax = Paralax.Middleground; SpellHandler = new SpellHandler(GameWorld, this); AttackMap = new Dictionary<ActionSlot, Func<Spell>>(); ExperienceWhenKilled = 300; Loot = new Loot(); Loot.Items.Add(new HealthPowerUp(Location, GameWorld)); Experience.LevelUp += Experience_LevelUp; Killed += Character_Killed; }
public IEnumerable <IGameObject> GetClosestGameObjects(DecimalPoint location, int range) { return(GameObjects.Where(x => GetDistance(location, x.Location) < range && x.IsPhysicalObject)); }
public double GetDistance(DecimalPoint location, DecimalPoint destination) { return(Math.Sqrt(Math.Pow(location.X - destination.X, 2) + Math.Pow(location.Y - destination.Y, 2))); }