예제 #1
0
 public static void CraftItem(Blueprint blueprint)
 {
     if (OnItemCraft != null)
     {
         OnItemCraft(blueprint);
     }
 }
 public static Blueprint ProcessFactoryPart(AvailablePart part)
 {
     var resources = new Dictionary<string, WorkshopResource>();
     if (PartRecipes.ContainsKey(part.name))
     {
         var recipe = FactoryRecipes[part.name];
         foreach (var workshopResource in recipe.Prepare(part.partPrefab.mass))
         {
             if (resources.ContainsKey(workshopResource.Name))
             {
                 resources[workshopResource.Name].Merge(workshopResource);
             }
             else
             {
                 resources[workshopResource.Name] = workshopResource;
             }
         }
     }
     else
     {
         Debug.LogWarning("[OSE] - No FactoryRecipeFound for " + part.title);
         return null;
     }
     var blueprint = new Blueprint();
     blueprint.AddRange(resources.Values);
     blueprint.Funds = Mathf.Max(part.cost - (float)blueprint.ResourceCosts(), 0);
     return blueprint;
 }
예제 #3
0
 public Mission(string name, MissionType mType, Blueprint requiredBP, string desc = "Unknown Signal")
 {
     missionName = name;
     missionType = mType;
     requiredBlueprint = requiredBP;
     description = desc;
 }
    public void BuildThis(Blueprint building)
    {
        // Set currBuilding to true to lock building options
        currentlyBuilding = true;

        // Mouse position so I can instantiate on the mouse!
        Vector3 m = Mouse_Controller.MouseController.currMouseP;
        Vector3 spawnPos = new Vector3(Mathf.Round(m.x), Mathf.Round(m.y), 0.0f);

        // At this point NanoBuild_handler should have checked if there's ENOUGH nanobots to build AND subtracted the NANOBOTS necessary, so just build!
        string halfName = "half_Built";

        // First: Load an icon representing the Building so player can decide if that's what they want or not.
        GameObject halfBuilt = objPool.GetObjectForType(halfName, true, spawnPos);

        // To get the sprite we can have a database of sprites that is ONLY filled with the sprites that the player has blueprints for building.
           // Sprite theSprite = BuildingSprite_Manager.Instance.GetSprite(building.buildingName);
           // theSprite.bounds.size
        halfBuilt.GetComponent<SpriteRenderer>().sprite = BuildingSprite_Manager.Instance.GetSprite(building.buildingName);

        Building_PositionHandler bPosHand = halfBuilt.GetComponent<Building_PositionHandler>();
        bPosHand.SetCurrentBlueprintID(building.buildingName);
        bPosHand.spawnPos = spawnPos;
        bPosHand.followMouse = true;
        bPosHand.tileType = building.tileType;
        bPosHand.currNanoBotCost = building.nanoBotCost;
        bPosHand.nanoBuild_handler = nanoBuild_handler;
    }
        public static IBlueprint Deserialize(string data)
        {
            if (data == null) throw new ArgumentNullException(nameof(data));

            var blueprint = new Blueprint(data.GetFilledLines().Select(DataWrapper.Parse).ToArray());

            return blueprint;
        }
예제 #6
0
 // Survival Mission:
 public Mission(string name, MissionType mType, Blueprint requiredBP, TileData.Types reqResource, int reqAmnt, string desc = "Unknown Signal")
 {
     missionName = name;
     missionType = mType;
     requiredBlueprint = requiredBP;
     description = desc;
     objectiveResource = reqResource;
     objectiveAmnt = reqAmnt;
 }
예제 #7
0
 //TODO Принимать параметры конструктора?
 public void Add(Blueprint blueprint)
 {
     if (FreeIDs.Count == 0)
         blueprint.Id = (uint)Blueprints.Count;
     else
     {
         blueprint.Id = FreeIDs[0];
         FreeIDs.RemoveAt(0);
     }
     Blueprints.Add(blueprint);
 }
예제 #8
0
        /**
         * This is the constructor for the BlueprintPanel.
         */
        public BlueprintPanel()
        {
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            this.ActiveBlueprint = null;
            this.OriginalBlueprint = null;

            this.BackColor = this.Renderer.ColorTable.BackgroundNormal;
            this.IsResizable = true;

            this._snapCorners = new List<Corner>();
        }
예제 #9
0
    public void Before()
    {
        _pool = Helper.CreatePool();

        var e = _pool.CreateEntity();
        var component = new NameAgeComponent();
        component.name = "Max";
        component.age = 42;
        e.AddComponent(CP.ComponentA, component);

        _blueprint = new Blueprint(string.Empty, string.Empty, e);
    }
예제 #10
0
    public void AddBluePrint(TileData.Types bpType, Blueprint bp)
    {
        blueprintsMap.Add(bpType, bp);

        if (bpType != TileData.Types.terraformer)
        {
            cur_memory -= bp.memoryCost;
        }

        if (!bpTypes.Contains(bpType))
            bpTypes.Add(bpType);
    }
        /// <summary>
        ///   Reads the next blueprint from the specified reader.
        /// </summary>
        /// <param name="reader">Reader to read the next blueprint from.</param>
        /// <returns>Read blueprint.</returns>
        public Blueprint Read(XmlReader reader)
        {
            reader.Read();
            reader.Read();

            var blueprintId = reader[BlueprintIdAttributeName];
            var blueprint = new Blueprint(blueprintId);

            // Read blueprint id.
            reader.ReadStartElement(BlueprintElementName);
            {
                // Read property values.
                reader.ReadStartElement(PropertyValuesElementName);
                {
                    while (reader.IsStartElement(PropertyElementName))
                    {
                        var key = reader[PropertyKeyAttributeName];
                        var typeName = reader[PropertyTypeAttributeName];
                        var type = Type.GetType(typeName);

                        reader.ReadStartElement(PropertyElementName);
                        {
                            var value =
                                new XmlSerializer(type, new XmlRootAttribute(PropertyValueElementName)).Deserialize(
                                    reader);

                            // Add to blueprint.
                            blueprint.PropertyValues.Add(key, value);
                        }
                        reader.ReadEndElement();
                    }
                }
                reader.ReadEndElement();

                // Read components.
                reader.ReadStartElement(ComponentsElementName);
                {
                    while (reader.IsStartElement(ComponentElementName))
                    {
                        var component = reader.ReadElementContentAsString();

                        // Add to blueprint.
                        blueprint.ComponentTypes.Add(component);
                    }
                }
                reader.ReadEndElement();
            }
            reader.ReadEndElement();

            return blueprint;
        }
예제 #12
0
 private void CraftItem(Blueprint blueprint)
 {
     bool EnoughSpace = Inventory.ItemsInInventory.Count < Inventory.Height * Inventory.Width;
     if (EnoughSpace)
     {
         Crafting.RemoveMaterials();
         Crafting.AddItem();
     }
     else
     {
         Debug.Log("Недостаточно места");
         return;
     }
 }
예제 #13
0
        public void HighYieldBlueprintScoresHigherThanLowYieldBlueprint()
        {
            var blueprintALow = new Blueprint("ALow", new ItemAndQuantity("Ore/A", 10f), new ItemAndQuantity("Ingot/A", 10f));
            var blueprintAHigh = new Blueprint("AHigh", new ItemAndQuantity("Ore/A", 10f), new ItemAndQuantity("Ingot/A", 12f));
            var stockpiles = new Stockpiles(
                new[] {
                    new IngotStockpile { Ingot = new IngotType("Ingot/A", 1, 10), CurrentQuantity = 50, TargetQuantity = 100 }
                },
                new[] { blueprintALow, blueprintAHigh });

            var aLowScore = stockpiles.ScoreBlueprint(blueprintALow);
            var aHighScore = stockpiles.ScoreBlueprint(blueprintAHigh);

            Assert.That(aHighScore, Is.GreaterThan(aLowScore));
        }
예제 #14
0
        public void AssignedWorkAffectsQuotaFactor()
        {
            var blueprint = new Blueprint("A", new ItemAndQuantity("Ore/A", 10f), new ItemAndQuantity("Ingot/A", 10f));

            var stockpiles = new Stockpiles(
                new[] { new IngotStockpile { Ingot = new IngotType("Ingot/A", 1, 10), CurrentQuantity = 50, TargetQuantity = 100 } },
                new[] { blueprint });

            var refinery = new Refinery(new Mock<IMyRefinery>().Object, new RefineryType("Refinery") { SupportedBlueprints = { "A" } });

            var initialStockpile = stockpiles.GetStockpiles().Single();
            stockpiles.UpdateStockpileEstimates(refinery, blueprint, 5f);
            var updatedStockpile = stockpiles.GetStockpiles().Single();

            Assert.That(updatedStockpile.QuotaFraction, Is.GreaterThan(initialStockpile.QuotaFraction));
            Assert.That(updatedStockpile.EstimatedProduction, Is.GreaterThan(0));
        }
예제 #15
0
        public void BlueprintWithAllOutputsInDemandScoresHigherThanBlueprintWithOnlyOneOutputInDemand()
        {
            var blueprintAB = new Blueprint("AB", new ItemAndQuantity("Ore/AB", 10f), new ItemAndQuantity("Ingot/A", 10f), new ItemAndQuantity("Ingot/B", 10f));
            var blueprintBC = new Blueprint("BC", new ItemAndQuantity("Ore/BC", 10f), new ItemAndQuantity("Ingot/B", 10f), new ItemAndQuantity("Ingot/C", 10f));
            var stockpiles = new Stockpiles(
                new[] {
                    new IngotStockpile { Ingot = new IngotType("Ingot/A", 1, 10), CurrentQuantity = 500, TargetQuantity = 100 },    // Not in demand.
                    new IngotStockpile { Ingot = new IngotType("Ingot/B", 1, 10), CurrentQuantity = 50, TargetQuantity = 100 },
                    new IngotStockpile { Ingot = new IngotType("Ingot/C", 1, 10), CurrentQuantity = 50, TargetQuantity = 100 }
                },
                new[] { blueprintAB, blueprintBC });

            var abScore = stockpiles.ScoreBlueprint(blueprintAB);
            var bcScore = stockpiles.ScoreBlueprint(blueprintBC);

            Assert.That(bcScore, Is.GreaterThan(abScore));
        }
예제 #16
0
    // Use this for initialization
    void Start()
    {
        Blueprint specs = new Blueprint(width, height, roomsRemaining);
        for(int i = 0; i<specs.width; i++){
            for(int j = 0; j<specs.height; j++){
                string imagePath = rooms.getRoom (specs.map[i,j].getRoomCode());
                GameObject roomObject = Instantiate(roomPrefab, new Vector3(.32f*(float)i, .32f*(float)j), Quaternion.identity) as GameObject;
                Debug.Log (imagePath);
                Debug.Log (Resources.Load<Sprite>(imagePath) as Sprite);
                roomObject.GetComponent<SpriteRenderer>().sprite = Resources.Load(imagePath, typeof(Sprite)) as Sprite;

                if(specs.map[i,j].isStart())
                    Instantiate(startMarker, new Vector3(.32f*(float)i, .32f*(float)j), Quaternion.identity);

                if(specs.map[i,j].isBoss())
                    Instantiate(endMarker, new Vector3(.32f*(float)i, .32f*(float)j), Quaternion.identity);
            }
        }
    }
예제 #17
0
        public Recipes()
        {
            RecipeTechBlowbot = new Recipe();
            RecipeTechBlowbot.Name = "Vacubot";
            RecipeTechBlowbot.AutoGrant = true;
            RecipeTechBlowbot.CraftingCategory = "Gadgets";
            RecipeTechBlowbot.Category = "Gadgets";
            RecipeTechBlowbot.ResultItem = new ResultRecipeItem((InventoryItemType)TechBlowbot.ID,1);
            //RecipeTechBlowbot.RequiredMaterials = new RequiredRecipeMaterial[]{
            //    new RequiredRecipeMaterial(InventoryItemType.TECH_BLOWER,1),
            //    new RequiredRecipeMaterial(InventoryItemType.MICROCHIP,5),
            //    new RequiredRecipeMaterial(InventoryItemType.WIRE_COPPER,25),
            //    new RequiredRecipeMaterial(InventoryItemType.MACHINE_PARTS_STEEL,2),
            //    new RequiredRecipeMaterial(InventoryItemType.RIVET_STEEL,10)
            //}.ToList();
            RecipeTechBlowbot.RequiredMaterials = DebugNoMats.ToList();
            RecipeTechBlowbot.AdditionalRequirement = "Material Printer";

            BlueprintIndustrialDrill = new Blueprint();
            BlueprintIndustrialDrill.Name = IndustrialDrill.TypeName;
            BlueprintIndustrialDrill.Description = "Enjoy your life while others work.";
            BlueprintIndustrialDrill.Hidden = false;
            BlueprintIndustrialDrill.ResultStaticPrefab =
                new ResultBlueprintStaticPrefab((StaticPrefabType)IndustrialDrill.TypeID);
            BlueprintIndustrialDrill.RequiredMaterials = new RequiredRecipeMaterial[]{

            }.ToList();

            BlueprintCombustionGenerator = new Blueprint();
            BlueprintCombustionGenerator.Name = CombustionGenerator.TypeName;
            BlueprintCombustionGenerator.Description = "As positive as possible.";
            BlueprintCombustionGenerator.Hidden = false;
            BlueprintCombustionGenerator.ResultStaticPrefab = new ResultBlueprintStaticPrefab((StaticPrefabType)CombustionGenerator.TypeID);
            BlueprintCombustionGenerator.RequiredMaterials = new RequiredRecipeMaterial[]{

            }.ToList();
        }
예제 #18
0
 private void CleanupRecycler()
 {
     _processedItem.DisableIcon();
     _processedItem = null;
     _processedBlueprint = null;
     progress = 0;
     Status = "Online";
 }
예제 #19
0
        public void ToleratesBlueprintsWithUnknownIngotTypes()
        {
            var blueprint = new Blueprint("A", new ItemAndQuantity("Ore/A", 10f), new ItemAndQuantity("Ingot/A", 10f));
            var stockpiles = new Stockpiles(
                new IngotStockpile[0],
                new[] { blueprint });

            var refinery = new Refinery(new Mock<IMyRefinery>().Object, new RefineryType("Refinery") { SupportedBlueprints = { "A" } });

            stockpiles.UpdateStockpileEstimates(refinery, blueprint, 5f);
        }
예제 #20
0
 public ParticleComponent(Blueprint bp, List <ParticleComponent> particles)
 {
     Bp        = bp;
     Particles = particles;
 }
예제 #21
0
            public void SilverAndCobalt2()
            {
                var cobalt = new Blueprint("CobaltOreToIngot", new ItemAndQuantity("Ore/Cobalt", 0.25f), new ItemAndQuantity("Ingot/Cobalt", 0.075f));
                var silver = new Blueprint("SilverOreToIngot", new ItemAndQuantity("Ore/Silver", 1f), new ItemAndQuantity("Ingot/Silver", 0.1f));
                var stockpiles = new Stockpiles(
                    new[] {
                        new IngotStockpile { Ingot = new IngotType("Ingot/Cobalt", 220f, 0.075f), CurrentQuantity = 220, TargetQuantity = 2200 },
                        new IngotStockpile { Ingot = new IngotType("Ingot/Silver", 10f, 0.1f), CurrentQuantity = 10, TargetQuantity = 100 }
                    },
                    new[] { cobalt, silver });

                var cobaltScore = stockpiles.ScoreBlueprint(cobalt);
                var silverScore = stockpiles.ScoreBlueprint(silver);

                Assert.That(silverScore, Is.EqualTo(cobaltScore).Within(0.01).Percent);
            }
예제 #22
0
    // Science Mission:
    public Mission(string name, MissionType mType, Blueprint requiredBP, int stages, string desc = "Unknown Signal")
    {
        missionName = name;
        missionType = mType;
        requiredBlueprint = requiredBP;
        description = desc;

        objectiveStages = stages;
    }
예제 #23
0
 private void SetVerticesCount(int count)
 {
     Blueprint.SetBaseVerticesCount(count);
     UpdatePointNameFields();
 }
예제 #24
0
    /*
     * building has been pressed
     */
    private void pressedHandler(object sender, EventArgs e)
    {
        //are we choosing building at the beginning of the game?
        if (state == BuildingState.Menu)
        {
        origin = Instantiate (gameObject) as GameObject;
        origin.transform.position = gameObject.transform.position;
        origin.transform.localScale = new Vector3(1,1,1);
        origin.transform.parent = gameObject.transform.parent;
        origin.SetActive (false);
        gameObject.transform.parent = null;
        } else {
        //check to see that the game is running properly
        var controller = GameObject.FindGameObjectWithTag (Tags.GameController);
        var clock = controller.GetComponent<Clock> ();
        if (clock == null) {
            Debug.LogError ("Oh shit no clock!");
        }
        //building is built
        if (state == BuildingState.Built) {
        //create building menu if one doesn't exist
        if (menu == null){
            GameObject obj = Instantiate (menuPrefab) as GameObject;
            obj.transform.position = gameObject.transform.position;
            obj.name = gameObject.name + "Menu";
            obj.transform.parent = gameObject.transform;
            obj.GetComponent<Popup>().setTarget(gameObject);
            menu = obj;
        }
        //if one does exist destroy it
        else {
            Destroy (menu);
            menu = null;
        }
        }
        //if the building is in the pallet
        if (state == BuildingState.Pallet) {
        //create a copy of the building, but disable it's creation methods etc.
        var obj = Instantiate (gameObject) as GameObject;
        obj.name = (gameObject.name);
        obj.GetComponent<Cube> ().enabled = true;
        obj.GetComponent<TapGesture> ().enabled = true;
        obj.transform.parent = gameObject.transform.parent;
        obj.GetComponent<Cube>().setState (BuildingState.Pallet);
        var pos = obj.transform.position;
        pos.z = -3.0f;
        gameObject.transform.position = pos;
        state = BuildingState.Dragging;
        tag = Tags.Placing;

        //spend materials for building
        switch(obj.name){
                case "City":
                    clock.spendMaterial(buildings.City);
                    break;
                case "Factory":
                    clock.spendMaterial(buildings.Factory);
                    break;
                case "Farm":
                    clock.spendMaterial(buildings.Farm);
                    break;
                case "Fishing":
                    clock.spendMaterial(buildings.Fishing);
                    break;
                case "Lumber":
                    clock.spendMaterial(buildings.Lumber);
                    break;
                case "Mine":
                    clock.spendMaterial(buildings.Mine);
                    break;
                case "Power":
                    clock.spendMaterial(buildings.Power);
                    break;
                case "School":
                    clock.spendMaterial(buildings.School);
                    break;
        }

        //create blueprint for the building
        GameObject newBlueprint = (GameObject)GameObject.Instantiate (blueprintPrefab, gameObject.transform.position, gameObject.transform.rotation);
        blueprint = newBlueprint.GetComponent<Blueprint> ();
        blueprint.setParent (this.gameObject);
        }
        }
    }
예제 #25
0
        public void Serialize(IEntity entity)
        {
            var blueprint = new Blueprint(entity.contextInfo.name, name, entity);

            Serialize(blueprint);
        }
예제 #26
0
 public SkyDomeComponent(GraphicsDevice GD, Blueprint bp) : base(GD, (float)bp.OutsideTime)
 {
     BP = bp;
 }
예제 #27
0
 public WorldPlatform2D(Blueprint bp)
 {
     this.bp = bp;
 }
예제 #28
0
        public override void Update(UpdateState state)
        {
            base.Update(state);
            var rcState = ((WorldStateRC)State);

            float terrainHeight = 0;

            if (Blueprint != null)
            {
                terrainHeight = (Blueprint.InterpAltitude(new Vector3(State.CenterTile, 0))) * 3;
                var targHeight = terrainHeight + (State.Level - 1) * 2.95f * 3;
                targHeight         = Math.Max((Blueprint.InterpAltitude(new Vector3(State.Camera.Position.X, State.Camera.Position.Z, 0) / 3) + (State.Level - 1) * 2.95f) * 3, terrainHeight);
                rcState.CamHeight += (targHeight - rcState.CamHeight) * (1f - (float)Math.Pow(0.8f, 60f / FSOEnvironment.RefreshRate));
            }

            if (Visible && !rcState.FixedCam)
            {
                if (state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.Tab))
                {
                    rcState.CameraMode = !rcState.CameraMode;
                }

                if (rcState.CameraMode)
                {
                    if (state.WindowFocused)
                    {
                        var mx = (int)State.WorldSpace.WorldPxWidth / (2 * PPXDepthEngine.SSAA);
                        var my = (int)State.WorldSpace.WorldPxHeight / (2 * PPXDepthEngine.SSAA);

                        var mpos = state.MouseState.Position;
                        if (LastFP)
                        {
                            rcState.RotationX -= (mpos.X - mx) / 500f;
                            rcState.RotationY += (mpos.Y - my) / 500f;
                        }
                        Mouse.SetPosition(mx, my);

                        var speed = (state.KeyboardState.IsKeyDown(Keys.LeftShift)) ? 1.5f : 0.5f;

                        if (state.KeyboardState.IsKeyDown(Keys.W))
                        {
                            FPCamVelocity.Z -= speed;
                        }
                        if (state.KeyboardState.IsKeyDown(Keys.S))
                        {
                            FPCamVelocity.Z += speed;
                        }
                        if (state.KeyboardState.IsKeyDown(Keys.A))
                        {
                            FPCamVelocity.X -= speed;
                        }
                        if (state.KeyboardState.IsKeyDown(Keys.D))
                        {
                            FPCamVelocity.X += speed;
                        }
                        if (state.KeyboardState.IsKeyDown(Keys.Q))
                        {
                            FPCamVelocity.Y -= speed;
                        }
                        if (state.KeyboardState.IsKeyDown(Keys.E))
                        {
                            FPCamVelocity.Y += speed;
                        }
                        LastFP = true;
                    }
                    else
                    {
                        LastFP = false;
                    }

                    Scroll(new Vector2(FPCamVelocity.X / FSOEnvironment.RefreshRate, FPCamVelocity.Z / FSOEnvironment.RefreshRate));
                    rcState.FPCamHeight = Math.Max((terrainHeight - rcState.CamHeight) - 2, rcState.FPCamHeight + (FPCamVelocity.Y * 3) / FSOEnvironment.RefreshRate);
                    for (int i = 0; i < FSOEnvironment.RefreshRate / 60; i++)
                    {
                        FPCamVelocity *= 0.9f;
                    }
                }
                else if (Visible)
                {
                    LastFP = false;
                    var md = state.MouseState.MiddleButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

                    if (MouseWasDown)
                    {
                        var mpos = state.MouseState.Position;
                        rcState.RotationX += (mpos.X - LastMouse.X) / 250f;
                        rcState.RotationY += (mpos.Y - LastMouse.Y) / 150f;
                    }

                    if (md)
                    {
                        LastMouse = state.MouseState.Position;
                    }
                    MouseWasDown = md;
                }
            }
        }
예제 #29
0
        public VMArchitecture(int width, int height, Blueprint blueprint, VMContext context)
        {
            if (Content.Content.Get().TS1)
            {
                DisableClip  = true;
                TerrainLimit = new Rectangle(1, 1, width - 2, height - 2);
            }
            else
            {
                TerrainLimit = new Rectangle(6, 6, 65, 65);
                TerrainLimit.Inflate(-1, -1);
            }

            this.Context = context;
            this.Width   = width;
            this.Height  = height;

            var numTiles = width * height;

            this.WallsAt  = new List <int> [Stories];
            this.Walls    = new WallTile[Stories][];
            this.VisWalls = new WallTile[Stories][];

            this.Floors    = new FloorTile[Stories][];
            this.VisFloors = new FloorTile[Stories][];

            this.ObjectSupport = new bool[Stories][];     //true if there's an object support in the specified position
            this.Supported     = new bool[Stories - 1][]; //no supported array for bottom floor. true if this tile is supported.
            if (blueprint != null)
            {
                blueprint.Supported = Supported;
            }

            this.Rooms   = new VMRoomMap[Stories];
            this.Terrain = new VMArchitectureTerrain(width, height);

            for (int i = 0; i < Stories; i++)
            {
                this.WallsAt[i]  = new List <int>();
                this.Walls[i]    = new WallTile[numTiles];
                this.VisWalls[i] = new WallTile[numTiles];

                this.Floors[i]        = new FloorTile[numTiles];
                this.VisFloors[i]     = new FloorTile[numTiles];
                this.ObjectSupport[i] = new bool[numTiles];

                if (i < Stories - 1)
                {
                    this.Supported[i] = new bool[numTiles];
                }

                this.Rooms[i] = new VMRoomMap();
            }

            this.RoomData = new List <VMRoom>();
            this.WorldUI  = blueprint;

            this.Commands = new List <VMArchitectureCommand>();
            this.Commands = new List <VMArchitectureCommand>();

            WallsDirty  = true;
            FloorsDirty = true;
            RealMode    = true;
            Redraw      = true;
        }
예제 #30
0
 public VMArchitecture(VMArchitectureMarshal input, VMContext context, Blueprint blueprint) : this(input.Width, input.Height, blueprint, context)
 {
     Load(input);
 }
예제 #31
0
 public void InitBlueprint(Blueprint bp)
 {
     Bp = bp;
 }
예제 #32
0
 private void StartManufacturing()
 {
     var nextQueuedPart = _queue.Pop();
     if (nextQueuedPart != null)
     {
         _processedItem = nextQueuedPart;
         _processedBlueprint = WorkshopRecipeDatabase.ProcessPart(nextQueuedPart.Part);
         foreach (var resource in _processedBlueprint)
         {
             resource.Units *= ConversionRate;
         }
     }
 }
예제 #33
0
    /// <summary>
    /// 右键物品栏且物品栏有物品
    /// </summary>
    public virtual void OnButtonRight()
    {
        ItemUI currentItem = transform.GetChild(0).GetComponent <ItemUI>();

        if (currentItem.Item.Type == Item.ItemType.Equipment || currentItem.Item.Type == Item.ItemType.ShootWeapon || currentItem.Item.Type == Item.ItemType.MeleeWeapon)
        {
            currentItem.ReduceAmount(1);
            Item tempItem = currentItem.Item;
            if (currentItem.Amount <= 0)
            {
                DestroyImmediate(currentItem.gameObject);
                InventoryManager.Instance.HideToolTip();
            }
            CharacterPanel.Instance.Equip(tempItem);
        }
        if (currentItem.Item.Type == Item.ItemType.Consumable)
        {
            //TODO 消耗品
            //TODO 普通消耗品(无持续性)
            //TODO 滋补品(有持续时间)
            currentItem.ReduceAmount(1);
            Consumable tempItem = (Consumable)currentItem.Item;
            if (currentItem.Amount <= 0)
            {
                DestroyImmediate(currentItem.gameObject);
                InventoryManager.Instance.HideToolTip();
            }
            if (tempItem.ContinuedTime != 0)
            {
                //使用了滋补品
                //Debug.Log("使用了"+tempItem.Name);
                CharacterPanel.Instance.AddBuff(tempItem.BuffID);
            }
            else
            {
            }
        }
        if (currentItem.Item.Type == Item.ItemType.Package)
        {
            //TODO 打开包裹
            currentItem.ReduceAmount(1);
            Package tempItem = (Package)currentItem.Item;
            if (currentItem.Amount <= 0)
            {
                DestroyImmediate(currentItem.gameObject);
                InventoryManager.Instance.HideToolTip();
            }
            if (tempItem.ItemIDs != null)
            {
                int   getItemID     = 0;
                int   getItemAmount = 1;
                float randomProb    = Random.value;
                for (int i = 0; i < tempItem.ItemProbabilities.Length; i++)
                {
                    float minProb = 0;
                    float maxProb = 0;
                    for (int j = 0; j < i; j++)
                    {
                        minProb += tempItem.ItemProbabilities[j];
                    }
                    for (int k = -1; k < i; k++)
                    {
                        maxProb += tempItem.ItemProbabilities[k + 1];
                    }
                    //string text= string.Format("第{0}组:最小概率:{1} 最大概率:{2} 本次概率:{3}", i, minProb, maxProb, randomProb);
                    if (randomProb >= minProb && randomProb <= maxProb)
                    {
                        getItemID     = tempItem.ItemIDs[i];
                        getItemAmount = tempItem.ItemCount[i];
                    }
                    //Debug.Log(text);
                }
                for (int i = 0; i < getItemAmount; i++)
                {
                    BackPack.Instance.SetItem(getItemID);
                }
            }
            else if (tempItem.ItemTypes != null)
            {
                if (tempItem.ItemTechnologies != null && tempItem.ItemProbabilities[0] == 1)
                {
                    for (int i = 0; i < tempItem.ItemTypes.Length; i++)
                    {
                        List <Item> items    = InventoryManager.Instance.FindItemsWithCondition(tempItem.ItemTypes[i], tempItem.ItemTechnologies[i]);
                        int         randomID = Random.Range(0, items.Count);

                        Item getItem   = items[randomID];
                        int  itemCount = tempItem.ItemCount[i] > getItem.MaxStark ? getItem.MaxStark : tempItem.ItemCount[i];
                        for (int j = 0; j < itemCount; j++)
                        {
                            BackPack.Instance.SetItem(getItem);
                        }
                    }
                }
                if (tempItem.ItemTechnologies != null && tempItem.ItemProbabilities[0] != 1)
                {
                    float randomProb = Random.value;
                    Item.ItemTechnology randomTech = Item.ItemTechnology.T1;
                    for (int i = 0; i < tempItem.ItemProbabilities.Length; i++)
                    {
                        float minProb = 0;
                        float maxProb = 0;
                        for (int j = 0; j < i; j++)
                        {
                            minProb += tempItem.ItemProbabilities[j];
                        }
                        for (int k = -1; k < i; k++)
                        {
                            maxProb += tempItem.ItemProbabilities[k + 1];
                        }
                        //string text = string.Format("第{0}组:最小概率:{1} 最大概率:{2} 本次概率:{3}", i, minProb, maxProb, randomProb);
                        //Debug.Log(text);
                        if (randomProb >= minProb && randomProb <= maxProb)
                        {
                            randomTech = (Item.ItemTechnology)(i + 1);
                        }
                    }
                    for (int i = 0; i < tempItem.ItemTypes.Length; i++)
                    {
                        List <Item> items     = InventoryManager.Instance.FindItemsWithCondition(tempItem.ItemTypes[i], randomTech);
                        int         randomID  = Random.Range(0, items.Count);
                        Item        getItem   = items[randomID];
                        int         itemCount = tempItem.ItemCount[i] > getItem.MaxStark ? getItem.MaxStark : tempItem.ItemCount[i];
                        for (int j = 0; j < itemCount; j++)
                        {
                            BackPack.Instance.SetItem(getItem);
                        }
                    }
                }
            }
        }
        if (currentItem.Item.Type == Item.ItemType.Blueprint)
        {
            //TODO 学习蓝图
            currentItem.ReduceAmount(1);
            Blueprint tempItem = (Blueprint)currentItem.Item;
            if (currentItem.Amount <= 0)
            {
                DestroyImmediate(currentItem.gameObject);
                InventoryManager.Instance.HideToolTip();
            }
            foreach (int craftID in tempItem.CraftIDs)
            {
                InventoryManager.Instance.LearnCraft(craftID);
            }
        }
    }
예제 #34
0
        public static void RestoreSurroundings(VM vm, byte[][] hollowAdj)
        {
            var myArch   = vm.Context.Architecture;
            var terrain  = vm.TSOState.Terrain;
            var size     = myArch.Width;
            var lotsMode = WorldConfig.Current.SurroundingLots;

            foreach (var world in vm.Context.Blueprint.SubWorlds)
            {
                world.Dispose();
            }
            vm.Context.Blueprint.SubWorlds.Clear();

            var baseHeight = GetBaseLevel(vm, terrain, 1, 1);

            //vm.Context.Blueprint.BaseAlt = 0;// 128;
            //vm.Context.World.State.BaseHeight = 0;// (128 * 3) / 16f;

            if (lotsMode == 0)
            {
                return;
            }
            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    if (x == 1 & y == 1)
                    {
                        continue;                  //that's us...
                    }
                    var gd       = vm.Context.World.State.Device;
                    var subworld = vm.Context.World.MakeSubWorld(gd);
                    subworld.Initialize(gd);
                    var tempVM = new VM(new VMContext(subworld), new VMServerDriver(new VMTSOGlobalLinkStub()), new VMNullHeadlineProvider());
                    tempVM.Init();

                    var state = (hollowAdj == null)? null : hollowAdj[y * 3 + x];
                    if (lotsMode == 1)
                    {
                        state = null;
                    }

                    float           height = 0;
                    VMHollowMarshal hollow = null;
                    if (state != null)
                    {
                        try
                        {
                            hollow = new VMHollowMarshal();
                            using (var reader = new BinaryReader(new MemoryStream(state))) {
                                hollow.Deserialize(reader);
                            }
                            tempVM.HollowLoad(hollow);
                            RestoreTerrain(tempVM, terrain.BlendN[x, y], terrain.Roads[x, y]);
                            if (hollow.Version < 19)
                            {
                                height = RestoreHeight(tempVM, terrain, x, y);
                            }
                            else
                            {
                                height = GetBaseLevel(tempVM, terrain, x, y);
                            }
                            tempVM.Context.Blueprint.BaseAlt = (int)((baseHeight - height));
                            foreach (var obj in tempVM.Entities)
                            {
                                obj.Position = obj.Position;
                            }

                            tempVM.Tick();
                        } catch (Exception)
                        {
                            hollow = null;
                        }
                    }

                    if (hollow == null)
                    {
                        var blueprint = new Blueprint(size, size);
                        tempVM.Context.Blueprint = blueprint;
                        subworld.InitBlueprint(blueprint);
                        tempVM.Context.Architecture = new VMArchitecture(size, size, blueprint, tempVM.Context);

                        tempVM.Context.Architecture.RegenRoomMap();
                        tempVM.Context.RegeneratePortalInfo();

                        var terrainC = new TerrainComponent(new Rectangle(0, 0, size, size), blueprint);
                        terrainC.Initialize(subworld.State.Device, subworld.State);
                        blueprint.Terrain = terrainC;

                        RestoreTerrain(tempVM, terrain.BlendN[x, y], terrain.Roads[x, y]);
                        height = RestoreHeight(tempVM, terrain, x, y);
                        tempVM.Context.Blueprint.BaseAlt = (int)((baseHeight - height));

                        PopulateBlankTerrain(tempVM);

                        tempVM.Tick();
                    }

                    subworld.State.Level = 5;

                    subworld.GlobalPosition = new Vector2((1 - y) * (size - 2), (x - 1) * (size - 2));

                    vm.Context.Blueprint.SubWorlds.Add(subworld);
                }
            }
            vm.Context.World.InitSubWorlds();
        }
 public static Blueprint Clone(Blueprint blueprint)
 {
     return(BlueprintScrappinUtil.Clone(blueprint));
 }
    //Executes the blueprint node set set variable instance
    public override void Execute()
    {
        //If dependent attribute connections are valid
        if (connections[0].connectionNodeID > -1 && connections[1].connectionNodeID > -1 && connections[2].connectionNodeID > -1)
        {
            //Create reference to the blueprint input attribute
            Blueprint blueprintInputAttribute = BlueprintInstanceManager.GetBlueprintAt((int)BlueprintInstanceManager.GetBlueprintAt(blueprintID).GetBlueprintNodeAt(connections[0].connectionNodeID).GetAttribute());

            //If the blueprint input attribute is valid
            if (blueprintInputAttribute != null)
            {
                //Flag indicating whether the blueprint variable has been found
                bool foundBlueprintVariable = false;

                //For each node in the blueprint input attribute
                for (int nodeIndex = 0; nodeIndex < blueprintInputAttribute.GetBlueprintNodeCount(); nodeIndex++)
                {
                    //If the blueprint node is a variable
                    if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariable != null)
                    {
                        //If the blueprint node variable has a matching variable name
                        if (((BlueprintNodeVariable)blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex)).variableName == (string)BlueprintInstanceManager.GetBlueprintAt(blueprintID).GetBlueprintNodeAt(connections[1].connectionNodeID).GetAttribute())
                        {
                            //Depending on the selected type
                            switch (selectedType)
                            {
                            //Bool
                            case 0:
                            {
                                //If the blueprint node is a variable bool
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableBool != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Float
                            case 1:
                            {
                                //If the blueprint node is a variable float
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableFloat != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //GameObject
                            case 2:
                            {
                                //If the blueprint node is a variable GameObject
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableGameObject != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Int
                            case 3:
                            {
                                //If the blueprint node is a variable int
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableInt != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Quaternion
                            case 4:
                            {
                                //If the blueprint node is a variable Quaternion
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableQuaternion != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //String
                            case 5:
                            {
                                //If the blueprint node is a variable string
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableString != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Vector2
                            case 6:
                            {
                                //If the blueprint node is a variable Vector2
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableVector2 != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Vector3
                            case 7:
                            {
                                //If the blueprint node is a variable Vector3
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableVector3 != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }

                            //Vector4
                            case 8:
                            {
                                //If the blueprint node is a variable Vector4
                                if (blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex) as BlueprintNodeVariableVector4 != null)
                                {
                                    //Set the found blueprint variable flag to true
                                    foundBlueprintVariable = true;
                                }

                                break;
                            }
                            }

                            //If the blueprint variable is found
                            if (foundBlueprintVariable)
                            {
                                //Set the blueprint nodes output attribute to the input attribute
                                blueprintInputAttribute.GetBlueprintNodeAt(nodeIndex).SetAttribute(BlueprintInstanceManager.GetBlueprintAt(blueprintID).GetBlueprintNodeAt(connections[2].connectionNodeID).GetAttribute());
                                break;
                            }
                        }
                    }
                }
            }
        }

        //Execute the output execution node
        ExecuteOutputExecutionNode();
    }
 public static int BodyCount(Blueprint blueprint)
 {
     return(BodyCount(blueprint?.Object));
 }
예제 #38
0
    /// <summary>
    /// 解析物品信息
    /// </summary>
    void ParseItemJson()
    {
        itemList = new List <Item>();
        TextAsset  itemText    = Resources.Load <TextAsset>("Items");
        string     itemJson    = itemText.text;
        JSONObject itemObjects = new JSONObject(itemJson);

        foreach (JSONObject temp in itemObjects.list)
        {
            Item.ItemType type = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["type"].str);

            int    id                      = (int)temp["id"].n;
            string name                    = temp["name"].str;
            string description             = temp["description"].str;
            Item.ItemTechnology technology = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["technology"].str);
            int    value                   = (int)temp["value"].n;
            string sprite                  = temp["sprite"].str;
            int    maxStark                = (int)temp["maxStark"].n;

            Item item = null;
            switch (type)
            {
                #region 解析消耗品
            case Item.ItemType.Consumable:
                int hp = temp.HasField("hp") ? (int)temp["hp"].n : 0;
                int eg = temp.HasField("eg") ? (int)temp["eg"].n : 0;
                int hl = temp.HasField("hl") ? (int)temp["hl"].n : 0;
                int tempConstitution  = temp.HasField("tempConstitution") ? (int)temp["tempConstitution"].n : 0;
                int tempStrength      = temp.HasField("tempStrength") ? (int)temp["tempStrength"].n : 0;
                int tempAgility       = temp.HasField("tempAgility") ? (int)temp["tempAgility"].n : 0;
                int tempDexterous     = temp.HasField("tempDexterous") ? (int)temp["tempDexterous"].n : 0;
                int tempConcentration = temp.HasField("tempConcentration") ? (int)temp["tempConcentration"].n : 0;
                int continuedTime     = temp.HasField("continuedTime") ? (int)temp["continuedTime"].n : 0;
                int con_buffID        = temp.HasField("buffID") ? (int)temp["buffID"].n : 0;
                item = new Consumable(id, name, description, type, technology, value, maxStark, sprite, hp, eg, hl, tempConstitution, tempStrength, tempAgility, tempDexterous, tempConcentration, continuedTime, con_buffID);
                break;
                #endregion

                #region 解析包裹
            case Item.ItemType.Package:
                bool  isGetOne = temp["isGetOne"].n == 1 ? true : false;
                int[] itemIDs  = temp.HasField("itemIDs") ? new int[temp["itemIDs"].list.Count] : null;
                if (itemIDs != null)
                {
                    for (int i = 0; i < temp["itemIDs"].list.Count; i++)
                    {
                        itemIDs[i] = int.Parse(temp["itemIDs"].list[i].str);
                    }
                }
                Item.ItemType[] itemTypes = temp.HasField("itemTypes") ? new Item.ItemType[temp["itemTypes"].list.Count] : null;
                if (itemTypes != null)
                {
                    for (int i = 0; i < temp["itemTypes"].list.Count; i++)
                    {
                        itemTypes[i] = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), temp["itemTypes"].list[i].str);
                    }
                }
                Item.ItemTechnology[] itemTechnologies = temp.HasField("itemTechnologies") ? new Item.ItemTechnology[temp["itemTechnologies"].list.Count] : null;
                if (itemTechnologies != null)
                {
                    for (int i = 0; i < temp["itemTechnologies"].list.Count; i++)
                    {
                        itemTechnologies[i] = (Item.ItemTechnology)System.Enum.Parse(typeof(Item.ItemTechnology), temp["itemTechnologies"].list[i].str);
                    }
                }
                int[] itemCount = new int[temp["itemCount"].list.Count];
                for (int i = 0; i < temp["itemCount"].list.Count; i++)
                {
                    itemCount[i] = int.Parse(temp["itemCount"].list[i].str);
                }
                float[] itemProbabilities = new float[temp["itemProbabilities"].list.Count];
                for (int i = 0; i < temp["itemProbabilities"].list.Count; i++)
                {
                    itemProbabilities[i] = float.Parse(temp["itemProbabilities"].list[i].str);
                }
                item = new Package(id, name, description, type, technology, value, maxStark, sprite, isGetOne, itemIDs, itemTypes, itemTechnologies, itemCount, itemProbabilities);
                break;
                #endregion

                #region 解析装备
            case Item.ItemType.Equipment:
                int equipmentID = (int)temp["equipmentID"].n;
                Equipment.EquipmentType equipmentType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipmentType"].str);
                int resistance    = (int)temp["resistance"].n;
                int constitution  = (int)temp["constitution"].n;
                int strength      = (int)temp["strength"].n;
                int agility       = (int)temp["agility"].n;
                int dexterous     = (int)temp["dexterous"].n;
                int concentration = (int)temp["concentration"].n;
                item = new Equipment(id, name, description, type, technology, value, maxStark, sprite, equipmentID, equipmentType, resistance, constitution, strength, agility, dexterous, concentration);
                break;
                #endregion

                #region 解析武器
            case Item.ItemType.MeleeWeapon:
                int   meleeWeaponID  = (int)temp["meleeWeaponID"].n;
                int   meleeDamage    = (int)temp["meleeDamage"].n;
                int   throwDamage    = (int)temp["throwDamage"].n;
                float attackInterval = temp["attackInterval"].n;
                MeleeWeapon.MeleeWeaponType mwType = (MeleeWeapon.MeleeWeaponType)System.Enum.Parse(typeof(MeleeWeapon.MeleeWeaponType), temp["mwType"].str);
                item = new MeleeWeapon(id, name, description, type, technology, value, maxStark, sprite, meleeWeaponID, meleeDamage, throwDamage, attackInterval, mwType);
                break;

            case Item.ItemType.ShootWeapon:
                int   shootWeaponID                = (int)temp["shootWeaponID"].n;
                int   shootDamage                  = (int)temp["shootDamage"].n;
                int   s_meleeDamage                = (int)temp["meleeDamage"].n;
                float s_attackInterval             = temp["attackInterval"].n;
                float lashuanTime                  = temp["lashuanTime"].n;
                float reloadTime                   = temp["reloadTime"].n;
                float damageRange                  = temp["damageRange"].n;
                ShootWeapon.ShootWeaponType swType = (ShootWeapon.ShootWeaponType)System.Enum.Parse(typeof(ShootWeapon.ShootWeaponType), temp["swType"].str);
                ShootWeapon.AmmoType        amType = (ShootWeapon.AmmoType)System.Enum.Parse(typeof(ShootWeapon.AmmoType), temp["amType"].str);
                int ammoCount = (int)temp["ammoCount"].n;
                int accuracy  = (int)temp["accuracy"].n;
                item = new ShootWeapon(id, name, description, type, technology, value, maxStark, sprite, shootWeaponID, shootDamage, s_meleeDamage, s_attackInterval, lashuanTime, reloadTime, damageRange, swType, amType, ammoCount, accuracy);
                break;
                #endregion

                #region 解析材料,蓝图,子弹
            case Item.ItemType.Unuseable:
                item = new Unuseable(id, name, description, type, technology, value, maxStark, sprite);
                break;

            case Item.ItemType.Blueprint:
                int[] craftIDs = new int[temp["craftIDs"].list.Count];
                for (int i = 0; i < temp["craftIDs"].list.Count; i++)
                {
                    craftIDs[i] = int.Parse(temp["craftIDs"].list[i].str);
                }
                item = new Blueprint(id, name, description, type, technology, value, maxStark, sprite, craftIDs);
                break;

            case Item.ItemType.Ammo:
                item = new Ammo(id, name, description, type, technology, value, maxStark, sprite);
                break;
                #endregion

                #region 解析BUFF,技能
            case Item.ItemType.Buff:
                int      buffID            = (int)temp["buffID"].n;
                int      durationTime      = (int)temp["durationTime"].n;
                string   effectDescription = temp["effectDescription"].str;
                string[] effectProp        = new string[temp["effectProp"].list.Count];
                int[]    effectValue       = new int[temp["effectValue"].list.Count];
                for (int i = 0; i < temp["effectProp"].list.Count; i++)
                {
                    effectProp[i] = temp["effectProp"].list[i].str;
                }
                for (int i = 0; i < temp["effectValue"].list.Count; i++)
                {
                    effectValue[i] = int.Parse(temp["effectValue"].list[i].str);
                }
                item = new Buff(id, name, description, type, technology, value, maxStark, sprite, buffID, durationTime, effectDescription, effectProp, effectValue);
                break;

            case Item.ItemType.Skill:
                int    skillID          = (int)temp["skillID"].n;
                int    maxPoint         = (int)temp["maxPoint"].n;
                string skillDescription = temp["skillDescription"].str;
                int[]  preSkillID       = new int[temp["preSkillID"].list.Count];
                for (int i = 0; i < temp["preSkillID"].list.Count; i++)
                {
                    preSkillID[i] = int.Parse(temp["preSkillID"].list[i].str);
                }
                int[] eachSkillNeed = new int[temp["eachSkillNeed"].list.Count];
                for (int i = 0; i < temp["eachSkillNeed"].list.Count; i++)
                {
                    eachSkillNeed[i] = int.Parse(temp["eachSkillNeed"].list[i].str);
                }
                item = new Skill(id, name, description, type, technology, value, maxPoint, sprite, skillID, maxPoint, skillDescription, preSkillID, eachSkillNeed);
                break;
                #endregion
            }
            itemList.Add(item);
        }
        //拳头,只用于属性调整
        MeleeWeapon hand = new MeleeWeapon(999, "拳头", " ", Item.ItemType.MeleeWeapon, Item.ItemTechnology.T0, 0, 1, " ", 0, 20, 0, 2, MeleeWeapon.MeleeWeaponType.刀);
        itemList.Add(hand);
    }
예제 #39
0
            public void IronAndGold()
            {
                var gold = new Blueprint("GoldOreToIngot", new ItemAndQuantity("Ore/Gold", 2.5f), new ItemAndQuantity("Ingot/Gold", 0.025f));
                var iron = new Blueprint("IronOreToIngot", new ItemAndQuantity("Ore/Iron", 20f), new ItemAndQuantity("Ingot/Iron", 14f));
                var stockpiles = new Stockpiles(
                    new[] {
                        new IngotStockpile { Ingot = new IngotType("Ingot/Gold", 5f, 0.025f), CurrentQuantity = 27, TargetQuantity = 50 },
                        new IngotStockpile { Ingot = new IngotType("Ingot/Iron", 80f, 14f), CurrentQuantity = 15000, TargetQuantity = 800 }
                    },
                    new[] { gold, iron });

                var goldScore = stockpiles.ScoreBlueprint(gold);
                var ironScore = stockpiles.ScoreBlueprint(iron);

                Assert.That(ironScore, Is.LessThan(goldScore));
            }
예제 #40
0
    void when_creating()
    {
        Pool pool = null;
        Entity entity = null;

        before = () => {
            pool = new Pool(CID.NumComponents);
            entity = pool.CreateEntity();
        };

        context["ComponentBlueprint"] = () => {

            it["creates a component blueprint from a component without members"] = () => {
                var component = new ComponentA();

                const int index = 42;

                var componentBlueprint = new ComponentBlueprint(index, component);
                componentBlueprint.index.should_be(index);
                componentBlueprint.fullTypeName.should_be(component.GetType().FullName);
                componentBlueprint.members.Length.should_be(0);
            };

            it["throws when unknown type"] = expect<ComponentBlueprintException>(() => {
                var componentBlueprint = new ComponentBlueprint();
                componentBlueprint.fullTypeName = "UnknownType";
                componentBlueprint.CreateComponent(null);
            });

            it["throws when type doesn't implement IComponent"] = expect<ComponentBlueprintException>(() => {
                var componentBlueprint = new ComponentBlueprint();
                componentBlueprint.fullTypeName = "string";
                componentBlueprint.CreateComponent(null);
            });

            it["creates a component blueprint from a component with members"] = () => {
                var component = new NameAgeComponent();
                component.name = "Max";
                component.age = 42;

                const int index = 24;

                var componentBlueprint = new ComponentBlueprint(index, component);
                componentBlueprint.index.should_be(index);
                componentBlueprint.fullTypeName.should_be(component.GetType().FullName);
                componentBlueprint.members.Length.should_be(2);

                componentBlueprint.members[0].name.should_be("name");
                componentBlueprint.members[0].value.should_be(component.name);

                componentBlueprint.members[1].name.should_be("age");
                componentBlueprint.members[1].value.should_be(component.age);
            };

            it["creates a component with and sets members values"] = () => {
                var componentBlueprint = new ComponentBlueprint();
                componentBlueprint.fullTypeName = typeof(ComponentWithFieldsAndProperties).FullName;
                componentBlueprint.index = CID.ComponentB;
                componentBlueprint.members = new [] {
                    new SerializableMember("publicField", "publicFieldValue"),
                    new SerializableMember("publicProperty", "publicPropertyValue")
                };

                var component = (ComponentWithFieldsAndProperties)componentBlueprint.CreateComponent(entity);
                component.publicField.should_be("publicFieldValue");
                component.publicProperty.should_be("publicPropertyValue");
            };

            it["throws when invalid member name"] = expect<ComponentBlueprintException>(() => {
                var componentBlueprint = new ComponentBlueprint();
                componentBlueprint.index = 0;
                componentBlueprint.fullTypeName = typeof(NameAgeComponent).FullName;
                componentBlueprint.members = new [] {
                    new SerializableMember("xxx", "publicFieldValue"),
                    new SerializableMember("publicProperty", "publicPropertyValue")
                };
                componentBlueprint.CreateComponent(entity);
            });
        };

        context["Blueprint"] = () => {

            it["creates a blueprint from an entity"] = () => {
                entity.AddComponentA();

                var component = new NameAgeComponent();
                component.name = "Max";
                component.age = 42;

                entity.AddComponent(CID.ComponentB, component);

                var blueprint = new Blueprint("My Pool", "Hero", entity);
                blueprint.poolIdentifier.should_be("My Pool");
                blueprint.name.should_be("Hero");
                blueprint.components.Length.should_be(2);

                blueprint.components[0].index.should_be(CID.ComponentA);
                blueprint.components[0].fullTypeName.should_be(Component.A.GetType().FullName);

                blueprint.components[1].index.should_be(CID.ComponentB);
                blueprint.components[1].fullTypeName.should_be(component.GetType().FullName);
            };

            context["when applying blueprint"] = () => {

                Blueprint blueprint = null;
                before = () => {
                    var component1 = new ComponentBlueprint();
                    component1.index = CID.ComponentA;
                    component1.fullTypeName = typeof(ComponentA).FullName;
                    component1.members = new SerializableMember[0];

                    var component2 = new ComponentBlueprint();
                    component2.index = CID.ComponentB;
                    component2.fullTypeName = typeof(NameAgeComponent).FullName;
                    component2.members = new [] {
                        new SerializableMember("name", "Max"),
                        new SerializableMember("age", 42)
                    };

                    blueprint = new Blueprint();
                    blueprint.name = "Hero";
                    blueprint.components = new [] { component1, component2 };
                };

                it["applies blueprint to entity"] = () => {
                    entity.ApplyBlueprint(blueprint).should_be(entity);

                    entity.GetComponents().Length.should_be(2);

                    entity.GetComponent(CID.ComponentA).GetType().should_be(typeof(ComponentA));

                    var nameAgeComponent = (NameAgeComponent)entity.GetComponent(CID.ComponentB);
                    nameAgeComponent.GetType().should_be(typeof(NameAgeComponent));
                    nameAgeComponent.name.should_be("Max");
                    nameAgeComponent.age.should_be(42);
                };

                it["throws when entity already has a component which should be added from blueprint"] = expect<EntityAlreadyHasComponentException>(() => {
                    entity.AddComponentA();
                    entity.ApplyBlueprint(blueprint);
                });

                it["can overwrite existing components"] = () => {
                    var nameAgeComponent = new NameAgeComponent();
                    nameAgeComponent.name = "Jack";
                    nameAgeComponent.age = 24;
                    entity.AddComponent(CID.ComponentB, nameAgeComponent);

                    entity.ApplyBlueprint(blueprint, true);

                };

                it["uses component from componentPool"] = () => {
                    var component = new ComponentBlueprint();
                    component.index = CID.ComponentA;
                    component.fullTypeName = typeof(ComponentA).FullName;
                    component.members = new SerializableMember[0];

                    blueprint = new Blueprint();
                    blueprint.name = "Hero";
                    blueprint.components = new [] { component };

                    var componentA = entity.CreateComponent<ComponentA>(CID.ComponentA);
                    entity.AddComponent(CID.ComponentA, componentA);
                    entity.RemoveComponentA();

                    entity.ApplyBlueprint(blueprint);

                    entity.GetComponentA().should_be_same(componentA);
                };
            };
        };
    }
예제 #41
0
 public WorkshopItem(AvailablePart part)
 {
     Part          = part;
     PartBlueprint = WorkshopRecipeDatabase.ProcessPart(part);
 }
예제 #42
0
    private void CreateBlueprint()
    {
        ScrollManageItem = GUILayout.BeginScrollView(ScrollManageItem);

        List<string> itemNames = new List<string>();

        EditorGUILayout.BeginHorizontal(GUILayout.Width(800));
        //ItemTypeToSearch = (ItemType)EditorGUILayout.EnumPopup("Item type", ItemTypeToSearch);
        foreach (Item item in ItemDatabase)
        {
            itemNames.Add(item.Name);
        }
        GUILayout.Label(ItemDatabase[CraftItemId].Icon.texture, GUILayout.Width(60f), GUILayout.Height(60f));
        CraftItemId = (uint)EditorGUILayout.Popup("Result item: ", (int)CraftItemId, itemNames.ToArray(), GUILayout.Width(300));
        GUILayout.Label("Result item ID: " + /*ItemDatabase[CraftItemId].Id*/CraftItemId.ToString()); //???
        Blueprint.Item = ItemDatabase[CraftItemId];

        EditorGUILayout.EndHorizontal();

        GUILayout.Space(25);

        EditorGUILayout.BeginHorizontal();

        CraftItemToAddId = (uint)EditorGUILayout.Popup("Required item: ", (int)CraftItemToAddId, itemNames.ToArray(), GUILayout.Width(300));
        if (GUILayout.Button("+", GUILayout.Width(25)))
        {
            Blueprint.ItemIds.Add(CraftItemToAddId);
            Blueprint.ItemsForCraft.Add(ItemDatabase[CraftItemToAddId]);
            Blueprint.RequiredAmount.Add(1);
        }

        EditorGUILayout.EndHorizontal();

        GUILayout.Space(25);

        for (int i = 0; i < Blueprint.ItemIds.Count; i++)
        {
            EditorGUILayout.BeginHorizontal("Box", GUILayout.Width(800));

            GUILayout.Label(Blueprint.ItemsForCraft[i].Icon.texture, GUILayout.Width(60f), GUILayout.Height(60f));
            EditorGUILayout.LabelField("Item ID: " + Blueprint.ItemIds[i].ToString());
            EditorGUILayout.LabelField("Name: " + ItemDatabase[Blueprint.ItemIds[i]].Name);
            Blueprint.RequiredAmount[i] = EditorGUILayout.IntSlider(new GUIContent("Amount: "), Blueprint.RequiredAmount[i], 1, ushort.MaxValue);
            if (GUILayout.Button("X", GUILayout.Width(25)))
            {
                Blueprint.ItemIds.Remove(Blueprint.ItemIds[i]);
                Blueprint.ItemsForCraft.Remove(Blueprint.ItemsForCraft[i]);
                Blueprint.RequiredAmount.Remove(Blueprint.RequiredAmount[i]);
            }
            EditorGUILayout.EndHorizontal();
        }
        Blueprint.CraftLevel = (byte)EditorGUILayout.IntSlider(new GUIContent("Craft level: "), Blueprint.CraftLevel, byte.MinValue, byte.MaxValue, GUILayout.Width(600));
        Blueprint.CraftTime = (byte)EditorGUILayout.IntSlider(new GUIContent("Craft time: "), Blueprint.CraftTime, byte.MinValue, byte.MaxValue, GUILayout.Width(600));

        if (GUILayout.Button("Create blueprint"))
        {
            if (Blueprint.ItemIds.Count > 0 && ItemDatabase != null)
            {
                for (uint i = 0; i < BlueprintDatabase.Count; i++)
                {
                    if (BlueprintDatabase[i].Item.Name == Blueprint.Item.Name)
                    {
                        EditorUtility.DisplayDialog("Item already exist.", "The item you're trying to add already exists", "Ok");
                        return;
                    }
                }
                Blueprint.Id = BlueprintDatabase.Count;
                /*for (int i = 0; i < Blueprint.ItemIds.Count; i++)
                {
                    Blueprint.ItemsForCraft.Add(ItemDatabase[Blueprint.ItemIds[i]]);
                }*/
                BlueprintDatabase.Add(Blueprint);
                Blueprint = new Blueprint();
                //UpdateBlueprintDatabase();
                EditorUtility.SetDirty(ItemDatabase);
            }
            else
            {
                EditorUtility.DisplayDialog("Materials error.", "You must add at least 1 material to the list", "Ok");
            }
        }
        GUILayout.EndScrollView();
    }
예제 #43
0
    private void BuildBlueprint(Blueprint blueprint)
    {
        int           yRotation = GameController.Random.Next(0, 4) * 2;
        QuaternionInt rotation  = new QuaternionInt(0, yRotation, 0);
        Coord         size      = blueprint.RandomSize();

        Coord offset = Blueprint.RotationOffset(yRotation);

        bool validPosition = false;
        int  tries         = 0;

        Coord bottomLeft = new Coord();

        while (!validPosition && tries < 1000)
        {
            int bottomLeftX = GameController.Random.Next(0, location.size - (rotation * size).x.Abs());
            int bottomLeftZ = GameController.Random.Next(0, location.size - (rotation * size).z.Abs());
            int floorHeight = location.heightMap[bottomLeftX, bottomLeftZ];
            bottomLeft = new Coord(bottomLeftX, floorHeight, bottomLeftZ);

            validPosition = true;

            for (int x = -1; x <= size.x; x++)
            {
                for (int y = 0; y < size.y; y++)
                {
                    for (int z = -1; z <= size.z; z++)
                    {
                        Coord tileCoord = new Coord(x, y, z);
                        Coord tilePos   = bottomLeft + rotation * tileCoord + offset;

                        if (!(location.GetTileFree(tilePos) && location.GetHeight(tilePos) == floorHeight))
                        {
                            validPosition = false;
                        }
                        if (!validPosition)
                        {
                            break;
                        }
                    }
                    if (!validPosition)
                    {
                        break;
                    }
                }
                if (!validPosition)
                {
                    break;
                }
            }

            tries++;
        }

        if (validPosition)
        {
            blueprint.GenerateBuilding(location, bottomLeft, size, rotation);
        }
        else
        {
            Debug.Log($"Could not find valid position for {blueprint}");
        }
    }
예제 #44
0
 public EmberGrid(Blueprint <EmberCell> blueprint)
 {
     GridSizeX = blueprint.GridSizeX;
     GridSizeY = blueprint.GridSizeY;
     Blueprint = blueprint;
 }
    static IEnumerable <Destination> FindDestinations(Router root, RouterMetadata metadata, Blueprint map, List <Site> visitedSites)
    {
        var connectedSites = map.Sites.Where(s => s.Routers.Any(r => r.Name == root.Name));

        foreach (var site in connectedSites)
        {
            if (visitedSites.Contains(site))
            {
                continue;
            }
            visitedSites.Add(site);
            foreach (var endpoint in site.Endpoints)
            {
                yield return(new Destination(endpoint, site.Name));
            }
            var nearbyGateways = site.Routers.Where(r => r.Name != metadata.Name);
            foreach (var router in nearbyGateways)
            {
                var furtherDestinations = FindDestinations(router, metadata, map, visitedSites);
                foreach (var furtherDestination in furtherDestinations)
                {
                    yield return(furtherDestination);
                }
            }
        }
    }
예제 #46
0
 private void PopulateTreeGroups(TreeNodeCollection pNode, ImageList images, List <InvMarketGroup> groups)
 {
     foreach (InvMarketGroup group in groups)
     {
         if (group.marketGroupID == 350001)
         {
             // Skip Infantry gear group.  (Obsolete)
             continue;
         }
         // Check for blueprint groups with no tech 1 bps.
         if (bpGroup.Contains(group.parentGroupID))
         {
             // A blueprint sub group.
             bpGroup.Add(group.marketGroupID);
             List <InvType>        groupTypes = InvType.GetMarketGroupTypes(group.marketGroupID);
             List <InvMarketGroup> subGroups  = InvMarketGroup.GetGroupChildren(group.marketGroupID);
             while (subGroups.Count > 0)
             {
                 InvMarketGroup subGroup = subGroups[0];
                 subGroups.Remove(subGroup);
                 groupTypes.AddRange(InvType.GetMarketGroupTypes(subGroup.marketGroupID));
                 subGroups.AddRange(InvMarketGroup.GetGroupChildren(subGroup.marketGroupID));
             }
             bool foundT1 = false;
             foreach (InvType type in groupTypes)
             {
                 Blueprint bp = Blueprint.GetType(type.typeID);
                 if (bp?.manufacturing != null)
                 {
                     foreach (ActivityProduct prod in bp.manufacturing.products)
                     {
                         if (InvMetaType.GetMetaType(prod.typeID) == null)
                         {
                             bpHasTech1.Add(group.marketGroupID);
                             foundT1 = true;
                             break;
                         }
                     }
                 }
                 if (foundT1)
                 {
                     break;
                 }
             }
             if (!bpHasTech1.Contains(group.marketGroupID))
             {
                 // No Tech I so don't list.
                 continue;
             }
         }
         // Create the new group node.
         TreeNode node = pNode.Add(group.marketGroupName);
         node.Tag = group;
         // Add temp holder.
         TreeNode gNode = node.Nodes.Add("Groups:");
         // Add node image.
         string imgName = "icon:" + group.iconID.ToString();
         Image  img     = ImageManager.GetIconImage(group.iconID);
         if (img != null)
         {
             images.Images.Add(imgName, img);
         }
         node.ImageKey         = imgName;
         node.SelectedImageKey = imgName;
     }
 }
예제 #47
0
 private void LoadModuleState(ConfigNode node)
 {
     foreach (ConfigNode cn in node.nodes)
     {
         if (cn.name == "ProcessedItem")
         {
             _processedItem = new WorkshopItem();
             _processedItem.Load(cn);
         }
         if (cn.name == "ProcessedBlueprint")
         {
             _processedBlueprint = new Blueprint();
             _processedBlueprint.Load(cn);
         }
         if (cn.name == "Queue")
         {
             _queue.Load(cn);
         }
     }
 }
예제 #48
0
 public override bool AppliesTo(Blueprint blueprint)
 {
     return(AppliesToDelegate(blueprint));
 }
예제 #49
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> splits)
        {
            if (!chat.Trim().ToLower().StartsWith("//paste"))
            {
                return(false);
            }

            if (null == player || NetworkID.Server == player.ID)
            {
                return(false);
            }

            //Player has permission
            if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.wand"))
            {
                return(true);
            }

            AdvancedWand wand = AdvancedWand.GetAdvancedWand(player);

            //Wand is OFF
            if (!wand.active)
            {
                Chat.Send(player, "<color=orange>Wand is OFF, use //wand to activate</color>");
                return(true);
            }

            Blueprint blueprint = null;

            if (chat.Trim().Equals("//paste"))  //Paste from copy
            {
                blueprint = wand.copy;

                if (blueprint == null)
                {
                    Chat.Send(player, string.Format("<color=orange>There is nothing copied</color>"));
                    return(true);
                }
            }
            else    //Paste from loaded blueprint
            {
                string blueprintName = chat.Substring(chat.IndexOf(" ") + 1).Trim();

                if (!BlueprintManager._blueprints.TryGetValue(blueprintName, out blueprint))
                {
                    Chat.Send(player, string.Format("<color=orange>There is not a bluerpint with that name.</color>"));
                    return(true);
                }
            }

            Chat.Send(player, string.Format("<color=lime>Pasting...</color>"));

            for (int x = 0; x < blueprint.xSize; x++)
            {
                for (int y = 0; y < blueprint.ySize; y++)
                {
                    for (int z = 0; z < blueprint.zSize; z++)
                    {
                        Vector3Int newPosition = new Vector3Int(player.Position) - blueprint.playerMod + new Vector3Int(x, y, z);
                        if (!World.TryGetTypeAt(newPosition, out ushort actualType) || actualType != blueprint.blocks[x, y, z])
                        {
                            AdvancedWand.AddAction(newPosition, blueprint.blocks[x, y, z], player);
                        }
                    }
                }
            }

            return(true);
        }
예제 #50
0
        /**
         * This method sets whether or not the panel is in Edit Mode.
         * The second parameter determines whether or not the original blueprint should be restored.
         * The second parameter does nothing when the editmode is activated.
         */
        public void SetEditMode(bool editMode, bool restore = false)
        {
            if(this._editMode == editMode) return;

            this._editMode = editMode;
            if(this._editMode) {
                this.BackColor = this.Renderer.ColorTable.BackgroundEdit;

                this.OriginalBlueprint = this.ActiveBlueprint;
                this.ActiveBlueprint = this.OriginalBlueprint.Clone();
            } else {
                this.BackColor = this.Renderer.ColorTable.BackgroundNormal;

                if(restore) this.ActiveBlueprint = this.OriginalBlueprint;
                this.OriginalBlueprint = null;

                this.HoveredRoom = null;
                this.HoveredCorner = null;
                this.HoveredWall = null;
                this.SelectedRoom = null;
                this.SelectedCorner = null;
                this.SelectedWall = null;
                this._currentRoom = null;
            }

            List<Corner> ac = new List<Corner>((IEnumerable<Corner>)WallHandler.GetInstance().GetAllWallCorners());
            List<Wall> aw = new List<Wall>((IEnumerable<Wall>)WallHandler.GetInstance().GetAllWalls());
            List<Room> ar = new List<Room>((IEnumerable<Room>)RoomHandler.GetInstance().GetAllRooms());

            //This first loop saves all corners...
            foreach(Room room in this.ActiveBlueprint.Rooms) {
                foreach(Corner corner in room.GetCorners()) {
                    corner.SaveChanges = !editMode;
                    if(!restore && !editMode) {
                        Corner orig = WallHandler.GetInstance().GetWallCornerByID(corner.GetID());
                        ac.Remove(orig);
                        if(orig != null) {
                            WallHandler.GetInstance().ReplaceWallCorner(orig, corner);
                        } else {
                            WallHandler.GetInstance().GetAllWallCorners().Add(corner);
                        }
                        if(corner.IsChanged) corner.OnChange(EventArgs.Empty);
                    }
                }
            }
            //This second loop is required because of foreign key constraints in the DB...
            //All corners need to exist before the walls can be saved.
            foreach(Room room in this.ActiveBlueprint.Rooms) {
                foreach(Corner corner in room.GetCorners()) {
                    foreach(Wall wall in corner.GetWalls()) {
                        wall.SaveChanges = !editMode;
                        if(!restore && !editMode) {
                            Wall orig = WallHandler.GetInstance().GetWallBy((w) => w.GetID() == wall.GetID());
                            aw.Remove(orig);
                            if(orig != null) {
                                WallHandler.GetInstance().ReplaceWall(orig, wall);
                            } else {
                                WallHandler.GetInstance().GetAllWalls().Add(wall);
                            }
                            if(wall.IsChanged) wall.OnChange(EventArgs.Empty);
                        }
                    }
                }
            }
            //This third loop is required because of foreign key constraints in the DB...
            //All walls need to exist before the rooms can be saved.
            foreach(Room room in this.ActiveBlueprint.Rooms) {
                room.SaveChanges = !editMode;
                if(!restore && !editMode) {
                    Room orig = RoomHandler.GetInstance().GetRoomBy((r) => r.GetID() == room.GetID());
                    ar.Remove(orig);
                    if(orig != null) {
                        RoomHandler.GetInstance().ReplaceRoom(orig, room);
                    } else {
                        RoomHandler.GetInstance().GetAllRooms().Add(room);
                    }
                    if(room.IsChanged) room.OnChange(EventArgs.Empty);
                }
            }

            //Remove removed rooms
            if(!restore && !editMode) {
                List<Room> removeR = new List<Room>();
                List<Wall> removeW = new List<Wall>();
                List<Corner> removeC = new List<Corner>();
                foreach(Room room in ar) {
                    if(room.GetFloorID() == DocumentHandler.GetInstance().CurrentFloor.GetID()) removeR.Add(room);
                }
                foreach(Wall wall in aw) {
                    foreach(Room room in RoomHandler.GetInstance().GetAllRooms()) {
                        if(room.GetFloorID() == DocumentHandler.GetInstance().CurrentFloor.GetID()
                            && (room.GetCorners().Contains(wall.Left) || room.GetCorners().Contains(wall.Right))
                            && !removeW.Contains(wall)) removeW.Add(wall);
                    }
                }
                foreach(Corner corner in ac) {
                    foreach(Room room in RoomHandler.GetInstance().GetAllRooms()) {
                        if(room.GetFloorID() == DocumentHandler.GetInstance().CurrentFloor.GetID()
                            && room.GetCorners().Contains(corner)
                            && !removeC.Contains(corner)) removeC.Add(corner);
                    }
                }
                ((ExtendedObservableCollection<Room>)RoomHandler.GetInstance().GetAllRooms()).RemoveRange(removeR.ToArray());
                ((ExtendedObservableCollection<Wall>)WallHandler.GetInstance().GetAllWalls()).RemoveRange(removeW.ToArray());
                ((ExtendedObservableCollection<Corner>)WallHandler.GetInstance().GetAllWallCorners()).RemoveRange(removeC.ToArray());
            }
        }
 public static int ChildrenCount(this Blueprint blueprint)
 {
     return(BlueprintScrappinUtil.ChildrenCount(blueprint));
 }
 public static int JointCount(Blueprint blueprint)
 {
     return(0);
 }
 public static int BodyCount(this Blueprint blueprint)
 {
     return(BlueprintScrappinUtil.BodyCount(blueprint));
 }
 public static int ChildrenCount(Blueprint blueprint)
 {
     return(ChildrenCount(blueprint?.Object));
 }
예제 #55
0
 public override void InitBlueprint(Blueprint blueprint)
 {
     this.Blueprint   = blueprint;
     HasInitBlueprint = true;
     HasInit          = HasInitGPU & HasInitBlueprint;
 }
예제 #56
0
 public Base(Blueprint blueprint)
 {
     this.Blueprint = blueprint;
 }
예제 #57
0
 //add new blueprint to the database
 void addBlueprint()
 {
     EditorUtility.SetDirty(bluePrintDatabase);          //message scriptable object for incoming changes
     Blueprint newBlueprint = new Blueprint(ingredients.ToList<int>(), amountOfFinalItem, amount.ToList<int>(), inventoryItemList.getItemByID(finalItemID));           //create a empty mask of an item
     bluePrintDatabase.blueprints.Add(newBlueprint);     //and add this to the itemdatabase
     EditorUtility.SetDirty(bluePrintDatabase);          //message scriptable object that you added something
 }
예제 #58
0
        /// <summary>
        /// Prep work before screen is painted
        /// </summary>
        /// <param name="gd"></param>
        /// <param name="state"></param>
        public virtual void PreDraw(GraphicsDevice gd, WorldState state)
        {
            if (Blueprint == null)
            {
                return;
            }
            var pxOffset = -state.WorldSpace.GetScreenOffset();
            var damage   = Blueprint.Damage;
            var _2d      = state._2D;
            var oldLevel = state.Level;
            var oldBuild = state.BuildMode;

            state.SilentLevel     = State.Level;
            state.SilentBuildMode = 0;

            /**
             * This is a little bit different from a normal 2d world. All objects are part of the static
             * buffer, and they are redrawn into the parent world's scroll buffers.
             */

            var recacheWalls   = false;
            var recacheObjects = false;

            if (TicksSinceLight++ > 60 * 4)
            {
                damage.Add(new BlueprintDamage(BlueprintDamageType.OUTDOORS_LIGHTING_CHANGED));
            }

            foreach (var item in damage)
            {
                switch (item.Type)
                {
                case BlueprintDamageType.ROTATE:
                case BlueprintDamageType.ZOOM:
                case BlueprintDamageType.LEVEL_CHANGED:
                    recacheObjects = true;
                    recacheWalls   = true;
                    break;

                case BlueprintDamageType.SCROLL:
                    break;

                case BlueprintDamageType.LIGHTING_CHANGED:
                    Blueprint.OutsideColor = state.OutsideColor;
                    Blueprint.GenerateRoomLights();
                    State.OutsideColor = Blueprint.RoomColors[1];
                    State.OutsidePx.SetData(new Color[] { state.OutsideColor });
                    State.AmbientLight.SetData(Blueprint.RoomColors);
                    TicksSinceLight = 0;
                    break;

                case BlueprintDamageType.OBJECT_MOVE:
                case BlueprintDamageType.OBJECT_GRAPHIC_CHANGE:
                case BlueprintDamageType.OBJECT_RETURN_TO_STATIC:
                    recacheObjects = true;
                    break;

                case BlueprintDamageType.WALL_CUT_CHANGED:
                case BlueprintDamageType.FLOOR_CHANGED:
                case BlueprintDamageType.WALL_CHANGED:
                    recacheWalls = true;
                    break;
                }
            }
            damage.Clear();

            var is2d = state.Camera is WorldCamera;

            if (is2d)
            {
                state._2D.End();
                state._2D.Begin(state.Camera);
            }
            if (recacheWalls)
            {
                //clear the sprite buffer before we begin drawing what we're going to cache
                Blueprint.Terrain.RegenTerrain(gd, state, Blueprint);
                Blueprint.FloorGeom.FullReset(gd, false);
                if (is2d)
                {
                    Blueprint.WallComp.Draw(gd, state);
                }
                StaticArchCache.Clear();
                state._2D.End(StaticArchCache, true);
            }

            if (recacheObjects && is2d)
            {
                state._2D.Pause();
                state._2D.Resume();

                foreach (var obj in Blueprint.Objects)
                {
                    if (obj.Level > state.Level)
                    {
                        continue;
                    }
                    var tilePosition = obj.Position;
                    state._2D.OffsetPixel(state.WorldSpace.GetScreenFromTile(tilePosition));
                    state._2D.OffsetTile(tilePosition);
                    state._2D.SetObjID(obj.ObjectID);
                    obj.Draw(gd, state);
                }
                StaticObjectsCache.Clear();
                state._2D.End(StaticObjectsCache, true);
            }

            state.SilentBuildMode = oldBuild;
            state.SilentLevel     = oldLevel;
        }
예제 #59
0
    private void ManageBlueprint()
    {
        ScrollPosition = GUILayout.BeginScrollView(ScrollPosition);
        for (uint i = 0; i < BlueprintDatabase.Count; i++)
        {
            if (BlueprintDatabase[i] != BlueprintToManage)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(BlueprintDatabase[i].Item.Name))
                {
                    BlueprintToManage = BlueprintDatabase[i];
                }
                GUI.color = Color.red;
                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    if (EditorUtility.DisplayDialog("Remove item", "Are you sure?", "Remove", "Cancel"))
                    {
                        BlueprintDatabase.Remove(i);
                        //UpdateBlueprintDatabase();
                    }
                }
                GUI.color = Color.white;
                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUI.indentLevel++;
                GUI.color = Color.gray;
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(BlueprintDatabase[i].Item.Name))
                {
                    BlueprintToManage = null;
                    return;
                }
                GUI.color = Color.red;
                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    if (EditorUtility.DisplayDialog("Remove item", "Are you sure?", "Remove", "Cancel"))
                    {
                        BlueprintDatabase.Remove(i);
                        //UpdateBlueprintDatabase();
                    }
                }
                GUI.color = Color.white;
                GUILayout.EndHorizontal();

                List<string> itemNames = new List<string>();

                for (uint j = 0; j < ItemDatabase.Count; j++)
                {
                    itemNames.Add(ItemDatabase[j].Name);
                }

                GUILayout.BeginHorizontal(GUILayout.Width(800));
                CraftItemId = /*BlueprintToManage.Item.Id*/ItemDatabase.GetID(BlueprintToManage.Item);
                GUILayout.Label(ItemDatabase[CraftItemId].Icon.texture, GUILayout.Width(60f), GUILayout.Height(60f));
                EditorGUILayout.LabelField("Blueprint ID: " + BlueprintToManage.Id.ToString());
                CraftItemId = (uint)EditorGUILayout.Popup("Result item: ", (int)CraftItemId, itemNames.ToArray()); //
                GUILayout.Label("Result item ID: " + CraftItemId.ToString());
                GUILayout.EndHorizontal();
                //SerializedProperty serPropItemIds = SerObj.FindProperty("BlueprintToManage").FindPropertyRelative("ItemIds");
                //SerializedProperty serPropMaterials = SerObj.FindProperty("BlueprintToManage").FindPropertyRelative("ItemsForCraft");
                //serPropMaterials.arraySize = serPropItemIds.arraySize;

                GUILayout.Space(25);

                EditorGUILayout.BeginHorizontal();
                CraftItemToAddId = (uint)EditorGUILayout.Popup("Required item: ", (int)CraftItemToAddId, itemNames.ToArray(), GUILayout.Width(300));
                if (GUILayout.Button("+", GUILayout.Width(25f)))
                {
                    BlueprintToManage.ItemIds.Add(CraftItemToAddId);
                    BlueprintToManage.ItemsForCraft.Add(ItemDatabase[CraftItemToAddId]);
                    BlueprintToManage.RequiredAmount.Add(1);
                }
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(25);

                for (int j = 0; j < BlueprintToManage.ItemIds.Count; j++)
                {
                    BlueprintToManage.ItemsForCraft[j] = ItemDatabase[BlueprintToManage.ItemIds[j]];
                    EditorGUILayout.BeginHorizontal("Box", GUILayout.Width(800));

                    GUILayout.Label(BlueprintToManage.ItemsForCraft[j].Icon.texture, GUILayout.Width(60f), GUILayout.Height(60f));
                    EditorGUILayout.LabelField("Item ID: " + BlueprintToManage.ItemIds[j]);
                    EditorGUILayout.LabelField("Name: " + ItemDatabase[BlueprintToManage.ItemIds[j]].Name);
                    BlueprintToManage.RequiredAmount[j] = EditorGUILayout.IntSlider(new GUIContent("Amount: "), BlueprintToManage.RequiredAmount[j], 1, ushort.MaxValue);
                    if (GUILayout.Button("X", GUILayout.Width(25)))
                    {
                        BlueprintToManage.ItemIds.Remove(BlueprintToManage.ItemIds[j]);
                        BlueprintToManage.RequiredAmount.Remove(BlueprintToManage.RequiredAmount[j]);
                        //UpdateBlueprintDatabase();
                    }

                    EditorGUILayout.EndHorizontal();
                }

                BlueprintToManage.CraftLevel = (byte)EditorGUILayout.IntSlider(new GUIContent("Craft level: "), BlueprintToManage.CraftLevel, byte.MinValue, byte.MaxValue, GUILayout.Width(600));
                BlueprintToManage.CraftTime = (byte)EditorGUILayout.IntSlider(new GUIContent("Craft time: "), BlueprintToManage.CraftTime, byte.MinValue, byte.MaxValue, GUILayout.Width(600));

                BlueprintToManage.Item = ItemDatabase[CraftItemId];
                EditorGUI.indentLevel--;
            }
            EditorUtility.SetDirty(ItemDatabase);
        }
        GUILayout.EndScrollView();
    }
 static Site FindSiteConnectedToInterface(Blueprint map, string router, string iface)
 {
     return(map.Sites.FirstOrDefault(s => s.Routers.Any(r => r.Name == router && r.Interface == iface)));
 }