Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.M))
        {
            Mordred();
        }


        if (Input.GetKeyDown("tab"))
        {
            statsToggle = true;
            PlayerStats = Resources.Load("PreFabs/Stats") as GameObject;
            PlayerStats = Instantiate(PlayerStats, GameObject.Find("MainUI").transform);
            displayUsersInfo();
        }
        if (statsToggle == true && Input.GetKeyUp("tab"))
        {
            logger.info("GameManager.cs :: 'tab' key has been pressed toggling Player Statistics.");
            Destroy(PlayerStats.gameObject);
            foreach (GameObject g in GameObject.FindGameObjectsWithTag("SmallCard"))
            {
                Destroy(g);
            }
            statsToggle = false;
        }
        if (GameObject.Find("Button (1)") != null)
        {
            GameObject.Find("Button (1)").GetComponent <Button>().onClick.AddListener(delegate { buttonToggle(); });
        }

        /* BRANDONS QUEST STUFF START */
        if (questInPlay)
        {
            if (counter < 4)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    logger.info("GameManager.cs :: Up Arrow Key has been pressed...");
                    logger.info("GameManager.cs :: Quest :: Player Sponsoring Quest: player" + playerTurn);
                    Debug.Log(playerTurn + "Sponsoring");
                    Quests.Setup(gameUsers.findByUserName("Player" + playerTurn).gameObject);
                    passed [playerTurn] = false;
                    sponsorturn         = playerTurn;
                    //questInProgress = true;
                    questInPlay = false;
                    counter     = 0;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    logger.info("GameManager.cs :: Down Arrow Key has been pressed...");
                    logger.info("GameManager.cs :: Quest :: Player NOT Sponsoring Quest: player" + playerTurn);

                    Debug.Log(playerTurn + "Not Sponsoring");
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
            }
            else
            {
                logger.info("GameManager.cs :: Quest :: No one has sponsored.");
                Debug.Log("no one sponsored so continue to next story card");
                questInProgress = false;
                questInPlay     = false;
                questPlaying    = false;
                playerTurn++;
                counter = 0;
                if (playerTurn > 3)
                {
                    playerTurn = 0;
                }
            }
        }
        if (questInProgress)
        {
            //Debug.Log (counter);
            if (counter < 3)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    logger.info("GameManager.cs :: Up Arrow Key has been pressed...");
                    logger.info("GameManager.cs :: Quest :: Player Joining Quest: player" + playerTurn);
                    Debug.Log(playerTurn + "Joining");
                    passed [playerTurn] = true;
                    PickUpAdventureCards(playerTurn, 1);
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    logger.info("GameManager.cs :: Down Arrow Key has been pressed...");
                    logger.info("GameManager.cs :: Quest :: Player NOT Joining Quest: player" + playerTurn);
                    Debug.Log(playerTurn + "Not Joining");
                    passed [playerTurn] = false;
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
            }
            else
            {
                logger.info("GameManager.cs :: Quest :: Starting runthrough of stages...");

                Debug.Log("Starting runthrouhg of stages");
                questInProgress = false;
                questPlaying    = true;
                keepPlaying     = true;
                counter         = 0;
                for (int j = 0; j < passed.Length; j++)
                {
                    //Debug.Log ("PT: " + j + " bool: " + passed[j]);
                    if (passed[j] == true)
                    {
                        playersPlaying++;
                    }
                }
                //start at first player to join, add necessary subzone and subbutton for stage
            }
        }

        if (questPlaying)
        {
            if (keepPlaying)
            {
                if (counter < 4)
                {
                    Debug.Log("Counter = " + counter);
                    Debug.Log("Player turn passed: " + playerTurn + " passed = " + passed [playerTurn]);
                    logger.test("GameManager.cs :: Quest :: player" + playerTurn + " has passed to the next stage.");

                    if (passed [playerTurn] == true)        //then playthrough with that player
                    {
                        if (stageInt != 6)                  //then quest not over yet
                        {
                            togglePlayerCanvas(playerTurn);
                            currentUser = gameUsers.findByUserName("Player" + playerTurn).GetComponent <User> ();
                            Quests.Playthrough(currentUser.gameObject, stageInt);
                            counter++;
                        }
                        else                    //the quest is done
                        {
                            logger.info("GameManager.cs :: Quest :: The Quest has finished.");

                            logger.info("GameManager.cs :: Quest :: The sponsor: player" + sponsorturn + " Picks up cards");

                            Debug.Log("THE QUEST IS DONE NINJA!!");
                            Debug.Log("Sponsor is drawing cards");
                            PickUpAdventureCards(sponsorturn, 6);
                            for (int j = 0; j < passed.Length; j++)
                            {
                                if (passed [j] == true)
                                {
                                    Debug.Log("Player: " + j + " is a winner");
                                    User temp = gameUsers.findByUserName("Player" + j).GetComponent <User> ();
                                    if (KingsRecognition)
                                    {
                                        logger.info("GameManager.cs :: Quest :: Kings Recognition is active.");
                                        temp.setShields(temp.getShields() + StoryCard.GetComponent <Quest> ().getStages() + 2);

                                        KingsRecognition = false;
                                    }
                                    else
                                    {
                                        temp.setShields(temp.getShields() + StoryCard.GetComponent <Quest> ().getStages());
                                    }

                                    passed [j] = false;
                                }
                            }
                            playerTurn = sponsorturn + 1;
                            if (playerTurn > 3)
                            {
                                playerTurn = 0;
                            }
                            questPlaying = false;
                        }
                        if (questPlaying)
                        {
                            playerTurn++;
                            if (playerTurn > 3)
                            {
                                playerTurn = 0;
                            }
                        }
                    }
                    else if (!allDead)                //they didnt pass and need to be incremented;
                    {
                        playerTurn++;
                        if (playerTurn > 3)
                        {
                            playerTurn = 0;
                        }
                        counter++;
                    }
                    else
                    {
                        logger.info("GameManager.cs :: Quest :: Everyone died before the end of the quest.");
                        questPlaying = false;
                        Debug.Log("Sponsor is drawing cards");
                        logger.info("GameManager.cs :: Quest :: The sponsor: player" + sponsorturn + " Picks up cards");

                        PickUpAdventureCards(sponsorturn, 6);
                        playerTurn = sponsorturn + 1;
                        if (playerTurn > 3)
                        {
                            playerTurn = 0;
                        }
                        //give sponsor cards;
                    }
                    playersPlaying = 0;
                    for (int j = 0; j < passed.Length; j++)
                    {
                        if (passed[j] == true)
                        {
                            playersPlaying++;
                            logger.info("GameManager.cs :: Quest :: There is " + playersPlaying + " in quest.");
                        }
                    }
                    if (playersPlaying < 1)
                    {
                        logger.info("GameManager.cs :: Quest :: All Players did not pass.");
                        allDead = true;
                    }
                }
                else
                {
                    if (playersPlaying > 0)
                    {
                        counter = 0;
                        stageInt++;
                        Debug.Log("Increasing the stage to: " + stageInt);
                        logger.info("GameManager.cs :: Quest :: Moving on to next stage: " + stageInt);
                        for (int m = 0; m < passed.Length; m++)
                        {
                            if (passed[m] == true)
                            {
                                logger.info("GameManager.cs :: Quest :: player" + m + " has passed. Drawing one card.");
                                Debug.Log("Player: " + m + " is drawing a card");
                                PickUpAdventureCards(m, 1);
                            }
                        }
                        if (stageInt > StoryCard.GetComponent <Quest>().getStages() - 1)
                        {
                            stageInt = 6;
                            Debug.Log("dont do this");
                        }
                    }
                }
            }
        }
        /* BRANDONS QUEST STUFF END */
        if (buttonPushed == true)
        {
            Instantiate(Resources.Load("PreFabs/MiddleScreen") as GameObject);
            logger.info("Toggling Middle Screen. Please click before moving on");


            togglePlayerCanvas(playerTurn);
            PickupStoryCards(playerTurn);
//			PickUpAdventureCards(playerTurn, 1);
            currentUser = gameUsers.findByUserName("Player" + playerTurn).GetComponent <User> ();
            logger.info("GameManager.cs :: Next turn: " + currentUser.getName());
            if (currentUser.getCards().Count > 12)
            {
                logger.info("GameManager.cs :: " + currentUser.getName() + "Hand Count is: " + currentUser.getCards().Count + " cards: Please Discard Cards. ");
            }
            handleStoryCards(currentUser);
            playerTurn++;
            if (playerTurn > 3)
            {
                playerTurn = 0;
            }
            buttonPushed = false;

            /*QUEST START */
            if (doThisOnce)
            {
                playerTurn--;
                doThisOnce = false;
            }
            /*QUEST END */
        }

        if (Tournaments.getCardsSubmitted() == true)
        {
            Tournaments.Tournament(gameUsers, StoryCard.GetComponent <Tournament>());
            Destroy(GameObject.FindGameObjectWithTag("TournamentSubmit").gameObject);
            Destroy(GameObject.FindGameObjectWithTag("Stage").gameObject);
            starts          += 1;
            startTournament += 1;
            logger.info("GameManager.cs :: Player" + startTournament + " has submitted their Cards.");
            if (startTournament == totalUsers)
            {
                startTournament = 0;
            }
            togglePlayerCanvas(startTournament);
            if (starts == endTournament)
            {
                string winner = Tournaments.endTournament();
                if (winner != "")
                {
                    logger.info("GameManager.cs :: " + winner + " has won the Tournament..");
                    int shields = gameUsers.findByUserName(winner).GetComponent <User> ().getShields();
                    int bonus   = StoryCard.GetComponent <Tournament> ().getBonusShields();
                    gameUsers.findByUserName(winner).GetComponent <User> ().setShields(shields + bonus + totalUsers);
                    starts = 0;
                }
            }
            Tournaments.setCardsSubmitted(false);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        //Debug.Log ("PlayerTUrn: "+playerTurn);
        if (Input.GetKeyDown("tab"))
        {
            statsToggle = true;
            PlayerStats = Resources.Load("PreFabs/Stats") as GameObject;
            PlayerStats = Instantiate(PlayerStats, GameObject.Find("MainUI").transform);
            displayUsersInfo();
        }
        if (statsToggle == true && Input.GetKeyUp("tab"))
        {
            Destroy(PlayerStats.gameObject);
            foreach (GameObject g in GameObject.FindGameObjectsWithTag("SmallCard"))
            {
                Destroy(g);
            }
            statsToggle = false;
        }
        if (GameObject.Find("Button (1)") != null)
        {
            GameObject.Find("Button (1)").GetComponent <Button>().onClick.AddListener(delegate { buttonToggle(); });
        }

        if (questInPlay)
        {
            if (counter < 4)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    Debug.Log(playerTurn + "Sponsoring");
                    Quests.Setup(gameUsers.findByUserName("Player" + playerTurn).gameObject);
                    passed [playerTurn] = false;
                    sponsorturn         = playerTurn;
                    //questInProgress = true;
                    questInPlay = false;
                    counter     = 0;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    Debug.Log(playerTurn + "Not Sponsoring");
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
            }
            else
            {
                Debug.Log("no one sponsored so continue to next story card");
                questInProgress = false;
                questInPlay     = false;
                questPlaying    = false;
                playerTurn++;
                counter = 0;
                if (playerTurn > 3)
                {
                    playerTurn = 0;
                }
            }
        }
        if (questInProgress)
        {
            //Debug.Log (counter);
            if (counter < 3)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    Debug.Log(playerTurn + "Joining");
                    passed [playerTurn] = true;
                    PickUpAdventureCards(playerTurn, 1);
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    Debug.Log(playerTurn + "Not Joining");
                    passed [playerTurn] = false;
                    playerTurn++;
                    if (playerTurn > 3)
                    {
                        playerTurn = 0;
                    }
                    togglePlayerCanvas(playerTurn);
                    counter++;
                }
            }
            else
            {
                Debug.Log("Starting runthrouhg of stages");
                questInProgress = false;
                questPlaying    = true;
                keepPlaying     = true;
                counter         = 0;
                for (int j = 0; j < passed.Length; j++)
                {
                    //Debug.Log ("PT: " + j + " bool: " + passed[j]);
                    if (passed[j] == true)
                    {
                        playersPlaying++;
                    }
                }
                //start at first player to join, add necessary subzone and subbutton for stage
            }
        }

        if (questPlaying)
        {
            if (keepPlaying)
            {
                if (counter < 4)
                {
                    Debug.Log("Counter = " + counter);
                    Debug.Log("Player turn passed: " + playerTurn + " passed = " + passed [playerTurn]);

                    if (passed [playerTurn] == true)                //then playthrough with that player
                    {
                        if (stageInt != 6)                          //then quest not over yet
                        {
                            togglePlayerCanvas(playerTurn);
                            currentUser = gameUsers.findByUserName("Player" + playerTurn).GetComponent <User> ();
                            Quests.Playthrough(currentUser.gameObject, stageInt);
                            counter++;
                        }
                        else                            //the quest is done
                        {
                            Debug.Log("THE QUEST IS DONE NINJA!!");
                            Debug.Log("Sponsor is drawing cards");
                            PickUpAdventureCards(sponsorturn, 6);
                            for (int j = 0; j < passed.Length; j++)
                            {
                                if (passed [j] == true)
                                {
                                    Debug.Log("Player: " + j + " is a winner");
                                    User temp = gameUsers.findByUserName("Player" + j).GetComponent <User> ();
                                    temp.setShields(temp.getShields() + StoryCard.GetComponent <Quest> ().getStages());
                                    passed [j] = false;
                                }
                            }
                            playerTurn = sponsorturn + 1;
                            if (playerTurn > 3)
                            {
                                playerTurn = 0;
                            }
                            questPlaying = false;
                        }
                        if (questPlaying)
                        {
                            playerTurn++;
                            if (playerTurn > 3)
                            {
                                playerTurn = 0;
                            }
                        }
                    }
                    else if (!allDead)                        //they didnt pass and need to be incremented;
                    {
                        playerTurn++;
                        if (playerTurn > 3)
                        {
                            playerTurn = 0;
                        }
                        counter++;
                    }
                    else
                    {
                        Debug.Log("Everyone died before the end of the quest");
                        questPlaying = false;
                        Debug.Log("Sponsor is drawing cards");
                        PickUpAdventureCards(sponsorturn, 6);
                        playerTurn = sponsorturn + 1;
                        if (playerTurn > 3)
                        {
                            playerTurn = 0;
                        }
                        //give sponsor cards;
                    }
                    playersPlaying = 0;
                    for (int j = 0; j < passed.Length; j++)
                    {
                        if (passed[j] == true)
                        {
                            playersPlaying++;
                        }
                    }
                    if (playersPlaying < 1)
                    {
                        allDead = true;
                    }
                }
                else
                {
                    if (playersPlaying > 0)
                    {
                        counter = 0;
                        stageInt++;
                        Debug.Log("Increasing the stage to: " + stageInt);
                        for (int m = 0; m < passed.Length; m++)
                        {
                            if (passed[m] == true)
                            {
                                Debug.Log("Player: " + m + " is drawing a card");
                                PickUpAdventureCards(m, 1);
                            }
                        }
                        if (stageInt > StoryCard.GetComponent <Quest>().getStages() - 1)
                        {
                            stageInt = 6;
                            Debug.Log("dont do this");
                        }
                    }
                }
            }
        }

        //here
        if (buttonPushed == true)
        {
            if (false)
            {
//			if(questInProgress == true){
//
//				//Debug.Log ("Quest in progress");
//				if(keepPlaying == true){
//					//Debug.Log ("keep playing");
//
//					if(playerTurn != sponsorturn){
//						if(stageInt == 0){
//							togglePlayerCanvas (playerTurn);
//							Quests.Playthrough (currentUser.gameObject, stageInt);
//						}else if(stageInt == 1){
//							//runThrough with people who have passed previous stage
//						}
//						if (playerTurn == totalUsers+1) {
//							playerTurn = 0;
//							//togglePlayerCanvas (playerTurn);
//						}
//					}else{
//						playerTurn++;
//						togglePlayerCanvas (playerTurn);
//						Quests.Playthrough (currentUser.gameObject, stageInt);
//					}
//					keepPlaying = false;
//				}
            }
            else
            {
                togglePlayerCanvas(playerTurn);
                PickupStoryCards2(playerTurn, storyCardToDraw);

                //			PickUpAdventureCards(playerTurn, 1);
                currentUser = gameUsers.findByUserName("Player" + playerTurn).GetComponent <User> ();
                handleStoryCards(currentUser);

                playerTurn++;
                if (playerTurn > 3)
                {
                    playerTurn = 0;
                }

                Debug.Log("Players turn = " + playerTurn);
                if (playerTurn == totalUsers + 1)
                {
                    playerTurn = 0;
                }
                buttonPushed = false;
                //if(!doThisOnce){
                if (storyCardToDraw == "Boar Hunt")
                {
                    storyCardToDraw = "Prosperity Throughout the Realm";
                }
                else if (storyCardToDraw == "Prosperity Throughout the Realm")
                {
                    storyCardToDraw = "Chivalrous Deed";
                }
                else
                {
                    storyCardToDraw = "Slay The Dragon";
                }
                //	}
                if (doThisOnce)
                {
                    playerTurn -= 1;
                    doThisOnce  = false;
                }
            }
        }

        if (Tournaments.getCardsSubmitted() == true)
        {
            Debug.Log("GetCardsSubmitted = true");
            Tournaments.Tournament(currentUser.gameObject, StoryCard.GetComponent <Tournament>());
            Tournaments.setCardsSubmitted(false);
        }
    }