private IEnumerator IECreateTower(GameObject tower)
    {
        if (CurTarget.gameObject.layer == LayerMask.NameToLayer("AvailableTile"))
        {
            if (!UsedTileMap.ContainsKey(CurTarget.GetInstanceID().ToString()))
            {
                GameObject tower_copy = GameObject.Instantiate(tower) as GameObject;

                tower_copy.name             = tower_copy.name.Replace("(Clone)", string.Empty);
                tower_copy.transform.parent = TowerParent;

                tower_copy.GetComponent <Tower>().UsedTile = CurTarget;
                tower_copy.GetComponent <Tower>().Init();

                UsedTileMap.Add(CurTarget.GetInstanceID().ToString(), CurTarget);

                yield return(new WaitForSeconds(0.0f));
            }
        }
    }
    private void Select(TouchInfo tInfo)
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(tInfo.Position);

        bool towerHit = false;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, TowerMask))
        {
            ;
        }
        {
            if (hit.transform != null && !CurTarget.Equals(hit.transform))
            {
                CurTarget            = hit.transform;
                G.i.StageM.CurTarget = hit.transform;
                SelectTower(CurTarget);

                towerHit = true;
            }
        }

        if (!towerHit)
        {
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, TileMask))
            {
                ;
            }
            {
                if (hit.transform != null && !CurTarget.Equals(hit.transform))
                {
                    CurTarget            = hit.transform;
                    G.i.StageM.CurTarget = hit.transform;
                    SelectTile(CurTarget);
                }
            }
        }
    }
Esempio n. 3
0
        public void CuringMonthTarget(CurTarget obj)
        {
            //string month = GetPropertyValue(obj,"month").ToString();
            //string curWay = GetPropertyValue(obj, "curWay").ToString();
            string          month  = obj.Month;
            string          curWay = obj.CurWay;
            MonthBonusModel bonus  = new MonthBonusModel();
            var             result = ValidateMonth(month, ref bonus);

            if (result == "")
            {
                var user = GetCurrentUserAsync().Result;
                //1.生成固化单
                #region bill
                MonthBill bill = new MonthBill
                {
                    Id         = 0,
                    BonusValue = bonus.BonusValue,
                    CurTime    = DateTime.Now,
                    CurUserId  = user.Id,//外部调用可能会报错
                    IsUse      = true,
                    Month      = month,
                    Status     = MonthBillConst.generate,
                    CurWay     = curWay
                };
                #endregion
                long billId = _MonthBillCase.InsertAndGetIdAsync(bill).Result;//获得固化单ID

                //写日志
                MonthLog(billId, "开始启动生成月份【" + month + "】固化单【" + billId.ToString() + "】:启动人【" + user.Name + "】");
                //2.生成月度指标内容
                var targetList = _TargetCase.GetAllList();
                if (targetList != null && targetList.Count > 0)
                {
                    try
                    {
                        var managerList  = _ManagerCase.GetAllList();                      //获取客户经理信息装入内存中
                        var districtList = _DistrictCase.GetAllList(p => p.CurLevel == 2); //获取所有二级组织(区县)

                        for (int i = 0; i < targetList.Count; i++)
                        {
                            var target = targetList[i];
                            MonthLog(billId, "===Start======固化指标【" + target.Name + "】编号【" + target.Id.ToString() + "】======");
                            MonthLog(billId, "->本次固化共有【" + targetList.Count.ToString() + "】个指标");

                            MonthLog(billId, "->第【" + i.ToString() + "】个指标:建立MonthTarget实例单开始");
                            #region mTarg
                            MonthTarget mTarg = new MonthTarget
                            {
                                Id           = 0,
                                ChooseType   = target.ChooseType,
                                EndTable     = target.EndTable,
                                MainField    = target.MainField,
                                Month        = month,
                                MonthBillId  = billId,
                                Weight       = target.Weight,
                                Remark       = target.Remark,
                                TargetId     = target.Id,
                                TargetName   = target.Name,
                                TargetTagId  = target.TargetTagId,
                                TargetTypeId = target.TargetTypeId,
                                CrisisValue  = target.CrisisValue//计分门槛值
                            };
                            #endregion
                            long monthTargetId = _MonthTargetCase.InsertAndGetIdAsync(mTarg).Result;//得到当前固化指标ID
                            MonthLog(billId, "->第【" + i.ToString() + "】个指标:建立MonthTarget实例单【" + monthTargetId.ToString() + "】完成");
                            //3.生成月度指标明细(当未获取到目标值时,默认为0)
                            InitMonthTargetDetail(month, monthTargetId, billId, target, managerList, districtList);

                            MonthLog(billId, "===End======固化指标【" + target.Name + "】编号【" + target.Id.ToString() + "】======");
                        }
                    }
                    catch (Exception ex)
                    {
                        bill.Status = MonthBillConst.error;
                        bill.IsUse  = false;
                        _MonthBillCase.UpdateAsync(bill);
                        string errStr = "月份【" + month + "】固化单生成失败.错误:" + ex.InnerException.Message;
                        MonthLog(billId, "失败:" + errStr);
                        bill.Status = MonthBillConst.error;
                        bill.IsUse  = false;
                        bill.Remark = errStr;
                        _MonthBillCase.UpdateAsync(bill);
                        throw new Exception(errStr);
                    }
                }
                bill.Status = MonthBillConst.success;
                _MonthBillCase.UpdateAsync(bill);

                //_MonthBillCase.InsertAsync(bill);
                MonthLog(billId, "结束:月份【" + month + "】固化单生成全部完成。成功");
            }
            else
            {
                throw new Exception(result);
            }
        }