BehaveResult Tick(Tree sender) { if (!Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Failure); } //吃到了合适的属性值或者没有合适的药品时停止 if (!NpcEatDb.IsContinueEat(entity, out mEatItem)) { return(BehaveResult.Failure); } if (GetCdByProtoId(mEatItem.protoId) >= PETools.PEMath.Epsilon) { return(BehaveResult.Failure); } if (mEatItem != null) { UseItem(mEatItem); if (CanDoAction(PEActionType.Eat) && !IsActionRunning(PEActionType.Eat)) { PEActionParamS param = PEActionParamS.param; param.str = m_Data.eatAnim; DoAction(PEActionType.Eat, param); } } return(BehaveResult.Running); }
void EatSth() { ItemAsset.ItemObject mEatItem; if (NpcEatDb.IsContinueEat(entity, out mEatItem)) { if (entity.UseItem.GetCdByItemProtoId(mEatItem.protoId) < PETools.PEMath.Epsilon) { UseItem(mEatItem); } } }
BehaveResult Init(Tree sender) { if (!GetData <Data>(sender, ref m_Data)) { return(BehaveResult.Failure); } if (!NpcEatDb.CanEat(entity)) { return(BehaveResult.Failure); } return(BehaveResult.Running); }
public override List <ItemIdCount> GetDesires() { List <ItemIdCount> desireList = new List <ItemIdCount> (); int[] staminaItemList = NpcEatDb.GetEatIDs(EEatType.Hunger); foreach (int protoId in staminaItemList) { if (CSUtils.GetItemCountFromAllStorage(protoId, Assembly) < CYCLE_DESIRE_MIN_COUNT) { desireList.Add(new ItemIdCount(protoId, CYCLE_DESIRE_ADD_COUNT)); } } return(desireList); }
BehaveResult Tick(Tree sender) { if (Time.time - startHideTime > CHECK_Hide_TIME) { Vector3 dir = mFind.GetHideDir(PeCreature.Instance.mainPlayer.peTrans.position, position, Enemies); if (mFind.bNeedHide) { Vector3 dirPos = position + dir.normalized * m_Data.RunRadius; MoveToPosition(dirPos, SpeedState.Run); } else { StopMove(); FaceDirection(PeCreature.Instance.mainPlayer.peTrans.position - position); //if(entity.target.beSkillTarget) //{ // MoveDirection(transform.right,SpeedState.Run); //} //else //{ // StopMove(); // FaceDirection(PeCreature.Instance.mainPlayer.peTrans.position - position); //} } startHideTime = Time.time; } if (Time.time - startRunTime > CHECK_TIME || entity.HPPercent > m_Data.minHpPercent || ItemAsset.SelectItem.HasCanEquip(entity, EeqSelect.combat, AttackType.Ranged)) { SetCambat(true); return(BehaveResult.Success); } //吃到了合适的属性值或者没有合适的药品时停止 ItemAsset.ItemObject mEatItem; if (NpcEatDb.IsContinueEat(entity, out mEatItem)) { if (entity.UseItem.GetCdByItemProtoId(mEatItem.protoId) < PETools.PEMath.Epsilon) { UseItem(mEatItem); } } return(BehaveResult.Running); }
public static List <int> GetAutoProtoIdList() { List <int> protoList = new List <int> (); protoList.Add(CYCLE_PROTOID_LIFE); int[] staminaItemList = NpcEatDb.GetEatIDs(EEatType.Hunger); protoList.AddRange(staminaItemList); protoList.Add(CYCLE_PROTOID_COMFORT); protoList.Add(CYCLE_PROTOID_OTHER_0); protoList.Add(CYCLE_PROTOID_OTHER_1); protoList.Add(CYCLE_PROTOID_BATTERY); protoList.Add(CYCLE_PROTOID_OTHER_3); protoList.Add(CYCLE_PROTOID_PPCOAL); protoList.Add(CYCLE_PROTOID_PPFUSION); protoList.Add(CYCLE_PROTOID_WATER); protoList.Add(CYCLE_PROTOID_INSECTICIDE); //lw:2017.3.1添加火把和碳、面粉 protoList.Add(CYCLE_PROTOID_CHARCOAL); protoList.Add(CYCLE_PROTOID_TORCH); protoList.Add(CYCLE_PROTOID_FLOUR); return(protoList); }
public override List <ItemIdCount> GetRequirements() { int lifeItemCount = 0; int staminaItemCount = 0; int comfortItemCount = 0; int[] lifeItemList = NpcEatDb.GetEatIDs(EEatType.Hp); //--to do int[] staminaItemList = NpcEatDb.GetEatIDs(EEatType.Hunger); int[] comortItemList = NpcEatDb.GetEatIDs(EEatType.Comfort); foreach (int protoId in lifeItemList) { lifeItemCount += CSUtils.GetItemCountFromAllStorage(protoId, Assembly); } foreach (int protoId in staminaItemList) { staminaItemCount += CSUtils.GetItemCountFromAllStorage(protoId, Assembly); } foreach (int protoId in comortItemList) { comfortItemCount += CSUtils.GetItemCountFromAllStorage(protoId, Assembly); } List <ItemIdCount> requireList = new List <ItemIdCount> (); if (lifeItemCount < CYCLE_MIN_PER_NPC_LIFE * m_MgCreator.GetNpcCount) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_LIFE, Mathf.Max(CYCLE_ADD_MIN_LIFE, Mathf.CeilToInt(CYCLE_MIN_PER_NPC_LIFE * m_MgCreator.GetNpcCount * MAX_ADD_PERCENT_FOR_PER_NPC)))); } if (staminaItemCount < CYCLE_MIN_PER_NPC_STAMINA * m_MgCreator.GetNpcCount) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_STAMINA, Mathf.Max(CYCLE_ADD_MIN_STAMINA, Mathf.CeilToInt(CYCLE_MIN_PER_NPC_STAMINA * m_MgCreator.GetNpcCount * MAX_ADD_PERCENT_FOR_PER_NPC)))); } if (comfortItemCount < CYCLE_MIN_PER_NPC_COMFORT * m_MgCreator.GetNpcCount) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_COMFORT, Mathf.Max(CYCLE_ADD_MIN_COMFORT, Mathf.CeilToInt(CYCLE_MIN_PER_NPC_COMFORT * m_MgCreator.GetNpcCount * MAX_ADD_PERCENT_FOR_PER_NPC)))); } if (CYCLE_MIN_OTHER_0 > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_OTHER_0, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_OTHER_0, CYCLE_ADD_MIN_OTHER_0)); } if (CYCLE_MIN_OTHER_1 > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_OTHER_1, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_OTHER_1, CYCLE_ADD_MIN_OTHER_1)); } //battery List <ItemObject> allBattery = CSUtils.GetItemListInStorage(CYCLE_PROTOID_BATTERY, Assembly); if (allBattery.Count < CYCLE_MIN_BATTERY) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_BATTERY, CYCLE_ADD_MIN_BATTERY)); } else { int availableBattery = 0; foreach (ItemObject bat in allBattery) { Energy eg = bat.GetCmpt <Energy>(); if (eg != null && eg.energy.percent > BATTERY_AVAILABLE) { availableBattery++; } } if (availableBattery < CYCLE_MIN_BATTERY) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_BATTERY, CYCLE_ADD_MIN_BATTERY)); } } if (CYCLE_MIN_OTHER_3 > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_OTHER_3, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_OTHER_3, CYCLE_ADD_MIN_OTHER_3)); } if (CYCLE_MIN_PPCOAL > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_PPCOAL, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_PPCOAL, CYCLE_ADD_MIN_PPCOAL)); } if (CYCLE_MIN_PPFUSION > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_PPFUSION, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_PPFUSION, CYCLE_ADD_MIN_PPFUSION)); } if (CYCLE_MIN_WATER > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_WATER, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_WATER, CYCLE_ADD_MIN_WATER)); } if (CYCLE_MIN_INSECTICIDE > CSUtils.GetItemCountFromAllStorage(CYCLE_PROTOID_INSECTICIDE, Assembly)) { requireList.Add(new ItemIdCount(CYCLE_PROTOID_INSECTICIDE, CYCLE_ADD_MIN_INSECTICIDE)); } return(requireList); }
BehaveResult Tick(Tree sender) { if (!NpcTypeDb.CanRun(NpcCmdId, ENpcControlType.Recourse)) { return(BehaveResult.Failure); } // Request req = GetRequest(EReqType.FollowPath) as RQFollowPath; // if(req != null && !req.CanRun()) // { // specialRecurse = true; // } // else // { // specialRecurse = false; // } if (Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Success); } if (Time.time - checkStarTime > Check_TIME) { checkStarTime = Time.time; if (!entity.NpcCmpt.HasEnemyLocked()) { entity.target.ClearEnemy(); } } float Hp = GetAttribute(AttribType.Hp); float HpMax = GetAttribute(AttribType.HpMax); if (Hp / HpMax >= 0.3f) //!specialRecurse && { return(BehaveResult.Success); } if (Time.time - hideStarTime > HIDE_TIME) { mdir = mfind.GetHideDir(playerTrans.position, position, Enemies); hideStarTime = Time.time; } Vector3 dirPos = position + mdir.normalized * 10.0f; if (mfind.bNeedHide) { MoveToPosition(dirPos, SpeedState.Run); } else { StopMove(); FaceDirection(playerTrans.position - position); } //吃到了合适的属性值或者没有合适的药品时停止 ItemAsset.ItemObject mEatItem; if (NpcEatDb.IsContinueEat(entity, out mEatItem)) { if (entity.UseItem.GetCdByItemProtoId(mEatItem.protoId) < PETools.PEMath.Epsilon) { UseItem(mEatItem); } } SetCambat(false); return(BehaveResult.Running); }