コード例 #1
0
ファイル: ApplePicker.cs プロジェクト: ecole5/UnityGames
    public void AppleDestroyed()
    {
        //// Destroy all of the falling Apples when one basket has been lost
        GameObject[] tAppleArray = GameObject.FindGameObjectsWithTag("Apple");
        foreach (GameObject tGO in tAppleArray)
        {
            Destroy(tGO);
        }

        // Get the index of the last Basket in basketList and change it so that next time it only generates two baskets
        int basketIndex = basketList.Count - 1;

        // Get a reference to the basket being removes
        GameObject tBasketGO = basketList[basketIndex];

        // Remove the Basket from the List and destroy the dead basket
        basketList.RemoveAt(basketIndex);
        Destroy(tBasketGO);

        // Restart the game if no baskets are remaining
        if (basketList.Count == 0)
        {
            HistoryMethods.addByScore(HistoryMethods.regLog(Basket.score.ToString()), GameData.Prefs.appleHist); //save apple history to server
            SceneManager.LoadScene("Apple_Splash");                                                              //load  splash screen
        }
    }
コード例 #2
0
ファイル: DeleteUser.cs プロジェクト: ecole5/UnityGames
    private IEnumerator deleteUser()
    {
        //Create the form and submit it to the server
        string  url  = "https://evancole.io/deleteuser.php";
        WWWForm form = new WWWForm();

        form.AddField("username", inputText.text);
        WWW result = new WWW(url, form);

        yield return(result);

        //Network done extended use case
        if (!string.IsNullOrEmpty(result.error))
        {
            statusText.text = "Could not connect to network, check connection and try again";
        }
        else
        {
            statusText.text = result.text;
            if (result.text == "User deleted successfully")
            {
                //Purge All the history object of that user
                HistoryMethods.remove(inputText.text, GameData.Prefs.spaceHist);
            }
            HistoryMethods.remove(inputText.text, GameData.Prefs.appleHist);
            HistoryMethods.remove(inputText.text, GameData.Prefs.ninjaHist);
            HistoryMethods.remove(inputText.text, GameData.Prefs.dinoHist);
            HistoryMethods.remove(inputText.text, GameData.Prefs.portalHist);
            HistoryMethods.remove(inputText.text, GameData.Prefs.spaceHist);
            //Save the history objects
            GameData.Prefs.saveData();
        }
    }
コード例 #3
0
    //Exit to the login screen
    public void Exit()
    {
        PortalAudio.output.playClick();         //play click sound
        HistoryMethods.addByDate(HistoryMethods.portalLog(Time.realtimeSinceStartup.ToString()), GameData.Prefs.portalHist);

        GameData.Prefs.saveData();          //save all game data to server
        SceneManager.LoadScene("Login");    //load login screen
    }
コード例 #4
0
ファイル: Dino_MainGame.cs プロジェクト: ecole5/UnityGames
	//Game Logic
	public void cardClicked(int index)
	{ 

		if (firstCard == null && cardsActive && !gameEnded){ //no cards assigned
			AudioController.speaker.playClip (0); //play click
			firstCard = cardList [index]; //keep reference to first card
			firstCard.flipBack (); //reveals the back side of the card
		}

		else if (secondCard == null && cardList[index] != firstCard && cardsActive && !gameEnded){ //first card assigned but second not, and card clicked is not first

			AudioController.speaker.playClip (0); //play click

			secondCard = cardList [index]; //keep reference to second card
			secondCard.flipBack();  //show the second card 

			if (firstCard.getValue () == secondCard.getValue()) { //there is a match with firstCard
				cardsActive = false;
				cardsLeft -= 2; //Adjust cards left 
				Invoke ("playWin", 0.3f); //give enough time to click
				Invoke ("yesMatch", 0.6f);//resets the cards
			}

			else { //there is not a match with firstCard
				cardsActive = false;
				score -= 40; //decrease score
				Invoke ("playLose", 0.3f);
				Invoke ("noMatch", 0.6f);
			}
				
			//GameOver Check
			if (cardsLeft == 0 || score == 0) { 
				gameEnded = true;
				count = false; //stop = false
				HistoryMethods.addByScore (HistoryMethods.regLog (score.ToString ()), GameData.Prefs.dinoHist); //save history to server
				Invoke ("loadEnd", 2f); //invoke the game over screen in 2 seconds
			}

		} //end card match check 

	} //end card clicked 
コード例 #5
0
    //NEW loads the new game over screen
    void gameOver()
    {
        string temp;

        //Convert game level to string to record in the history
        switch (gameLevel)
        {
        case 0:
            temp = "Bronze";
            break;

        case 1:
            temp = "Silver";
            break;

        default:
            temp = "Gold";
            break;
        }
        HistoryMethods.addByScore(HistoryMethods.spaceLog(points.ToString(), temp), GameData.Prefs.spaceHist);           //save history to server
        SceneManager.LoadScene("Scene_SpaceGameOver");
    }