void ShowAttributeItem(bool _show) { if (_show) { if (!m_TraineeNpc.m_Npc.GetCmpt <NpcCmpt>().CanAttributeUp()) { mCannotUpgradeLabel.enabled = true; mUpgradeTimesLabel.text = ""; mUpgradeTimesLabel.transform.parent.gameObject.SetActive(false); mAttributeItemNameLabel.text = ""; mAttributeItemPlusLabel.text = ""; mAttributeItemContentLabel.text = ""; return; } mCannotUpgradeLabel.enabled = false; mUpgradeTimesLabel.text = "[00bbff]" + m_TraineeNpc.m_Npc.GetCmpt <NpcCmpt>().curAttributeUpTimes.ToString() + "/" + AttPlusNPCData.GetPlusCount(m_TraineeNpc.m_Npc.entityProto.protoId).ToString() + "[-]"; mUpgradeTimesLabel.transform.parent.gameObject.SetActive(true); AttribType mType = AttPlusNPCData.GetRandMaxAttribute(m_InsNpc.m_Npc.entityProto.protoId, m_InsNpc.m_Npc.GetCmpt <SkAliveEntity>()); if (mType == AttribType.Max) { Debug.Log(m_InsNpc.m_Npc.entityProto.protoId); mAttributeItemNameLabel.text = ""; mAttributeItemPlusLabel.text = ""; mAttributeItemContentLabel.text = ""; mUpgradeTimesLabel.text = ""; mUpgradeTimesLabel.transform.parent.gameObject.SetActive(false); mCannotUpgradeLabel.enabled = false; return; } float baseVal = m_TraineeNpc.m_Npc.GetAttribute(mType); AttPlusNPCData.AttrPlus.RandomInt randomInt = new AttPlusNPCData.AttrPlus.RandomInt(); if (AttPlusNPCData.GetRandom(m_InsNpc.m_Npc.entityProto.protoId, mType, out randomInt)) { mAttributeItemNameLabel.text = AtToString(mType) + ":"; mAttributeItemPlusLabel.text = baseVal + "" + "+"; mAttributeItemContentLabel.text = "[00ff00]" + randomInt.m_Min + "~" + randomInt.m_Max + "[-]"; } else { Debug.Log("没有获取到属性"); } } else { mAttributeItemNameLabel.text = ""; mAttributeItemPlusLabel.text = ""; mAttributeItemContentLabel.text = ""; mUpgradeTimesLabel.text = ""; mUpgradeTimesLabel.transform.parent.gameObject.SetActive(false); mCannotUpgradeLabel.enabled = false; } }
public void OnTrainAttributeFinish() { m_CurTime = -1F; m_Time = -1F; CSMain.Instance.RemoveCounter(m_Counter); if (PeGameMgr.IsMulti) { return; } //1.get the top attribute AttribType mType; csp_instructorNpc = m_Creator.GetNpc(InstructorNpcId); csp_traineeNpc = m_Creator.GetNpc(TraineeNpcId); if (csp_instructorNpc.IsRandomNpc) { mType = AttPlusNPCData.GetRandMaxAttribute(csp_instructorNpc.m_Npc.entityProto.protoId, csp_instructorNpc.m_Npc.GetCmpt <SkAliveEntity>()); } else { mType = AttPlusNPCData.GetProtoMaxAttribute(csp_instructorNpc.m_Npc.entityProto.protoId, csp_instructorNpc.m_Npc.GetCmpt <SkAliveEntity>()); } //2.count attribute AttPlusNPCData.AttrPlus.RandomInt randomInt = new AttPlusNPCData.AttrPlus.RandomInt(); AttPlusNPCData.GetRandom(csp_instructorNpc.m_Npc.entityProto.protoId, mType, out randomInt); float value = new System.Random().Next(randomInt.m_Min, randomInt.m_Max + 1); //3.apply skill Debug.LogError("Train sucess: " + mType.ToString() + ":" + value); csp_traineeNpc.UpgradeAttribute(mType, value); SetNpcIsTraining(false); SetStopBtn(false); LockUI(false); UpdateUI(); }