示例#1
0
        /// <summary>
        /// A circular field.
        /// </summary>
        public SystemicField(string affects, float amountPerFrame, float lifetime, float radius) : this(affects, amountPerFrame, lifetime)
        {
            Collider circle = new CircleCollider((int)radius, (int)CollisionTags.SystemicAreaOfEffect);

            circle.CenterOrigin();
            AddCollider(circle);
        }
示例#2
0
        private void setOffset(ref CircleCollider collider, Vector2 offset)
        {
            var o = Util.Rotate(offset, sprite.Angle);

            collider.CenterOrigin();
            collider.OriginX += o.X;
            collider.OriginY += o.Y;
        }
示例#3
0
        public PickupItem(float x = 0, float y = 0, Graphic graphic = null, Collider collider = null, string name = "")
            : base(x, y, graphic, collider, name)
        {
            Graphic  = graphic ?? Image.CreateCircle(ItemRadius, Color.Green);
            Collider = new CircleCollider(ItemRadius, Tag.PickupItem);

            Graphic.CenterOrigin();
            Collider.CenterOrigin();
        }
示例#4
0
 public Projectile(float x, float y, Vector2 direction, float speed, int radius, float lifespan, int damage, params int[] tags) : base(x, y)
 {
     direction.Normalize();
     this.velocity = direction * speed;
     this.lifespan = lifespan;
     Collider      = new CircleCollider(radius, tags);
     Collider.CenterOrigin();
     this.damage = damage;
 }
示例#5
0
        public FatFish(float x, float y, bool baby = false) : base(x, y, 10, 0.5f)
        {
            if (baby)
            {
                // TODO: Set scale
            }

            sprite.CenterOrigin();
            Graphic = sprite;

            Collider = new CircleCollider(50, (int)Tags.ENEMY, (int)Tags.FATFISH);
            Collider.CenterOrigin();

            // Initilize velocity values
            velocity     = new Vector2(0, 1);
            velocity     = Util.Rotate(velocity, Rand.Int(0, 360));
            minspeed     = 2.0f;
            sprite.Angle = Util.RAD_TO_DEG * (float)Math.Atan2(-velocity.Y, velocity.X) - 90;
            direction    = velocity;
        }
示例#6
0
        public Squid(float x, float y) : base(x, y, 10, 0.5f)
        {
            Graphic = sprite;
            sprite.CenterOrigin();

            Collider = new CircleCollider(40, (int)Tags.ENEMY, (int)Tags.ENEMYATTACK);
            Collider.CenterOrigin();

            // Set up sprite
            sprite.Add(AnimType.Go, new Anim(new int[] { 1, 2, 3, 4, 0, }, new float[] { 7.0f }));
            sprite.Add(AnimType.Ink, new Anim(new int[] { 5, 6, 7, 8, 9, }, new float[] { 4.0f }));
            sprite.Play(AnimType.Go);

            // Initilize velocity values
            velocity     = new Vector2(0, 1);
            velocity     = Util.Rotate(velocity, Rand.Int(0, 360));
            minspeed     = 2.0f;
            sprite.Angle = Util.RAD_TO_DEG * (float)Math.Atan2(-velocity.Y, velocity.X) - 90;
            direction    = velocity;
        }
示例#7
0
        public Ink(float x, float y, float angle) : base(x, y)
        {
            // Init sprite
            sprite.Add(AnimType.Go, new Anim(new int[] { 0, 1, 2 }, new float[] { 8.0f }));
            sprite.Play(AnimType.Go);
            sprite.CenterOrigin();
            sprite.Angle    = angle;
            offset          = Util.Rotate(offset, sprite.Angle);
            sprite.OriginX += offset.X;
            sprite.OriginY += offset.Y;
            offset.Normalize();
            offset *= 2.7f;
            Graphic = sprite;

            // Set up collider
            Collider = new CircleCollider(250, (int)Tags.INK);
            Collider.CenterOrigin();

            // Get that sound
            snd.Volume = 0.01f;
            snd.Play();
        }
示例#8
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;
        }
示例#9
0
        public Pickup(float x, float y, Int16 type)
            : base(x, y)
        {
            this.PickupType = type;
            switch (type)
            {
            case (int)PickupManager.PICKUPTYPES.UPGRADE_WEAPON_PRIMARY:
                img = new Image(Assets.GRAPHIC_PICKUP_UPGRADE_WEAPON_PRIMARY);
                break;

            case (int)PickupManager.PICKUPTYPES.AMMO_ROCKET:
                img = new Image(Assets.GRAPHIC_PICKUP_AMMO_ROCKET);
                break;

            case (int)PickupManager.PICKUPTYPES.POWERUP_INV:
                img = new Image(Assets.GRAPHIC_PICKUP_POWERUP_INV);
                break;

            case (int)PickupManager.PICKUPTYPES.POWERUP_HEALTH:
                img = new Image(Assets.GRAPHIC_PICKUP_POWERUP_HEALTH);
                break;

            case (int)PickupManager.PICKUPTYPES.POWERUP_LEVEL_UP:
                img = new Image(Assets.GRAPHIC_PICKUP_POWERUP_LEVEL_UP);
                break;

            case (int)PickupManager.PICKUPTYPES.POWERUP_PLAYER_SHIP:
                img = new Image(Assets.GRAPHIC_PICKUP_POWERUP_PLAYER_SHIP);
                break;

            case (int)PickupManager.PICKUPTYPES.DEGRADE_WEAPON_PRIMARY:
                img = new Image(Assets.GRAPHIC_PICKUP_DEGRADE_WEAPON_PRIMARY);
                break;

            case (int)PickupManager.PICKUPTYPES.AMMO_ROCKET_LOOSE:
                img = new Image(Assets.GRAPHIC_PICKUP_AMMO_ROCKET_LOOSE);
                break;

            case (int)PickupManager.PICKUPTYPES.DEGRADE_50HEALTH:
                img = new Image(Assets.GRAPHIC_PICKUP_DEGRADE_50HEALTH);
                break;

            case (int)PickupManager.PICKUPTYPES.UPGRADE_SPEED:
                img = new Image(Assets.GRAPHIC_PICKUP_UPGRADE_SPEED);
                break;

            case (int)PickupManager.PICKUPTYPES.DEGRAGE_SPEED:
                img = new Image(Assets.GRAPHIC_PICKUP_DEGRADE_SPEED);
                break;

            default:
                img = Image.CreateRectangle(5, Color.Red);
                break;
            }
            this.X       = x;
            this.Y       = y;
            this.speed   = new Speed(Global.SPEED_PICKUP_MAX);
            this.speed.Y = Rand.Int(2, Global.SPEED_PICKUP_MAX);
            img.CenterOrigin();
            this.SetGraphic(img);

            CircleCollider col = new CircleCollider((int)this.img.HalfWidth, (int)Global.HIT_TYPES.PICKUP);

            col.CenterOrigin();
            this.AddCollider(col);
        }