示例#1
0
	void Awake(){
		//使用自己
		m_Instance = this;
		//WayPoint
		m_WayPoint = new WayPoint ();
		m_WayPoint.Init ();
		LoadPathPoint.LoadPathPointDesc (m_WayPoint.GetNodeList ());
		//牆壁阻擋
		//m_Wall = GameObject.FindGameObjectsWithTag ("Wall");
		gos = GameObject.FindGameObjectsWithTag ("Wall");
		iLength = gos.Length;
		m_Wall = new Wall[iLength];
		for (int i=0; i<iLength; i++) {
			m_Wall [i] = gos [i].GetComponent<Wall> ();
		}

		//Obstacle障礙物
		gos = GameObject.FindGameObjectsWithTag ("Obstacle");
		iLength = gos.Length;
		m_Obs = new Obstacle[iLength];
		for (int i=0; i<iLength; i++) {
			m_Obs [i] = gos [i].GetComponent<Obstacle> ();
		}

		//生成Prefab
		iPlayerCount = 2;
		m_EnemyTarget = new GameObject[iPlayerCount];
		for (int i=0; i<iPlayerCount; i++) {
			if (i == 0){ go = ObjectPool.m_Instance.InitObjectsInPool (m_Player, 1); }
			if (i == 1){ go = ObjectPool.m_Instance.InitObjectsInPool (m_Player2, 1); }
			m_EnemyTarget [i] = go;
		}
		go = ObjectPool.m_Instance.LoadObjectFromPool (0);
		pos = Vector3.zero;
		pos.x = 5.7f;
		pos.y = 4.0f;
		pos.z = -109.0f;
		go.transform.position = pos;
		m_NowPlayer = go.gameObject;
		pComponent = m_NowPlayer.GetComponent <Player> ();

		//生成敵人Prefab
		iEnemyCount = 0;
		for (int i=0; i<1; i++) {
			ObjectPool.m_Instance.InitObjectsInPool (m_Enemy, 1);
			iEnemyCount += 1;
		}
		m_Target = new GameObject[iEnemyCount];
		for (int i=0; i<iEnemyCount; i++) {
			Debug.Log("敵人的"+i);
			go = ObjectPool.m_Instance.LoadObjectFromPool (i+iPlayerCount);
			//到時直接安排位置,不用Random
			pos = Vector3.zero;
			pos.x = 5.0f;
			pos.y = 1.0f;
			pos.z = -95.0f;
			//存Z軸值
			nComponent = go.gameObject.GetComponent<NPC> ();
			nComponent.m_AIData.thisPositionZ = pos.z;
			//存物件到ObjectPool
			go.transform.position = pos;
			go.transform.forward = Vector3.left;
			//目前玩家==================================
		}
	}