Example #1
0
 public Trooper(long id, int x, int y, long playerId,
                int teammateIndex, bool isTeammate, TrooperType type, TrooperStance stance,
                int hitpoints, int maximalHitpoints, int actionPoints, int initialActionPoints,
                double visionRange, double shootingRange, int shootCost,
                int standingDamage, int kneelingDamage, int proneDamage, int damage,
                bool isHoldingGrenade, bool isHoldingMedikit, bool isHoldingFieldRation)
     : base(id, x, y)
 {
     this.playerId             = playerId;
     this.teammateIndex        = teammateIndex;
     this.isTeammate           = isTeammate;
     this.type                 = type;
     this.stance               = stance;
     this.hitpoints            = hitpoints;
     this.maximalHitpoints     = maximalHitpoints;
     this.actionPoints         = actionPoints;
     this.initialActionPoints  = initialActionPoints;
     this.visionRange          = visionRange;
     this.shootingRange        = shootingRange;
     this.shootCost            = shootCost;
     this.standingDamage       = standingDamage;
     this.kneelingDamage       = kneelingDamage;
     this.proneDamage          = proneDamage;
     this.damage               = damage;
     this.isHoldingGrenade     = isHoldingGrenade;
     this.isHoldingMedikit     = isHoldingMedikit;
     this.isHoldingFieldRation = isHoldingFieldRation;
 }
Example #2
0
 public Trooper(long id, int x, int y, long playerId,
     int teammateIndex, bool isTeammate, TrooperType type, TrooperStance stance,
     int hitpoints, int maximalHitpoints, int actionPoints, int initialActionPoints,
     double visionRange, double shootingRange, int shootCost,
     int standingDamage, int kneelingDamage, int proneDamage, int damage,
     bool isHoldingGrenade, bool isHoldingMedikit, bool isHoldingFieldRation)
     : base(id, x, y)
 {
     this.playerId = playerId;
     this.teammateIndex = teammateIndex;
     this.isTeammate = isTeammate;
     this.type = type;
     this.stance = stance;
     this.hitpoints = hitpoints;
     this.maximalHitpoints = maximalHitpoints;
     this.actionPoints = actionPoints;
     this.initialActionPoints = initialActionPoints;
     this.visionRange = visionRange;
     this.shootingRange = shootingRange;
     this.shootCost = shootCost;
     this.standingDamage = standingDamage;
     this.kneelingDamage = kneelingDamage;
     this.proneDamage = proneDamage;
     this.damage = damage;
     this.isHoldingGrenade = isHoldingGrenade;
     this.isHoldingMedikit = isHoldingMedikit;
     this.isHoldingFieldRation = isHoldingFieldRation;
 }
Example #3
0
 private void SetVisible(double visionRange, TrooperStance stance, int x, int y)
 {
     for (var i = 0; i < Width; i++)
     {
         for (var j = 0; j < Height; j++)
         {
             circle_visible[0, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Prone);
             circle_visible[1, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Kneeling);
             circle_visible[2, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Standing);
         }
     }
 }
Example #4
0
 int GetStanceId(TrooperStance stance)
 {
     if (stance == TrooperStance.Prone)
     {
         return(0);
     }
     if (stance == TrooperStance.Kneeling)
     {
         return(1);
     }
     if (stance == TrooperStance.Standing)
     {
         return(2);
     }
     throw new InvalidDataException();
 }
Example #5
0
 int GetMoveCost(TrooperStance stance)
 {
     if (stance == TrooperStance.Prone)
     {
         return(game.ProneMoveCost);
     }
     if (stance == TrooperStance.Kneeling)
     {
         return(game.KneelingMoveCost);
     }
     if (stance == TrooperStance.Standing)
     {
         return(game.StandingMoveCost);
     }
     throw new InvalidDataException();
 }
Example #6
0
        public int GetDamage(TrooperStance stance)
        {
            switch (stance)
            {
            case TrooperStance.Prone:
                return(proneDamage);

            case TrooperStance.Kneeling:
                return(kneelingDamage);

            case TrooperStance.Standing:
                return(standingDamage);

            default:
                throw new ArgumentException("Unsupported stance: " + stance + '.');
            }
        }
Example #7
0
        public bool IsVisible(
            double maxRange,
            int viewerX, int viewerY, TrooperStance viewerStance,
            int objectX, int objectY, TrooperStance objectStance)
        {
            int minStanceIndex = Math.Min((int)viewerStance, (int)objectStance);
            int xRange         = objectX - viewerX;
            int yRange         = objectY - viewerY;

            return(xRange * xRange + yRange * yRange <= maxRange * maxRange &&
                   cellVisibilities[
                       viewerX * height * width * height * StanceCountHolder.STANCE_COUNT
                       + viewerY * width * height * StanceCountHolder.STANCE_COUNT
                       + objectX * height * StanceCountHolder.STANCE_COUNT
                       + objectY * StanceCountHolder.STANCE_COUNT
                       + minStanceIndex
                   ]);
        }
Example #8
0
 // Возврящает ShootingRange с учетом бонуса
 double GetShootingRange(Trooper trooper, TrooperStance stance)
 {
     return(GetShootingRange(trooper, GetStanceId(stance)));
 }
Example #9
0
 public int GetDamage(TrooperStance stance)
 {
     switch (stance)
     {
         case TrooperStance.Prone:
             return proneDamage;
         case TrooperStance.Kneeling:
             return kneelingDamage;
         case TrooperStance.Standing:
             return standingDamage;
         default:
             throw new ArgumentException("Unsupported stance: " + stance + '.');
     }
 }
Example #10
0
 int HowManyCanShoot(Point position, TrooperStance stance)
 {
     return Opponents.Count(
         trooper => world.IsVisible(GetShootingRange(self, self.Stance), position.X, position.Y, stance, trooper.X, trooper.Y, trooper.Stance)
     );
 }
Example #11
0
 private void SetVisible(double visionRange, TrooperStance stance, int x, int y)
 {
     for (var i = 0; i < Width; i++)
     {
         for (var j = 0; j < Height; j++)
         {
             circle_visible[0, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Prone);
             circle_visible[1, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Kneeling);
             circle_visible[2, i, j] |= world.IsVisible(visionRange, x, y, stance, i, j, TrooperStance.Standing);
         }
     }
 }
Example #12
0
        public bool IsVisible(
            double maxRange,
            int viewerX, int viewerY, TrooperStance viewerStance,
            int objectX, int objectY, TrooperStance objectStance)
        {
            int minStanceIndex = Math.Min((int) viewerStance, (int) objectStance);
            int xRange = objectX - viewerX;
            int yRange = objectY - viewerY;

            return xRange * xRange + yRange * yRange <= maxRange * maxRange
                && cellVisibilities[
                viewerX * height * width * height * StanceCountHolder.STANCE_COUNT
                + viewerY * width * height * StanceCountHolder.STANCE_COUNT
                + objectX * height * StanceCountHolder.STANCE_COUNT
                + objectY * StanceCountHolder.STANCE_COUNT
                + minStanceIndex
                ];
        }
Example #13
0
 int HowManyCanShoot(Point position, TrooperStance stance)
 {
     return(Opponents.Count(
                trooper => world.IsVisible(GetShootingRange(self, self.Stance), position.X, position.Y, stance, trooper.X, trooper.Y, trooper.Stance)
                ));
 }
Example #14
0
 public MyTrooper(Trooper trooper)
     : base(trooper.Id, trooper.X, trooper.Y)
 {
     this.playerId = trooper.PlayerId;
     this.teammateIndex = trooper.TeammateIndex;
     this.isTeammate = trooper.IsTeammate;
     this.type = trooper.Type;
     this.stance = trooper.Stance;
     this.hitpoints = trooper.Hitpoints;
     this.maximalHitpoints = trooper.MaximalHitpoints;
     this.actionPoints = trooper.ActionPoints;
     this.initialActionPoints = trooper.InitialActionPoints;
     this.visionRange = trooper.VisionRange;
     this.shootingRange = trooper.ShootingRange;
     this.shootCost = trooper.ShootCost;
     this.standingDamage = trooper.StandingDamage;
     this.kneelingDamage = trooper.KneelingDamage;
     this.proneDamage = trooper.ProneDamage;
     this.damage = trooper.Damage;
     this.isHoldingGrenade = trooper.IsHoldingGrenade;
     this.isHoldingMedikit = trooper.IsHoldingMedikit;
     this.isHoldingFieldRation = trooper.IsHoldingFieldRation;
 }
Example #15
0
 public double GetVisionRange(Trooper viewer, Trooper objectTr, TrooperStance objectStance)
 {
     return(GetVisionRange(viewer, objectTr, GetStanceId(objectStance)));
 }
Example #16
0
 bool IsCanUpper(TrooperStance stance, int actionPoints)
 {
     return(stance != TrooperStance.Standing && actionPoints >= game.StanceChangeCost);
 }
Example #17
0
 bool IsVisible(int x, int y, TrooperStance stance = TrooperStance.Prone)
 {
     return(Team.Any(
                trooper => world.IsVisible(trooper.VisionRange, trooper.X, trooper.Y, trooper.Stance, x, y, stance)
                ));
 }