// Update is called once per frame void Update() { if (Input.GetButtonDown("A_P1") && hasJoined[1] == false) { hasJoined[1] = true; GlobalControl.AddPlayer(1); playerBlocks [GlobalControl.NumPlayers].GetComponent <SpriteRenderer> ().color = PlayerState.playerColor [GlobalControl.NumPlayers]; } if (Input.GetButtonDown("A_P2") && hasJoined[2] == false) { hasJoined[2] = true; GlobalControl.AddPlayer(2); playerBlocks[GlobalControl.NumPlayers].GetComponent <SpriteRenderer>().color = PlayerState.playerColor [GlobalControl.NumPlayers]; } if (Input.GetButtonDown("A_P3") && hasJoined[3] == false) { hasJoined[3] = true; GlobalControl.AddPlayer(3); playerBlocks[GlobalControl.NumPlayers].GetComponent <SpriteRenderer>().color = PlayerState.playerColor [GlobalControl.NumPlayers]; } if (Input.GetButtonDown("A_P4") && hasJoined[4] == false) { hasJoined[4] = true; GlobalControl.AddPlayer(4); playerBlocks[GlobalControl.NumPlayers].GetComponent <SpriteRenderer>().color = PlayerState.playerColor [GlobalControl.NumPlayers]; } if (GlobalControl.NumPlayers > 1) { startText.text = "Player 1 Press Start"; if (GlobalControl.GetButtonDownStart(1)) { PlayerState.playerType = new PlayerType[5]; PlayerState.playerType[1] = PlayerType.APPLE; PlayerState.playerType[2] = PlayerType.CARROT; PlayerState.playerType[3] = PlayerType.SAUSAGE; PlayerState.playerType[4] = PlayerType.STRAWBERRY; SceneManager.LoadScene("HotPotato"); } if (GlobalControl.GetButtonDownBack(1)) { PlayerState.easterEgg = true; PlayerState.playerType = new PlayerType[5]; PlayerState.playerType[1] = PlayerType.APPLE; PlayerState.playerType[2] = PlayerType.CARROT; PlayerState.playerType[3] = PlayerType.SAUSAGE; PlayerState.playerType[4] = PlayerType.STRAWBERRY; SceneManager.LoadScene("HotPotato"); } } }
// Use this for initialization void Start() { bounds = ConveyerPlayerMovement.OrthographicBounds(camera); int pTcount = 0; if (PlayerState.playerType == null) { GlobalControl.AddPlayer(1); GlobalControl.AddPlayer(2); PlayerState.playerType = new PlayerType[5] { PlayerType.APPLE, PlayerType.CHEF, PlayerType.APPLE, PlayerType.CARROT, PlayerType.SAUSAGE }; } for (int i = 1; i <= GlobalControl.NumPlayers; i++) { if (PlayerState.playerType != null && PlayerState.playerType [i] == PlayerType.CHEF) { BossPNum = i; Debug.Log("Boss number is " + i); } else { Debug.Log((int)PlayerState.playerType [i]); var player = Instantiate(playerFabs [(int)PlayerState.playerType [i]]); pTcount++; //playerbounds = OrthographicBounds(transform.parent.GetComponentInChildren<Camera> ()); //TODO: set player based on PlayerState player.transform.position += new Vector3(i, 0, 0); player.GetComponent <ConveyerPlayerMovement> ().playerNum = i; player.GetComponent <ConveyerPlayerMovement> ().bounds = ConveyerPlayerMovement.OrthographicBounds(camera); player.GetComponent <AffectedByConveyor> ().conveyor = GetComponent <ConveyorController> (); players.Add(player); } } // //GlobalControl.AddPlayer (2); currentObstacle = Instantiate(obPreFabs[Random.Range(0, obPreFabs.Length)]).GetComponent <Obstacle>(); currentObstacle.GetComponent <AffectedByConveyor> ().conveyor = conveyor; currentObstacle.transform.position = new Vector3(0, 7, 0); StartCoroutine(GameTimer(60)); }
// Use this for initialization void Start() { int numPlayers = GlobalControl.NumPlayers; if (numPlayers == 0) { GlobalControl.AddPlayer(1); GlobalControl.AddPlayer(2); GameObject Boss = GameObject.Find("Boss"); Boss.GetComponent <knifeThrow>().playerNum = 1; GameObject.Find("fairy").GetComponent <targetFairy>().num = 1; GameObject.Find("Meat-Mallet-icon").GetComponent <mallet_time>().num = 1; Boss.GetComponent <BossHealth>().numPlayers = 1; GameObject ply = Instantiate(applePrefab); ply.GetComponent <PlayerControlBossBattle>().num = 2; ply.GetComponent <PlayerShootFood>().playerNum = 2; } else { for (int x = 1; x <= numPlayers; x++) { Debug.Log(PlayerState.playerType[x]); if (PlayerState.playerType[x] == PlayerType.CHEF) { GameObject Boss = GameObject.Find("Boss"); Boss.GetComponent <knifeThrow>().playerNum = x; GameObject.Find("fairy").GetComponent <targetFairy>().num = x; GameObject.Find("Meat-Mallet-icon").GetComponent <mallet_time>().num = x; Boss.GetComponent <BossHealth>().numPlayers = numPlayers - 1; } else { GameObject ply; if (PlayerState.playerType[x] == PlayerType.SAUSAGE) { ply = Instantiate(sausagePrefab); } else if (PlayerState.playerType[x] == PlayerType.CARROT) { ply = Instantiate(carrotPrefab); } else if (PlayerState.playerType[x] == PlayerType.STRAWBERRY) { ply = Instantiate(strawberryPrefab); } else if (PlayerState.playerType[x] == PlayerType.APPLE) { ply = Instantiate(applePrefab); } else { ply = Instantiate(strawberryPrefab); } ply.GetComponent <PlayerControlBossBattle>().num = x; ply.GetComponent <PlayerShootFood>().playerNum = x; } } } }