コード例 #1
0
	private void AddItems(){
		container = GetContainer ();

		if (container != null) {
			if (clearContainer) {
				container.Clear ();
			}

			if (execute != null) {
				if(behaviour == null){
					behaviour = gameObject.AddBehaviour(execute);
					behaviour.stateMachine.SetVariable ("Items", items);
					behaviour.stateMachine.SetVariable ("Container", container.gameObject);
				}
				return;
			}

			for (int i=0; i< items.Length; i++) {
				if (items [i] != null) {
					container.Add (items[i]);
				}
			}

			if(openContainer){
				OpenContainer();
			}
		}
	}
コード例 #2
0
        void slot_Clicked()
        {
            isOpen = !isOpen;

            if (weaponSlotStyle == null)
            {
                weaponSlotStyle = new UIButtonStyle(
                    new UIButtonAppearance(Game1.font, Color.White, TextureCache.castIronButton, Color.White, new Vector2(25, 0)),
                    new UIButtonAppearance(Game1.font, Color.White, TextureCache.castIronButton_hover, Color.White, new Vector2(25, 0)),
                    new UIButtonAppearance(Game1.font, Color.White, TextureCache.castIronButton_pressed, Color.White, new Vector2(25, 1)),
                    new UIButtonAppearance(Game1.font, Color.White, TextureCache.castIronButton, Color.White, new Vector2(25, 0))
                    );
            }

            const int BUTTONHEIGHT = 50;

            dropDown.Clear();
            Vector2 nextSelectablePos = new Vector2(frame.X, frame.Y - BUTTONHEIGHT * (availableWeapons.Count() - 1));

            foreach (Weapon w in availableWeapons)
            {
                if (w != slot.weapon)
                {
                    dropDown.Add(new UIWeaponSelectable(w, new Rectangle((int)nextSelectablePos.X, (int)nextSelectablePos.Y, 175, BUTTONHEIGHT), weaponSlotStyle, button_SelectWeapon));
                    nextSelectablePos.Y += BUTTONHEIGHT;
                }
            }
        }
コード例 #3
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;
            }
        }