private void OtherMorphingBegin(long serverID, int changeID, float scale) { OtherPlayer player = CoreEntry.gActorMgr.GetPlayerActorByServerID(serverID) as OtherPlayer; if (null == player) { return; } player.transform.localScale = Vector3.one; Vector3 pos = player.transform.position; Vector3 angle = player.transform.eulerAngles; MsgData_sSceneObjectEnterHuman humanStruct = CoreEntry.gSceneObjMgr.GetEntityData(serverID) as MsgData_sSceneObjectEnterHuman; if (null == humanStruct) { return; } //���� humanStruct.Ride = 0; CoreEntry.gActorMgr.RemoveActor(player); player.RecycleObj(); humanStruct.ChangeID = changeID; var other = CoreEntry.gSceneLoader.LoadOtherPlayer(humanStruct); other.transform.localScale = new Vector3(scale, scale, scale); other.transform.position = pos; other.transform.eulerAngles = angle; }
private void OtherMorphFinish(long serverID) { OtherPlayer player = CoreEntry.gActorMgr.GetPlayerActorByServerID(serverID) as OtherPlayer; if (null == player) { return; } MsgData_sSceneObjectEnterHuman humanStruct = CoreEntry.gSceneObjMgr.GetEntityData(serverID) as MsgData_sSceneObjectEnterHuman; if (null == humanStruct) { return; } Vector3 pos = player.transform.position; Vector3 angle = player.transform.eulerAngles; CoreEntry.gActorMgr.RemoveActor(player); player.RecycleObj(); humanStruct.ChangeID = 0; var other = CoreEntry.gSceneLoader.LoadOtherPlayer(humanStruct); other.transform.position = pos; other.transform.eulerAngles = angle; }
/// <summary> /// 逐步改变玩家外观,如果改变过程中玩家被消耗则停止 /// </summary> IEnumerator ChangeOtherPlayerShow(OtherPlayer player, MsgData_sSceneObjectEnterHuman hes) { yield return(null); if (player != null) { player.ChangeWing(GetWingModelID(hes.FashionState == 0 ? hes.FashionWing : 0, hes.Wing, hes.Prof)); } else { yield break; } yield return(null); if (player != null) { player.FuckHorse(hes.Ride); } else { yield break; } yield return(null); if (player != null) { player.ChangeWeapon(GetWeaponModelID(hes.FashionState == 0 ? hes.FashionWeapon : 0, hes.ShenBin, hes.Weapon, hes.Prof)); } else { yield break; } yield return(null); if (player != null) { player.ShowMagicKey(hes.MagicKey); player.ShowMagicKeyByStar(hes.MagicKeyStar); } else { yield break; } yield return(null); if (player != null) { player.ChangeZhenFa(hes.ZhenfaId); } else { yield break; } }
IEnumerator ChangeVirtualPlayerShow(OtherPlayer player, MsgData_sSceneObjectEnterVirtualPlayer hes) { yield return(null); if (player != null) { player.ChangeWing(GetWingModelID(0, hes.Wing, hes.Job)); } else { yield break; } yield return(null); if (player != null) { player.FuckHorse(hes.WuHunID); } else { yield break; } yield return(null); if (player != null) { player.ChangeWeapon(GetWeaponModelID(hes.FashionWeapon, hes.ShenBing, hes.Weapon, hes.Job)); } else { yield break; } yield return(null); if (player != null) { player.ShowMagicKey(hes.MagicKey); player.ShowMagicKeyByStar(hes.MagicKeyStar); } else { yield break; } yield return(null); if (player != null) { player.ChangeZhenFa(hes.ZhenfaId); } else { yield break; } }
/// <summary> /// 加载其它玩家 /// </summary> /// <param name="humanStruct"></param> /// <returns></returns> public GameObject LoadOtherPlayer(MsgData_sSceneObjectEnterHuman humanStruct) { int modelID = GetClothesModelID(humanStruct.FashionState == 0 ? humanStruct.FashionDress : 0, humanStruct.Dress, humanStruct.Prof, humanStruct.EquipStarMin); if (humanStruct.ChangeID != 0) { CoreEntry.gMorphMgr.SetInMorph(humanStruct.Guid); //Configs.changeConfig changeCfg = CSVConfigLoader.GetchangeConfig((int)humanStruct.ChangeID); LuaTable changeCfg = ConfigManager.Instance.Actor.GetChangeConfig((int)humanStruct.ChangeID); if (changeCfg != null) { modelID = changeCfg.Get <int>("model_id"); } } GameObject obj = LoadOtherPlayer(modelID); Vector3 position = CommonTools.ServerPosToClient(humanStruct.PosX, humanStruct.PosY); position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.z)); Vector3 eulerAngle = CommonTools.ServerDirToClient(humanStruct.Dir); obj.transform.position = position; obj.transform.eulerAngles = eulerAngle; obj.transform.localScale = Vector3.one; OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>(); otherPlayer.Faction = humanStruct.Faction; otherPlayer.Init(modelID, modelID, humanStruct.Guid); otherPlayer.ServerID = humanStruct.Guid; otherPlayer.InitAttr(humanStruct); CoreEntry.gActorMgr.AddActorObj(otherPlayer); otherPlayer.Health.OnCreateHPBar(); //名字有更新,重新创建血条 PetObj petObj = CoreEntry.gActorMgr.GetPetActorByServerID(humanStruct.MoShenID) as PetObj; if (petObj != null) { petObj.SetMaster(otherPlayer); //Debug.LogError("找到 moshenid: " + humanStruct.MoShenID + " otherplayer:" + humanStruct.Guid); } else { //Debug.LogError("未找到 moshenid: " + humanStruct.MoShenID + " otherplayer:" + humanStruct.Guid); } //LoadMagicKey(otherPlayer, 620000001, position, eulerAngle); StartCoroutine(ChangeOtherPlayerShow(otherPlayer as OtherPlayer, humanStruct)); EventParameter parameter = new EventParameter(); parameter.objParameter = otherPlayer; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_OTHERPLAYER_LOAD_OVER, parameter); return(obj); }
/// <summary> /// 加载镖车, 由于镖车有血量和阵营,并且可以被攻击,类似同阵营玩家,先用于玩家代替!! /// </summary> public GameObject LoadBiaoChe(MsgData_sSceneObjectEnterBiaoChe cheStruct) { ActorObj ao = CoreEntry.gActorMgr.GetPlayerActorByServerID(cheStruct.Guid); if (null != ao) { return(ao.gameObject); } LuaTable row = RawLuaConfig.Instance.GetRowData("t_kuafubiaoche", cheStruct.DartID); if (null == row) { return(null); } int modelid = row.Get <int>("model"); Vector3 position = CommonTools.ServerPosToClient(cheStruct.PosX, cheStruct.PosY); Vector3 eulerAngle = CommonTools.ServerDirToClient(cheStruct.Dir); Vector3 scale = new Vector3(1, 1, 1); GameObject obj = LoadOtherPlayer(modelid); obj.transform.position = position; obj.transform.eulerAngles = eulerAngle; obj.transform.localScale = scale; OtherPlayer BiaoChe = obj.AddComponent <OtherPlayer>(); BiaoChe.Faction = cheStruct.Camp; if (BiaoChe.mBaseAttr == null) { BiaoChe.mBaseAttr = new BaseAttr(); } BiaoChe.mBaseAttr.MaxHP = cheStruct.HP; BiaoChe.mBaseAttr.CurHP = cheStruct.HP; BiaoChe.mBaseAttr.Level = cheStruct.Level; BiaoChe.mBaseAttr.Name = CommonTools.BytesToString(cheStruct.LeaderName) + "的镖车"; BiaoChe.Init(modelid, modelid, cheStruct.Guid); BiaoChe.mActorType = ActorType.AT_MECHANICS; BiaoChe.mBaseAttr.Speed = CommonTools.ServerValueToClient(cheStruct.Speed); BiaoChe.SetSpeed(BiaoChe.mBaseAttr.Speed); BiaoChe.ServerID = cheStruct.Guid; CoreEntry.gActorMgr.AddActorObj(BiaoChe); return(obj); }
private void LoadFigters() { for (int i = 0; i < 2; i++) { if (i == mLocalIndex) { continue; } MsgData_sResArenaMemVo player = ArenaFighters[i]; int modelID = SceneLoader.GetClothesModelID(player.FashionDress, player.Dress, player.Job, 0); GameObject obj = CoreEntry.gSceneLoader.CreateGameObject(modelID); if (obj == null) { return; } ActorObj actorObject = null; actorObject = obj.GetComponent <ActorObj>(); if (null != actorObject) { UnityEngine.Object.DestroyImmediate(actorObject); } PlayerAgent agent = obj.GetComponent <PlayerAgent>(); if (null != agent) { agent.enabled = false; } Vector3 position = Vector3.zero; position.x = initPos[1 - mLocalIndex].x; position.z = initPos[1 - mLocalIndex].y; position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.y)); obj.transform.position = position; obj.transform.rotation = Quaternion.identity; obj.transform.localScale = Vector3.one; OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>(); otherPlayer.Init(modelID, modelID, player.RoleID, "", true); otherPlayer.ServerID = player.RoleID; CoreEntry.gActorMgr.AddActorObj(otherPlayer); int weaponID = SceneLoader.GetWeaponModelID(player.FashionWeapon, player.ShenBing, player.Weapon, player.Job); LoadWeapon(obj.transform, weaponID, player.Job == 4); } }
public GameObject LoadVirtualPlayer(MsgData_sSceneObjectEnterVirtualPlayer player) { int modelID = SceneLoader.GetClothesModelID(player.FashionDress, player.Dress, player.Job, 0); Vector3 position = CommonTools.ServerPosToClient(player.PosX, player.PosY); Vector3 eulerAngle = CommonTools.ServerDirToClient(player.Dir); GameObject obj = CreateGameObject(modelID, position, eulerAngle); ActorObj actorObject = null; actorObject = obj.GetComponent <ActorObj>(); if (null != actorObject) { UnityEngine.Object.DestroyImmediate(actorObject); } PlayerAgent agent = obj.GetComponent <PlayerAgent>(); if (null != agent) { agent.enabled = false; } /*Vector3 position = Vector3.zero; * position.x = player.PosX; * position.z = player.PosY; * position.y = CommonTools.GetTerrainHeight(new Vector2(position.x, position.y)); * * obj.transform.position = position; * obj.transform.rotation = Quaternion.identity; * obj.transform.localScale = Vector3.one;*/ OtherPlayer otherPlayer = obj.AddComponent <OtherPlayer>(); otherPlayer.Init(modelID, modelID, player.Guid, "", true); otherPlayer.InitEnterHumanAttr(player); CoreEntry.gActorMgr.AddActorObj(otherPlayer); otherPlayer.Health.OnCreateHPBar(); StartCoroutine(ChangeVirtualPlayerShow(otherPlayer as OtherPlayer, player)); int weaponID = SceneLoader.GetWeaponModelID(player.FashionWeapon, player.ShenBing, player.Weapon, player.Job); LoadWeapon(obj.transform, weaponID, player.Job == 4); return(obj); }
/// <summary> /// 频道是否可攻击玩家。 /// </summary> /// <param name="player">目标玩家。</param> /// <returns>是否可攻击。</returns> public bool IsCanAttack(OtherPlayer player) { //双方都有阵营 if (Faction != 0 && player.Faction != 0) { return(Faction != player.Faction); } //新手和保护状态不能被攻击 if (player.PKStatus == PKStatus.PK_STATUS_NEWBIE || player.PKStatus == PKStatus.PK_STATUS_PROTECT) { return(false); } if (mCurPKMode == PKMode.PK_MODE_ALL) { return(true); } else if (mCurPKMode == PKMode.PK_MODE_EVIL) { return(player.PKStatus == PKStatus.PK_STATUS_GRAY || player.PKStatus == PKStatus.PK_STATUS_RED); } else if (mCurPKMode == PKMode.PK_MODE_TEAM) { return(!mTeamData.IsInTeam(player.ServerID)); } else if (mCurPKMode == PKMode.PK_MODE_ALLY) { // LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; // long attackid = G.GetInPath<long>("ConfigData.EliteBossConfig.AttackPlayerID"); // return player.ServerID == attackid; return(!mTeamData.IsInTeam(player.ServerID) && !mGuildData.IsInGuild(player.ServerID)); } return(false); }
private void OnPlayerDeath(GameEvent ge, EventParameter parameter) { if (ArenaMgr.Instance.IsArenaFight) { return; } ActorObj actor = parameter.goParameter.GetComponent<ActorObj>(); if (MainRole.Instance.serverID == actor.ServerID) { LuaTable mapCfg = ConfigManager.Instance.Map.GetMapConfig(MapMgr.Instance.EnterMapId); int maptype = mapCfg != null ? mapCfg.Get<int>("type") : 0; #if false if (maptype == (int)ESceneType.SCENE_TYPE_SECERETFB) { int rtime = ConfigManager.Instance.Consts.GetValue<int>("secretAreaTeamRelivetime", "val1"); TipAutoClose.Show(rtime, "你已死亡!", (int sec) => { if (sec == 0) { NetLogicGame.Instance.SendReqRevive(1, 1); } return string.Format("{0}秒后自动复活......", sec); }); return; } else #endif if (maptype == (int)ESceneType.SCENE_TYPE_PERSONBOSS) { MsgData_sPersonalBossResult pBossRes = new MsgData_sPersonalBossResult(); pBossRes.result = 1;//fail CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_PersonalBossResult, EventParameter.Get(pBossRes)); return; } else if (maptype == (int)ESceneType.SCENE_TYPE_PERSONVIP_BOSS) { int relivetime = ConfigManager.Instance.Consts.GetValue<int>("zhiyuanfb", "val1"); TipAutoClose.Show(relivetime, "你已死亡!", (int sec) => { return string.Format("{0}秒后自动复活......", sec); }); } else if (maptype == (int)ESceneType.SCENE_TYPE_ZHIYUANFB ) { int relivetime = ConfigManager.Instance.Consts.GetValue<int>("zhiyuanfb", "val1"); TipAutoClose.Show(relivetime, "你已死亡!", (int sec) => { return string.Format("{0}秒后自动复活......", sec); }); } else if (maptype == (int)ESceneType.SCENE_TYPE_WATER_DUNGEON || maptype == (int)ESceneType.SCENE_TYPE_ZHUZAIROAD) { int relivetime = ConfigManager.Instance.Consts.GetValue<int>("zhiyuanfb", "val1"); TipAutoClose.Show(relivetime, "你已死亡!", (int sec) => { if (sec == 0) { NetLogicGame.Instance.SendReqRevive(1, 1); } return string.Format("{0}秒后自动复活......", sec); }); } else if (maptype == (int)ESceneType.SCENE_TYPE_GUILD_HELL) { } else if (maptype == (int)ESceneType.SCENE_TYPE_ARENA) { } else if (maptype == (int)ESceneType.SCENE_TYPE_CRWON) { } else if (maptype == (int)ESceneType.SCENE_TYPE_YUANZHENG) { } else if(maptype == (int)ESceneType.SCENE_TYPE_GUILD_WAR_ACTIVITY) { int relivetime = ConfigManager.Instance.Consts.GetValue<int>("factfightpowerInfo", "fval"); TipAutoClose.Show(relivetime-1, "你已死亡!", (int sec) => { return string.Format("{0}秒后自动复活......", sec); }); } else { if (CoreEntry.gAutoAIMgr.AutoFight && CoreEntry.gAutoAIMgr.Config.Relive) { //自动复活 System.Action fun = LuaMgr.Instance.GetLuaEnv().Global.Get<System.Action>("CommonRevive"); if (fun != null) { fun(); } } else { OtherPlayer oo = actor.hitActorObject as OtherPlayer; if(oo != null) { UnityEngine.Events.UnityAction<string> fun = LuaMgr.Instance.GetLuaEnv().Global.Get<UnityEngine.Events.UnityAction<string>>("CommonPKReviveSimple"); if (fun != null) { fun(oo.mBaseAttr.Name); } } else { System.Action fun = LuaMgr.Instance.GetLuaEnv().Global.Get<System.Action>("CommonReviveSimple"); if (fun != null) { fun(); } } } } } }
private void RefreshDisplayActors() { int i = 0; for (i = 0; i < 5; i++) { mOtherPlayers[i].Clear(); } int displayNum = SettingManager.Instance.ActorDisplayNum; bool showModel = CoreEntry.bModelShow; List <ActorObj> actors = CoreEntry.gActorMgr.GetAllPlayerActors(); for (i = 0; i < actors.Count; i++) { ActorObj actor = actors[i]; if (actor is PlayerObj) { continue; } OtherPlayer otherActor = actor as OtherPlayer; if (otherActor != null && otherActor.mActorType == ActorType.AT_MECHANICS) //镖车类不隐藏 { continue; } if (null != PlayerData.Instance.TeamData.GetTeamRole(otherActor.ServerID)) { mOtherPlayers[0].Add(otherActor); continue; } if (PlayerData.Instance.FriendData.IsEnemy(otherActor.ServerID)) { mOtherPlayers[1].Add(otherActor); continue; } if (PlayerData.Instance.FriendData.IsFriend(otherActor.ServerID)) { mOtherPlayers[2].Add(otherActor); continue; } if (PlayerData.Instance.GuildData.IsInGuild(otherActor.ServerID)) { mOtherPlayers[3].Add(otherActor); continue; } mOtherPlayers[4].Add(otherActor); } displayNum--; int tmpNum = 0; int count = 0; for (i = 0; i < 5; i++) { List <OtherPlayer> list = mOtherPlayers[i]; count = list.Count; tmpNum = displayNum < count ? displayNum : count; if (!showModel) { tmpNum = 0; } displayNum -= tmpNum; int j = 0; for (j = 0; j < tmpNum; j++) { list[j].ShowModel(); } for (; j < count; j++) { list[j].HideModel(); } } }
/// <summary> /// 初始化PK状态。 /// </summary> /// <param name="pkvalue">目标玩家。</param> public void InitPKStatus(OtherPlayer player) { //判定边境3v3或者边境远征 int MeFact = PlayerData.Instance.Faction; int OtFact = player.Faction; if ((MeFact == 11 || MeFact == 12 || MeFact == 14 || MeFact == 15 || MeFact == 16) && (OtFact == 11 || OtFact == 12 || OtFact == 14 || OtFact == 15 || OtFact == 16)) { if (player.Faction != PlayerData.Instance.Faction) { int Fact = player.Faction - 13; if (Fact > 0) { switch (Fact) { case 1: SetNameTextValue(BlueRgb); break; case 2: SetNameTextValue(YellowRgb); break; case 3: SetNameTextValue(OrangeRgb); break; default: SetNameTextValue(StrawberryRgb); break; } } else { SetNameTextValue(RedRgb); } SetHpImageType(true); } else { SetNameTextValue(GreenRgb); SetHpImageType(false); } return; } if (PlayerData.Instance.CurPKMode == PKMode.PK_MODE_GUILD && !PlayerData.Instance.GuildData.IsInGuild(player.ServerID)) { LuaTable mapConfig = ConfigManager.Instance.Map.GetMapConfig(MapMgr.Instance.EnterMapId); int mType = mapConfig.Get <int>("type"); if (mType == (int)ESceneType.SCENE_TYPE_GUILD_WAR_ACTIVITY) { SetNameTextValue(RedRgb); SetHpImageType(true); return; } } //红名的直接显示 if (player.PKStatus == PKStatus.PK_STATUS_RED) { SetNameTextValue(RedRgb); SetHpImageType(true); return; } //可攻击对象显示红色(善恶看灰名除外) bool canattack = PlayerData.Instance.IsCanAttack(player); if (canattack) { //善恶模式看灰名时灰色 bool grey = PlayerData.Instance.CurPKMode == PKMode.PK_MODE_EVIL && player.PKStatus == PKStatus.PK_STATUS_GRAY; SetNameTextValue(grey ? GreyRgb : RedRgb); SetHpImageType(true); return; } //灰名灰色,其它黄色 SetNameTextValue(player.PKStatus == PKStatus.PK_STATUS_GRAY ? GreyRgb : (PlayerData.Instance.TeamData.IsInTeam(player.ServerID) ? GreenRgb : NormalRgb)); bool isTeamAndGuild = PlayerData.Instance.TeamData.IsInTeam(player.ServerID) || PlayerData.Instance.GuildData.IsInGuild(player.ServerID); if (isTeamAndGuild) { SetHpImageType(false); } else { SetHpImageType(player.PKStatus == PKStatus.PK_STATUS_GRAY ? true : false); } }