/// <summary> /// Stop the module, serialize the data object out /// </summary> /// <returns></returns> public override bool ModuleStop() { try { GuardData d = data; if (data != null) { if (!data.Save) { data.Loaded_Lists = new List <string>(); available_lists = new List <string>(); data.logBlocked = false; data.blockIncoming = false; } } Save <GuardData>(d); } catch (Exception e) { LogCenter.Instance.LogException(e); return(false); } return(true); }
/// <summary> /// 初始化守卫数据 /// </summary> public void InitGuard() { //当前守卫数量 this.m_nvWaCuardNum = 0; m_dicGuardName.Clear(); m_listGuardData.Clear(); List <NWGuardDataBase> dbList = GameTableManager.Instance.GetTableList <NWGuardDataBase>(); if (dbList != null) { for (int i = 0; i < dbList.Count; i++) { if (m_dicGuardName.ContainsKey(dbList[i].id) == false) { List <string> nameList = GetNameList(dbList[i].name); m_dicGuardName.Add(dbList[i].id, nameList); } GuardData guardData = new GuardData { id = dbList[i].id, lv = 1 }; m_listGuardData.Add(guardData); } } }
/// <summary> /// Start the mod, deserialize data into GuardData /// </summary> /// <returns></returns> public override ModuleError ModuleStart() { ModuleError error = new ModuleError(); error.errorType = ModuleErrorType.Success; try { LoadConfig(); if (PersistentData == null) { data = new GuardData(); } else { data = (GuardData)PersistentData; } // block ranges aren't serialized, so go rebuild them with the loaded lists // when the module is started rebuild(); } catch (Exception e) { error.errorMessage = e.Message; error.errorType = ModuleErrorType.UnknownError; error.moduleName = "IPGuard"; data = new GuardData(); } return(error); }
public override void Start() { data = gameobject.GetComponent <GuardData>(); anim = gameobject.GetComponent <Animator>(); rigid = gameobject.GetComponent <Rigidbody>(); //播放走路动画 anim.SetFloat("forward", 1.0f); }
public override void Start() { data = gameobject.GetComponent <GuardData>(); anim = gameobject.GetComponent <Animator>(); rigid = gameobject.GetComponent <Rigidbody>(); speed = data.runSpeed; anim.SetFloat("forward", 2.0f); }
public static void SaveGuard(GameObject guard) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/" + guard.name + ".orb"; FileStream stream = new FileStream(path, FileMode.Create); GuardData data = new GuardData(guard); formatter.Serialize(stream, data); stream.Close(); }
/// <summary> /// Get random points between which bots will move /// </summary> /// <param name="guardData"></param> /// <returns></returns> private Vector3[] GetRandomPointsForMoving(GuardData guardData) { List <Vector3> tempVal = new List <Vector3>(); for (int i = 0; i < guardData.PointsForMovingCount; i++) { tempVal.Add(GetRandomPositionOnNavMesh()); } Vector3[] retVal = tempVal.ToArray(); return(retVal); }
/// <summary> /// Init data based on the one from LevelManager /// </summary> /// <param name="data"></param> // Start is called before the first frame update public void Init(GuardData data) { speed = data.Speed; delayBeforNextMove = data.TimeDelay; mesh.material = data.MainMaterial; movePoints = data.PointsForMoving; fieldOfView.viewAngle = data.Angle; fieldOfView.viewRadius = data.Radius; CancelInvoke(); isInit = true; moved = false; }
/// <summary> /// 升级守卫 /// </summary> /// <param name="cmd"></param> public void OnNvWaLvUpGuard(stLvUpGuardCopyUserCmd_CS cmd) { GuardData guardData = m_listGuardData.Find((data) => { return(data.id == cmd.npc_base_id); }); if (guardData != null) { guardData.lv = cmd.level; if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.MissionAndTeamPanel)) { DataManager.Manager <UIPanelManager>().SendMsg(PanelID.MissionAndTeamPanel, UIMsgID.eNvWaLvUp, guardData); } } }
void RestoreGuardData() { if (_guardData != null) { if (_guardData.NavMeshDestination != null) { _navMeshAgent.SetDestination(_guardData.NavMeshDestination.Value); } GetColorChanger().TurnColor(_guardData.GuardColor); _guardData = null; } }
void SaveGuardData() { if (_guardData == null) { _guardData = new GuardData(); if (_navMeshAgent.hasPath) { _guardData.NavMeshDestination = _navMeshAgent.destination; } _guardData.GuardColor = GetColorChanger().GetColor(); } }
/// <summary> /// Start the mod, deserialize data into GuardData /// </summary> /// <returns></returns> public override bool ModuleStart() { try { data = Load<GuardData>(); if (null == data) data = new GuardData(); // block ranges aren't serialized, so go rebuild them with the loaded lists // when the module is started rebuild(); } catch (Exception e) { LogCenter.Instance.LogException(e); return false; } return true; }
public void LoadGuard() { GuardData data = SaveSystem.LoadGuard(gameObject); //GetComponent<EnemyHealth>().health = data.health; if (data.dead != "") { GetComponent <EnemyHealth>().deadString = data.dead; } if (data.position != null) { Vector3 position; position.x = data.position[0]; position.y = data.position[1]; position.z = data.position[2]; transform.position = position; } }
/// <summary> /// Start the mod, deserialize data into GuardData /// </summary> /// <returns></returns> public override bool ModuleStart() { try { data = Load <GuardData>(); if (null == data) { data = new GuardData(); } // block ranges aren't serialized, so go rebuild them with the loaded lists // when the module is started rebuild(); } catch (Exception e) { LogCenter.Instance.LogException(e); return(false); } return(true); }
public static GuardData LoadGuard(GameObject guard) { string path = Application.persistentDataPath + "/" + guard.name + ".orb"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); GuardData data = formatter.Deserialize(stream) as GuardData; stream.Close(); Debug.Log("Loaded Guards"); return(data); } else { Debug.LogError("Save file not found in " + path); return(null); } }
/// <summary> /// Same as SpawnKeys /// </summary> private void SpawnEnemies() { enemyCount = rand.Next(minEnemyNumber, maxEnemyNumber); //keysNumber = rand.Next(); for (int i = 0; i < enemyCount; i++) { if (i >= Guards.Count) { var obj = Instantiate(GuardsPrefab, GetRandomPositionOnNavMesh(), Quaternion.identity); GuardsSpawned.Add(obj.GetComponentInChildren <GuardPatroll>()); Guards.Add(GuardsSpawned[i], obj); } else { Guards[GuardsSpawned[i]].SetActive(true); Guards[GuardsSpawned[i]].transform.position = GetRandomPositionOnNavMesh(); Guards[GuardsSpawned[i]].transform.rotation = Quaternion.identity; } GuardData guardData = guardDataBase.GetRandomElement(rand); guardData.PointsForMoving = GetRandomPointsForMoving(guardData); GuardsSpawned[i].Init(guardData); } }
/// <inheritdoc /> public override void SetTarget(Vector3 target, GuardData guardData) { Target = target; }
/// <summary> /// Start the mod, deserialize data into GuardData /// </summary> /// <returns></returns> public override ModuleError ModuleStart() { ModuleError error = new ModuleError(); error.errorType = ModuleErrorType.Success; try { LoadConfig(); if (PersistentData == null) data = new GuardData(); else data = (GuardData)PersistentData; // block ranges aren't serialized, so go rebuild them with the loaded lists // when the module is started rebuild(); } catch (Exception e) { error.errorMessage = e.Message; error.errorType = ModuleErrorType.UnknownError; error.moduleName = "IPGuard"; data = new GuardData(); } return error; }
/// <inheritdoc /> public abstract void PlaySound(GuardData guardData);
/// <inheritdoc /> public abstract void SetTarget(Vector3 target, GuardData guardData);