示例#1
0
 private void ExecuteRestorePrecentageStatus(RestorePercentageStatus status, Team team)
 {
     foreach (IFighter fighter in team.Fighters)
     {
         ExecuteRestorePrecentageStatus(status, fighter);
     }
 }
        public override bool AreEqual(Status status)
        {
            bool areEqual = false;

            RestorePercentageStatus restoreStatus = status as RestorePercentageStatus;

            if (restoreStatus != null)
            {
                areEqual = Math.Abs(restoreStatus.Percentage - Percentage) < .01;
            }

            return(areEqual);
        }
示例#3
0
        private void ExecuteTurnEndStatus(Status status, object sender)
        {
            RestorePercentageStatus restoreStatus = status as RestorePercentageStatus;


            if (restoreStatus != null)
            {
                Team senderAsTeam = sender as Team;

                IFighter senderAsFighter = sender as IFighter;

                if (senderAsTeam != null)
                {
                    ExecuteRestorePrecentageStatus(restoreStatus, senderAsTeam);
                }
                else if (senderAsFighter != null)
                {
                    ExecuteRestorePrecentageStatus(restoreStatus, senderAsFighter);
                }
            }
        }
示例#4
0
        private void ExecuteRestorePrecentageStatus(RestorePercentageStatus status, IFighter fighter)
        {
            if (fighter == null)
            {
                throw new ArgumentException("RestorePercentageStatus somehow given to something that is not an IFighter!");
            }

            int restoreAmount;

            switch (status.RestorationType)
            {
            case RestorationType.Health:
                restoreAmount = (int)(fighter.MaxHealth * status.Percentage);
                fighter.Heal(restoreAmount);
                break;

            case RestorationType.Mana:
                restoreAmount = (int)(fighter.MaxMana * status.Percentage);
                fighter.RestoreMana(restoreAmount);
                break;
            }
        }