Ejemplo n.º 1
0
 public void P2Char2()
 {
     if (P2Lock == false)
     {
         Instantiate(P2Character2, P2Spawn.position, P2Spawn.rotation);
         P2Lock = true;
         CharSpawner charspawner = GameObject.Find("Character Spawner").GetComponent <CharSpawner>();
         charspawner.P2Char2 = true;
     }
 }
Ejemplo n.º 2
0
 public void P1Char3()
 {
     if (P1Lock == false)
     {
         Instantiate(P1Character3, P1Spawn.position, P1Spawn.rotation);
         P1Lock = true;
         CharSpawner charspawner = GameObject.Find("Character Spawner").GetComponent <CharSpawner>();
         charspawner.P1Char3 = true;
     }
 }
Ejemplo n.º 3
0
    //public void showgameover()
    //{
    //    foreach (GameObject g in gameWinObjects)
    //    {
    //        g.SetActive(true);

    //    }
    //}
    // Update is called once per frame
    void Update()
    {
        hmove = Input.GetAxis("P1Horizontal");          // hmove is the horizontal axis of movement -s
        //vmove = Input.GetAxis ("P1Vertical"); // vmove is the vertical axis of movement -s
        // rb.velocity = new Vector2(Hspeed * hmove, vspeed * vmove);

        if (playerhealth <= 0)
        {
            ScoreKeeper scorekeeper = GameObject.Find("Score Keeper").GetComponent <ScoreKeeper>();
            CharSpawner charspawner = GameObject.Find("Character Spawner").GetComponent <CharSpawner>();
            scorekeeper.addP2Score(1);
            charspawner.Player1Spawner();
            Destroy(this.gameObject);
        }
        if (playerhealth >= 100)
        {
            playerhealth = 100;
        }

        //      if (score > 160) {
        //	SceneManager.LoadScene (4);

        //}


        //if (winscoretext != null) {
        //	winscoretext.text = ("score:" + GameObject.Find ("CharacterP").GetComponent<Player1Move> ().score.ToString ());   // seets the text object to show the score
        //}

        //if (rb.transform.position.y < -26) {
        //	SceneManager.LoadScene (3);
        //}

        if ((Input.GetKey(KeyCode.A)))
        {
            //facingright = false;                               // changes the facingright bool to false because the character is facing left -s
            //spriterenderer.flipX = true;                       // flips the sprite -s
            rb.velocity = new Vector2(Hspeed * hmove, rb.velocity.y);               // moves the character left  because hmove is less than 0  -s
            //   Debug.Log(hmove);
        }
        if ((Input.GetKey(KeyCode.D)))
        {
            //facingright = true;
            //spriterenderer.flipX = false;  // flips the sprite renderer

            rb.velocity = new Vector2(Hspeed * hmove, rb.velocity.y);                 //moves the character right because Hmove is above 0   -s
            //  Debug.Log(hmove);
        }
        if ((Input.GetKeyDown(KeyCode.W)))
        {
            if (!isgrounded())
            {
                return;
            }
            else
            {
                rb.velocity = new Vector2(rb.velocity.x, vspeed);                    // allows the player to jump   -s
                //  Debug.Log(vmove);
            }
        }



        if (Input.GetKey(KeyCode.LeftShift) && (Time.time > nextshot))
        {
            nextshot = Time.time + RRate;

            Ranged();               // calls the ranged function
        }
        if (hmove > 0 && !facingRight)
        {
            Flip();
        }
        else if (hmove < 0 && facingRight)
        {
            Flip();
        }
    }