using System.Collections.Generic; using Snxxz.UI; using TableConfig; using UnityEngine; public static class GAStaticDefine { public const string WeaponBindBoneName = "Bip001 Prop1"; public readonly static string[] SecondaryBindBoneName = { "Bip001 L Forearm", "Bip001 Prop2" }; public const string WingBindBoneName = "Bip001 Spine1"; public const string MountPointBoneName = "Bip001"; public static readonly int State_IdleHash = Animator.StringToHash("Idle_0"); public static readonly int State_RunHash = Animator.StringToHash("Run_1"); public static readonly int State_HurtHash = Animator.StringToHash("Hurt_3"); public static readonly int State_DeadHash = Animator.StringToHash("Dead_4"); public static readonly int State_StunHash = Animator.StringToHash("Stun_5"); public static readonly int State_AirIdleHash = Animator.StringToHash("AirIdle_8"); public static readonly int State_AirRunHash = Animator.StringToHash("AirRun_9"); public static readonly int State_HorseIdleHash = Animator.StringToHash("HorseIdle_6"); public static readonly int State_HorseIdle1Hash = Animator.StringToHash("HorseIdle_61"); public static readonly int State_HorseIdle2Hash = Animator.StringToHash("HorseIdle_62"); public static readonly int State_HorseIdle3Hash = Animator.StringToHash("HorseIdle_63"); public static readonly int State_HorseIdle4Hash = Animator.StringToHash("HorseIdle_64"); public static readonly int State_HorseRunHash = Animator.StringToHash("HorseRun_7"); public static readonly int State_HorseRun1Hash = Animator.StringToHash("HorseRun_71"); public static readonly int State_HorseRun2Hash = Animator.StringToHash("HorseRun_72"); public static readonly int State_HorseRun3Hash = Animator.StringToHash("HorseRun_73"); public static readonly int State_HorseRun4Hash = Animator.StringToHash("HorseRun_74"); public static readonly int State_SitDown = Animator.StringToHash("SitDown_100"); public static readonly int State_Prepare = Animator.StringToHash("Prepare_200"); public static readonly int State_HurtDown1Hash = Animator.StringToHash("HurtDown_800"); public static readonly int State_HurtDown2Hash = Animator.StringToHash("HurtDown_801"); public static readonly int State_RollHash = Animator.StringToHash("Skill_99"); public static readonly int State_Dance = Animator.StringToHash("Dance"); public static readonly int State_Attack1Hash = Animator.StringToHash("Attack_10"); public static readonly int State_Attack2Hash = Animator.StringToHash("Attack_11"); public static readonly int State_Attack3Hash = Animator.StringToHash("Attack_12"); public static readonly int State_Attack4Hash = Animator.StringToHash("Attack_13"); public static readonly int State_Skill21 = Animator.StringToHash("Skill_21"); public static readonly int State_Skill22 = Animator.StringToHash("Skill_22"); public static readonly int State_Skill23 = Animator.StringToHash("Skill_23"); public static readonly int State_Skill24 = Animator.StringToHash("Skill_24"); public static readonly int State_Skill25 = Animator.StringToHash("Skill_25"); public static readonly int State_Skill26 = Animator.StringToHash("Skill_26"); public static readonly int State_Skill27 = Animator.StringToHash("Skill_27"); public static readonly int State_Skill28 = Animator.StringToHash("Skill_28"); public static readonly int State_Skill29 = Animator.StringToHash("Skill_29"); public static readonly int State_WarnHash = Animator.StringToHash("Warn_300"); public static readonly int State_CollectHash = Animator.StringToHash("Collect_400"); public static readonly int State_Open = Animator.StringToHash("Open"); public static readonly int Param_Action = Animator.StringToHash("Action"); public static readonly int Param_ActorInstID = Animator.StringToHash("ActorInstID"); public static readonly int Param_MoveState = Animator.StringToHash("MoveState"); public const int Act_Idle = 0; public const int Act_Run = 1; public const int Act_Hurt = 3; public const int Act_Dead = 4; public const int Act_Stun = 5; public const int Act_HorseIdle = 6; public const int Act_HorseIdle1 = 61; public const int Act_HorseIdle2 = 62; public const int Act_HorseIdle3 = 63; public const int Act_HorseIdle4 = 64; public const int Act_HorseRun = 7; public const int Act_HorseRun1 = 71; public const int Act_HorseRun2 = 72; public const int Act_HorseRun3 = 73; public const int Act_HorseRun4 = 74; public const int Act_AirIdle = 8; public const int Act_AirRun = 9; public const int Act_Attack1 = 10; public const int Act_Attack2 = 11; public const int Act_Attack3 = 12; public const int Act_Attack4 = 13; public const int Act_Skill1 = 21; public const int Act_Skill2 = 22; public const int Act_Skill3 = 23; public const int Act_Skill4 = 24; public const int Act_Skill5 = 25; public const int Act_Skill6 = 26; public const int Act_Skill7 = 27; public const int Act_Skill8 = 28; public const int Act_Dazuo = 100; public const int Act_Show = 200; public const int Act_Warn = 300; public const int Act_Collect = 400; public const int Act_HurtDown = 800; public const int Act_Roll = 99; public static Dictionary HorseItemID2ConfigID = new Dictionary(); public static Dictionary NpcID2ServerInstID = new Dictionary(); private static List s_MapNpcConfigs = null; private static List MapNpcConfigs { get { return s_MapNpcConfigs ?? (s_MapNpcConfigs = Config.Instance.GetAllValues()); } } private static Dictionary> mapNpcPositions = new Dictionary>(); public static bool TryGetMapNPCLocation(int _npcId, out NPCLocation _position) { return TryGetMapNPCLocation(_npcId, 0, out _position); } public static bool TryGetMapNPCLocation(int _npcId, int _mapId, out NPCLocation _location) { if (mapNpcPositions.ContainsKey(_npcId)) { var positions = mapNpcPositions[_npcId]; if (_mapId == 0) { if (positions.Count > 0) { var enumerator = positions.Values.GetEnumerator(); enumerator.MoveNext(); _location = enumerator.Current; return true; } } else { if (positions.ContainsKey(_mapId)) { _location = positions[_mapId]; return true; } } } var monsterRefreshConfig = Config.Instance.Get(_npcId); if (monsterRefreshConfig != null) { Dictionary mapPositions = null; if (mapNpcPositions.ContainsKey(_npcId)) { mapPositions = mapNpcPositions[_npcId]; } else { mapNpcPositions[_npcId] = mapPositions = new Dictionary(); } mapPositions[monsterRefreshConfig.MapId] = _location = new NPCLocation(monsterRefreshConfig.MapId, monsterRefreshConfig.turned, monsterRefreshConfig.Position * 0.5f, monsterRefreshConfig.scope * .5f); return true; } mapnpcConfig mapNpcConfig = null; if (_mapId == 0) { foreach (var config in MapNpcConfigs) { if (config.NPCID == _npcId) { mapNpcConfig = config; break; } } } else { foreach (var config in MapNpcConfigs) { if (config.MapID == _mapId && config.NPCID == _npcId) { mapNpcConfig = config; break; } } } if (mapNpcConfig != null) { Dictionary mapPositions = null; if (mapNpcPositions.ContainsKey(_npcId)) { mapPositions = mapNpcPositions[_npcId]; } else { mapNpcPositions[_npcId] = mapPositions = new Dictionary(); } var location = new NPCLocation(mapNpcConfig.MapID, mapNpcConfig.NPCFace, GetClientPostionFromHex(mapNpcConfig.HexPosNPCRefreshAreaChaseArea), 1); mapPositions[mapNpcConfig.MapID] = _location = location; return true; } _location = default(NPCLocation); return false; } public static int GetMapIdByNpcId(int _npcId) { NPCLocation location; if (TryGetMapNPCLocation(_npcId, out location)) { return location.mapId; } else { return 0; } } public static Vector2 GetClientPostionFromHex(string hex) { Vector2 _position; string[] _values = hex.Split(' '); string _hex16 = StringUtility.Contact(_values[3], _values[2], _values[1], _values[0]); _position.x = System.Convert.ToInt32(_hex16, 16) * .5f; _hex16 = StringUtility.Contact(_values[7], _values[6], _values[5], _values[4]); _position.y = System.Convert.ToInt32(_hex16, 16) * .5f; _values = null; return _position; } public struct NPCLocation { public int mapId; public int face; public Vector2 position; public float scope; public NPCLocation(int _mapId, int _face, Vector2 _postion, float _scope) { mapId = _mapId; face = _face; position = _postion; scope = _scope; } } public static void PopHp(GActor caster, GActor target, int attackType, int value) { if (target == null || CameraController.Instance == null) { return; } ///** 普通伤害 1*/ //Normal = 1, ///** 恢复 2*/ //Recovery, ///** 反弹伤害 3*/ //BounceHurt, ///** 留血 4*/ //Bleed, ///** 抵御 5*/ //Parry, ///** 连击 6*/ //DoubleHit, ///** 暴击 7*/ //SuperHit, ///** 会心一击 8*/ //LuckyHit, ///** 闪避 9*/ //Miss, // 判断伤血的归属是否为玩家或者玩家的召唤物或者宠物 //bool _isHurtHero = target.ServerInstID == PlayerDatas.Instance.PlayerId; //if (!_isHurtHero) //{ //} // ---- 判断是否显示 if ((caster != null// 来源不能为空 && (caster.ServerInstID == PlayerDatas.Instance.PlayerId // 自己攻击 || (caster.ActorInfo.ownerSID != 0 && caster.ActorInfo.ownerSID == PlayerDatas.Instance.PlayerId))) // 或者是自己的宠物或者召唤物攻击 || target.ServerInstID == PlayerDatas.Instance.PlayerId// 或者受伤的人是自己 || (attackType == (int)HurtAttackType.Recovery && (target.ActorType == GameObjType.gotNPC || (PlayerDatas.Instance.hero != null && target == PlayerDatas.Instance.hero.SelectTarget))))// npc和当前选中目标的回血显示 { // 决定显示的类型 int _base = (int)PopUpNum.Pattern.PlayerAttack; if (caster is GA_Pet) { _base = (int)PopUpNum.Pattern.PetAttack; } else if (caster is GA_NpcSummonFight) { if (caster.ActorInfo.ownerSID == PlayerDatas.Instance.PlayerId) { _base = (int)PopUpNum.Pattern.PlayerAttack; } else { _base = (int)PopUpNum.Pattern.EnemyAttack; } } else if (caster is GActorNpcFight) { _base = (int)PopUpNum.Pattern.EnemyAttack; } if (target is GA_Hero || caster == null) { _base = (int)PopUpNum.Pattern.EnemyAttack; } var direction = Vector3.up; if (caster != null) { var screenFrom = CameraController.Instance.CameraObject.WorldToScreenPoint(target.Pos); var screenTo = CameraController.Instance.CameraObject.WorldToScreenPoint(caster.Pos); direction = screenFrom - screenTo; } PopUpNum.Pattern _pattern = (PopUpNum.Pattern)((attackType - 1) * 3); var damageNum = value; var camera = CameraController.Instance.CameraObject; var mountPoint = (target is GA_NpcFightBoss || target is GA_NpcClientFightBoss) ? target.MP_Stun : target.MP_Name; var _casterRealm = 0; var _targetRealm = 0; if (caster is GA_Hero) { if (target is GActorPlayerBase) { int[] _grounp = GeneralConfig.Instance.RealmGroup; for (int i = 0; i < _grounp.Length; ++i) { if (PlayerDatas.Instance.baseData.realmLevel > _grounp[i]) { _casterRealm = i + 1; } if (target.ActorInfo.realm > _grounp[i]) { _targetRealm = i + 1; } } } else if (target is GA_NpcFightNorm) { _casterRealm = PlayerDatas.Instance.baseData.realmLevel; _targetRealm = (int)target.ActorInfo.realm == 0 ? 99999999 : (int)target.ActorInfo.realm; } } else if (target is GA_Hero) { if (caster is GActorPlayerBase) { int[] _grounp = GeneralConfig.Instance.RealmGroup; for (int i = 0; i < _grounp.Length; ++i) { if (caster.ActorInfo.realm > _grounp[i]) { _casterRealm = i + 1; } if (PlayerDatas.Instance.baseData.realmLevel > _grounp[i]) { _targetRealm = i + 1; } } } else if (caster is GA_NpcFightNorm) { _casterRealm = (int)caster.ActorInfo.realm; _targetRealm = PlayerDatas.Instance.baseData.realmLevel; } } if (attackType == (int)HurtAttackType.Suppress) { _casterRealm = 1; _targetRealm = 0; _pattern = (PopUpNum.Pattern)(((int)HurtAttackType.Normal - 1) * 3); } else if (attackType == (int)HurtAttackType.Immune) { _base = (int)PopUpNum.Pattern.PlayerAttack; } var popupInfo = new PopUpNum.PopupInfo() { pattern = _pattern + _base, num = damageNum, camera = camera, direction = direction, target = mountPoint, isPlayer = target is GA_Hero, realmSuppress = _casterRealm > _targetRealm }; PopUpNum.RecordPopup(popupInfo); //if (caster is GA_Hero) //{ // Debug.LogFormat("{0} 攻击了 {1} 执行了飘血: {2}", caster.ServerInstID, target.ServerInstID, value); //} } } }