public void SetTarget(Character target, bool msg = true) { int tid = 0; if (target != null) { tid = target.gid; } if (TargetID != tid) { TargetID = tid; if (mEvent != null) { mEvent(CharacterEventType.OnTargetChg, this); } if (msg) { ReqTargetChg targetChg = new ReqTargetChg(); targetChg.uid = gid; targetChg.targetID = tid; NetWork.SendPacket <ReqTargetChg>(CTS.CTS_TargetChg, targetChg, null); } } }
public void SetTarget(Character target, bool sendToSelf = true) { int tid = 0; if (target != null) { tid = target.gid; } if (targetID != tid) { targetID = tid; if (mEvent != null) { mEvent(CharacterEventType.OnTargetChg, this); } for (int i = 0; i < mScene.GetPlayerCount(); ++i) { Player player = mScene.GetPlayerByIndex(i); if (player == null) { continue; } if (!sendToSelf && player == this) { continue; } ReqTargetChg targetChg = new ReqTargetChg(); targetChg.uid = gid; targetChg.targetID = tid; NetWork.NotifyMessage <ReqTargetChg>(player.UserID, STC.STC_TargetChg, targetChg); } } }
static void TargetChg(byte[] data, Action5001 action) { ReqTargetChg targetChg = ProtoBufUtils.Deserialize <ReqTargetChg>(data); Character cha = SceneManager.Instance.FindCharacter(targetChg.uid); if (cha == null) { return; } Character target = cha.mScene.FindCharacter(targetChg.targetID); if (target == null) { return; } cha.SetTarget(target, false); }
static void OnTargetChg(byte[] data) { Scene scn = SceneSystem.Instance.mCurrentScene; if (scn == null) { return; } ReqTargetChg targetChg = ProtoBufUtils.Deserialize <ReqTargetChg>(data); Character cha = scn.GetCharacter(targetChg.uid); if (cha == null) { return; } Character target = scn.GetCharacter(targetChg.targetID); cha.SetTarget(target, false); }