示例#1
0
 public static int CalculateDamage(Actor a, IAttack attack, Actor d)
 {
     int maxDamage = CalculateMaximumDamage(a, attack, d);
     int avgAccuracy = a.ActorType.AccuracyTrend.Calculate(a.Level) + a.Level;
     int totalAccuracy = a.Accuracy + attack.Accuracy;
     int accuracyDelta = totalAccuracy - avgAccuracy;
     double minDamagePercentage = CalculateMinimumDamagePercentage(accuracyDelta);
     int minDamage = (int)(maxDamage * minDamagePercentage);
     return Game.Random.Next(minDamage, maxDamage);
 }
示例#2
0
        public void Move(Actor actor, Tile tile)
        {
            actor.Tile.Actor = null;

            actor.X = tile.X;
            actor.Y = tile.Y;

            tile.Actor = actor;
            actor.Tile = tile;
        }
示例#3
0
        public void AddActor(Actor actor, Tile tile)
        {
            actor.X = tile.X;
            actor.Y = tile.Y;

            Actors.Add(actor);

            tile.Actor = actor;
            actor.Tile = tile;
        }
示例#4
0
        public override ActionResult Process(Actor actor, Game game)
        {
            int newX = RTools.GetX(actor.X, Direction);
            int newY = RTools.GetY(actor.Y, Direction);

            // is space off map
            if (!game.Map.CheckLimits(newX, newY))
            {
                return ActionResult.Fail; // fail
            }

            // Is space collision free
            Tile tile = game.Map.Tiles[newY][newX];
            if (tile.IsSolid)
            {
                return ActionResult.Fail;  //fail
            }
            if (tile.Actor != null)
            {
                if (tile.Actor.IsPlayable == !(actor.IsPlayable))
                {
                    CombatAction action = new CombatAction();
                    action.Attack = new SwipeAttack();
                    action.Direction = Direction;
                    AlternateAction = action;
                    return ActionResult.Alternate;
                }
                else
                {
                    return ActionResult.Fail;
                }
            }//fail

            Move(actor, tile);
            return ActionResult.Success;
        }
示例#5
0
 public abstract ActionResult Process(Actor actor, Game game);
示例#6
0
 public static int CalculateMaximumDamage(Actor a, IAttack attack, Actor d)
 {
     int totalAttack = a.Attack + attack.Attack;
     int totalDefence = d.Defence;
     return Math.Abs(totalAttack - totalDefence);
 }
示例#7
0
 public void RemoveActor(Actor actor)
 {
     Actors.Remove(actor);
     actor.Tile.Actor = null;
     actor.Tile = null;
     if (Hero == actor) Hero = null;
 }
示例#8
0
 public void ReportCombat(CombatAction action, Actor owner)
 {
     if (action.Defender == null)
     {
         Display.Info("No one to attack");
     }
     else
     {
         Display.Info(String.Format("{2} gave {0} ({3}hp) {1} dmg", action.Defender.Name, action.Damage, owner.Name, action.Defender.Health));
         if (action.Defender.Health == 0) Display.Info(String.Format("{1} killed {0}!", action.Defender.Name, owner.Name));
     }
 }