Ejemplo n.º 1
0
        // Every Entity needs an Update sequence. This is where we do the bulk of our checking for things.
        public override void Update()
        {
            // Let's not do anything if the Strawberry is waiting for seeds.
            if (WaitingOnSeeds)
            {
                return;
            }

            if (!collected)
            {
                // Subtle up-and-down movement sequence.
                wobble  += Engine.DeltaTime * 4f;
                sprite.Y = bloom.Y = light.Y =
                    (float)Math.Sin(wobble) * 2f;

                // We'll check collection rules for our strawberry here. It's standard collection rules, so...
                if (Follower.Leader != null)
                {
                    Player player = Follower.Leader.Entity as Player;

                    // First in line of the normal-collection train?
                    if (Follower.DelayTimer <= 0f && StrawberryRegistry.IsFirstStrawberry(this))
                    {
                        if (player != null && player.Scene != null &&
                            !player.StrawberriesBlocked && player.OnSafeGround &&
                            player.StateMachine.State != 13)
                        {
                            // lot of checks!
                            collectTimer += Engine.DeltaTime;
                            if (collectTimer > 0.15f)
                            {
                                OnCollect();
                            }
                        }
                        else
                        {
                            collectTimer = Math.Min(collectTimer, 0f);
                        }
                    }
                    // Not first in line?
                    else if (Follower.FollowIndex > 0)
                    {
                        collectTimer = -0.15f;
                    }
                }
            }

            // This spawns glittery particles if we're carrying the berry!
            if (Follower.Leader != null && Scene.OnInterval(0.08f))
            {
                ParticleType type;
                if (!isOwned)
                {
                    type = P_Glow;
                }
                else
                {
                    type = P_GhostGlow;
                }

                SceneAs <Level>().ParticlesFG.Emit(type, Position + Calc.Random.Range(-Vector2.One * 6f, Vector2.One * 6f));
            }

            base.Update();
        }
Ejemplo n.º 2
0
 public void orig_Update()
 {
     if (WaitingOnSeeds)
     {
         return;
     }
     if (!collected)
     {
         if (!Winged)
         {
             wobble += Engine.DeltaTime * 4f;
             Sprite     obj        = sprite;
             BloomPoint bloomPoint = bloom;
             float      num2       = light.Y = (float)Math.Sin(wobble) * 2f;
             obj.Y = (bloomPoint.Y = num2);
         }
         int followIndex = Follower.FollowIndex;
         if (Follower.Leader != null && Follower.DelayTimer <= 0f && StrawberryRegistry.IsFirstStrawberry(this))
         {
             bool flag = false;
             if (Follower.Leader.Entity is Player player && player.Scene != null && !player.StrawberriesBlocked)
             {
                 if (Golden)
                 {
                     if (player.CollideCheck <GoldBerryCollectTrigger>() || (Scene as Level).Completed)
                     {
                         flag = true;
                     }
                 }
                 else if (player.OnSafeGround && (!Moon || player.StateMachine.State != 13))
                 {
                     flag = true;
                 }
             }
             if (flag)
             {
                 collectTimer += Engine.DeltaTime;
                 if (collectTimer > 0.15f)
                 {
                     OnCollect();
                 }
             }
             else
             {
                 collectTimer = Math.Min(collectTimer, 0f);
             }
         }
         else
         {
             if (followIndex > 0)
             {
                 collectTimer = -0.15f;
             }
             if (Winged)
             {
                 Y += flapSpeed * Engine.DeltaTime;
                 if (flyingAway)
                 {
                     if (Y < (SceneAs <Level>().Bounds.Top - 16))
                     {
                         RemoveSelf();
                     }
                 }
                 else
                 {
                     flapSpeed = Calc.Approach(flapSpeed, 20f, 170f * Engine.DeltaTime);
                     if (Y < start.Y - 5f)
                     {
                         Y = start.Y - 5f;
                     }
                     else if (Y > start.Y + 5f)
                     {
                         Y = start.Y + 5f;
                     }
                 }
             }
         }
     }
     base.Update();
     if (Follower.Leader != null && Scene.OnInterval(0.08f))
     {
         ParticleType type = isGhostBerry ? Strawberry.P_GhostGlow : (Golden ? Strawberry.P_GoldGlow : ((!Moon) ? Strawberry.P_Glow : Strawberry.P_MoonGlow));
         SceneAs <Level>().ParticlesFG.Emit(type, Position + Calc.Random.Range(-Vector2.One * 6f, Vector2.One * 6f));
     }
 }