public HealthPowerUp(DecimalPoint location, GameWorld gameWorld)
     : base(location, gameWorld)
 {
     Image = Properties.Resources.heart;
     health = 500;
     DropChance = 50;
 }
Пример #2
0
        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;
        }
Пример #3
0
        /// <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;
 }
Пример #5
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());
 }
Пример #6
0
        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;
        }
Пример #7
0
 protected Character(GameWorld gameWorld, DecimalPoint location)
 {
     Location       = location;
     GameWorld      = gameWorld;
     MotionBehavior = new NormalMotionBehavior(this, gameWorld);
     Targets        = new List <Type>();
     Init();
 }
Пример #8
0
 /// <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 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());
 }
 public EvasiveMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint targetLocation) : base(gameObject, gw)
 {
     TargetLocation   = targetLocation;
     MinRange         = 200;
     MidRange         = 400;
     MaxRange         = 1000;
     this.targetSpeed = gameObject.TargetSpeed;
 }
Пример #11
0
 /// <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;
 }
Пример #12
0
 protected Character(GameWorld gameWorld, DecimalPoint location)
 {
     Location = location;
     GameWorld = gameWorld;
     MotionBehavior = new NormalMotionBehavior(this, gameWorld);
     Targets = new List<Type>();
     Init();
 }
 public EvasiveMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint targetLocation)
     : base(gameObject, gw)
 {
     TargetLocation = targetLocation;
     MinRange = 200;
     MidRange = 400;
     MaxRange = 1000;
     this.targetSpeed = gameObject.TargetSpeed;
 }
Пример #14
0
 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();
 }
Пример #15
0
        /// <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);
        }
Пример #16
0
 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();
 }
Пример #17
0
 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();
 }
Пример #18
0
        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;
        }
Пример #19
0
 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;
 }
Пример #20
0
        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;
        }
Пример #21
0
 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();
 }
Пример #22
0
 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;
 }
Пример #23
0
 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;
 }
Пример #24
0
        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);
            }
        }
Пример #25
0
        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;
        }
Пример #26
0
        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;
        }
Пример #27
0
 protected override DecimalPoint VisitDecimalPoint(DecimalPoint node)
 {
     visitedDecimalPoint = true;
     Assert.IsTrue(node.Value == ".");
     return(base.VisitDecimalPoint(node));
 }
Пример #28
0
        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;
 }
Пример #30
0
 protected Enemy(GameWorld gameWorld, DecimalPoint location)
     : base(gameWorld, location)
 {
     Targets.Add(typeof(Player));
     Target = gameWorld.Player;
 }
Пример #31
0
 public MotionEventArgs(DecimalPoint distanceMoved, double totalDistanceMoved)
 {
     DistanceMoved      = distanceMoved;
     TotalDistanceMoved = totalDistanceMoved;
 }
Пример #32
0
 protected Enemy(GameWorld gameWorld, DecimalPoint location) : base(gameWorld, location)
 {
     Targets.Add(typeof(Player));
     Target = gameWorld.Player;
 }
 public CircleMotionBehavior(IGameObject gameObject, GameWorld gw, DecimalPoint center) : base(gameObject, gw)
 {
     Center = center;
     Range  = 200;
     angle  = 0;
 }
Пример #34
0
        /// <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);
        }
Пример #36
0
 public OffensiveMotionBehavior(IGameObject gameObject, GameWorld gameWorld, DecimalPoint targetLocation)
     : base(gameObject, gameWorld)
 {
     this.TargetLocation = targetLocation;
 }
Пример #37
0
 public HealthPowerUp(DecimalPoint location, GameWorld gameWorld) : base(location, gameWorld)
 {
     Image      = Properties.Resources.heart;
     health     = 500;
     DropChance = 50;
 }
Пример #38
0
 public DecimalPoint GetDistance(DecimalPoint location, DecimalPoint destination)
 {
     return(new DecimalPoint(Math.Abs(location.X - destination.X), Math.Abs(location.Y - destination.Y)));
 }
Пример #39
0
 public double GetDistance(DecimalPoint location, DecimalPoint destination)
 {
     return  Math.Sqrt(Math.Pow(location.X - destination.X, 2) + Math.Pow(location.Y - destination.Y, 2));
 }
Пример #40
0
 public IEnumerable<IGameObject> GetClosestGameObjects(DecimalPoint location, int range)
 {
     return GameObjects.Where(x => GetDistance(location, x.Location) < range && x.IsPhysicalObject);
 }
Пример #41
0
        /// <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;
        }
Пример #42
0
 protected virtual DecimalPoint VisitDecimalPoint(DecimalPoint node)
 {
     return(VisitSyntaxNode(node) as DecimalPoint);
 }
Пример #43
0
        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;
        }
Пример #44
0
 public IEnumerable <IGameObject> GetClosestGameObjects(DecimalPoint location, int range)
 {
     return(GameObjects.Where(x => GetDistance(location, x.Location) < range && x.IsPhysicalObject));
 }
Пример #45
0
 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;
 }
Пример #46
0
 public double GetDistance(DecimalPoint location, DecimalPoint destination)
 {
     return(Math.Sqrt(Math.Pow(location.X - destination.X, 2) + Math.Pow(location.Y - destination.Y, 2)));
 }
Пример #47
0
 public MotionEventArgs(DecimalPoint distanceMoved, double totalDistanceMoved)
 {
     DistanceMoved = distanceMoved;
     TotalDistanceMoved = totalDistanceMoved;
 }