예제 #1
0
 // returns Player obj for a given Player.Id (player one or player two)
 public Player PlayerById(Player.Id playerId)
 {
     if (playerId == Player.Id.one)
     {
         return(playerOne);
     }
     if (playerId == Player.Id.two)
     {
         return(playerTwo);
     }
     Debug.Log("Invalid Player.Id");
     return(null);
 }
예제 #2
0
 void Start()
 {
     text = GetComponent <Text>();
     // display recipe for local player
     if (name.Contains("2"))
     {
         playerId = Player.Id.two;
     }
     if (name.Contains("1"))
     {
         playerId = Player.Id.one;
     }
     player = Game.Instance.PlayerById(playerId);
 }
예제 #3
0
    /// <summary>
    /// Score the specified playerId according to ingredientNames.
    /// </summary>
    /// <param name="playerId">Player identifier.</param>
    /// <param name="ingredientNames">Ingredient names.</param>
    public void Score(Player.Id playerId, List <string> ingredientNames)
    {
        Player player = PlayerById(playerId);

        // should make this event last a long time, counting each ingredient infront of the player somewhere
        foreach (string ingredientName in ingredientNames)
        {
            // search for ingredient in recipe by name
            GameObject ingredient = player.currentRecipe.ingredients.Find(
                delegate(GameObject search) {
                return(search.name == ingredientName);
            }
                );
            // if found increment player score
            if (ingredient)
            {
                player.player.AddScore(ingredient.GetComponent <Ingredient>().score);
            }
        }

        // recipes are only scored the one time! go to next recipe
        SpawnRecipe(player);
    }