public PersistentRunningTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName)
     : base(achievementManager, entityWorld, achievementName)
 {
     Ensure.Is<FloatProgression>(_achievement.Progression);
     _progression = (FloatProgression)_achievement.Progression;
     _playerTransform = _entityWorld.FindEntityByName(EntityNames.Player).Transform;
     _previousPosition = _playerTransform.Position;
 }
 public SurviveWithoutMovingTracker(AchievementManager achievementManager, EntityWorld entityWorld, string achievementName, float seconds)
     : base(achievementManager, entityWorld, achievementName)
 {
     Ensure.Is<BooleanProgression>(_achievement.Progression);
     _targetSeconds = seconds;
     _playerTransform = entityWorld.FindEntityByName(EntityNames.Player).Transform;
     _previousPosition = _playerTransform.Position;
 }
        protected override void Initialize()
        {
            _playerTransform = this.EntityWorld.FindEntityByName(EntityNames.Player).Get<CTransform2D>();
            _previousPosition = _playerTransform.Transform.Position;

            this.EntityWorld.SubscribeToMessage<ZombieKilledMessage>(this.OnZombieKilled);
            this.EntityWorld.SubscribeToMessage<GameExitMessage>(this.OnGameExit);
            this.EntityWorld.SubscribeToMessage<GameOverMessage>(this.OnGameOver);
        }
        private void UpdateEscaping(UpdateContext updateContext, CGoldenGoblinAI goldenGoblinAI, CTransform2D transform, float speedMultiplier)
        {
            // Escape speed is a bit faster than normal speed (3.5f)
            const float Speed = SkypieaConstants.PixelsPerMeter * 4f;

            Vector2 velocity = FlaiMath.NormalizeOrZero(transform.Position - _playerTransform.Transform.Position) * Speed * speedMultiplier * updateContext.DeltaSeconds;
            goldenGoblinAI.Velocity = FlaiMath.ClampLength(goldenGoblinAI.Velocity + velocity, Speed);

            transform.Position += goldenGoblinAI.Velocity * updateContext.DeltaSeconds;
            transform.RotationVector = goldenGoblinAI.Velocity;

            // if the goblin is outside the map, delete it
            if (!SkypieaConstants.MapAreaInPixels.Inflate(128, 128).Contains(transform.Position))
            {
                goldenGoblinAI.Entity.Delete();
            }
        }
示例#5
0
        private Segment2D GetLaserSegment(CTransform2D rayStartTransform, EntityWorld entityWorld)
        {
            Ray2D ray = new Ray2D(rayStartTransform);
            RectangleF cameraArea = SkypieaConstants.GetAdjustedCameraArea(CCamera2D.Active);
            Vector2 rayEndPoint;
            if (!ray.Intersects(cameraArea, out rayEndPoint))
            {
                return new Segment2D(-Vector2.One * 1000, -Vector2.One * 1000);
            }

            return new Segment2D(ray.Position, rayEndPoint);
        }
示例#6
0
 public static void TriggerBloodSplatter(CTransform2D transform, Vector2 direction)
 {
     IParticleEngine particleEngine = transform.Entity.EntityWorld.Services.Get<IParticleEngine>();
     particleEngine[ParticleEffectID.ZombieBloodSplatter].Trigger(transform.Position);
 }
示例#7
0
 public static void TriggerBloodSplatter(CTransform2D transform)
 {
     ZombieHelper.TriggerBloodSplatter(transform, Vector2.Zero);
 }
示例#8
0
        public static void TriggerBloodExplosion(CTransform2D transform, Vector2 velocity)
        {
            IParticleEngine particleEngine = transform.Entity.EntityWorld.Services.Get<IParticleEngine>();
            ParticleEffect effect = particleEngine[ParticleEffectID.ZombieExplosion];
            RotationalPointEmitter emitter = (RotationalPointEmitter)effect.Emitters[0].EmitterStyle;
            if (velocity == Vector2.Zero)
            {
                emitter.RotationalRange = Range.FullRotation;
                effect.Emitters[0].ReleaseParameters.Speed = ParticleEffectHelper.ZombieExplosionDefaultSpeed;
            }
            else
            {
                const float ExplosionRotationalBias = 1.15f;
                emitter.RotationalRange = Range.CreateCentered(FlaiMath.GetAngle(velocity), ExplosionRotationalBias);
                effect.Emitters[0].ReleaseParameters.Speed = new Range(0, velocity.Length());
            }

            effect.Trigger(transform.Position);
        }
 protected override void Initialize()
 {
     _playerTransform = this.EntityWorld.FindEntityByName(EntityNames.Player).Transform;
     _boosterState = this.EntityWorld.Services.Get<IBoosterState>();
     _zombieStatsProvider = this.EntityWorld.Services.Get<IZombieStatsProvider>();
 }
        // waypoint stun is atm 0 so this code doesn't even matter at all. but it should work just fine
        private void UpdateWaypointStun(UpdateContext updateContext, CGoldenGoblinAI goldenGoblinAI, CTransform2D transform)
        {
            // this is frame-rate dependent but shouldnt matter too much
            goldenGoblinAI.Velocity *= 0.98f;
            transform.Position += goldenGoblinAI.Velocity * updateContext.DeltaSeconds;

            if (goldenGoblinAI.WaypointStunTimer.HasFinished)
            {
                goldenGoblinAI.State = GoldenGoblinState.TravellingToWaypoint;
            }
        }
        private void UpdateTravelling(UpdateContext updateContext, CTransform2D transform, CGoldenGoblinAI goldenGoblinAI, float speedMultiplier)
        {
            const float Speed = SkypieaConstants.PixelsPerMeter * 3.5f;

            // calculate the new velocity
            Vector2 velocity = FlaiMath.NormalizeOrZero(goldenGoblinAI.CurrentWaypoint - transform.Position) * Speed * speedMultiplier; // * updateContext.DeltaSeconds;
            goldenGoblinAI.Velocity = FlaiMath.ClampLength(goldenGoblinAI.Velocity + velocity * updateContext.DeltaSeconds, Speed);
            goldenGoblinAI.Velocity += new Vector2(velocity.Y, velocity.X) * FlaiMath.Sin(updateContext.DeltaSeconds * 3) / 8;

            // if the goblin is near enough to a waypoint, move to the next waypoint
            if (Vector2.Distance(transform.Position, goldenGoblinAI.CurrentWaypoint) < SkypieaConstants.PixelsPerMeter * 2)
            {
                // if the current waypoint is the last one, then change the state to escape
                if (goldenGoblinAI.CurrentWaypointIndex + 1 >= goldenGoblinAI.Waypoints.Count)
                {
                    goldenGoblinAI.State = GoldenGoblinState.EscapingFromPlayer;
                    return;
                }

                // change state to WaypointStun
                goldenGoblinAI.CurrentWaypointIndex++;
                goldenGoblinAI.WaypointStunTimer.Restart();
                goldenGoblinAI.State = GoldenGoblinState.WaypointStun;

                if (goldenGoblinAI.CurrentWaypointIndex >= goldenGoblinAI.Waypoints.Count)
                {
                    goldenGoblinAI.CurrentWaypointIndex = goldenGoblinAI.CurrentWaypointIndex;
                }
            }
            else
            {
                // otherwise move to the current waypoint
                transform.Position += goldenGoblinAI.Velocity * updateContext.DeltaSeconds;
                transform.RotationVector = goldenGoblinAI.Velocity;
            }
        }