Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isServer || roundOver)
        {
            return;
        }

        // Run this is there's no time left
        if (timeLeft <= 0 && roundOver == false)
        {
            EndRound();
            roundOver = true;
        }

        // Subtract a second every second
        timeLeft -= Time.deltaTime;

        nextRecipe -= Time.deltaTime;

        timeLeft = Mathf.Clamp(timeLeft, 0, timeLeft);

        // Generate recipes every now and then.
        if (nextRecipe <= 0)
        {
            nextRecipe = Random.Range(nextRecipeMin, nextRecipeMax);
            // Check how many recipes are in play. We don't want more than 5 at a time.
            if (recGen.recipesInPlay.Count < maximumRecipes)
            {
                recGen.GenerateRecipe();
            }
        }

        RpcUpdateTimer(timeLeft);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        timerText      = timerObj.GetComponent <Text>();
        scoreText      = scoreObj.GetComponent <Text>();
        scoreText.text = totalScore.ToString();
        recGen         = GetComponent <RecipeGenerator>();

        //Get a reference to the network manager
        netMan = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <RoboNetManager>();

        if (isServer)
        {
            //Generate a recipe
            recGen.GenerateRecipe();

            //Spawn the players
            List <GameObject> matchPlayers = new List <GameObject>();

            //Create a temp list of all the players in the current match
            foreach (GameObject g in netMan.playerManagers)
            {
                g.GetComponent <PlayerManager>().InitCamGimbal();

                foreach (GameObject p in g.GetComponent <PlayerManager>().playerObjs)
                {
                    matchPlayers.Add(p);
                }
            }

            //See if there are any spawn points. If not, we won't take over spawning
            if (spawnPoints.Count == 0)
            {
                return;
            }

            //Temp count for spawning players
            int tempCount = 0;

            //Spawn the players
            for (int i = 0; i < matchPlayers.Count; i++)
            {
                if (i > spawnPoints.Count)
                {
                    tempCount += matchPlayers.Count;
                }
                matchPlayers[i].GetComponent <ActionHandler>().MovePlayer(spawnPoints[i - tempCount].transform.position);
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Calls the generate recipe function in RecipeGenerator, and sets the chef's canvas to the returned list of ingredients
    /// Also sets the name of the recipe
    /// </summary>
    public void GenerateAndSetNewRecipe()
    {
        List <string> recipe = RG.GenerateRecipe(numberOfPlayers);

        int x = 0;

        foreach (string ingredient in recipe)
        {
            if (chefsRecipeList[x] == null)
            {
                break;
            }
            chefsRecipeList[x].text = ingredient;
            x++;
        }

        //Set the text and the images
        recipeName.text = RG.GetCurrentRecipeName();
    }