public Config.npcactionCell PlayActionAnim() { int idx = Const.Invalid_Int; Math_F.TableProbability(animWeight, ref idx); #if UNITY_EDITOR if (idx == Const.Invalid_Int) { string e = string.Format("随机动画异常{0}", mainGameObject.name); throw new System.Exception(e); } #endif //var cell = Config.npcactionConfig.getInstace().getCell(idx); var cell = GlobalDataManager.GetInstance().logicTableVisitorAction.actionList[idx]; #if UNITY_EDITOR if (cell == null) { string e = string.Format("随机动画异常{0}, {1}", mainGameObject.name, idx); throw new System.Exception(e); } #endif anim.Play(cell.actionname); DebugFile.GetInstance().WriteKeyFile(entityID, "{0} PlayAnim {1}", entityID, cell.actionname); return(cell); }
protected void OnVisitorGetRandomLittleZooApply(Message msg) { var _msg = msg as VisitorGetRandomLittleZooApply; var entity = EntityManager.GetInstance().GetEntityMovable(_msg.entityID) as EntityVisitor; int groupID = entity.stayGroupID; if (_msg.isFirstApply) { //groupID = GlobalDataManager.GetInstance().logicTableGroup.sortedGroupID[0]; var playerData = GlobalDataManager.GetInstance().playerData; groupID = GlobalDataManager.GetInstance().logicTableGroup.GetSortedGroupIDs(sceneID)[0]; } openedLittleZooIDs.Clear(); bool retCode = false; int nextGroupID = Const.Invalid_Int; while (true) { retCode = GetOpenedLittleZooIDs(groupID, openedLittleZooIDs); if (!retCode) { //失败 VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null); return; } //wouldGotoLittleZooIDs = //从开放的动物栏中 剔除 去过的 retCode = GetWouldGotoLittleZooIDs(entity, groupID, openedLittleZooIDs, wouldGotoLittleZooIDs); if (!retCode) { //retCode = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID); retCode = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(sceneID, groupID, ref nextGroupID); if (!retCode) { //找下一组失败 VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null); return; } groupID = nextGroupID; } else { break; } } //构建 wouldGotoLittleZooIDs 对应的权重 retCode = GetWouldGotoWeights(groupID, wouldGotoLittleZooIDs, wouldGotoWeights); if (!retCode) { //失败 VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null); return; } int idx = Const.Invalid_Int; Math_F.TableProbability(wouldGotoWeights, ref idx); int littleZooID = wouldGotoLittleZooIDs[idx]; EntityVisitor.RecordVisitedLittleZoo(entity, groupID, littleZooID); VisitorGetRandomLittleZooReply.Send(_msg.entityID, true, groupID, littleZooID, false, null); }