// ================================================================================================================
	#region Init/Start

	void Awake()
	{
		_instance = this;

		// get the player spawn points before they become inactive (spawnpoint sets itself diabled in Start() as needed)
		// also create a cache of ALL SpawnPoint while running through them

		SpawnPoints = new SpawnPoint[0];
		PlayerSpawnPoints = new List<SpawnPoint>();

		GameObject parent = GameObject.Find("SpawnPoints");
		if (parent)
		{
			SpawnPoints = parent.GetComponentsInChildren<SpawnPoint>();
			for (int i = 0; i < SpawnPoints.Length; i++)
			{
				if (SpawnPoints[i].isPlayerSpawn) PlayerSpawnPoints.Add(SpawnPoints[i]);
			}
		}

#if UNITY_EDITOR
		// check if UniRPGGLobal is loaded, if not then load it now. This is a hack which is only needed during development
		// time to allow developer to run the scene in unity editor but still load the needed global scene
		if (!UniRPGGlobal.Instance)
		{
			UniRPGGlobal.LoadLevelAdditive("menudata");
			UniRPGGlobal.LoadLevelAdditive("unirpg");
		}
#endif

		// Load the game gui
		UniRPGGlobal.LoadLevelAdditive("gamegui");
	}
示例#2
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;
			}
		}
示例#3
0
	// ================================================================================================================

	/// <summary>The SpawnPoint will call this function to notify the character that this point spawned it</summary>
	public virtual void SetSpawnPoint(SpawnPoint sp)
	{
		this.IsPersistent = false; // do not save character created by a spawn point as there is no real way to restore them when loading
		this.SpawnPoint = sp;
	}