Esempio n. 1
0
        public static LocomotionManager <UnitModelComponent> CreatePushJourney(GameCourseModel model, UnitModelComponent unit, MyHexPosition target)
        {
            var journeySteps = new Queue <IJourneyStep <UnitModelComponent> >();

            journeySteps.Enqueue(new JourneyDisplacement()
            {
                To = target
            });
            journeySteps.Enqueue(new JourneyPassiveOnlyBattle());

            var delta = target - unit.Model.Position;

            journeySteps.Enqueue(new JourneyStepRepeat()
            {
                Delta = delta,
                NextStepsGenerator = (to) => new List <IJourneyStep <UnitModelComponent> >()
                {
                    new JourneyMotion()
                    {
                        To = to
                    },
                    (new JourneyPassiveOnlyBattle())
                }
            });
            return(new LocomotionManager <UnitModelComponent>(unit, journeySteps));
        }
Esempio n. 2
0
        public List <IJourneyStep <UnitModelComponent> > GenerateFinalSteps(GameCourseModel model, UnitModelComponent locomotionTarget)
        {
            var target       = locomotionTarget.PawnModel.Position;
            var journeySteps = new List <IJourneyStep <UnitModelComponent> >();

            if (model.IsRepeatField(target))
            {
                var nextField = target + Delta;

                if ((!model.HasTileAt(nextField)) || model.HasUnitAt(nextField))
                {
                    journeySteps.Add(new JourneyDeath());
                }
                else
                {
                    journeySteps.AddRange(NextStepsGenerator(nextField));
                    journeySteps.Add(new JourneyStepRepeat()
                    {
                        Delta = Delta,
                        NextStepsGenerator = NextStepsGenerator
                    });
                }
            }
            return(journeySteps);
        }
Esempio n. 3
0
        public JourneyStepPairs <T> AdvanceJourney(GameCourseModel model)
        {
            Assert.IsTrue(_journeySteps.Any() || _currentStep != null, "There are no more steps to do");
            IJourneyStep <T> nextStep = null;

            if (_journeySteps.Any())
            {
                nextStep = _journeySteps.Dequeue();
            }
            var steps = new JourneyStepPairs <T>()
            {
                PreviousStep = _currentStep,
                NextStep     = nextStep
            };

            _currentStep = nextStep;
            if (_currentStep != null)
            {
                _currentAnimation = _currentStep.CreateAnimation(model, _locomotionTarget);
                _currentAnimation.StartAnimation();

                if (!_journeySteps.Any())
                {
                    _currentStep.GenerateFinalSteps(model, _locomotionTarget).ForEach(c => _journeySteps.Enqueue(c));
                }
            }
            return(steps);
        }
 public IAnimation CreateAnimation(GameCourseModel model, ProjectileModelComponent animationTarget)
 {
     return(new CompositeAnimation(new List <IAnimation>()
     {
         new ProjectileConstantSpeedMotionAnimation(animationTarget, From, To),
         new PerpetualSpinningAnimation(animationTarget)
     }));
 }
Esempio n. 5
0
        public static LocomotionManager <UnitModelComponent> CreateMovementJourney(GameCourseModel model, UnitModelComponent unit, MyHexPosition target)
        {
            Assert.IsFalse(unit.Model.Position.Equals(target), "Unit is arleady at target");

            // todo, now it supports movement by only one hex, should be more
            Orientation targetOrientation = Orientation.N;

            for (int i = 0; i < 6; i++)
            {
                if (target.Equals(unit.Model.Position.Neighbors[i]))
                {
                    targetOrientation = unit.Model.Position.NeighborDirections[i];
                }
            }

            List <Orientation> transitionalOrientations = OrientationUtils.GetOrientationsToTarget(unit.Model.Orientation, targetOrientation);
            var journeySteps = new Queue <IJourneyStep <UnitModelComponent> >();

            foreach (var orientation in transitionalOrientations)
            {
                journeySteps.Enqueue(new JourneyDirector()
                {
                    To = orientation
                });
            }
            journeySteps.Enqueue(new JourneyBattle(BattleCircumstances.Director));
            journeySteps.Enqueue(new JourneyMotion()
            {
                To = target
            });
            journeySteps.Enqueue(new JourneyBattle(BattleCircumstances.Step));

            var delta = target - unit.Model.Position;

            journeySteps.Enqueue(new JourneyStepRepeat()
            {
                Delta = delta,
                NextStepsGenerator = (to) => new List <IJourneyStep <UnitModelComponent> >()
                {
                    new JourneyMotion()
                    {
                        To = to
                    },
                    (new JourneyBattle(BattleCircumstances.Step))
                }
            });

            return(new LocomotionManager <UnitModelComponent>(unit, journeySteps));
        }
Esempio n. 6
0
        public MagicUsage(MagicType type, MyHexPosition position, GameCourseModel model, MyPlayer player, CameraShake cameraShake, MasterSound masterSound)
        {
            _type            = type;
            _position        = position;
            _player          = player;
            _model           = model;
            _magicUsageEnded = false;

            if (type == MagicType.Earth) //todo ugly, should not be if, rather should be polymorphism
            {
                _animation = new EarthMagicUsageAnimation(model.GetTileAt(position).gameObject, cameraShake, masterSound);
            }
            else
            {
                _animation = new WindMagicUsageAnimation(model.GetTileAt(position).gameObject, cameraShake, masterSound);
            }
            _animation.StartAnimation();
        }
 private IJourneyStep <UnitModelComponent> GetInternalStep(GameCourseModel model)
 {
     if (_step == null)
     {
         if (model.HasTileAt(To) && !model.HasUnitAt(To))
         {
             _step = new JourneyMotion()
             {
                 To = To
             };
         }
         else
         {
             _step = new JourneyDeath();
         }
     }
     return(_step);
 }
Esempio n. 8
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(new RotationAnimation(locomotionTarget, To));
 }
Esempio n. 9
0
 public BattleResults ApplyStepToModel(GameCourseModel model, ProjectileModelComponent locomotionTarget)
 {
     return(model.PerformProjectileHitAtPlace(locomotionTarget.Model.Position));
 }
Esempio n. 10
0
 public List <IJourneyStep <ProjectileModelComponent> > GenerateFinalSteps(GameCourseModel model, ProjectileModelComponent locomotionTarget)
 {
     return(new List <IJourneyStep <ProjectileModelComponent> >());
 }
Esempio n. 11
0
 public bool ShouldRemoveUnitAfterStep(GameCourseModel model)
 {
     return(true);
 }
Esempio n. 12
0
 public IAnimation CreateAnimation(GameCourseModel model, ProjectileModelComponent animationTarget)
 {
     return(new EmptyAnimation());
 }
Esempio n. 13
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(BattleResults.Empty);
 }
Esempio n. 14
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent animationTarget)
 {
     return(GetInternalStep(model).CreateAnimation(model, animationTarget));
 }
Esempio n. 15
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(GetInternalStep(model).ApplyStepToModel(model, locomotionTarget));
 }
Esempio n. 16
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(model.PerformBattleAtPlace(locomotionTarget.Model.Position, _battleCircumstances));
 }
 public BattleResults ApplyStepToModel(GameCourseModel model, ProjectileModelComponent locomotionTarget)
 {
     model.MoveProjectile(locomotionTarget.Model, To);
     return(BattleResults.Empty);
 }
Esempio n. 18
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent animationTarget)
 {
     return(new UnitMotionAnimation(animationTarget, To));
 }
Esempio n. 19
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     model.FinalizeKillUnit(locomotionTarget.Model);
     return(BattleResults.Empty);
 }
Esempio n. 20
0
 public IAnimation EngagementAnimation(GameCourseModel courseMode, MasterSound sound, PawnModelComponent active, PawnModelComponent passive) => _effectUsageAnimationGenerator(courseMode, sound, active, passive);
Esempio n. 21
0
        public bool ShouldRemoveUnitAfterStep(GameCourseModel model)
        {
            var sr = GetInternalStep(model).ShouldRemoveUnitAfterStep(model);

            return(sr);
        }
Esempio n. 22
0
 public IAnimation CreateAnimation(GameCourseModel model, ProjectileModelComponent animationTarget)
 {
     return(new ProjectileConstantSpeedMotionAnimation(animationTarget, From, To));
 }
Esempio n. 23
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(new EmptyAnimation());
 }