示例#1
0
        public void FireGun()
        {
            if (ammo > 0 && hasBeenUnpressed)
            {
                Blob bulletBlob = new Blob();
                bulletBlob.transform.Position = blob.transform.Position;
                Sprite headSprite = new Sprite(ResourceManager.bullet);
                bulletBlob.AddComponent(headSprite);
                Collider collider = new Collider();
                collider.bounds = ResourceManager.GetBounds(headSprite.texture);
                collider.offset = new Vector2(collider.bounds.X, collider.bounds.Y);
                bulletBlob.AddComponent(collider);
                bulletBlob.AddComponent(new Damage(DamageValues.throwDamage, DamageValues.gunLegPiercing));
                bulletBlob.AddComponent(new DieOutOfBounds());


                SoundManager.PlaySound(SoundManager.SFX_GUN_LEG_SHOT);

                if (!thrown)
                {
                    facing = body.GetFacing();
                }
                bulletBlob.AddComponent(new Bullet(VectorFacing.RotateVectorToFacing(bulletFireTrajectory, facing)));
                ammo--;
            }
            else if (ammo <= 0 && hasBeenUnpressed)
            {
                SoundManager.PlaySound(SoundManager.SFX_EMPTY_GUN);
            }
        }
示例#2
0
        public void Explode(Vector2 atPosition)
        {
            Blob     explosion       = new Blob();
            Sprite   explosionSprite = new Sprite(ResourceManager.explosion);
            Damage   bombDamage      = new Damage(5);
            Collider newCollider     = new Collider();

            bombDamage.explosive = true;

            float chargedExplosionSize = baseExplosionSize * chargePower;

            newCollider.bounds = new Rectangle((int)-chargedExplosionSize / 2, (int)-chargedExplosionSize / 2,
                                               (int)chargedExplosionSize / 2, (int)chargedExplosionSize / 2);

            //bombDamage.shakeStrength = 0f;
            //bombDamage.stickLength = .1;
            explosionSprite.SetSize(newCollider.bounds.Width, newCollider.bounds.Height);
            explosion.AddComponent(explosionSprite);
            explosion.AddComponent(bombDamage);
            explosion.AddComponent(newCollider);
            explosion.AddComponent(new DieInSeconds(.5f));
            explosion.AddComponent(new FadeInSeconds(.7f));
            explosion.transform.Position = atPosition - (explosionSprite.GetSize() / 2) + (limbSprite.GetSize() / 2);


            SoundManager.PlaySound(SoundManager.SFX_BOMB_EXPLODE);

            if (!thrown && body != null)
            {
                body.RemoveBodyPart(limbType);
            }
            blob.Destroy();
        }
示例#3
0
        public override void Start()
        {
            base.Start();

            one   = new Blob();
            two   = new Blob();
            three = new Blob();

            one.transform.Parent   = this.blob.transform;
            two.transform.Parent   = this.blob.transform;
            three.transform.Parent = this.blob.transform;

            one.transform.LocalPosition   = Vector2.Zero;
            two.transform.LocalPosition   = Vector2.Zero;
            three.transform.LocalPosition = Vector2.Zero;

            Sprite oneSprite   = new Sprite(tex);
            Sprite twoSprite   = new Sprite(tex);
            Sprite threeSprite = new Sprite(tex);

            oneSprite.z   = z;
            twoSprite.z   = z;
            threeSprite.z = z;

            one.AddComponent(oneSprite);
            two.AddComponent(twoSprite);
            three.AddComponent(threeSprite);

            two.transform.Position   = one.transform.Position + new Vector2(oneSprite.width, 0);
            three.transform.Position = one.transform.Position + new Vector2(oneSprite.width * 2, 0);
        }
示例#4
0
        public void SpawnEnemy()
        {
            timer = rand.Next(spawnTime, spawnTimeMax);

            //determine how many to spawn
            int spawnCount = spawnCounts[0];

            for (int i = 0; i < scoreThresholds.Length; i++)
            {
                if (ScoreManager.Instance.Score < scoreThresholds[i])
                {
                    spawnCount = spawnCounts[i - 1];
                    break;
                }

                //last
                else if (i == scoreThresholds.Length - 1)
                {
                    spawnCount = spawnCounts[i];
                }
            }

            //spawnCount = rand.Next(1, spawnCount);

            for (int i = 0; i < spawnCount; i++)
            {
                Blob  enemy = new Blob();
                Enemy comp  = new Enemy(this.blob.transform.Position, RandomPointInRect(target));
                enemy.AddComponent(comp);
                enemy.transform.Parent   = blob.transform;
                enemy.transform.Position = blob.transform.Position;
            }
        }
示例#5
0
        public void GoToTitle()
        {
            //main logic components
            mainGame = new Blob();
            TitleScreen gameLogic = new TitleScreen();

            mainGame.AddComponent(gameLogic);
        }
示例#6
0
        public void GoToNewGame()
        {
            //main logic components
            mainGame = new Blob();
            GameManager gameLogic = new GameManager();

            mainGame.AddComponent(gameLogic);
        }
示例#7
0
        public void GoToEndScreen()
        {
            //main logic components
            mainGame = new Blob();
            ScoreScreen gameLogic = new ScoreScreen();

            mainGame.AddComponent(gameLogic);
        }
示例#8
0
        public TitleScreen()
        {
            Instance = this;

            instructions = new Blob();
            instructions.AddComponent(new Sprite(ResourceManager.Instructions));
            instructions.GetComponent <Sprite>().z     = 0.1f;
            instructions.GetComponent <Sprite>().color = Color.White;
        }
示例#9
0
        public override void EndPunch()
        {
            if (chargePower >= sweetMin)
            {
                Blob b = new Blob();
                b.AddComponent(new HitFlash(DamageValues.humanMelee + (chargePower == chargeMax?1:0), 0f, body.GetFacing(), DamageValues.humanPiercing, body.Collider));
                Vector2 position = VectorFacing.RotateVectorToFacing(new Vector2(0, 50), body.GetFacing());
                b.transform.Position = body.GetColliderCenter() + position + new Vector2(0, -20);

                SoundManager.PlaySound(SoundManager.SFX_PUNCH);
            }
        }
示例#10
0
        public override void EndPunch()
        {            //TODO nick tweak pubch attack
            if (chargePower > 0 && ammo-- >= 0)
            {
                //make an attack
                Blob b = new Blob();
                b.AddComponent(new HitFlash(DamageValues.robotMelee, 20f, body.GetFacing(), DamageValues.robotPiercing, body.Collider));
                Vector2 position = VectorFacing.RotateVectorToFacing(new Vector2(0, 50), body.GetFacing());
                b.transform.Position = body.GetColliderCenter() + position + new Vector2(0, -20);

                SoundManager.PlaySound(SoundManager.SFX_PUNCH);
            }
        }
示例#11
0
        public override void EndPunch()
        {
            if (chargePower > 0 && ammo-- >= 0)
            {
                Blob b = new Blob();
                b.AddComponent(new HitFlash(DamageValues.robotMelee, 20f, body.GetFacing(), DamageValues.robotPiercing, body.Collider));
                b.transform.Parent = this.blob.transform;

                Vector2 position = VectorFacing.RotateVectorToFacing(new Vector2(0, 50), body.GetFacing());
                b.transform.LocalPosition = position + new Vector2(25, 0);

                SoundManager.PlaySound(SoundManager.SFX_PUNCH);
            }
        }
示例#12
0
        public override void EndPunch()
        {
            if (chargePower >= .7)
            {
                //make an attack
                int  damage = IsSweet() ? 2 : 1;
                Blob b      = new Blob();
                b.AddComponent(new HitFlash(DamageValues.humanArm * damage, 50f, body.GetFacing(), DamageValues.humanPiercing, body.Collider));
                b.transform.Parent = this.blob.transform;

                Vector2 position = VectorFacing.RotateVectorToFacing(new Vector2(0, 50), body.GetFacing());
                b.transform.LocalPosition = position + new Vector2(25, 0);

                SoundManager.PlaySound(SoundManager.SFX_PUNCH);
                chargeSpeed -= .5f;
            }
        }
示例#13
0
        public void AddLimbFromLimb(LimbType limbType, Limb previousLimb)
        {
            if (GetBodyPart(limbType) == null)
            {
                Blob limb = new Blob();
                limb.transform.Parent        = blob.transform;
                limb.transform.LocalPosition = new Vector2(0, yCoordinates[(int)limbType]);

                Limb.LimbPosition positionType = Limb.LimbPosition.Left;
                if (limbType == LimbType.RightLeg || limbType == LimbType.RightArm)
                {
                    positionType = Limb.LimbPosition.Right;
                }

                Limb visual = new Limb(previousLimb, positionType, randomDepth);
                limb.AddComponent(visual);

                SetBodyPart(limbType, limb);
                SetFacing(facing);
            }
        }
示例#14
0
        public void AddLimb(LimbType limbType, bool isHuman)
        {
            if (GetBodyPart(limbType) == null)
            {
                Blob limb = new Blob();
                limb.transform.Parent        = blob.transform;
                limb.transform.LocalPosition = new Vector2(0, yCoordinates[(int)limbType]);

                Limb.LimbComponentType componentType = Limb.LimbComponentType.Head;
                if (limbType == LimbType.Head)
                {
                    componentType = Limb.LimbComponentType.Head;
                }
                else if (limbType == LimbType.LeftArm || limbType == LimbType.RightArm)
                {
                    componentType = Limb.LimbComponentType.Arm;
                }
                else if (limbType == LimbType.LeftLeg || limbType == LimbType.RightLeg)
                {
                    componentType = Limb.LimbComponentType.Leg;
                }
                else if (limbType == LimbType.Torso)
                {
                    componentType = Limb.LimbComponentType.Torso;
                }

                Limb.LimbPosition positionType = Limb.LimbPosition.Left;
                if (limbType == LimbType.RightLeg || limbType == LimbType.RightArm)
                {
                    positionType = Limb.LimbPosition.Right;
                }

                Limb visual = new Limb(componentType, positionType, randomDepth, isHuman);
                limb.AddComponent(visual);

                SetBodyPart(limbType, limb);
                SetFacing(facing);
            }
        }
示例#15
0
        public override void Throw()
        {
            base.Throw();
            velocity = VectorFacing.RotateVectorToFacing(velocity, body.GetFacing());

            if (IsSweet())
            {
                GameManager.Instance.SetSecondLabel("SWEET SHOT");
            }

            SoundManager.PlaySound(SoundManager.SFX_RIP_HUMAN_LIMB);

            Blob blood = new Blob();

            blood.AddComponent(new Sprite(ResourceManager.Blood));
            blood.transform.Position = this.blob.transform.Position;
            blood.GetComponent <Sprite>().SetAnchor(Sprite.AnchorType.Upper_Left);
            blood.GetComponent <Sprite>().z     = 0.99f;
            blood.GetComponent <Sprite>().scale = 0.5f;

            velocity *= chargePower + (IsSweet() ? sweetBonus : 0f);
        }
示例#16
0
        public void Hit(Damage damage, Collider relativeCollider)
        {
            health -= damage.damageValue;

            if (damage.explosive)
            {
                Blob head = GetBodyPart(LimbType.Head);
                if (head != null)
                {
                    if (head.GetComponent <Limb>().head == Limb.HeadSubType.Bomb)
                    {
                        BombHead bombHead = (BombHead)head.AddComponent(new BombHead(null, LimbType.Head));
                        bombHead.MaxCharge();
                        bombHead.Explode(collider.Center());
                        RemoveBodyPart(LimbType.Head);
                    }
                }
            }

            if (health <= 0)
            {
                //die
                Die();
            }
            else
            {
                LimbFly(health, damage.damageValue);
                //knockback
                if (relativeCollider == null)
                {
                    relativeCollider = damage.blob.collider;
                }

                Vector2 direction = collider.Center() - relativeCollider.Center();
                direction.Normalize();
                blob.transform.Translate(direction * damage.knockbackPower);
                SoundManager.PlaySound(SoundManager.SFX_HIT_2);
            }
        }
示例#17
0
        void SetupLimb(Blob bodyPart, Limb.LimbComponentType type, Limb.LimbPosition position)
        {
            Limb visual = new Limb(type, position, randomDepth);

            bodyPart.AddComponent(visual);
        }
示例#18
0
        public void Hit()
        {
            if (!dying)
            {
                timer            = dieDuration;
                dying            = true;
                movement.enabled = false;

                Blob head = RemoveBodyPart(LimbType.Head);
                if (head != null)
                {
                    head.transform.Parent = null;
                    head.RemoveComponent <LimbPunch>();
                    head.GetComponent <LimbVisual>().FlyInRandomDirection();
                }

                Blob lLeg = RemoveBodyPart(LimbType.LeftArm);
                if (lLeg != null)
                {
                    lLeg.transform.Parent = null;
                    lLeg.RemoveComponent <LimbPunch>();
                    lLeg.GetComponent <LimbVisual>().FlyInRandomDirection();
                }

                Blob rLeg = RemoveBodyPart(LimbType.LeftLeg);
                if (rLeg != null)
                {
                    rLeg.transform.Parent = null;
                    rLeg.RemoveComponent <LimbPunch>();
                    rLeg.GetComponent <LimbVisual>().FlyInRandomDirection();
                }

                Blob rArm = RemoveBodyPart(LimbType.RightArm);
                if (rArm != null)
                {
                    rArm.transform.Parent = null;
                    rArm.RemoveComponent <LimbPunch>();
                    rArm.GetComponent <LimbVisual>().FlyInRandomDirection();
                }

                Blob lArm = RemoveBodyPart(LimbType.RightLeg);
                if (lArm != null)
                {
                    lArm.transform.Parent = null;
                    lArm.RemoveComponent <LimbPunch>();
                    lArm.GetComponent <LimbVisual>().FlyInRandomDirection();
                }


                Blob blood = new Blob();
                blood.AddComponent(new Sprite(ResourceManager.Blood));
                blood.transform.Parent        = this.blob.transform;
                blood.transform.LocalPosition = new Vector2(-17, 20);
                blood.GetComponent <Sprite>().SetAnchor(Sprite.AnchorType.Upper_Left);
                blood.GetComponent <Sprite>().z = 0.99f;

                blood = new Blob();
                blood.AddComponent(new Sprite(ResourceManager.Blood));
                blood.transform.Parent        = this.blob.transform;
                blood.transform.LocalPosition = new Vector2(15, 40);
                blood.GetComponent <Sprite>().SetAnchor(Sprite.AnchorType.Middle_Center);
                blood.GetComponent <Sprite>().z     = 0.0f;
                blood.GetComponent <Sprite>().scale = 3f;
                blood.AddComponent(new FadeInSeconds(1));

                SoundManager.PlaySound(SoundManager.SFX_PLAYER_DIES_MAYBE);
            }
        }
示例#19
0
        public void FireGun(Vector2 position)
        {
            if (ammo > 0 && hasBeenUnpressed)
            {
                if (!thrown)
                {
                    facing = body.GetFacing();
                }

                chargePower = Math.Max(chargePower, 1);
                int  laserWidth = (int)(60 * chargePower);
                Blob bulletBlob = new Blob();
                bulletBlob.transform.Position = position;

                Sprite laserSprite = new Sprite(ResourceManager.laserBeam);
                //laserSprite.SetAnchor(Sprite.AnchorType.Upper_Center);
                laserSprite.rotation = VectorFacing.FacingToPi(facing);
                laserSprite.SetSize(laserWidth * 2, 1000);
                bulletBlob.AddComponent(laserSprite);
                Collider collider = new Collider();
                bulletBlob.AddComponent(collider);

                laserWidth /= 2;
                Rectangle colliderRectangle = new Rectangle();
                switch (facing)
                {
                case Facing.Down:
                    colliderRectangle = new Rectangle(0, 0, laserWidth, 1000);
                    collider.offset   = new Vector2(laserWidth * 1.5f, 0);
                    bulletBlob.transform.Translate(new Vector2(-laserWidth * 2, 0));
                    break;

                case Facing.Left:
                    colliderRectangle = new Rectangle(0, 0, 1000, laserWidth);
                    collider.offset   = new Vector2(-1000, laserWidth * 1.5f);
                    bulletBlob.transform.Translate(new Vector2(0, -laserWidth * 2));
                    break;

                case Facing.Right:
                    colliderRectangle = new Rectangle(0, 0, 1000, laserWidth);
                    collider.offset   = new Vector2(0, -laserWidth * 2.5f);
                    bulletBlob.transform.Translate(new Vector2(0, laserWidth * 2));
                    break;

                case Facing.Up:
                    colliderRectangle = new Rectangle(0, 0, laserWidth, 1000);
                    collider.offset   = new Vector2(-laserWidth * 2.5f, -1000);
                    bulletBlob.transform.Translate(new Vector2(laserWidth * 2, 0f));
                    break;
                }

                collider.bounds = colliderRectangle;


                float dieTime = .3f * chargePower;
                bulletBlob.AddComponent(new DieInSeconds(dieTime));
                bulletBlob.AddComponent(new FadeInSeconds(dieTime));

                bulletBlob.AddComponent(new Damage(5));
                bulletBlob.AddComponent(new DieOutOfBounds());

                //bulletBlob.AddComponent(new Bullet(VectorFacing.RotateVectorToFacing(bulletFireTrajectory, facing)));
                ammo--;

                SoundManager.PlaySound(SoundManager.SFX_LASER_FIRE);
            }
            else if (ammo <= 0 && hasBeenUnpressed)
            {
                SoundManager.PlaySound(SoundManager.SFX_EMPTY_GUN);
            }
        }
示例#20
0
        public void AttachAbilityToPart(LimbType type, Limb newLimb)
        {
            Blob      part   = GetBodyPart(type);
            LimbPunch action = null;

            if (newLimb.type == Limb.LimbComponentType.Head)
            {
                if (newLimb.head == Limb.HeadSubType.Bite)
                {
                    action = new BiteHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Bomb)
                {
                    action = new BombHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Laser)
                {
                    action = new LaserHead(this, type);
                }
                else if (newLimb.head == Limb.HeadSubType.Human)
                {
                    action = new HumanHead(this, type);
                }
            }
            else if (newLimb.type == Limb.LimbComponentType.Arm)
            {
                if (newLimb.arm == Limb.ArmSubType.Hammer)
                {
                    action = new HammerArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Hook)
                {
                    action = new HookArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Long)
                {
                    action = new LongArm(this, type);
                }
                else if (newLimb.arm == Limb.ArmSubType.Human)
                {
                    action = new HumanArm(this, type);
                }
            }
            else if (newLimb.type == Limb.LimbComponentType.Leg)
            {
                if (newLimb.leg == Limb.LegSubType.Gun)
                {
                    action = new GunLeg(this, type);
                }
                else if (newLimb.leg == Limb.LegSubType.Rocket)
                {
                    action = new RocketLeg(this, type);
                }
                else if (newLimb.leg == Limb.LegSubType.Human)
                {
                    action = new HumanArm(this, type);
                }
            }

            part.AddComponent(action);
        }
示例#21
0
        public GameManager()
        {
            Instance = this;

            EnemyManager.Instance.Clean();
            LimbManager.Instance.Clean();

            characterSheet = new Blob();
            CharacterSheet characterComp = new CharacterSheet();

            characterSheet.AddComponent(characterComp);
            characterSheet.transform.Translate(80, 150);

            label = new Blob();
            label.AddComponent(new Label());
            label.transform.Position = new Vector2(300, 20);
            label.GetComponent <Label>().SetAlign(Label.AlignType.Right);
            label.enabled = false;

            secondLabel = new Blob();
            secondLabel.AddComponent(new Label());
            secondLabel.transform.Position = new Vector2(300, 40);
            secondLabel.GetComponent <Label>().SetAlign(Label.AlignType.Right);
            secondLabel.enabled = false;

            dude = new Blob();
            Dude dudeComp = new Dude();

            dude.AddComponent(dudeComp);
            DudeMovement movement = new DudeMovement(dudeComp);

            dude.AddComponent(movement);
            dude.transform.Translate(Constants.GAME_WIDTH / 2 - 30, 550);

            blobShake = new Blob();
            blobShake.AddComponent(new Shake());

            Blob platform = new Blob();

            platform.AddComponent(new Sprite(ResourceManager.Stage));
            platform.GetComponent <Sprite>().z = 0.998f;
            platform.GetComponent <Sprite>().SetAnchor(Sprite.AnchorType.Middle_Center);
            platform.transform.Position = new Vector2(Constants.GAME_WIDTH / 2, Constants.GAME_HEIGHT / 2);

            //right
            Rectangle landingZone  = new Rectangle(Constants.GAME_WIDTH - 290, 80, 10, 500);
            Blob      enemySpawner = new Blob();

            enemySpawner.AddComponent(new EnemySpawner(landingZone));
            enemySpawner.transform.Position = new Vector2(Constants.GAME_WIDTH + 100, Constants.GAME_HEIGHT / 2);

            //left
            landingZone  = new Rectangle(260, 80, 10, 500);
            enemySpawner = new Blob();
            enemySpawner.AddComponent(new EnemySpawner(landingZone));
            enemySpawner.transform.Position = new Vector2(-100, Constants.GAME_HEIGHT / 2);

            //top
            enemySpawner = new Blob();
            landingZone  = new Rectangle(260, 80, 700, 10);
            enemySpawner.AddComponent(new EnemySpawner(landingZone));
            enemySpawner.transform.Position = new Vector2(Constants.GAME_WIDTH / 2, -120);
            enemySpawner.GetComponent <EnemySpawner>().SpawnEnemy();


            Blob background = new Blob();

            background.transform.Position = new Vector2(0, 0);
            background.AddComponent(new CloudRepeater(ResourceManager.texture_BG, -10, 1));

            Blob high = new Blob();

            high.transform.Position = new Vector2(0, 50);
            high.AddComponent(new CloudRepeater(ResourceManager.cloudTop, -50, 0.9999f));

            Blob mid = new Blob();

            mid.transform.Position = new Vector2(0, 140);
            mid.AddComponent(new CloudRepeater(ResourceManager.cloudMid, -80, 0.9995f));

            Blob bottom = new Blob();

            bottom.transform.Position = new Vector2(0, 380);
            bottom.AddComponent(new CloudRepeater(ResourceManager.cloudBottom, -170, 0.9990f));
        }