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));
        }
Beispiel #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);
        }
        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)
     }));
 }
        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));
        }
Beispiel #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);
 }
Beispiel #8
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(new RotationAnimation(locomotionTarget, To));
 }
Beispiel #9
0
 public BattleResults ApplyStepToModel(GameCourseModel model, ProjectileModelComponent locomotionTarget)
 {
     return(model.PerformProjectileHitAtPlace(locomotionTarget.Model.Position));
 }
Beispiel #10
0
 public List <IJourneyStep <ProjectileModelComponent> > GenerateFinalSteps(GameCourseModel model, ProjectileModelComponent locomotionTarget)
 {
     return(new List <IJourneyStep <ProjectileModelComponent> >());
 }
Beispiel #11
0
 public bool ShouldRemoveUnitAfterStep(GameCourseModel model)
 {
     return(true);
 }
Beispiel #12
0
 public IAnimation CreateAnimation(GameCourseModel model, ProjectileModelComponent animationTarget)
 {
     return(new EmptyAnimation());
 }
Beispiel #13
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(BattleResults.Empty);
 }
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent animationTarget)
 {
     return(GetInternalStep(model).CreateAnimation(model, animationTarget));
 }
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     return(GetInternalStep(model).ApplyStepToModel(model, locomotionTarget));
 }
Beispiel #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);
 }
Beispiel #18
0
 public IAnimation CreateAnimation(GameCourseModel model, UnitModelComponent animationTarget)
 {
     return(new UnitMotionAnimation(animationTarget, To));
 }
Beispiel #19
0
 public BattleResults ApplyStepToModel(GameCourseModel model, UnitModelComponent locomotionTarget)
 {
     model.FinalizeKillUnit(locomotionTarget.Model);
     return(BattleResults.Empty);
 }
Beispiel #20
0
 public IAnimation EngagementAnimation(GameCourseModel courseMode, MasterSound sound, PawnModelComponent active, PawnModelComponent passive) => _effectUsageAnimationGenerator(courseMode, sound, active, passive);
        public bool ShouldRemoveUnitAfterStep(GameCourseModel model)
        {
            var sr = GetInternalStep(model).ShouldRemoveUnitAfterStep(model);

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