Example #1
0
        public Bubbler(EntityData data, Vector2 offset) : base(data.Position + offset)
        {
            visible  = data.Bool("visible", false);
            Collider = new Hitbox(14f, 14f, 0f, 0f);
            Collider.CenterOrigin();
            Add(new PlayerCollider(new Action <Player>(OnPlayer), null, null));
            color = ColorHelper.GetColor(data.Attr("color", "White"));

            nodes = data.NodesOffset(offset);

            if (visible)
            {
                Add(sprite = new Sprite(GFX.Game, "objects/FrostHelper/bubble"));
                sprite.AddLoop("idle", "", 0.1f);
                sprite.CenterOrigin();
                sprite.Play("idle", false, false);
                sprite.SetColor(color);
                Add(previewSprite = new Sprite(GFX.Game, "objects/FrostHelper/bubble"));
                previewSprite.AddLoop("idle", "", 0.1f);
                previewSprite.CenterOrigin();
                previewSprite.Play("idle", false, false);
                previewSprite.Position = nodes.Last() - Position;
                previewSprite.SetColor(new Color(color.R, color.G, color.B, 128f) * 0.3f);
            }
        }
Example #2
0
        public Player(float x, float y) : base(x, y)
        {
            // Add a simple graphic.
            AddGraphic(imageRect);
            imageRect.CenterOrigin();

            // Add a hitbox and center it.
            SetHitbox(10, 24);
            Hitbox.CenterOrigin();

            // Create controls to use for platforming movement.
            var axis       = Axis.CreateArrowKeys();
            var jumpButton = new Button().AddKey(Key.Space);

            // Create the platforming movement and adjust some values.
            var platformingMovement = new PlatformingMovement(300, 1000, 15);

            platformingMovement.JumpStrength = 500;
            platformingMovement.Acceleration[AccelType.Ground] = 100;
            platformingMovement.Acceleration[AccelType.Air]    = 10;

            // Register the controls with the platforming movement.
            platformingMovement.JumpButton = jumpButton;
            platformingMovement.Axis       = axis;

            // Register the Solid tag as a collidable surface.
            platformingMovement.AddCollision(CollisionTag.Solid);

            // Register the Entity's hitbox as the platforming collider.
            platformingMovement.Collider = Hitbox;

            // Add all the components.
            AddComponents(
                axis,
                jumpButton,
                platformingMovement
                );

            /*
             * ======== Notes
             * INPUT:
             * The platforming movement component relies on an axis for movement, and
             * a button for jumping.  The axis and button are not updated by the
             * platforming movement, so they must be updated from another source.
             * Adding the axis and jump button to the Entity ensures that they are
             * updated.
             *
             * COLLIDING WITH STUFF:
             * The AddCollision method will register a tag with the platforming
             * movement to use as solid ground.  There is also a method for registering
             * a tag as a jump through platform.
             *
             * The platforming movement also needs a Collider to be set to its Collider
             * field.  This will be the collider that the platforming movement uses
             * as the primary collider when checking for solids and jump through
             * platforms.
             */
        }
Example #3
0
 public BiggestTonk(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0", 4);
     spritemap.Add(Animation.Shoot, "0-16", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     cooldown = scene.random.Next(60 * 2, 60 * 3);
     scene.Add(this);
     SetHitbox(187, 80, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #4
0
 public Turret(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0, 1", 4);
     spritemap.Add(Animation.Shoot, "2-17", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     scene.Add(this);
     cooldown = scene.random.Next(2 * 60, 3 * 60);
     SetHitbox(170, 80, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #5
0
 public Rocket(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0", 4);
     spritemap.Add(Animation.Shoot, "0,1,2,3,4,5,6,7, 8,9,10,8,9,10,8,9,10,8,9,10,8,9,10,8,9,10,8,9,10,8,9,10,8,9,10,8,9,10, 11,12,13,14,15,16,11,12,13,14,15,16,11,12,13,14,15,16,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     cooldown = scene.random.Next(60 * 4, 60 * 5);
     scene.Add(this);
     SetHitbox(124, 110, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #6
0
 public Sniper(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0", 4);
     spritemap.Add(Animation.Shoot, "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22", 3).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     cooldown = scene.random.Next(60 * 2, 60 * 3);
     scene.Add(this);
     SetHitbox(66, 27, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #7
0
 public Mortar(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0", 4);
     spritemap.Add(Animation.Shoot, "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     cooldown = scene.random.Next(60 * 1, 60 * 2);
     scene.Add(this);
     SetHitbox(40, 42, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #8
0
 public Minigun(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0, 1, 2, 3", 4);
     spritemap.Add(Animation.Shoot, "4-20", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     scene.Add(this);
     this.cooldown = scene.random.Next(60 * 4, 60 * 6);
     SetHitbox(128, 63, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #9
0
 public FatTonk(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, "0, 1", 4);
     spritemap.Add(Animation.Shoot, "2-17", 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     cooldown = scene.random.Next(60 * 1, 60 * 2);
     scene.Add(this);
     SetHitbox(130, 62, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #10
0
 public Soldier(float x, float y) : base(x, y)
 {
     spritemap.Add(Animation.Idle, scene.GetAnimationString(0, 0), 5).NoRepeat();
     spritemap.Add(Animation.Throw, scene.GetAnimationString(0, 11), 4).NoRepeat();
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     runtime = (int)spritemap.Anim(Animation.Idle).TotalDuration *scene.random.Next(3, 4);
     AddGraphic(spritemap);
     scene.Add(this);
     SetHitbox(43, 42, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
 }
Example #11
0
        /*public override void Render() {
         *      base.Render();
         *
         *      for (int i = 0; i < Colliders.Count; ++i) {
         *              Colliders[i].Render();
         *      }
         * }*/

        public override void Update()
        {
            sprite.Alpha = alpha;

            // Scale breath
            sprite.ScaleY += Rand.Float(scaleSpeed) * scaleVelocity;
            scaleVelocity  = Util.Lerp(scaleVelocity, scaleDirection, 0.05f);
            var difference = sprite.ScaleY - (1 - maxScaleDistance);

            if (Math.Abs(difference) > maxScaleDistance)
            {
                if (Math.Sign(difference) == scaleDirection)
                {
                    scaleDirection *= -1;
                }
            }

            switch (curState)
            {
            case State.Idle:
                IdleUpdate();
                break;

            case State.Swim:
                SwimUpdate();
                break;
            }

            base.Update();

            // Set hitbox size/position
            var hOffset = Util.Rotate(hitboxOffset, sprite.Angle);

            Hitbox.CenterOrigin();
            Hitbox.Width    = Math.Abs(hOffset.Y) * 10 + 70;
            Hitbox.Height   = Math.Abs(hOffset.X) * 10 + 70;
            Hitbox.OriginX += hOffset.X;
            Hitbox.OriginY += hOffset.Y;

            // Set softspot positions
            setOffset(ref softSpot1, softSpot1Offset);
            setOffset(ref softSpot2, softSpot2Offset);
            setOffset(ref repelCollider, repelOffset);

            CheckCollision(softSpot1);
            CheckCollision(softSpot2);
        }
Example #12
0
        public Flippy(Session session) : base()
        {
            Session = session;

            Image.OutlineThickness = 3;
            Image.OutlineColor     = Color.Orange;

            Graphic = Image;

            SetHitbox(10, 10);
            Hitbox.CenterOrigin();
            Image.CenterOrigin();

            AddComponent(Movement);
            Movement.Collider = Hitbox;

            Y = Game.Instance.HalfWidth;
            X = 120;
        }
Example #13
0
 public MyPlayer(int x, int y)
 {
     this.level = 0;
     //this.stage = 0;
     this.gold  = 0;
     this.honor = 0;
     spritemap.Add(Animation.Idle, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15", 4);
     spritemap.Add(Animation.IdleToShooting, "16,17,18,19", 2).NoRepeat();
     spritemap.Add(Animation.Spin, "19", 2).NoRepeat();
     spritemap.Add(Animation.ShootingToIdle, "19,18,17,16", 2).NoRepeat();
     spritemap.Add(Animation.Shoot, "20,21,22,23,24", 2);
     spritemap.CenterOrigin();
     spritemap.Play(Animation.Idle);
     AddGraphic(spritemap);
     this.X = x;
     this.Y = y;
     SetHitbox(140, 61, ColliderTags.Garbage);
     Hitbox.CenterOrigin();
     //Sound.GlobalVolume = 0.1f;
 }
Example #14
0
        public Player(float x, float y, Session session) : base(x, y)
        {
            // Assign session
            this.session = session;

            // Init bounce sounds
            bounce[0] = new Sound("assets/sfx/bounce1.wav");
            bounce[1] = new Sound("assets/sfx/bounce2.wav");
            bounce[2] = new Sound("assets/sfx/bounce3.wav");
            for (int i = 0; i < 3; ++i)
            {
                bounce[i].Volume = 0.98f;
            }

            // Set up animations
            sprite.Add(AnimType.Go, new Anim(new int[] { 0, 1, 2, 3, 4, }, new float[] { 5.0f }));
            sprite.Add(AnimType.Attack, new Anim(new int[] { 7, 8, 9, 10, 11, 12, 13 }, new float[] { 4.0f }));
            sprite.Play(AnimType.Go);

            // Set up hitboxes
            SetHitbox(sprite.Width - 24, sprite.Height - 24, (int)Tags.PLAYER);
            Hitbox.CenterOrigin();

            // Sprite stuff
            sprite.CenterOrigin();
            Graphic = sprite;

            Layer = -1;

            // Initilize light
            light = new Light();
            light.SetAlpha(0.7f);
            light.SetColor(new Color("879DFF"), new Color("62D8E0"));
            light.SetColorSpan(5.0f);
            light.SetRadius(sprite.Width + 30, sprite.Width + 60);
            light.SetRadiusSpan(5.0f);
            light.entity = this;
            Level.lights.Add(light);

            // TODO: Make ink slow you down
        }
Example #15
0
 public Corner(int x, int y) : base(x + size.X * 0.5f, y + size.Y * 0.5f)
 {
     SetHitbox((int)size.X + 80, (int)size.Y + 80, (int)Tags.SOLID);
     Hitbox.CenterOrigin();
 }
Example #16
0
        public FlyingGurnard(Entity target) : base(960, 540, 20, 10.0f)
        {
            // Initialize sprite
            sprite.CenterOrigin();
            Graphic = sprite;

            // Set the target
            this.target = target;

            // Set up hitbox (actually realized with the repel collider this hitbox is useless)
            SetHitbox(200, 200, -1);
            Hitbox.CenterOrigin();
            Hitbox.OriginX += hitboxOffset.X;
            Hitbox.OriginY += hitboxOffset.Y;

            // Make it so the player can't touch the enemy
            repelCollider.CenterOrigin();
            AddCollider(repelCollider);

            // Set up soft spots
            softSpot1.CenterOrigin();
            softSpot1.OriginX += softSpot1Offset.X;
            softSpot1.OriginY += softSpot1Offset.Y;

            softSpot2.CenterOrigin();
            softSpot2.OriginX += softSpot2Offset.X;
            softSpot2.OriginY += softSpot2Offset.Y;

            AddColliders(softSpot1, softSpot2);

            softlight1 = new Light();
            softlight1.SetAlpha(0.0f);
            softlight1.SetColor(new Color("C42679"));
            softlight1.SetRadius(300.0f);
            softlight1.SetOffset(softSpot1Offset);
            softlight1.entity = this;
            Level.lights.Add(softlight1);

            softlight2 = new Light();
            softlight2.SetAlpha(0.0f);
            softlight2.SetColor(new Color("C42679"));
            softlight2.SetRadius(300.0f);
            softlight2.SetOffset(softSpot2Offset);
            softlight2.entity = this;
            Level.lights.Add(softlight2);

            // Lights
            eye1 = new Light(0, 4.0f);
            eye1.SetAlpha(0.6f);
            eye1.SetRadius(100.0f);
            eye1offset = new Vector2(-170, 50);
            eye1.SetOffset(eye1offset);
            eye1.entity = this;
            Level.lights.Add(eye1);

            eye2 = new Light(0, 4.0f);
            eye2.SetAlpha(0.6f);
            eye2.SetRadius(100.0f);
            eye2offset = new Vector2(-170, -15);
            eye2.SetOffset(eye2offset);
            eye2.entity = this;
            Level.lights.Add(eye2);

            // Reset direction to right
            direction = new Vector2(0, 1);

            // Set max speed
            maxspeed = 30.0f;
        }
Example #17
0
 public Explosions(float x, float y, ExplosionType type, int delay, bool isVehicleDestruction) : base(x, y)
 {
     explosion_sound_library.Add(new Sound("Assets/Sounds/explosion_big.ogg")
     {
         Loop = false
     });
     explosion_sound_library.Add(new Sound("Assets/Sounds/explosion_09.ogg")
     {
         Loop = false
     });
     explosion_sound_library.Add(new Sound("Assets/Sounds/explosion_10.ogg")
     {
         Loop = false
     });
     explosion_sound_library.Add(new Sound("Assets/Sounds/explosion_11.ogg")
     {
         Loop = false
     });
     explosion_sound_library.Add(new Sound("Assets/Sounds/explosion_12.ogg")
     {
         Loop = false
     });
     this.type = type;
     this.isVehicleDestruction = isVehicleDestruction;
     sound = explosion_sound_library[scene.random.Next(1, 5)];
     if (this.type == ExplosionType.small)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_small.png", 32, 48);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 27), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
     }
     else if (this.type == ExplosionType.medium)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_medium.png", 70, 70);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 27), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
     }
     else if (this.type == ExplosionType.big)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_big.png", 80, 96);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 27), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
     }
     else if (this.type == ExplosionType.huge)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_huge.png", 113, 137);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 23), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
         Hitbox.SetPosition(0, -137 / 2);
         spritemap.SetPosition(0, -137 / 2);
         sound = explosion_sound_library[0];
         //Console.WriteLine(X + "," + Y);
     }
     else if (this.type == ExplosionType.shell_normal)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_shell_normal.png", 60, 112);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 26), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
         Hitbox.SetPosition(0, -112 / 2);
         spritemap.SetPosition(0, -112 / 2);
     }
     else if (this.type == ExplosionType.shell_big)
     {
         spritemap = new Spritemap <Animation>("Assets/Img/Sprites/Explosions/explosion_shell_big.png", 68, 170);
         spritemap.Add(Animation.explosion, scene.GetAnimationString(0, 29), 3).NoRepeat();
         SetHitbox(spritemap.TextureRegion.Width, spritemap.TextureRegion.Height, ColliderTags.Garbage);
         Hitbox.SetPosition(0, -170 / 2);
         spritemap.SetPosition(0, -170 / 2);
     }
     if (isVehicleDestruction)
     {
         Hitbox.Width  *= 2;
         Hitbox.Height *= 2;
     }
     spritemap.CenterOrigin();
     Hitbox.CenterOrigin();
     this.delay = delay;
     Layer      = -600;
 }