예제 #1
0
    //on collision with object
    void OnTriggerEnter2D(Collider2D respawn)
    {
        //post to debug
        Debug.Log("respawn collider hit");

        //if the object is the player(s)
        if (respawn.gameObject.name == "player 1")
        {
            //fin the gameobject called MAN (can be changed in final Vesion)
            GameObject goOne = GameObject.Find("player 1");
            //finf the scrips called characterController (changed in final version)
            playerOne callrespawnOne = (playerOne)goOne.GetComponent(typeof(playerOne));
            //in found script call the method called respawn
            callrespawnOne.setDeadOne();
        }
        //if the object is the player(s)
        if (respawn.gameObject.name == "player 2")
        {
            //fin the gameobject called MAN (can be changed in final Vesion)
            GameObject goTwo = GameObject.Find("player 2");
            //finf the scrips called characterController (changed in final version)
            playerTwo callrespawnTwo = (playerTwo)goTwo.GetComponent(typeof(playerTwo));
            //in found script call the method called respawn
            callrespawnTwo.setDeadTwo();
        }
    }
예제 #2
0
    //on collision with object
    void OnTriggerEnter2D(Collider2D checkpoint)
    {
        //if the object is the player(s)
        if (checkpoint.gameObject.tag == "Player" && ranGenDone == false)
        {
            //post to debug
            Debug.Log("checkpoint collider hit");

            //fin the gameobject with tag player
            GameObject goone = GameObject.Find("player 1");
            //finf the scrips called playerOne
            playerOne callcheckpointone = (playerOne)goone.GetComponentInChildren(typeof(playerOne));
            //in found script call the method called respawn
            callcheckpointone.checkpointOne();
            callcheckpointone.setSpawnedOne();

            //fin the gameobject with tag player
            GameObject gotwo = GameObject.Find("player 2");
            //finf the scrips called playerTwo
            playerTwo callcheckpointtwo = (playerTwo)gotwo.GetComponentInChildren(typeof(playerTwo));
            //in found script call the method called respawn
            callcheckpointtwo.checkpointTwo();
            callcheckpointtwo.setSpawnedTwo();

            //fin the gameobject called ran tile gen
            GameObject tile = GameObject.Find("ran tile gen");
            //finf the scrips called rantilegen
            rantilegen callgentile = (rantilegen)tile.GetComponent(typeof(rantilegen));
            //in found script call the method called respawn
            callgentile.spawntiles();

            ranGenDone = true;
        }
    }
예제 #3
0
 public void CheckForWinner(playerOne, playerTwo)
 {
     if (playerOne.score == 2)
     {
         Console.WriteLine(playerOne.name + " You Won!");
     }
     else if (playerTwo.score == 2)
     {
         Console.WriteLine(playerTwo.name + " You Won!");
     }
 }
    public static void saveFile(playerOne player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          savePath  = Application.persistentDataPath + "/playerFILE.txt";
        FileStream      stream    = new FileStream(savePath, FileMode.Create);

        playerFile playerData = new playerFile(player);

        formatter.Serialize(stream, playerData);
        stream.Close();
    }
예제 #5
0
    private void Start()
    {
        pDead.enabled = false;
        pRetry.SetActive(false);

        playerScript = player.GetComponent <playerOne>();

        //screen width
        float halfHeight = cam.orthographicSize;
        float halfWidtth = cam.aspect * halfHeight;

        verticalMin = -halfHeight;
        verticalMax = halfHeight;

        horizontalMin = -halfWidtth;
        horizontalMax = halfWidtth;
    }
예제 #6
0
 public void DetermineScore(playerOne, playerTwo)
 {
     if (playerOne.hand == "1" && playerTwo.hand == "3" || playerTwo.hand == "4")
     {
         playerOne.score++;
         Console.WriteLine("Congratulations " + playerOne.name + ", You Win This Round!");
         Console.ReadLine();
     }
     else if (playerOne.hand == "2" && playerTwo.hand == "1" || playerTwo.hand == "5")
     {
         playerOne.score++;
         Console.WriteLine("Congratulations " + playerOne.name + ", You Win This Round!");
         Console.ReadLine();
     }
     else if (playerOne.hand == "3" && playerTwo.hand == "2" || playerTwo.hand == "4")
     {
         playerOne.score++;
         Console.WriteLine("Congratulations " + playerOne.name + ", You Win This Round!");
         Console.ReadLine();
     }
     else if (playerOne.hand == "4" && playerTwo.hand == "2" || playerTwo.hand == "5")
     {
         playerOne.score++;
         Console.WriteLine("Congratulations " + playerOne.name + ", You Win This Round!");
         Console.ReadLine();
     }
     else if (playerOne.hand == "5" && playerTwo.hand == "1" || playerTwo.hand == "3")
     {
         playerOne.score++;
         Console.WriteLine("Congratulations " + playerOne.name + ", You Win This Round!");
         Console.ReadLine();
     }
     else if (playerOne.hand == playerTwo.hand)
     {
         Console.WriteLine("You Tied, Try Again");
         Console.ReadLine();
         DetermineScore(playerOne, playerTwo);
     }
     else
     {
         playerTwo.score++;
         Console.WriteLine("Congratulations " + playerTwo.name + ", You Win This Round!");
         Console.ReadLine();
         CheckForWinner(playerOne, playerTwo);
     }
 }
 public playerFile(playerOne player)
 {
     userName = player.getUserName();
 }