Beispiel #1
0
        private bool _selected = false; //I guess as in "currently doing something"

        #endregion Fields

        #region Constructors

        public Shot(Stat _soldierStat, string _type)
            : base()
        {
            type = _type;

            if (Texture == null)
                LoadContent();

            //Transform.World.Origin = new Vector2(16, 16);

            Stat = _soldierStat;

            if (type == "Rocket")
            {
                Stat.Strength = 50000;
            }

            this.Color = Color.White;
            var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
            rc.Offset = new Vector2(16, 16);
            AddComponent(rc);

            var cc = new Collision(this, 32, 32);
            AddComponent(cc);
        }
Beispiel #2
0
        private bool _selected; //I guess as in "currently doing something"

        #endregion Fields

        #region Constructors

        public SmallEnemy(ref List<SmallEnemy> swarm)
            : base()
        {
            if (Texture == null)
                LoadContent();

            this.Swarm = swarm;

            Transform.World.Origin = new Vector2(20, 16);

            this.Color = Color.White;
            var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
            AddComponent(rc);

            var cc = new Collision(this, 32, 32);
            cc.Solid = true;
            AddComponent(cc);

            var pfc = new PathFinder(this);
            AddComponent(pfc);

            var stat = new Component.Stat(this)
                           {
                               Life = 50,
                               Defence = 25,
                               Strength = 70,
                               GetAim = 100,
                               GetDodge = 50
                           };
            AddComponent(stat);
        }
Beispiel #3
0
 public static bool AttackTest(Stat attacker, Entity defender, int chanceToHit)
 {
     Component.Stat shooting = attacker;
     Component.Stat dodging = defender.GetComponent<Component.Stat>();
     Random rand = new Random();
     if (rand.Next(0, 100) < chanceToHit)
     {
         dodging.Life -= shooting.Strength - dodging.Defence / 2;
         return true;
     }
     return false;
 }
Beispiel #4
0
        public static bool AttackTest(Stat attacker, Entity defender, int chanceToHit)
        {
            Component.Stat shooting = attacker;
            Component.Stat dodging  = defender.GetComponent <Component.Stat>();
            Random         rand     = new Random();

            if (rand.Next(0, 100) < chanceToHit)
            {
                dodging.Life -= shooting.Strength - dodging.Defence / 2;
                return(true);
            }
            return(false);
        }
Beispiel #5
0
        public Soldier(ref List <Soldier> squad)
            : base()
        {
            if (Texture == null)
            {
                LoadContent();
            }

            this.Squad = squad;

            Transform.World.Origin = new Vector2(16, 16);

            this.Color = Color.White;
            var rc = new SpriteRenderer(this)
            {
                Texture = Texture, Color = Color.White
            };

            AddComponent(rc);

            var cc = new Collision(this, 32, 32);

            AddComponent(cc);

            var pfc = new PathFinder(this);

            AddComponent(pfc);

            var flashlight = new Flashlight(this)
            {
                Intensity = 0.8f
            };

            AddComponent(flashlight);

            var stat = new Component.Stat(this)
            {
                MaxHP    = 100,
                MaxPanic = 100,
                Life     = 100,
                Defence  = 25,
                Strength = 50,
                GetAim   = 40,
                GetDodge = 20
            };

            AddComponent(stat);
        }
Beispiel #6
0
 /// <summary>
 /// Calculate the chance of an entity with a Stat component to hit another unit.
 /// </summary>
 /// <param name="attacker">The attacking unit.</param>
 /// <param name="defender">The recieving unit.</param>
 /// <returns>Returns a hit chance percentage.</returns>
 public static int CalculateHitChance(Stat attacker, Vector2 attackerPosition, Entity defender)
 {
     Stat shooting = attacker;
     Stat dodging = defender.GetComponent<Stat>();
     if (shooting == null || dodging == null)
     {
         return 0;
     }
     int baseHitChance = shooting.GetAim;
     int baseDodgeChance = dodging.GetDodge;
     int distance = (int)Vector2.Distance(attackerPosition, defender.Transform.World.Position);
     int basePenalty = shooting.Penalty(distance / (Grid.TileSize));
     Console.WriteLine("Penalty = " + basePenalty);
     int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
     //Console.WriteLine(chanceToHit);
     return chanceToHit;
 }
Beispiel #7
0
        public SmallEnemy(ref List <SmallEnemy> swarm)
            : base()
        {
            if (Texture == null)
            {
                LoadContent();
            }

            this.Swarm = swarm;

            Transform.World.Origin = new Vector2(20, 16);

            this.Color = Color.White;
            var rc = new SpriteRenderer(this)
            {
                Texture = Texture, Color = Color.White
            };

            AddComponent(rc);

            var cc = new Collision(this, 32, 32);

            cc.Solid = true;
            AddComponent(cc);

            var pfc = new PathFinder(this);

            AddComponent(pfc);

            var stat = new Component.Stat(this)
            {
                Life     = 50,
                Defence  = 25,
                Strength = 70,
                GetAim   = 100,
                GetDodge = 50
            };

            AddComponent(stat);
        }
Beispiel #8
0
        public Soldier(ref List<Soldier> squad)
            : base()
        {
            if (Texture == null)
                LoadContent();

            this.Squad = squad;

            Transform.World.Origin = new Vector2(16, 16);

            this.Color = Color.White;
            var rc = new SpriteRenderer(this) {Texture = Texture, Color = Color.White};
            AddComponent(rc);

            var cc = new Collision(this, 32, 32);
            AddComponent(cc);

            var pfc = new PathFinder(this);
            AddComponent(pfc);

            var flashlight = new Flashlight(this)
                {
                    Intensity = 0.8f
                };
            AddComponent(flashlight);

            var stat = new Component.Stat(this)
                           {
                               MaxHP = 100,
                               MaxPanic = 100,
                               Life = 100,
                               Defence = 25,
                               Strength = 50,
                               GetAim = 40,
                               GetDodge = 20
                           };
            AddComponent(stat);
        }