Exemple #1
0
		public override void SetSpawnPoint(SpawnPoint sp)
		{
			base.SetSpawnPoint(sp);

			// init AI
			idleAction = sp.idleAction;
			wanderInCricle = sp.wanderInCricle;
			wanderWH = sp.wanderWH;
			wanderRadius = sp.wanderRadius;
			SpawnLocation = sp.transform.position;
			wanderDelayMin = sp.wanderDelayMin;
			wanderDelayMax = sp.wanderDelayMax;
			patrolPath = sp.patrolPath;

			wanderIdleTimer = 0.1f;
			currPatrolPoint = 0;

			if (patrolPath == null && idleAction == UniRPGGlobal.AIBehaviour.Patrol)
			{
				Debug.LogError("IdleAction.Patrol selected but no Patrol Path specified.");
				enabled = false;
				IsPersistent = false;
				return;
			}
		}
Exemple #2
0
		protected override void LoadState()
		{
			base.LoadState();
			if (UniRPGGlobal.Instance.DoNotLoad) return;

			chaseSpeed = UniRPGGlobal.LoadFloat(saveKey + "chaseSpeed", chaseSpeed);
			_tr.position = UniRPGGlobal.LoadVector3(saveKey + "pos", _tr.position);

			if (idleAction != UniRPGGlobal.AIBehaviour.Stay)
			{
				_tr.position += new Vector3(0f, 0.1f, 0f); // for sanity sake cause sometimes it falls through floor after spawned
			}

			actorType = (UniRPGGlobal.ActorType)UniRPGGlobal.LoadInt(saveKey + "type", (int)actorType);
			idleAction = (UniRPGGlobal.AIBehaviour)UniRPGGlobal.LoadInt(saveKey + "idleAct", (int)idleAction);
			if (idleAction == UniRPGGlobal.AIBehaviour.Wander)
			{
				wanderInCricle = UniRPGGlobal.LoadBool(saveKey + "wndr_is_c", wanderInCricle);
				wanderWH = UniRPGGlobal.LoadVector3(saveKey + "wndr_rec", wanderWH);
				wanderRadius = UniRPGGlobal.LoadFloat(saveKey + "wndr_r", wanderRadius);
				wanderDelayMin = UniRPGGlobal.LoadFloat(saveKey + "wnrd_dmin", wanderDelayMin);
				wanderDelayMax = UniRPGGlobal.LoadFloat(saveKey + "wndr_dmax", wanderDelayMax);
			}
			if (idleAction == UniRPGGlobal.AIBehaviour.Patrol)
			{
				string s = UniRPGGlobal.LoadString(saveKey + "patrol", null);
				if (!string.IsNullOrEmpty(s))
				{	// find the path in the scene
					GameObject parent = GameObject.Find("PatrolPaths");
					if (parent)
					{
						GUID id = new GUID(s);
						if (!id.IsEmpty)
						{
							PatrolPath[] paths = parent.GetComponentsInChildren<PatrolPath>();
							for (int i = 0; i < paths.Length; i++)
							{
								if (paths[i].id == id)
								{
									patrolPath = paths[i];
								}
							}
						}
					}
				}
			}

		}