Esempio n. 1
0
        public MarioShell(EntityData data, Vector2 offset) : base(data.Position + offset)
        {
            colors  = new List <Color>();
            timeAcc = 0;

            bool lights = data.Bool("lights", false);

            texture   = data.Attr("texture", "koopa");
            dangerous = data.Bool("dangerous", dangerousTextures.ContainsKey(texture) && dangerousTextures[texture]);
            disco     = data.Bool("disco", false);
            grabbable = data.Bool("grabbable", true);

            String rawColor = data.Attr("color", "Green");

            colorSpeed = data.Float("colorSpeed", 0.8f);

            foreach (String s in rawColor.Split(','))
            {
                colors.Add(ColorHelper.GetColor(s));
            }

            int direction = Math.Sign(data.Int("direction", 0));

            Speed = new Vector2(baseSpeed * direction, 0f);
            grace = 0f;

            prevLiftspeed = Vector2.Zero;

            pickupIdleCollider   = new Hitbox(18f, 18f, -9, -9);
            pickupMovingCollider = new Hitbox(0f, 0f, 0f, 0f);

            shellHeldCollider    = new Hitbox(8f, 14f, -4f, -7f);
            shellNotHeldCollider = new Hitbox(14f, 14f, -7f, -7f);

            Add(new PlayerCollider(new Action <Player>(OnPlayer)));
            Collider = shellNotHeldCollider;

            onCollideH = new Collision(OnCollideH);
            onCollideV = new Collision(OnCollideV);

            Add((Component)(decorationIdle = new Sprite(GFX.Game, $"objects/pandorasBox/shells/{texture}/deco_idle")));
            decorationIdle.AddLoop("deco_idle", "", 0.1f);
            decorationIdle.Play("deco_idle", true, false);
            decorationIdle.CenterOrigin();

            Add((Component)(shellIdle = new Sprite(GFX.Game, $"objects/pandorasBox/shells/{texture}/shell_idle")));
            shellIdle.AddLoop("shell_idle", "", 0.1f);
            shellIdle.Play("shell_idle", true, false);
            shellIdle.CenterOrigin();
            shellIdle.Color = colors[0];

            Add((Component)(decorationMoving = new Sprite(GFX.Game, $"objects/pandorasBox/shells/{texture}/deco_moving")));
            decorationMoving.AddLoop("deco_moving", "", 0.1f);
            decorationMoving.Play("deco_moving", true, false);
            decorationMoving.CenterOrigin();

            Add((Component)(shellMoving = new Sprite(GFX.Game, $"objects/pandorasBox/shells/{texture}/shell_moving")));
            shellMoving.AddLoop("shell_moving", "", 0.1f);
            shellMoving.Play("shell_moving", true, false);
            shellMoving.CenterOrigin();
            shellMoving.Color = colors[0];

            Add((Component)(Hold = new Holdable()));
            Hold.PickupCollider = new Hitbox(18f, 18f, -9, -9);
            Hold.OnPickup       = new Action(OnPickup);
            Hold.OnRelease      = new Action <Vector2>(OnRelease);
            Hold.SpeedGetter    = () => Speed;
            Hold.DangerousCheck = DangerousCheck;
            Hold.OnHitSpring    = HitSpring;

            decorationMoving.Visible = shellMoving.Visible = false;

            id = data.ID;

            if (lights)
            {
                Add((Component)(bloom = new BloomPoint(1f, 16f)));
                Add((Component)(light = new VertexLight(Collider.Center, Color.White, 1f, 8, 24)));

                bloom.Visible = light.Visible = true;
            }
        }