Beispiel #1
0
        public void Update(MouseButtonState buttonState, Vector2 mousePos, PlatformCharacter shooter, List <PlatformObject> allObjects, List <Projectile> projectiles)
        {
            if (buttonState == null)
            {
                return;
            }

            if (buttonState.justPressed)
            {
                foreach (PlatformObject p in allObjects)
                {
                    if (p is ChemBlock && p.bounds.Contains(mousePos))
                    {
                        clicked       = (ChemBlock)(p as ChemBlock).GetPrimaryBlock();
                        clickedOffset = mousePos - clicked.pos;
                        break;
                    }
                }
            }
            else if (buttonState.justReleased)
            {
                clicked = null;
            }

            if (clicked != null)
            {
                Vector2 offset = mousePos - (clicked.pos + clickedOffset);
                clicked.velocity = offset;
            }
        }
Beispiel #2
0
 public void Update(MouseButtonState buttonState, Vector2 mousePos, PlatformCharacter shooter, List <PlatformObject> allObjects, List <Projectile> projectiles)
 {
     if (buttonState != null && buttonState.isDown)
     {
         shooter.jetting = true;
     }
 }
Beispiel #3
0
        public void Update(MouseButtonState buttonState, Vector2 mousePos, PlatformCharacter shooter, List <PlatformObject> allObjects, List <Projectile> projectiles)
        {
            if (buttonState == null)
            {
                return;
            }

            showGhost = false;
            if (buttonState.isDown)
            {
                Game1.instance.platformLevel.PauseFrame();
            }

            if (buttonState.isDown || buttonState.justReleased)
            {
                Vectangle targetBounds       = new Vectangle(mousePos - shooter.size / 2, shooter.size);
                bool      targetBoundsFailed = false;
                Vectangle altBounds          = new Vectangle(mousePos - new Vector2(shooter.size.X / 2, shooter.size.Y), shooter.size);
                bool      altBoundsFailed    = false;
                foreach (PlatformObject p in allObjects)
                {
                    if (!targetBoundsFailed && p.bounds.Intersects(targetBounds))
                    {
                        targetBoundsFailed = true;
                        if (altBoundsFailed)
                        {
                            break;
                        }
                    }
                    if (!altBoundsFailed && p.bounds.Intersects(altBounds))
                    {
                        altBoundsFailed = true;
                        if (targetBoundsFailed)
                        {
                            break;
                        }
                    }
                }

                if (!targetBoundsFailed)
                {
                    ghostPos  = targetBounds.XY;
                    showGhost = true;
                }
                else if (!altBoundsFailed)
                {
                    ghostPos  = altBounds.XY;
                    showGhost = true;
                }
            }

            if (buttonState.justReleased && showGhost)
            {
                shooter.pos = ghostPos;
                showGhost   = false;
            }
        }
Beispiel #4
0
        public override void ShootProjectile(PlatformCharacter shooter, Vector2 shootDir, List <Projectile> projectiles)
        {
            const float SHOTSPEED = 10.0f;

            projectiles.Add(new Projectile(TextureCache.white, Color.Yellow, shooter.bounds.Center, new Vector2(15, 3), shootDir * SHOTSPEED, ProjectileAction.RIVET));

            const float RECOILSPEED = 0.0f;// 2.5f;

            shooter.velocity -= shootDir * RECOILSPEED;
        }
Beispiel #5
0
 public void Update(MouseButtonState buttonState, Vector2 mousePos, PlatformCharacter shooter, List <PlatformObject> allObjects, List <Projectile> projectiles)
 {
     if (buttonState != null && buttonState.justReleased)
     {
         Vector2 shootPos  = shooter.bounds.Center;
         Vector2 targetPos = mousePos;
         Vector2 shootDir  = (targetPos - shootPos);
         shootDir.Normalize();
         ShootProjectile(shooter, shootDir, projectiles);
     }
 }
Beispiel #6
0
 public void UpdateWeapons(InputState input, PlatformCharacter character, List <PlatformObject> allObjects, List <Projectile> projectiles)
 {
     if (leftWeapon.weapon != null)
     {
         leftWeapon.weapon.Update(input.hoveringElement == null ? input.mouseLeft : null, input.MousePos, character, allObjects, projectiles);
     }
     if (rightWeapon.weapon != null)
     {
         rightWeapon.weapon.Update(input.hoveringElement == null ? input.mouseRight : null, input.MousePos, character, allObjects, projectiles);
     }
 }
Beispiel #7
0
        void InitObjects()
        {
            Vector2 playerPos = new Vector2(50, 200);

            if (player != null)
            {
                playerPos = player.bounds.XY;
            }

            objects      = new List <PlatformObject>();
            triggerables = new List <Command>();

            isDoubleFactory = (factory.rightSocket != null && factory.rightSocket.connectedPipes.Count > 0);
            isBigFactory    = factory.isBigFactory;

            if (isBigFactory)
            {
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(-16, 0), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(-16, 128), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(-16, 256), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(-16, 384), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(550, 0), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(550, 128), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(550, 256), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(550, 384), new Vector2(32, 128)));

                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(187 - 32, 272), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(187 - 32, 400), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.woodFloor, new Vector2(187, 272), new Vector2(192, 32)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(187 + 192, 272), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(187 + 192, 400), new Vector2(32, 128)));

                objects.Add(new PlatformObject(TextureCache.buttonHood, new Vector2(0, 64), new Vector2(32, 32)));

                //objects.Add(new PlatformObject(TextureCache.cement_dark, new Vector2(187-32, 230), new Vector2(128, 42), Color.White, PlatformObjectType.JumpThrough));

                Command_Spawn spawner = new Command_Spawn(new Vectangle(250, -36, 78, 32), factory, 0);
                triggerables.Add(spawner);
                objects.Add(new PushButton(spawner, TextureCache.clear, TextureCache.white, new Vector2(16, 96), new Vector2(8, 32), Color.Red));

                if (isDoubleFactory)
                {
                    objects.Add(new PlatformObject(TextureCache.buttonHood, new Vector2(550 - 16, 64), new Vector2(32, 32)));

                    Command_Spawn spawner2 = new Command_Spawn(new Vectangle(256, -36, 78, 32), factory, 1);
                    triggerables.Add(spawner2);
                    objects.Add(new PushButton(spawner2, TextureCache.clear, TextureCache.white, new Vector2(550 - 8, 96), new Vector2(8, 32), Color.Red));
                }

                ChemicalSignature outputChemical1 = null;
                ChemicalSignature outputChemical2 = null;
                bool setOutput1 = true;
                foreach (OutputPipe pipe in factory.pipes)
                {
                    PipeSocket receiver = pipe.connectedTo;
                    if (setOutput1)
                    {
                        if (receiver != null)
                        {
                            outputChemical1 = receiver.parent.GetInputChemical();
                        }
                        setOutput1 = false;
                    }
                    else
                    {
                        if (receiver != null)
                        {
                            outputChemical2 = receiver.parent.GetInputChemical();
                        }
                        break;
                    }
                }

                objects.Add(new OutputZone(outputChemical1, null, new Vector2(32, 400), new Vector2(155, 32)));
                objects.Add(new OutputZone(outputChemical2, null, new Vector2(187 + 192 + 32, 400), new Vector2(155, 32)));

                saveButton.frame = new Rectangle(185, 302, 100, 40);
            }
            else
            {
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(-16, 0), new Vector2(32, 136)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(0, 136), new Vector2(32, 136)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(400, 0), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(400, 128), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(400, 256), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(400, 384), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.buttonHood, new Vector2(16, 204), new Vector2(32, 32)));
                objects.Add(new PlatformObject(TextureCache.woodFloor, new Vector2(0, 272), new Vector2(192, 32)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(192, 272), new Vector2(32, 128)));
                objects.Add(new PlatformObject(TextureCache.cement, new Vector2(192, 400), new Vector2(32, 128)));

                if (factory.internalSeller != null)
                {
                    objects.Add(new SellerZone(factory.internalSeller, factory.sellerPrice, factory.sellerAction, new Vector2(192, 300), new Vector2(160, 32)));
                }
                else
                {
                    //ChemicalSignature inputChemical = new ChemicalSignature(2, new ChemicalElement[] { ChemicalElement.WHITE, ChemicalElement.GREEN });
                    ChemicalSignature outputChemical  = null;
                    ChemicalSignature outputChemical2 = null;
                    foreach (OutputPipe pipe in factory.pipes)
                    {
                        PipeSocket receiver = pipe.connectedTo;
                        if (receiver != null)
                        {
                            if (outputChemical == null)
                            {
                                outputChemical = receiver.parent.GetInputChemical();
                            }
                            else
                            {
                                outputChemical2 = receiver.parent.GetInputChemical();
                                break;
                            }
                        }
                    }

                    objects.Add(new OutputZone(outputChemical, outputChemical2, new Vector2(192, 300), new Vector2(192, 32)));
                }

                Command_Spawn spawner = new Command_Spawn(new Vectangle(92, -36, 78, 32), factory, 0);
                triggerables.Add(spawner);

                objects.Add(new PushButton(spawner, TextureCache.clear, TextureCache.white, new Vector2(32, 240), new Vector2(8, 32), Color.Red));

                if (isDoubleFactory)
                {
                    objects.Add(new PlatformObject(TextureCache.buttonHood, new Vector2(382, 28), new Vector2(32, 32)));
                    objects.Add(new PlatformObject(TextureCache.woodFloor, new Vector2(192, 96), new Vector2(208, 32)));

                    Command_Spawn spawner2 = new Command_Spawn(new Vectangle(256, -36, 78, 32), factory, 1);
                    triggerables.Add(spawner2);
                    objects.Add(new PushButton(spawner2, TextureCache.clear, TextureCache.white, new Vector2(400 - 8, 64), new Vector2(8, 32), Color.Red));
                }

                saveButton.frame = new Rectangle(10, 302, 100, 40);
            }

            player = new PlatformCharacter(TextureCache.character, playerPos, new Vector2(14, 32), Color.White, new Rectangle(9, 0, 14, 32));
            objects.Add(player);

            //weaponButtons.selectedButton = rivetGunButton;

            projectiles = new List <Projectile>();
            paused      = false;
            recordedCommands.Clear();
            currentTime = 0;
            UpdateAnyBlocksLeft();

/*            if (rightSlotUI != null && Game1.instance.inventory.rightWeapon.weapon != null)
 *          {
 *              ui.Add(rightSlotUI);
 *              rightSlotUI = null;
 *          }*/

            if (Game1.instance.inventory.newWeaponAdded)
            {
                Game1.instance.splashes.Add(new Splash("NEW WEAPON", TextAlignment.CENTER, Game1.font, Color.Orange, new Vector2(600, 425), new Vector2(0, -5), 0.90f, 0, 2));
                Game1.instance.inventory.newWeaponAdded = false;
            }

            weaponSlots.Clear();
            Rectangle currentRect    = new Rectangle(600, 425, 175, 50);
            int       WEAPON_SPACING = 55;

            currentRect.Y -= Game1.instance.inventory.availableWeapons.Count * WEAPON_SPACING;
            foreach (Weapon w in Game1.instance.inventory.availableWeapons)
            {
                weaponSlots.Add(new UIWeaponButton(w, Game1.instance.inventory.leftWeapon, Game1.instance.inventory.rightWeapon, currentRect, weaponButtonStyle));
                currentRect.Y += WEAPON_SPACING;
            }
        }
Beispiel #8
0
        public override void ShootProjectile(PlatformCharacter shooter, Vector2 shootDir, List <Projectile> projectiles)
        {
            const float SHOTSPEED = 10.0f;

            projectiles.Add(new Projectile(TextureCache.white, Color.Cyan, shooter.bounds.Center, new Vector2(15, 3), shootDir * SHOTSPEED, ProjectileAction.BUBBLE));
        }
Beispiel #9
0
 public abstract void ShootProjectile(PlatformCharacter shooter, Vector2 shootDir, List <Projectile> projectiles);
Beispiel #10
0
        public void Update(MouseButtonState buttonState, Vector2 mousePos, PlatformCharacter shooter, List <PlatformObject> allObjects, List <Projectile> projectiles)
        {
            if (beamTraceDuration > 0)
            {
                beamTraceDuration--;
            }

            if (buttonState != null && buttonState.justReleased)
            {
                Game1.instance.platformLevel.Record(FactoryCommandType.SPENDCRYSTAL);

                beamTraceDuration = 20;
                beamTraceAngle    = beamAngle;
                beamTraceOrigin   = beamSource;

                if (beamTraceOffset.X == 0)
                {
                    Cut(new Vectangle(beamTraceOrigin + new Vector2(BEAMSPACING * 0.5f, 0), beamTraceOffset), allObjects);
                    Cut(new Vectangle(beamTraceOrigin + new Vector2(BEAMSPACING * -0.5f, 0), beamTraceOffset), allObjects);
                }
                else
                {
                    Cut(new Vectangle(beamTraceOrigin + new Vector2(0, BEAMSPACING * 0.5f), beamTraceOffset), allObjects);
                    Cut(new Vectangle(beamTraceOrigin + new Vector2(0, BEAMSPACING * -0.5f), beamTraceOffset), allObjects);
                }
            }

            if (buttonState != null && buttonState.isDown)
            {
                // preview beam
                beamSource      = shooter.bounds.Center;
                beamTraceOffset = mousePos - beamSource;

                if (Math.Abs(beamTraceOffset.X) > Math.Abs(beamTraceOffset.Y))
                {
                    if (beamTraceOffset.X > 0)
                    {
                        beamAngle       = 0;
                        beamTraceOffset = new Vector2(BEAMLENGTH, 0);
                    }
                    else
                    {
                        beamAngle       = (float)Math.PI;
                        beamTraceOffset = new Vector2(-BEAMLENGTH, 0);
                    }
                }
                else if (beamTraceOffset.Y > 0)
                {
                    beamAngle       = (float)Math.PI * 0.5f;
                    beamTraceOffset = new Vector2(0, BEAMLENGTH);
                }
                else
                {
                    beamAngle       = (float)Math.PI * 1.5f;
                    beamTraceOffset = new Vector2(0, -BEAMLENGTH);
                }
            }
            else
            {
                beamAngle = -1;
            }
        }