Пример #1
0
 public BuildTask(ConstructionPlan plan, MotionComponent motionComponent, Vector2Int targetPosition)
 {
     this.AddCommand(new MoveCommand(motionComponent, targetPosition));
     this.AddCommand(new RotateToCommand(motionComponent, Utils.NodeAt(plan.Position)));
     this.AddCommand(new WaitCommand(1f));
     this.AddCommand(new BuildCommand(plan));
 }
Пример #2
0
        public async Task <ApiResult> Update(ConstructionPlan obj)
        {
            ApiResult ret = new ApiResult();

            try
            {
                ConstructionPlan et = await _repo.GetByID(obj.Id);

                if (et != null)
                {
                    DateTime dt = DateTime.Now;
                    obj.UpdatedTime = dt;
                    obj.UpdatedBy   = _userID;
                    ret.data        = await _repo.Update(obj);

                    ret.code = Code.Success;
                }
                else
                {
                    ret.code = Code.DataIsnotExist;
                    ret.msg  = "所要修改的数据不存在";
                }
                return(ret);
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
                return(ret);
            }
        }
Пример #3
0
 private void ResetCurrentBuilding()
 {
     currentBuilding.SetActive(false);
     currentBuilding         = null;
     currentBuildingDisplay  = null;
     currentConstructionPlan = null;
     offset = Vector2.zero;
     currentBuldingTiles.Clear();
 }
Пример #4
0
        private IEnumerator cancel_construction_plan(ConstructionPlan plan)
        {
            plan.CancelPlan();
            yield return(null);

            if (plan.WasPlanCanceledCorrectly() == false)
            {
                Assert.Fail();
            }
        }
Пример #5
0
    public static ConstructionPlan CreateConstructionPlan(string constructionName, Vector2Int position)
    {
        if (!_isInitialized)
        {
            Initialize();
        }

        ConstructionPlan plan = new ConstructionPlan();

        plan.SetData(_constructionPlanData[constructionName], position);
        plan.SetGameObject(GameObject.Instantiate(_constructionPlanData[constructionName].planPrefab, GetParent <ConstructionPlan>()));
        return(plan);
    }
Пример #6
0
        public async Task <ApiResult> GetByID(int id)
        {
            ApiResult ret = new ApiResult();

            try
            {
                ConstructionPlan obj = await _repo.GetByID(id);

                string orgurl = await _consulclient.GetServiceAsync("EqpService");

                orgurl = orgurl + "/api/v1/Upload/ListByEntity2/" + id + "/" + (int)SystemResource.ConstructionPlan;
                string    orgret    = HttpClientHelper.GetResponse(orgurl);
                ApiResult orgretobj = JsonConvert.DeserializeObject <ApiResult>(orgret);
                if (orgretobj.data != null)
                {
                    List <UploadFileModel> jdata = new List <UploadFileModel>();
                    JArray arr = (JArray)orgretobj.data;
                    foreach (var item in arr)
                    {
                        jdata.Add(new UploadFileModel()
                        {
                            ID                 = int.Parse(item["id"].ToString()),
                            FileName           = item["fileName"].ToString(),
                            FilePath           = item["filePath"].ToString(),
                            Type               = int.Parse(item["type"].ToString()),
                            TypeName           = item["typeName"].ToString(),
                            SystemResource     = int.Parse(item["systemResource"].ToString()),
                            SystemResourceName = item["systemResourceName"].ToString(),
                            Entity             = int.Parse(item["entity"].ToString())
                        });
                    }
                    if (jdata != null)
                    {
                        obj.FileIDs = JsonConvert.SerializeObject(UploadFileCommonHelper.ListShow(jdata));
                    }
                }



                ret.data = obj;
                ret.code = Code.Success;
                return(ret);
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
                return(ret);
            }
        }
Пример #7
0
    public void TryBuild(GameObject building)
    {
        if (!building.GetComponent <ConstructionPlan>() || !building.GetComponentInChildren <SpriteRenderer>() || !building.GetComponent <BuildingDisplay>())
        {
            return;
        }

        playerInput.CurrentState = State.build;
        currentBuilding          = building;
        currentBuildingDisplay   = currentBuilding.GetComponent <BuildingDisplay>();
        currentBuildingDisplay.Init();
        currentConstructionPlan = currentBuilding.GetComponent <ConstructionPlan>();
        offset = currentConstructionPlan.offset;
    }
Пример #8
0
    private void CreateJobs()
    {
        Dictionary <Tile, GameObject> temp = new Dictionary <Tile, GameObject>(_tiles);

        foreach (KeyValuePair <Tile, GameObject> pair in temp)
        {
            if (pair.Key.Contents.ConstructionPlan != null)
            {
                continue;
            }
            ConstructionPlan plan = new ConstructionPlan();
            plan.SetData(_constructionData, pair.Key.Position);
            plan.SetGameObject(pair.Value);
            _tiles.Remove(pair.Key);
        }
    }
Пример #9
0
        public async Task <ActionResult <ApiResult> > Save(ConstructionPlan obj)
        {
            ApiResult ret = new ApiResult {
                code = Code.Failure
            };

            try
            {
                ret = await _service.Save(obj);
            }
            catch (System.Exception ex)
            {
                ret.msg = string.Format(
                    "新增数据ConstructionPlan失败, 异常信息:{0}",
                    ex.Message);
            }
            return(ret);
        }
Пример #10
0
        public async Task <ApiResult> Save(ConstructionPlan obj)
        {
            ApiResult ret = new ApiResult();

            try
            {
                DateTime dt = DateTime.Now;
                obj.UpdatedTime = dt;
                obj.CreatedTime = dt;
                obj.UpdatedBy   = _userID;
                obj.CreatedBy   = _userID;
                ret.data        = await _repo.Save(obj);

                ret.code = Code.Success;
                return(ret);
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
                return(ret);
            }
        }
Пример #11
0
 public void SetConstructionPlan(ConstructionPlan value) => ConstructionPlan = value;
Пример #12
0
 public BuildJob(ConstructionPlan plan) : base(plan.Position)
 {
     _plan = plan;
 }
Пример #13
0
        private ConstructionPlan create_construction_plan(string dataName)
        {
            ConstructionPlan plan = Factory.CreateConstructionPlan("plank wall", _spawnPosition);

            //check data + check all fields
            if (plan.Data is null)
            {
                Assert.Fail();
            }

            if (plan.Data.construction is null)
            {
                Assert.Fail();
            }

            if (plan.Data.ingredients == null ||
                plan.Data.ingredients.Count == 0)
            {
                Assert.Fail();
            }

            //check position
            if (plan.Position != _spawnPosition)
            {
                Assert.Fail();
            }

            //check traversability
            if (plan.IsTraversable == false)
            {
                Assert.Fail();
            }

            //check ingredients
            if (plan.Ingredients.Count != plan.Data.ingredients.Count)
            {
                Assert.Fail();
            }

            //check gameobject + position
            if (plan.gameObject == null)
            {
                Assert.Fail();
            }

            //check tile content
            if (Utils.TileAt(plan.Position).Contents.ConstructionPlan != plan)
            {
                Assert.Fail();
            }

            //check that tile doesn't have a stockpile
            if (Utils.TileAt(plan.Position).Contents.StockpilePart != null)
            {
                Assert.Fail();
            }

            //check that if there was an item on construction plan
            //haul job to remove the item was created and other jobs were not created
            if (Utils.TileAt(plan.Position).Contents.HasItem == true)
            {
                bool hasHaulJob = false;
                foreach (Job job in JobSystem.GetInstance().AllJobs)
                {
                    if (job.GetType() == typeof(HaulToItemHolderJob))
                    {
                        Assert.Fail();
                    }

                    if (job.GetType() == typeof(HaulJob))
                    {
                        hasHaulJob = true;
                    }
                }

                if (hasHaulJob == false)
                {
                    Assert.Fail();
                }
            }
            else if (Utils.TileAt(plan.Position).Contents.StaticObject is ICuttable)
            {
                bool hasCutJob = false;
                foreach (Job job in JobSystem.GetInstance().AllJobs)
                {
                    if (job.GetType() == typeof(HaulToItemHolderJob))
                    {
                        Assert.Fail();
                    }

                    if (job.GetType() == typeof(CutJob))
                    {
                        hasCutJob = true;
                    }
                }

                if (hasCutJob == false)
                {
                    Assert.Fail();
                }
            }

            return(plan);
        }
Пример #14
0
 public BuildCommand(ConstructionPlan plan)
 {
     _plan = plan;
 }