// Start is called before the first frame update void Start() { audioSource = GetComponent <AudioSource>(); gameLogic = FindObjectOfType <MultiGameLogic>(); gameManager = FindObjectOfType <MultiGameManager>(); PlaygroudP1 = GameObject.FindGameObjectWithTag("Playground P1"); PlaygroudP2 = GameObject.FindGameObjectWithTag("Playground P2"); }
bool CheckValid(int clientId) { foreach (Transform subBlock in rig.transform) { if (PlaygroudP1) { if (clientId == 1) { gameLogic = PlaygroudP1.GetComponent <MultiGameLogic>(); if (subBlock.transform.position.x >= PlaygroudP1.transform.position.x + 8.5f || subBlock.transform.position.x < PlaygroudP1.transform.position.x - 8.5f || subBlock.transform.position.y < 0) { height = subBlock.position.y; return(false); } if (subBlock.position.y < MultiGameLogic.height && gameLogic.grid[Mathf.FloorToInt(subBlock.position.x), Mathf.FloorToInt(subBlock.position.y)] != null) { height = subBlock.position.y; return(false); } } } if (PlaygroudP2) { if (clientId == 2) { gameLogic = PlaygroudP2.GetComponent <MultiGameLogic>(); if (subBlock.transform.position.x >= PlaygroudP2.transform.position.x + 8.5f || subBlock.transform.position.x < PlaygroudP2.transform.position.x - 8.5f || subBlock.transform.position.y < 0) { height = subBlock.position.y; return(false); } if (subBlock.position.y < MultiGameLogic.height && gameLogic.grid[Mathf.FloorToInt(subBlock.position.x - 21), Mathf.FloorToInt(subBlock.position.y)] != null) { height = subBlock.position.y; return(false); } } } } return(true); }