private void Spawn() { _view = Instantiate(_currentInfo.groundView, position: this.position); _view.npc = _currentInfo; _currentRechargeTimer = 0f; }
public void RemoveMiniMapItem(NPCView npcView) { if (miniMap != null) { miniMap.RemoveMinimap(npcView); } }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var count = reader.GetInt(); for (int i = 0; i < count; i++) { var npcid = reader.GetLong(); var npcType = (NpcType)reader.GetUShort(); var position = reader.GetVector3(); var rotation = reader.GetQuaternion(); NPCView npcView = null; switch (npcType) { case NpcType.Player: npcView = npcMgr.CreateNpc <TankView>(); break; case NpcType.Monster: npcView = npcMgr.CreateNpc <AnimalView>(); break; } if (npcView != null) { npcView.Initialize(npcid); npcView.InitInterpolateFields(position, rotation); } Debugger.LogWarning("OnResNpcs--->>>" + npcid + " " + npcType + " " + position); } }
private void Awake() { nPCView = GetComponent <NPCView>(); nPCModel = GetComponent <NPCModel>(); nPCModel.animationSpeed = 2.0f; }
public void AddNpc(long npcId, NPCView view) { lock (npcLock) { mNpcs.Add(npcId, view); } }
/// <summary> /// 填充数据 /// </summary> void FillInfo(ref NetDataWriter dw, Protocal protocal, NPCView npcView) { dw.Reset(); dw.Put((ushort)protocal); dw.Put(npcView.npcId); dw.Put(npcView.position); dw.Put(Quaternion.identity); }
public override void Init(object args = null) { Characters.Clear(); foreach (var npc in CharacterModel.Instance.Characters.NPCs) { var view = new NPCView(this, npc); Characters.Add(view); } }
/// <summary> /// 帧更新 /// </summary> /// <param name="deltaTime"></param> //public override void OnFrameUpdate(float deltaTime) //{ // base.OnFrameUpdate(deltaTime); // if (miniMap != null) // { // miniMap.UpdateMiniMapPosition(); // } //} /// <summary> /// 初始化小地图 /// </summary> public void AddMiniMapItem(NPCView npcView) { if (miniMap == null) { cachedNpcView.Add(npcView); } else { //miniMap.AddMinimap(npcView); } }
public NPCController(ScriptableObjectCharacter npc, IProjectileService projectileService, float health) { _scriptableObjectCharacter = npc; _projectileService = projectileService; GameObject npcObject = GameObject.Instantiate(npc.npcView.gameObject); npcObject.transform.position = npc.npcSpawnPosition; _npcView = npcObject.GetComponent <NPCView>(); health = npc.health; _npcView.SetNpcController(this); SetHealthBarFirst(health); fixedPos = npcObject.transform.position; }
void StartMonsterCreateDone() { TimerMgr.AddTimer("Monster Create", 2, delegate() { if (mNpcs.Count == 0) { var spawnPoint = ConfigMgr.MonsterSpawnPoints; var list = spawnPoint.ToList(); var index = AppUtil.Random(0, list.Count); var npcid = DateTime.UtcNow.Ticks; var view = new NPCView(npcid, NpcType.Monster); view.position = list[index].Value; mNpcs.Add(npcid, view); Log.Info("Check Monster OnScene Count:>" + mNpcs.Count); } }); }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var npcid = peer.ConnectId; var list = ConfigMgr.HeroSpawnPoints.Values.ToList(); var index = AppUtil.Random(0, list.Count); var spawnPos = list[index]; var npcView = new NPCView(npcid, NpcType.Player); npcView.mPeer = peer; npcView.position = spawnPos; Log.Warn("ReqUserInfoHandler Player:> " + npcid + " SpwanPos:> " + spawnPos); var dw = new NetDataWriter(); FillInfo(ref dw, Protocal.RetNewPlayer, npcView); var npcs = NpcMgr.mNpcs; foreach (var de in npcs) { var mPeer = de.Value.mPeer; if (mPeer != null && mPeer.ConnectionState == ConnectionState.Connected) { mPeer.Send(dw, DeliveryMethod.ReliableOrdered); } } //------------------------------------------------------------------------------------ FillInfo(ref dw, Protocal.ReqUserInfo, npcView); peer.Send(dw, DeliveryMethod.ReliableOrdered); ///添加到NPC管理器 NpcMgr.AddNpc(npcid, npcView); }