예제 #1
0
 public Battery(Vector2 position, EntityID id) : base(position)
 {
     ID           = id;
     Collider     = new Hitbox(12f, 12f, -6f, -6f);
     Add(follower = new Follower(id));
     Add(new PlayerCollider(OnPlayer));
     Add(new MirrorReflection());
     Add(sprite = FactoryHelperModule.SpriteBank.Create("battery"));
     sprite.CenterOrigin();
     sprite.Play("rotating");
     Add(new TransitionListener
     {
         OnOut = delegate
         {
             StartedUsing = false;
             if (!IsUsed)
             {
                 if (tween != null)
                 {
                     tween.RemoveSelf();
                     tween = null;
                 }
                 if (alarm != null)
                 {
                     alarm.RemoveSelf();
                     alarm = null;
                 }
                 Turning        = false;
                 Visible        = true;
                 sprite.Visible = true;
                 sprite.Rate    = 1f;
                 sprite.Scale   = Vector2.One;
                 sprite.Play("rotating");
                 sprite.Rotation = 0f;
                 wiggler.Stop();
                 follower.MoveTowardsLeader = true;
             }
         }
     });
     Add(wiggler = Wiggler.Create(0.4f, 4f, delegate(float v)
     {
         sprite.Scale = Vector2.One * (1f + v * 0.35f);
     }));
     Add(light = new VertexLight(Color.LightSeaGreen, 1f, 32, 48));
 }