void Awake() { sceneIndex = SceneManager.GetActiveScene().buildIndex; if (GM == null) { DontDestroyOnLoad(gameObject); GM = this; } else if (GM != this) { Destroy(gameObject); } up = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2UpKey", "UpArrow")); down = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2DownKey", "DownArrow")); left = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2LeftKey", "LeftArrow")); right = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2RightKey", "RightArrow")); jump = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2JumpKey", "Keypad1")); attack = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2AttackKey", "Keypad2")); guard = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2GuardKey", "Keypad3")); projectile = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("p2ProjectileKey", "Keypad0")); }
void Start() { controller = GetComponent <Controller2D>(); playerSprite = GetComponent <SpriteRenderer>(); playerIcon = GetComponentInChildren <SpriteRenderer>(); boxCollider = GetComponent <BoxCollider2D>(); respawnUp = GameObject.FindGameObjectWithTag("RespawnUp"); respawnDown = GameObject.FindGameObjectWithTag("RespawnDown"); respawnLeft = GameObject.FindGameObjectWithTag("RespawnLeft"); respawnRight = GameObject.FindGameObjectWithTag("RespawnRight"); if (gameObject.tag == "Player1") { opponent = GameObject.FindGameObjectWithTag("Player2"); } if (gameObject.tag == "Player2") { opponent = GameObject.FindGameObjectWithTag("Player1"); } activeAreaUp = GameObject.FindGameObjectWithTag("ActiveAreaUp"). GetComponent <BoxCollider2D>(); activeAreaDown = GameObject.FindGameObjectWithTag("ActiveAreaDown"). GetComponent <BoxCollider2D>(); activeAreaLeft = GameObject.FindGameObjectWithTag("ActiveAreaLeft"). GetComponent <BoxCollider2D>(); activeAreaRight = GameObject.FindGameObjectWithTag("ActiveAreaRight"). GetComponent <BoxCollider2D>(); p1Script = GameObject.FindGameObjectWithTag("Player1"). GetComponent <Player1>(); p2Script = GameObject.FindGameObjectWithTag("Player2"). GetComponent <Player2>(); opponentSprite = opponent.GetComponent <SpriteRenderer>(); opponentIcon = opponent.GetComponentInChildren <SpriteRenderer>(); p1Score = GameObject.FindGameObjectWithTag("P1Score"). GetComponent <P1Score>(); p2Score = GameObject.FindGameObjectWithTag("P2Score"). GetComponent <P2Score>(); opponentSprite.enabled = true; opponentIcon.enabled = true; killSound = GetComponents <AudioSource>()[0]; clingSound = GetComponents <AudioSource>()[1]; p1Hurtbox = GameObject.FindGameObjectWithTag("Player1"). GetComponent <PolygonCollider2D>(); p2Hurtbox = GameObject.FindGameObjectWithTag("Player2"). GetComponent <PolygonCollider2D>(); playerProjectileScript = GameObject.FindGameObjectWithTag("P2Projectile"). GetComponent <Projectile>(); opponentProjectileScript = GameObject.FindGameObjectWithTag("P1Projectile"). GetComponent <Projectile>(); gm = P2GameManager.GM; sceneIndex = SceneManager.GetActiveScene().buildIndex; if (sceneIndex == 5) { inPractice = true; } player = ReInput.players.GetPlayer(1); }
// Use this for initialization void Start() { sceneIndex = SceneManager.GetActiveScene().buildIndex; if (gameObject.tag == "P1Config") { p1Config = transform.Find("Buttons"); p1GM = P1GameManager.GM; waitingForKey = false; if (sceneIndex == 2) { for (int i = 0; i < p1Config.childCount; i++) { if (p1Config.GetChild(i).name == "UpButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.up.ToString(); } else if (p1Config.GetChild(i).name == "DownButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.down.ToString(); } else if (p1Config.GetChild(i).name == "LeftButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.left.ToString(); } else if (p1Config.GetChild(i).name == "RightButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.right.ToString(); } else if (p1Config.GetChild(i).name == "JumpButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.jump.ToString(); } else if (p1Config.GetChild(i).name == "AttackButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.attack.ToString(); } else if (p1Config.GetChild(i).name == "GuardButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.guard.ToString(); } else if (p1Config.GetChild(i).name == "ProjectileButton") { p1Config.GetChild(i).GetComponentInChildren <Text>().text = p1GM.projectile.ToString(); } } } } if (gameObject.tag == "P2Config") { p2Config = transform.Find("Buttons"); p2GM = P2GameManager.GM; waitingForKey = false; if (sceneIndex == 2) { for (int i = 0; i < p2Config.childCount; i++) { if (p2Config.GetChild(i).name == "UpButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.up.ToString(); } else if (p2Config.GetChild(i).name == "DownButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.down.ToString(); } else if (p2Config.GetChild(i).name == "LeftButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.left.ToString(); } else if (p2Config.GetChild(i).name == "RightButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.right.ToString(); } else if (p2Config.GetChild(i).name == "JumpButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.jump.ToString(); } else if (p2Config.GetChild(i).name == "AttackButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.attack.ToString(); } else if (p2Config.GetChild(i).name == "GuardButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.guard.ToString(); } else if (p2Config.GetChild(i).name == "ProjectileButton") { p2Config.GetChild(i).GetComponentInChildren <Text>().text = p2GM.projectile.ToString(); } } } } }