// Use this for initialization void Start() { PlayerController[] pController = FindObjectsOfType <PlayerController>(); for (int i = 0; i < pController.Length; i++) { Debug.Log(i); pControllers[i] = new PConnections(pController[i], new List <GameObject>()); } }
public void Connect(PlayerController pController, GameObject connectedBody) { PConnections updatedConnection = null; updatedConnection = pControllers[FindPConIndex(pController)]; updatedConnection.connectedObjects.Add(connectedBody); if (connectedBody.CompareTag("Player")) { pControllers[FindPConIndex(connectedBody.transform.parent.GetComponent <PlayerController>())].connectedObjects.Add(pController.leftHinge.gameObject); } if (updatedConnection != null) { CheckWalls(); } }
bool CheckConnectedToWall(PConnections pCon) { bool wall = false; foreach (GameObject go in pCon.connectedObjects) { if (!go.CompareTag("Player")) { pCon.connectedToWall = true; wall = true; return(wall); } } pCon.connectedToWall = false; return(wall); }
void CheckIfOthersConnectedToWall(PConnections pCon) { //Debug.Log(pCon.connectedToWall); if (pCon.connectedToWall == false) { foreach (GameObject go in pCon.connectedObjects) { //Debug.Log("not player: " + go.name); if (go.CompareTag("Player")) { //Debug.Log("Is player: " + go.transform.parent.name); if (pControllers[FindPConIndex(go.transform.parent.GetComponent <PlayerController>())].connectedToWall) { //Debug.Log(go.transform.parent.name); pCon.connectedToWall = true; } } } } //Debug.Log(pCon.connectedToWall); }