/// <summary> /// 播放动作 /// </summary> /// <param name="strActionName"></param> public void PlayAction(string strActionName, int nStartFrame = 0, float fSpeed = 1f, float fBlendTime = -1.0f, int nLoop = -1, Engine.ActionEvent callback = null, object param = null) { if (EntitySystem.m_ClientGlobal.IsMainPlayer(this)) { if (strActionName == EntityAction.Stand_Combat || strActionName == EntityAction.Stand) { Engine.Utility.Log.LogGroup("ZDY", "play " + strActionName); } // Engine.Utility.Log.LogGroup("ZDY","play " + strActionName); if (strActionName == "Attack001") { // Debug.LogError("play Attack001"); } } float speedFact = 1.0f; // 目前简单播放动画 if (m_EntityView != null) { // 根据移动速度修正动画速度 if (strActionName == EntityAction.Run || strActionName == EntityAction.Run_Combat) { if (GetEntityType() == EntityType.EntityType_Player || GetEntityType() == EntityType.EntityTYpe_Robot) { uint speed = GameTableManager.Instance.GetGlobalConfig <uint>("Base_Move_Speed"); if (speed == 0) { speed = 1; } speedFact = (float)GetProp((int)WorldObjProp.MoveSpeed) / (float)speed; } else if (GetEntityType() == EntityType.EntityType_NPC) { // 速度修正 int nNpcID = GetProp((int)EntityProp.BaseID); var table_data = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)nNpcID); if (table_data != null) { uint speed = table_data.dwRunSpeed; if (speed == 0) { speed = 1; } speedFact = (float)GetProp((int)WorldObjProp.MoveSpeed) / (float)speed; } } } // 对动作名称按区域类型进行修正 string strAiName = strActionName; if (GetEntityType() == EntityType.EntityType_Player || GetEntityType() == EntityType.EntityTYpe_Robot) { bool bRide = (bool)SendMessage(EntityMessage.EntityCommond_IsRide, null); if (bRide) { if (strActionName == EntityAction.Run_Combat) { strAiName = EntityAction.Run; } if (strActionName == EntityAction.Stand_Combat) { strAiName = EntityAction.Stand; } } else { if (strActionName == EntityAction.Run || strActionName == EntityAction.Stand) { MapAreaType type = EntitySystem.m_ClientGlobal.GetMapSystem().GetAreaTypeByPos(GetPos()); if (type != MapAreaType.Safe && type != MapAreaType.Fish) { strAiName = string.Format("{0}_Combat", strActionName); } } } } m_EntityView.PlayAction(strAiName, nStartFrame, fSpeed * speedFact, fBlendTime, nLoop, callback, param); } }