void Awake() { controller = GameObject.Find("MuzzleSpawns_red").GetComponent <Shoot2> (); EnemyHitCrosshairImage = Resources.Load("Textures/targetHit") as Texture2D; RedCrosshairImage = Resources.Load("Textures/targetRed") as Texture2D; GreenCrosshairImage = Resources.Load("Textures/targetGreen") as Texture2D; m_WindowSize = new Vector2(Screen.width, Screen.height); CalculateRect(); }
IEnumerator LateStart(float waitTime) { yield return(new WaitForSeconds(waitTime)); PlayerAuthority[] players = GameObject.FindObjectsOfType <PlayerAuthority>(); foreach (var playerAuthority in players) { if (playerAuthority.hasAuthority) { playerOne = GameObject.FindWithTag("PlayerOne"); playerTwo = GameObject.FindWithTag("PlayerTwo"); localPlayer = playerAuthority.gameObject; playerClick = localPlayer.GetComponent <PlayerClick>(); playerShoot = localPlayer.GetComponent <Shoot2>(); } } if ((playerOne == null || playerTwo == null) && setUpAttempt < 5) { setUp = false; setUpAttempt++; // if this fails 5 times, assume only one player will load in (for testing purpose) } else { if (setUpAttempt != 5) { playerTwo.GetComponent <SpriteRenderer>().sprite = playerTwoSprite; playerTwo.GetComponent <Animator>().runtimeAnimatorController = playerTwoAnimatorController; playerTwo.GetComponent <PlayerMovement2>().enabled = true; playerTwo.GetComponent <PlayerClick>().enabled = true; playerTwo.GetComponent <Shoot2>().enabled = true; } playerOne.GetComponent <PlayerMovement2>().enabled = true; playerOne.GetComponent <PlayerClick>().enabled = true; playerOne.GetComponent <Shoot2>().enabled = true; // Disable collider that blocks trap placement. This is only to exist on other players localPlayer.transform.GetChild(1).GetComponent <CircleCollider2D>().enabled = false; } }