Beispiel #1
0
			public object ConvertFromSerializable(object value)
			{
				if (value == null)
					return null;

				var key = (string)value;
				return Workbenches.FindBuildableItem(key);
			}
Beispiel #2
0
        public MoveBuildItemAssignment(IJobObserver parent, IItemObject workplace, string buildableItemKey, IItemObject[] items)
            : base(parent, workplace.Environment, workplace.Location)
        {
            m_workplace        = workplace;
            m_items            = items;
            m_buildableItemKey = buildableItemKey;

            var bii = Workbenches.GetWorkbenchInfo(workplace.ItemID);
            var bi  = bii.FindBuildableItem(buildableItemKey);

            this.LaborID = bi.LaborID;
        }
Beispiel #3
0
        public static bool SwitchWorkbench(Workbenches i)
        {
            var Catia = CatiaApplication.Instance;
            var wbID  = GetWorkbenchId();

            if (Workbench.dict[wbID] != i)
            {
                Catia.StartWorkbench(dict.KeyByValue(i));
                System.Threading.Thread.Sleep(1000);
            }
            return(true);
        }
Beispiel #4
0
 public static string GetWorkbenchName(Workbenches workbench)
 {
     return _workbenches[workbench];
 }
Beispiel #5
0
 public void ChangeWorkbench(string benchName)
 {
     Workbenches.ChangeWorkbench(benchName);
 }
    public void SetParams()
    {
        if (ParamsNotSet)
        {
            //Debug.Log("Unit type fullname is " + typeof(Unit).FullName);
            //Debug.Log("Tree type fullname is " + typeof(Tree).FullName);
            //WorldWidth = _WorldWidth;
            //WorldHeight = _WorldHeight;
            //WorldLength = _WorldLength;
            BrickPrefab     = _BrickPrefab;
            UnitPrefab      = _UnitPrefab;
            TreePrefab      = _TreePrefab;
            DigToolPrefab   = _DigTool;
            CraftToolPrefab = _CraftTool;
            PunchToolPrefab = _PunchTool;
            ZoneRod         = Instantiate(_ZoneRodPrefab);
            ZoneRod.SetActive(false);
            WorkbenchesStoragePath = "C:/GD/You and world/v.0.0.1/First/Configs/Workbenches.xml";
            BuildingsStoragePath   = "C:/GD/You and world/v.0.0.1/First/Configs/Buildings.xml";
            TexturesFolderPath     = "C:/GD/GDart/Textures/Resources/";
            ComplexObjectsTags     = new List <string>()
            {
                "WorkbenchBrick", "BuildingBrick", "Tree", "Unit"
            };
            Vector3Neighbours = new List <Vector3>()
            {
                Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back
            };
            Vector2Neighbours = new List <Vector2>()
            {
                Vector2.left, Vector2.right, Vector2.up, Vector2.down
            };
            BranchesGrowTime      = 15f;
            KernelSize            = 27;
            MapBlurParam          = 0;
            MapBlurCoeffitient    = 0.06f;
            MapHeight             = 4;
            WaterLevel            = 5;
            MapSoilLevel          = 18;
            MapLandscapeScale     = 1;
            BasicMapRadius        = 0;
            MaxMapRadius          = 1000;
            NoizeShift            = Random.Range(0, MaxMapRadius * KernelSize);
            MenuTextFont          = _MenuTextFont;
            ResourceBasicMaterial = _Material;

            Log.Notice(scr, "Settings set");
            ZoneController.Initialize();
            Resources.UploadResources();
            Workbenches.UploadTemplates();
            Structures.Initialize();
            //Links.WorldBuilder.BuildTheWorld();
            StartCoroutine(Map.InitializeMap());
            //foreach (Kernel _k in Map.Kernels)
            //    StartCoroutine(MapGenerator.LandscapeGenerator(_k));
        }
        else
        {
            Debug.LogError("Settings are already set!");
        }
    }
Beispiel #7
0
        ActionState ProcessAction(BuildItemAction action)
        {
            if (this.ActionTicksUsed == 1)
            {
                var workbench = this.World.FindObject <ItemObject>(action.WorkbenchID);
                if (workbench == null)
                {
                    throw new Exception();
                }

                var bi = Workbenches.GetWorkbenchInfo(workbench.ItemID);

                var buildableItem = bi.FindBuildableItem(action.BuildableItemKey);
                if (buildableItem == null)
                {
                    throw new Exception();
                }

                this.ActionTotalTicks = GetTicks(buildableItem.SkillID);
            }

            if (this.ActionTicksUsed < this.ActionTotalTicks)
            {
                return(ActionState.Ok);
            }
            else
            {
                var workbench = this.World.FindObject <ItemObject>(action.WorkbenchID);

                var report = new BuildItemActionReport(this, action.BuildableItemKey);

                if (workbench == null)
                {
                    SendFailReport(report, "cannot find building");
                    return(ActionState.Fail);
                }

                /*
                 *                      if (this.ActionTicksLeft != 0)
                 *                      {
                 *                              var ok = building.VerifyBuildItem(this, action.SourceObjectIDs, action.DstItemID);
                 *                              if (!ok)
                 *                                      SetActionError("build item request is invalid");
                 *                              return ok;
                 *                      }
                 */


                var bi2 = Workbenches.GetWorkbenchInfo(workbench.ItemID);

                var bi = bi2.FindBuildableItem(action.BuildableItemKey);

                var item = PerformBuildItem(this, bi, action.SourceObjectIDs);

                if (item == null)
                {
                    SendFailReport(report, "unable to build the item");
                    return(ActionState.Fail);
                }

                report.ItemObjectID = item.ObjectID;
                SendReport(report);

                return(ActionState.Done);
            }
        }
Beispiel #8
0
        static void HandleBuildItem(string str)
        {
            var living = GameData.Data.FocusedObject;

            var workbench = living.Environment.GetContents(living.Location).OfType <ItemObject>()
                            .Where(item => item.ItemCategory == ItemCategory.Workbench && item.IsInstalled)
                            .FirstOrDefault();

            if (workbench == null)
            {
                Inform("No workbench");
                return;
            }

            var wbInfo = Workbenches.GetWorkbenchInfo(workbench.ItemID);

            BuildableItem buildableItem;

            {
                var dlg = new ItemSelectorDialog();
                dlg.Owner       = App.Current.MainWindow;
                dlg.DataContext = wbInfo.BuildableItems;
                dlg.Title       = "Buildable Items";
                bool?res = dlg.ShowDialog();

                if (res.HasValue == false || res == false)
                {
                    return;
                }

                buildableItem = (BuildableItem)dlg.SelectedItem;
            }

            foreach (var component in buildableItem.FixedBuildMaterials)
            {
                var obs = living.Inventory.Where(item => component.Match(item));

                if (obs.Any() == false)
                {
                    Inform("Missing required components");
                    return;
                }
            }

            List <ItemObject> materials = new List <ItemObject>();

            foreach (var component in buildableItem.FixedBuildMaterials)
            {
                var obs = living.Inventory.Where(item => component.Match(item));

                var dlg = new ItemSelectorDialog();
                dlg.Owner       = App.Current.MainWindow;
                dlg.DataContext = obs;
                dlg.Title       = "Select component";
                bool?res = dlg.ShowDialog();
                if (res.HasValue == false || res == false)
                {
                    return;
                }
                materials.Add((ItemObject)dlg.SelectedItem);
            }

            var action = new BuildItemAction(workbench, buildableItem.Key, materials);

            action.GUID = new ActionGUID(living.World.PlayerID, 0);
            living.RequestAction(action);
        }