コード例 #1
0
ファイル: Humanoid.cs プロジェクト: grsu-PY/ITGame
 private void SetNewSurfaceRule(SurfaceAffectEventArgs e)
 {
     switch (HumanoidRace)
     {
         case HumanoidRace.Dwarf:
             switch (e.surfaceType)
             {
                 case ITGame.CLI.Models.Environment.SurfaceType.Ground:
                     ApplySurfaceRule(e.actionRule, bonus: true, bonusRate: 1.2);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Water:
                     ApplySurfaceRule(e.actionRule, bonus: true, bonusRate: 0.2);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Lava:
                     ApplySurfaceRule(e.actionRule, bonus: false, bonusRate: 0.8);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Swamp:
                     ApplySurfaceRule(e.actionRule, bonus: false, bonusRate: 0.6);
                     break;
                 default:
                     break;
             }
             break;
         case HumanoidRace.Elf:
             switch (e.surfaceType)
             {
                 case ITGame.CLI.Models.Environment.SurfaceType.Ground:
                     ApplySurfaceRule(e.actionRule, bonus: true);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Water:
                     ApplySurfaceRule(e.actionRule, bonus: true);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Lava:
                     ApplySurfaceRule(e.actionRule, bonus: false, bonusRate: 1.5);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Swamp:
                     ApplySurfaceRule(e.actionRule, bonus: false);
                     break;
                 default:
                     break;
             }
             break;
         case HumanoidRace.Human:
             switch (e.surfaceType)
             {
                 case ITGame.CLI.Models.Environment.SurfaceType.Ground:
                     ApplySurfaceRule(e.actionRule, bonus: true);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Water:
                     ApplySurfaceRule(e.actionRule, bonus: true, bonusRate: 0.5);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Lava:
                     ApplySurfaceRule(e.actionRule, bonus: false);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Swamp:
                     ApplySurfaceRule(e.actionRule, bonus: false, bonusRate: 0.5);
                     break;
                 default:
                     break;
             }
             break;
         case HumanoidRace.Orc:
             switch (e.surfaceType)
             {
                 case ITGame.CLI.Models.Environment.SurfaceType.Ground:
                     ApplySurfaceRule(e.actionRule, bonus: true);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Water:
                     ApplySurfaceRule(e.actionRule, bonus: false);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Lava:
                     ApplySurfaceRule(e.actionRule, bonus: false, bonusRate: 0.8);
                     break;
                 case ITGame.CLI.Models.Environment.SurfaceType.Swamp:
                     ApplySurfaceRule(e.actionRule, bonus: true);
                     break;
                 default:
                     break;
             }
             break;
         default:
             break;
     }
 }
コード例 #2
0
ファイル: Creature.cs プロジェクト: grsu-PY/ITGame
 protected abstract void OnSurfaceChangedHandler(object sender, SurfaceAffectEventArgs e);
コード例 #3
0
ファイル: Humanoid.cs プロジェクト: grsu-PY/ITGame
        protected override void OnSurfaceChangedHandler(object sender, SurfaceAffectEventArgs e)
        {
            if (e.surfaceType == _lastSurfaceType) return;//могут ли сюда прийти новые правила для старой поверхности?

            OnActionPerformed(new ActionPerformedEventArgs(
                string.Format("Oh, look at this, {0}. Surface was changed to {1}", Name, e.surfaceType),
                ActionType.Info)
                );

            RemoveOldSurfaceBonus();

            _lastSurfaceRule = e.actionRule;
            _lastSurfaceType = e.surfaceType;

            SetNewSurfaceRule(e);
        }