Beispiel #1
0
    public void Explose()
    {
        Debug.Log("Explose");

        m_ExplosionIndex = m_PathGrid.GetPathNodeIndex(this.gameObject.transform.position);

        m_ExplosionList.Clear();
        m_Index2PathGridPosList.Clear();

        //add the first one
        List <Vector3> firstPosList = new List <Vector3>(1);

        firstPosList.Add(m_PathGrid.GetPathNodePos(m_ExplosionIndex));
        m_Index2PathGridPosList.Add(firstPosList);
        //add others
        for (int i = 0; i < (int)PathGrid.eNeighborDirection.kNumNeighbors; i++)
        {
            List <Vector3> positions = CommonHelper.PositionsByDirection(m_ExplosionIndex, m_length, (PathGrid.eNeighborDirection)i, m_PathGrid);
            m_Index2PathGridPosList.Add(positions);
        }

        foreach (List <Vector3> PathGridPosList in m_Index2PathGridPosList)
        {
            foreach (Vector3 PathGridPos in PathGridPosList)
            {
                GameObject gameObject = m_ExplosionPoolInstance.DequeueFromPool();
                gameObject.transform.position = PathGridPos;
                gameObject.GetComponent <Animator>().SetTrigger("Explosion");
                m_ExplosionList.Add(gameObject);
            }
        }

//
//		//add the first one
//		GameObject gameObject = m_ExplosionPoolInstance.DequeueFromPool();
//		gameObject.transform.position = m_PathGrid.GetPathNodePos(m_ExplosionIndex);
//		gameObject.GetComponent<Animator>().SetTrigger("Explosion");
//		m_ExplosionList.Add(gameObject);
//
//		//add others
//		for (int i = 0; i < (int)PathGrid.eNeighborDirection.kNumNeighbors; i++) {
//			Vector3[] positions = CommonHelper.PositionsByDirection(m_ExplosionIndex, m_length, (PathGrid.eNeighborDirection) i, m_PathGrid);
//			for (int j = 0; j < m_length; j++) {
//				gameObject = m_ExplosionPoolInstance.DequeueFromPool();
//				gameObject.transform.position = positions[j];
//				gameObject.GetComponent<Animator>().SetTrigger("Explosion");
//				//Debug.Log("Set Explosion: pos" + gameObject.transform.position );
//				m_ExplosionList.Add(gameObject);
//			}
//		}
    }