예제 #1
0
    public static void SetAnimations(Sprite givenSprite, ref Dictionary <string, SpriteMap> givenDictionary)
    {
        Color     animationColour        = transparent;
        Rect      currentAnimationBorder = new Rect(new Vector2(0, 0), new Vector2(givenSprite.rect.size.x, 0));
        SpriteMap currentSpriteMap       = new SpriteMap();
        string    currentSpriteMapId;

        for (int i = 0; i < givenSprite.rect.size.y; i++)
        {
            Color pixelColour = givenSprite.texture.GetPixel(0, i);
            if (animationColour != pixelColour)
            {
                if (pixelColour != transparent)
                {
                    if (animationColour != transparent)
                    {
                        currentSpriteMapId = currentSpriteMap.GetName() + ColourToString(currentSpriteMap.GetColour());
                        givenDictionary.Add(currentSpriteMapId, currentSpriteMap);
                    }
                    animationColour          = pixelColour;
                    currentAnimationBorder.y = i;
                    currentSpriteMap.Initialise(givenSprite.name, animationColour);
                }
                else
                {
                    currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y);
                    PlayAnimation currentAnimation = SetAnimation(currentAnimationBorder, animationColour, givenSprite.texture);
                    currentSpriteMap.AddAnimation(currentAnimation);
                    i += YGAP - 1;
                    currentAnimationBorder.y = i + 1;
                }
            }
            else if (i == givenSprite.rect.size.y - 1)
            {
                if (pixelColour == transparent)
                {
                    throw new TextureNotfoundException(givenSprite.name + " didn't find any textures to make an animation from");
                }
                currentAnimationBorder.size = new Vector2(currentAnimationBorder.size.x, i - currentAnimationBorder.y);
                Rect          currentFrameBorder = new Rect(currentAnimationBorder.position, new Vector2(0, currentAnimationBorder.size.y));
                PlayAnimation currentAnimation   = SetAnimation(currentAnimationBorder, animationColour, givenSprite.texture);
                currentSpriteMap.AddAnimation(currentAnimation);
                i += YGAP - 1;
            }
        }
        currentSpriteMapId = currentSpriteMap.GetName() + ColourToString(currentSpriteMap.GetColour());
        givenDictionary.Add(currentSpriteMapId, currentSpriteMap);
    }
예제 #2
0
        public TunnelGrenadeActive(float xval, float yval) : base(xval, yval)
        {
            d                          = duck;
            this.ammo                  = 1;
            this._ammoType             = new ATShrapnel();
            this._ammoType.penetration = 0.4f;
            this._type                 = "gun";
            //this.ignoreCollisions = true;
            //this._impactThreshold = 500f;

            this._sprite = new SpriteMap(GetPath("weapons/TunnelGrenade"), 32, 32, true);
            base.graphic = this._sprite;
            _sprite.AddAnimation("animation", 1.6f, true, 0, 1, 2, 3, 4);


            this.center          = new Vec2(16f, 16f);
            this.collisionOffset = new Vec2(-4f, -5f);
            this.collisionSize   = new Vec2(8f, 10f);
            base.bouncy          = 0.7f;
            this.friction        = 0.025f;
            this.weight          = 0.1f;
            this._weight         = 0.1f;
            this._editorName     = "(teleport) Tunnel Grenade";
            this._bio            = "Like a Grenade, teleports the duck who threw it!";
        }
예제 #3
0
        public DubstepGun(float xval, float yval)
            : base(xval, yval)
        {
            PlayBinding = new StateBinding("Playing");

            _bio        = "Plays generic dubstep loop and destroys everything";
            _editorName = "Dubstep Gun";

            ammo      = LoopTimings.Length + Rando.Int(-5, 5);
            _ammoType = new ATGrenade();
            _type     = "gun";

            sprite = new SpriteMap(DuckUtils.GetAsset("weapons/dubstep_gun.png"), 16, 16);
            sprite.AddAnimation("anim", Maths.IncFrameTimer() * 4f, true, 0, 1, 2, 3);
            sprite.SetAnimation("anim");
            graphic = sprite;
            center  = new Vec2(8f, 10f);

            sound = SFX.Get(DuckUtils.GetAsset("sounds/dubstep_sample.wav"), 1f, 0f, 0f, false);

            collisionOffset = new Vec2(-8f, -6f);
            collisionSize   = new Vec2(16f, 11f);
            _barrelOffsetTL = new Vec2(16f, 6f);
            _fireSound      = "pistolFire";
            _kickForce      = 3f;
            _holdOffset     = new Vec2(-1f, 0f);
            loseAccuracy    = 0.1f;
            maxAccuracyLost = 1f;
            physicsMaterial = PhysicsMaterial.Metal;
        }
예제 #4
0
        public PimpRCCar(float xpos, float ypos) : base(xpos, ypos)
        {
            this._sprite = new SpriteMap("rcBody", 32, 32, false);
            SpriteMap arg_9C_0 = this._sprite;
            string    arg_9C_1 = "idle";
            float     arg_9C_2 = 1f;
            bool      arg_9C_3 = true;

            int[] frames = new int[1];
            arg_9C_0.AddAnimation(arg_9C_1, arg_9C_2, arg_9C_3, frames);
            this._sprite.AddAnimation("beep", 0.2f, true, new int[]
            {
                0,
                1
            });
            this.graphic         = this._sprite;
            this.center          = new Vec2(16f, 24f);
            this.collisionOffset = new Vec2(-8f, 0f);
            this.collisionSize   = new Vec2(16f, 11f);
            base.depth           = -0.5f;
            this._editorName     = "RC Car";
            this.thickness       = 2f;
            this.weight          = 5f;
            this.flammable       = 0.3f;
            this._wheel          = new Sprite("rcWheel", 0f, 0f);
            this._wheel.center   = new Vec2(4f, 4f);
            this.weight          = 0.5f;
            this.physicsMaterial = PhysicsMaterial.Metal;
        }
예제 #5
0
 public PermafrostExplosion(float xpos, float ypos, bool doWait = true) : base(xpos, ypos)
 {
     _sprite = this.ReadyToRunWithFrames(tex_Effect_PermafrostExplosion, 15, 15);
     _sprite.AddAnimation("loop", 0.7f, false, new int[]
     {
         0,
         1,
         2,
         3,
         4,
         5,
         6,
         7
     });
     _sprite.SetAnimation("loop");
     graphic = _sprite;
     xscale  = 2f;
     yscale  = xscale;
     center  = new Vec2(7.5f, 7.5f);
     depth   = 1;
     if (!doWait)
     {
         _wait = 0f;
     }
 }
        public ChallengeConfetti(float xpos, float ypos)
            : base(xpos, ypos)
        {
            SpriteMap spriteMap = new SpriteMap("arcade/confetti", 8, 8);

            spriteMap.AddAnimation("idle", 0.1f, true, 0, 1);
            spriteMap.SetAnimation("idle");
            this.graphic    = (Sprite)spriteMap;
            this._fallSpeed = Rando.Float(0.5f, 1.2f);
            this.layer      = Layer.HUD;
            int num = Rando.ChooseInt(0, 1, 2, 3);

            if (num == 0)
            {
                spriteMap.color = Color.Violet;
            }
            if (num == 1)
            {
                spriteMap.color = Color.SkyBlue;
            }
            if (num == 2)
            {
                spriteMap.color = Color.Wheat;
            }
            if (num == 4)
            {
                spriteMap.color = Color.GreenYellow;
            }
            this.depth = new Depth(1f);
        }
예제 #7
0
 public DuckPlaceHolder(float xpos, float ypos) : base(xpos, ypos)
 {
     _gravMult    = 0;
     _sprite      = new SpriteMap(GetPath("/weapons/placeholder"), 32, 32);
     base.graphic = _sprite;
     _sprite.AddAnimation("animation", 1.5f, true, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
     this.center = new Vec2(16f, 16f);
 }
예제 #8
0
        public ClashShield(float xval, float yval)
            : base(xval, yval)
        {
            ActiveBinding    = new StateBinding("Active");
            LowChargeBinding = new StateBinding("LowCharge");

            _editorName = "Clash Shield";

            graphic    = spriteMap = new SpriteMap(DuckUtils.GetAsset("weapons/clash_shield.png"), 32, 32);
            lightning1 = new SpriteMap(DuckUtils.GetAsset("weapons/clash_shield_lightnings.png"), 12, 6);
            lightning2 = new SpriteMap(DuckUtils.GetAsset("weapons/clash_shield_lightnings.png"), 12, 6);

            depth = depth - 2;

            spriteMap.AddAnimation("idle", 0.4f, false, 0);
            spriteMap.AddAnimation("active", 0.2f, true, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2);
            spriteMap.AddAnimation("low", 0.2f, true, 1, 0, 2, 0, 0, 3, 4, 0, 5, 0, 6, 0, 7, 0, 5, 0, 4, 0, 3, 0, 2);

            lightning1.AddAnimation("idle", 0.4f, false, 0);
            lightning1.AddAnimation("active", 0.2f, true, LightningPattern1);
            lightning1.AddAnimation("low", 0.2f, true, 15, 0, 12, 0, 0, 3, 7, 0, 1, 0, 9, 0, 5, 0, 10, 0, 9, 0, 4);

            lightning2.AddAnimation("idle", 0.4f, false, 0);
            lightning2.AddAnimation("active", 0.2f, true, LightningPattern2);
            lightning2.AddAnimation("low", 0.2f, true, 5, 0, 7, 0, 0, 1, 8, 0, 12, 0, 11, 0, 8, 0, 3, 0, 2, 0, 4);

            sound = SFX.Get(DuckUtils.GetAsset("sounds/clash_shield.wav"), 1f, 0f, 0f, true);

            ammo            = 99;
            thickness       = 8.9f;
            weight          = 9f;
            center          = new Vec2(16f, 18f);
            collisionOffset = new Vec2(-3f, -18f);
            collisionSize   = new Vec2(16f, 27f);
            handOffset      = new Vec2(0f, 1000000f);
            _holdOffset     = new Vec2(-3f, 4f);
            _barrelOffsetTL = new Vec2(23f, 12f);
        }
예제 #9
0
        public FrogLauncher(float xval, float yval)
            : base(xval, yval)
        {
            AimAngleBinding = new StateBinding("aimAngle");
            StateBinding    = new StateBinding("stateIndex");

            _editorName = "Frog Launcher";
            _bio        = "This boy can fit " + MaxAmmo + " frogs innit!";

            ammo       = MaxAmmo;
            _type      = "gun";
            graphic    = baseSprite = new SpriteMap(DuckUtils.GetAsset("weapons/frog_launcher_base.png"), 24, 12);
            ammoSprite = new SpriteMap(DuckUtils.GetAsset("weapons/frog_launcher_ammo.png"), 26, 12);

            for (int i = 1; i <= 4; i++)
            {
                int rowStartIdx = (5 - i) * 4;
                ammoSprite.AddAnimation("idle" + i, 0.4f, false, rowStartIdx + 0);
                ammoSprite.AddAnimation("load" + i, 0.4f, false, rowStartIdx + 1, rowStartIdx + 2, rowStartIdx + 3);
            }

            ammoSprite.AddAnimation("empty", 0.4f, false, 21);
            ammoSprite.AddAnimation("idleOver", 0.4f, false, 0);
            ammoSprite.AddAnimation("loadOver", 0.4f, false, 1, 2, 3, 20);
            ammoSprite.SetAnimation("empty");

            center          = new Vec2(6f, 7f);
            collisionOffset = new Vec2(-6f, -4f);
            collisionSize   = new Vec2(16f, 8f);
            _barrelOffsetTL = new Vec2(25f, 4f);
            _laserOffsetTL  = new Vec2(22f, 4f);
            _fireSound      = "pistol";
            _kickForce      = 3f;
            _holdOffset     = new Vec2(-3f, 0f);
            _ammoType       = new ATGrenade();

            UpdateSprites();
        }
예제 #10
0
        public TeleportPistol(float xval, float yval) : base(xval, yval)
        {
            _ammoType            = new ATLaser();
            _editorName          = "Telport Pistol";
            _bio                 = "Pew pew";
            this.ammo            = 3;
            this.center          = new Vec2(16f, 16f);
            this.collisionOffset = new Vec2(-6f, -4f);
            this.collisionSize   = new Vec2(12f, 8f);
            this._barrelOffsetTL = new Vec2(20f, 15f);
            _kickForce           = 0.2f;
            this._fireSound      = GetPath("/sfx/pewsound");
            physicsMaterial      = PhysicsMaterial.Wood;



            sprite       = new SpriteMap(GetPath("/weapons/TeleportPistol.png"), 32, 32);
            base.graphic = sprite;
            sprite.AddAnimation("3", 0.4f, true, 0, 1, 2, 3);
            sprite.AddAnimation("2", 0.4f, true, 4, 5, 6, 7);
            sprite.AddAnimation("1", 0.4f, true, 8, 9, 10, 11);
            sprite.AddAnimation("0", 0.4f, true, 12);
        }
예제 #11
0
 public AT_BigFB()
 {
     accuracy       = 0.8f;
     range          = 300f;
     penetration    = 1f;
     rangeVariation = 10f;
     combustable    = true;
     bulletSpeed    = 0.5f;
     //sprite.CenterOrigin();
     bulletType      = typeof(Bullet_BigFB);
     sprite          = _spriteMap;
     bulletThickness = 4f;
     bulletLength    = 5f;
     bulletColor     = Color.Orange;
     _spriteMap.AddAnimation("loop", 0.4f, true, 0, 1, 2);
     _spriteMap.SetAnimation("loop");
 }
예제 #12
0
        public TunnelGrenade(float xval, float yval) : base(xval, yval)
        {
            this.ignoreCollisions      = true;
            this.ammo                  = 1;
            this._ammoType             = new ATShrapnel();
            this._ammoType.penetration = 0.4f;
            this._type                 = "gun";

            this._sprite = new SpriteMap(GetPath("weapons/TunnelGrenade"), 32, 32, true);
            base.graphic = this._sprite;
            _sprite.AddAnimation("animation", 1.6f, true, 0, 1, 2, 3, 4);


            this.center          = new Vec2(16f, 16f);
            this.collisionOffset = new Vec2(-4f, -5f);
            this.collisionSize   = new Vec2(8f, 10f);
            base.bouncy          = 0.4f;
            this.friction        = 0.05f;
            this._editorName     = "(non teleport) Tunnel Grenade";
            this._bio            = "Basically a better looking Grenade. Does not teleport.";
        }
예제 #13
0
 public NovaExp(float xpos, float ypos, bool doWait = true) : base(xpos, ypos)
 {
     _sprite = this.ReadyToRunWithFrames(tex_Effect_CrystalExplosionPurple, 36, 36);
     _sprite.AddAnimation("loop", 1f, false, new int[]
     {
         0,
         1,
         2,
         3,
         4,
         5,
         6,
         7,
         8,
         9,
         10,
         11,
         12,
         13,
         14,
         15,
         16,
         17,
         18,
     });
     _sprite.SetAnimation("loop");
     graphic       = _sprite;
     _sprite.speed = 0.6f;
     xscale        = 0.5f;
     yscale        = xscale;
     center        = new Vec2(18f, 18f);
     depth         = 1f;
     if (!doWait)
     {
         _wait = 0f;
     }
 }
예제 #14
0
        public VoteGun(float xval, float yval)
            : base(xval, yval)
        {
            PlayBinding = new StateBinding("Playing");

            _bio        = "Golosovanie!";
            _editorName = "Vote Gun";

            ammo      = LoopTimingsAmount;
            _ammoType = new ATGrenade();
            _type     = "gun";

            sprite = new SpriteMap(DuckUtils.GetAsset("weapons/dubstep_gun.png"), 16, 16);
            sprite.AddAnimation("anim", Maths.IncFrameTimer() * 4f, true, 0, 1, 2, 3);
            sprite.SetAnimation("anim");
            graphic = sprite;
            center  = new Vec2(8f, 10f);

            sound = SFX.Get(DuckUtils.GetAsset("sounds/vote_loop.wav"), 1f, 0f, 0f, false);

            collisionOffset = new Vec2(-8f, -6f);
            collisionSize   = new Vec2(16f, 11f);
            _barrelOffsetTL = new Vec2(16f, 6f);
            _kickForce      = 3f;
            _holdOffset     = new Vec2(-1f, 0f);
            loseAccuracy    = 0.1f;
            maxAccuracyLost = 2f;
            physicsMaterial = PhysicsMaterial.Metal;

            _ammoType       = new ATShotgun();
            _ammoType.range = 100f;
            _type           = "gun";

            _kickForce         = 10f;
            _numBulletsPerFire = 7;
        }