// Use this for initialization
 void Start()
 {
     p1Script = GameObject.FindGameObjectWithTag("Player1").
                GetComponent <Player1>();
     p2Script = GameObject.FindGameObjectWithTag("Player2").
                GetComponent <Player2>();
     p1Trans = GameObject.FindGameObjectWithTag("Player1").
               GetComponent <Transform>();
     p2Trans = GameObject.FindGameObjectWithTag("Player2").
               GetComponent <Transform>();
     p1Respawn = GameObject.FindGameObjectWithTag("P1Respawn").
                 GetComponent <Transform>();
     p2Respawn = GameObject.FindGameObjectWithTag("P2Respawn").
                 GetComponent <Transform>();
     p1Sprite = GameObject.FindGameObjectWithTag("Player1").
                GetComponent <SpriteRenderer>();
     p2Sprite = GameObject.FindGameObjectWithTag("Player2").
                GetComponent <SpriteRenderer>();
     p1Score = GameObject.FindGameObjectWithTag("P1Score").
               GetComponent <P1Score>();
     p2Score = GameObject.FindGameObjectWithTag("P2Score").
               GetComponent <P2Score>();
     p1Color = p1Sprite.color;
     p2Color = p2Sprite.color;
 }
示例#2
0
 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>();
     p1Win = p2Win = false;
     opponentSprite.enabled = true;
     opponentIcon.enabled   = true;
     //p1WinCanvas = GameObject.FindGameObjectWithTag("P1Win").
     GetComponent <Canvas>();
     //p2WinCanvas = GameObject.FindGameObjectWithTag("P2Win").
     GetComponent <Canvas>();
     //p1WinCanvas.enabled = p2WinCanvas.enabled = false;
     killSound  = GetComponents <AudioSource>()[0];
     clingSound = GetComponents <AudioSource>()[1];
     p1Hurtbox  = GameObject.FindGameObjectWithTag("Player1").
                  GetComponent <PolygonCollider2D>();
     p2Hurtbox = GameObject.FindGameObjectWithTag("Player2").
                 GetComponent <PolygonCollider2D>();
     playerProjectileScript = GameObject.FindGameObjectWithTag("P1Projectile").
                              GetComponent <Projectile>();
     opponentProjectileScript = GameObject.FindGameObjectWithTag("P2Projectile").
                                GetComponent <Projectile>();
     gm     = P1GameManager.GM;
     player = ReInput.players.GetPlayer(0);
 }
示例#3
0
 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);
 }
示例#4
0
 public void AddPoint(PlayerType playerType)
 {
     if (playerType == PlayerType.player1)
     {
         P1Score++;
         p1ScoreTMP.SetText(P1Score.ToString());
         StartCoroutine(ShakeScore(p1ScoreTMP));
     }
     else
     {
         P2Score++;
         p2ScoreTMP.SetText(P2Score.ToString());
         StartCoroutine(ShakeScore(p2ScoreTMP));
     }
 }
示例#5
0
 void Start()
 {
     p1Object = GameObject.FindGameObjectWithTag("Player1");
     p2Object = GameObject.FindGameObjectWithTag("Player2");
     p1Score  = GameObject.FindGameObjectWithTag("P1Score").
                GetComponent <P1Score>();
     p2Score = GameObject.FindGameObjectWithTag("P2Score").
               GetComponent <P2Score>();
     //p1WinCanvas = GameObject.FindGameObjectWithTag("P1Win").
     //    GetComponent<Canvas>();
     //p2WinCanvas = GameObject.FindGameObjectWithTag("P2Win").
     //    GetComponent<Canvas>();
     //p1WinCanvas.enabled = p2WinCanvas.enabled = false;
     print(p1Object);
     print(p2Object);
 }