/// <summary> /// //制作返回 /// </summary> /// <param name="TID">实例ID</param> private void OnBuildBack(int TID) { Debug.Log("制作返回 = " + TID); ProduceInfoVO foundryMember = m_FoundryProxy.GetFoundryById(TID); if (foundryMember == null) { return; } bool finshed = foundryMember.StartTime + foundryMember.SpendTime >= foundryMember.EndTime; ProduceState state = finshed ? ProduceState.Finsh : ProduceState.Producing; float progress = 0; if (foundryMember.EndTime > foundryMember.StartTime && foundryMember.SpendTime >= 0) { progress = (float)foundryMember.SpendTime / (foundryMember.EndTime - foundryMember.StartTime); } m_FoundryProxy.SetGirdDataInfo(foundryMember.TID, state, progress); //蓝图生产状态 0,不可生产,1 生产中,2可生产 3 生产完成 if (m_FoundryProxy.GetBluePrintDic().TryGetValue(foundryMember.TID, out ProduceInfoVO girdInfo)) { if (girdInfo.Elelment) { girdInfo.Elelment.RefreshData(girdInfo.Progress, girdInfo.BluePrintState); } RefreshHotKey(girdInfo.BluePrintState); //UpdateTips(TID); } }
/// <summary> /// 刷新数据 /// </summary> public void RefreshData(float progress, ProduceState State) { progress = Mathf.Clamp01(progress); m_Progress = progress == 0 ? 0f : progress; m_ProgressRootImage.fillAmount = m_Progress; GetProduceTime(State); UpdateTime(); }
public void GetResource() { if (m_curState == ProduceState.Full) { fullEffect.SetActive(false); m_curState = ProduceState.Producing; Messenger.Broadcast <int, ResourceType>("Gain Resource", produceAmount, resourceType); } }
// Update is called once per frame void Update() { if (m_curState != ProduceState.Full) { m_timer += Time.deltaTime; if (m_timer >= produceTime) { m_curState = ProduceState.Full; m_timer = 0f; fullEffect.SetActive(true); } } }
/// <summary> /// 设置蓝图状态信息 /// </summary> /// <param name="uId">实例id</param> /// <param name="tId">蓝图id</param> /// <param name="num">蓝图数量</param> /// <param name="state">蓝图状态</param> /// <param name="progress">蓝图进度</param> /// <param name="active">是否激活</param> public void SetGirdDataInfo(int tId, ProduceState state, float progress = 0, bool active = true) { if (!GetBluePrintDic().ContainsKey(tId)) { ProduceInfoVO girdInfo = new ProduceInfoVO(); girdInfo.TID = tId; girdInfo.MItem = GetItemByProduceKey(tId); girdInfo.MProduce = GetItemByKey((uint)tId); girdInfo.BluePrintState = state; girdInfo.Progress = progress; GetBluePrintDic().Add(tId, girdInfo); girdInfo.Active = active; } else { ProduceInfoVO girdInfo = GetBluePrintDic()[tId]; girdInfo.Progress = progress; girdInfo.BluePrintState = state; girdInfo.Active = active; } }
/// <summary> /// 热键显示更新 /// </summary> /// <param name="state">状态</param> public void RefreshHotKey(ProduceState state) { // 根据策划需求刷新 //蓝图生产状态 0,不可生产,1 生产中,2可生产 3 生产完成 State.GetAction(UIAction.Product_ProduceAndCollect).Visible = true; State.GetAction(UIAction.Product_Accelerate).Visible = false; switch (state) { case ProduceState.CanNotProduce: SetHotKeyEnabled(UIAction.Product_Cancel, false); SetHotKeyEnabled(UIAction.Product_ProduceAndCollect, false, 0, false); break; case ProduceState.Producing: SetHotKeyEnabled(UIAction.Product_Cancel, true); SetHotKeyEnabled(UIAction.Product_Accelerate, true, 0); State.GetAction(UIAction.Product_ProduceAndCollect).Visible = false; State.GetAction(UIAction.Product_Accelerate).Visible = true; break; case ProduceState.CanProduce: SetHotKeyEnabled(UIAction.Product_Cancel, false); SetHotKeyEnabled(UIAction.Product_ProduceAndCollect, true, 0, false); break; case ProduceState.Finsh: SetHotKeyEnabled(UIAction.Product_Cancel, false); SetHotKeyEnabled(UIAction.Product_ProduceAndCollect, true, 1, false); break; case ProduceState.Have: SetHotKeyEnabled(UIAction.Product_Accelerate, false, 0); break; default: break; } }
/// <summary> /// 获取生产时间 /// </summary> /// <param name="finish"> 生产状态是否为完成</param> private void GetProduceTime(ProduceState state) { if (state == ProduceState.Producing) { ProduceInfoVO foundryMember = m_FoundryProxy.GetFoundryMemberByTID(m_TID); if (foundryMember == null) { IsUpdateTime = false; return; } m_MaxTime = foundryMember.EndTime - foundryMember.StartTime; m_Needtime = foundryMember.EndTime - foundryMember.StartTime - foundryMember.SpendTime; if (m_Needtime <= 0 || m_MaxTime <= 0) { return; } IsUpdateTime = true; } else { IsUpdateTime = false; if (state == ProduceState.CanNotProduce) { m_BlueprintStateLabel.text = TableUtil.GetLanguageString("production_title_1060"); } else if (state == ProduceState.CanProduce) { m_BlueprintStateLabel.text = TableUtil.GetLanguageString("production_title_1061"); } else if (state == ProduceState.Finsh) { m_BlueprintStateLabel.text = TableUtil.GetLanguageString("production_title_1059"); } else if (state == ProduceState.Have) { m_BlueprintStateLabel.text = TableUtil.GetLanguageString("production_text_1045"); } } }
/// <summary> /// 是否生产完成 /// </summary> /// <param name="tid">蓝图tID</param> /// <returns></returns> private bool BeFinshed(int tid) { bool finshed = false; if (GetServerBluePrintDic().ContainsKey(tid)) { if (GetServerBluePrintDic().TryGetValue(tid, out ProduceInfoVO produceInfoVO)) { float progress = 0; if (produceInfoVO.EndTime > produceInfoVO.StartTime && produceInfoVO.SpendTime >= 0) { progress = (float)produceInfoVO.SpendTime / (produceInfoVO.EndTime - produceInfoVO.StartTime); } finshed = produceInfoVO.Finished; ProduceState state = produceInfoVO.Finished ? ProduceState.Finsh : ProduceState.Producing; SetGirdDataInfo(produceInfoVO.TID, state, progress); } } return(finshed); }
protected void Wait() { this.OnWait(); state_ = ProduceState.Running; }
// Use this for initialization void Start() { m_curState = ProduceState.Producing; }