private CCSprite CreateFruitGraphic(FruitColor color) { CCSprite graphic; if (color == FruitColor.Yellow) { graphic = new CCSprite(CCTextureCache.SharedTextureCache.AddImage("lemon.png")) { IsAntialiased = false }; _scoreLabel.Color = CCColor3B.Black; _scoreLabel.PositionY = 0; } else { graphic = new CCSprite(CCTextureCache.SharedTextureCache.AddImage("cherry.png")) { IsAntialiased = false }; _scoreLabel.Color = CCColor3B.White; _scoreLabel.PositionY = -8; } FruitColor = color; return(graphic); }
/// <summary> /// Compare the given color to the fruit types that defined on the tree. /// </summary> /// <returns><c>true</c> if the color is possible; otherwise, <c>false</c>.</returns> /// <param name="diceColor">Dice color.</param> public bool IsColorPossible(FruitColor fruitColor) { FruitColor colorOfTheFruit = FruitColor.None; if (possibleFruits != null && possibleFruits.Length > 0) { string[] fruitTypes = FruitToColor.Instance.GetFruitsForColor(fruitColor); // -- If user set manually possible fruits -- for (int i = 0; i < fruitTypes.Length; i++) { for (int y = 0; i < possibleFruits.Length; y++) { if (fruitTypes[i] == possibleFruits[i]) { return(true); } } } } else { // -- If any fruit is possible -- return(true); } return(false); }
/// <summary> /// Get a fruit type by diceColor. /// </summary> /// <returns>The fruit type by color.</returns> /// <param name="diceColor">Dice color.</param> public string GetFruitTypeByColor(FruitColor fruitColor) { if (possibleFruits != null && possibleFruits.Length > 0) { string[] shuffledPossibleFruits = Shuffle <string>(possibleFruits); string[] fruitTypes = FruitToColor.Instance.GetFruitsForColor(fruitColor); // -- If user set manually possible fruits -- for (int i = 0; i < fruitTypes.Length; i++) { for (int y = 0; i < possibleFruits.Length; y++) { if (fruitTypes[i] == possibleFruits[i]) { return(fruitTypes[i]); } } } } else { // -- If any fruit is possible -- return(GetRandomFruitType(fruitColor)); } return(null); }
public void DiceRoleComplete(DiceFieldType diceNumber, FruitColor color) { if (!voiceOverOfColorDone) { VoiceOverOfColor(color); } }
public void OnAddToBasket(FruitColor color) { if (!playerCheeringDone && currentFruitsToPickCount >= fruitsToPickCount) { CheeringPlayer(); playerCheeringDone = true; } }
/// <summary> /// Gets the random entry of the fruit enum. /// </summary> private string GetRandomFruitType() { // Random Color Array values = Enum.GetValues(typeof(FruitColor)); System.Random random = new System.Random(); FruitColor randomFruitColor = (FruitColor)values.GetValue(random.Next(values.Length)); return(GetRandomFruitType(randomFruitColor)); }
public FruitColor GetFruitColorToDiceNumber(DiceFieldType diceNumber) { FruitColor color = FruitColor.None; if ((int)diceNumber > 0) { color = imageColorList[GetSpecificFruitIndex(diceNumber)]; } return(color); }
/// <summary> /// Gets the specific fruit count. /// </summary> /// <returns>The specific fruit count.</returns> /// <param name="id">Identifier.</param> public int GetSpecificFruitCount(FruitColor id) { int count = 0; if (GetSpecificFruitIndex(id) > -1) { count = specificFruitCount[GetSpecificFruitIndex(id)]; } return(count); }
/// <summary> /// Creates the tree fruits by diceColor. /// </summary> /// <param name="diceColor">Dice color.</param> public void CreateTreeFruits(FruitColor color) { GetFruitPlaceholders(); if (FruitPlaceholders.Count <= 0) { return; } SetupTreeFruits(GetFruitTypeByColor(color)); }
public int GetTreeIndexOfColor(FruitColor color) { for (int i = 0; i < imageColorList.Length; i++) { if (color == imageColorList[i]) { return(i); } } return(-1); }
public static CCColor4B ToCCColor(this FruitColor color) { switch (color) { case FruitColor.Yellow: return(new CCColor4B(150, 150, 0, 150)); case FruitColor.Red: return(new CCColor4B(150, 0, 0, 150)); } throw new ArgumentException("Unknown color " + color); }
/// <summary> /// Gets the color of the fruits for. /// </summary> /// <returns>The fruits for color.</returns> /// <param name="fruitColor">Fruit color.</param> public string[] GetFruitsForColor(FruitColor fruitColor) { List <string> fruits = new List <string>(); for (int i = 0; i < fruitEntries.Count; i++) { if (fruitColor == fruitEntries[i].FruitColor) { fruits.Add(fruitEntries[i].FruitType); } } return(fruits.ToArray()); }
/// <summary> /// Gets the random entry of the fruit enum. /// </summary> private string GetRandomFruitType(FruitColor fruitColor) { string[] fruittypes = FruitToColor.Instance.GetFruitsForColor(fruitColor); if (fruittypes == null || fruittypes.Length <= 0) { Debug.Log("No Fruittype found!"); return(null); } else { return(fruittypes [UnityEngine.Random.Range(0, fruittypes.Length)]); } }
public void RemoveFruitFromTheBasket(FruitColor id) { // -- Count down the fruit amount -- fruitCount += 1; int fruitCountIterator = GetSpecificFruitIndex(id); // --- Decrease added fruit --- if (fruitCountIterator > -1) { specificFruitCount[fruitCountIterator]++; } print(id.ToString() + " in the basket"); print("Fruits remaining: " + fruitCount); }
public Fruit(FruitColor fruitCollor, FruitsPool pool) { _pool = pool; Score = 1; _scoreLabel = CreateScoreLabel(); CreateCollision(); Acceleration.Y = GameCoefficients.FruitGravity; AddChild(CreateFruitGraphic(fruitCollor)); AddChild(_scoreLabel); CreateDebugGraphic(); }
public void VoiceOverOfColor(FruitColor id) { showPointerAtColorWheelTutorial = false; if (id > 0) { UnityAction callback = null; if (currentFruitsToPickCount >= fruitsToPickCount - 1) { voiceOverOfColorDone = true; } AudioManager.Instance.SetVoiceOver(voiceOversColor[currentFruitsToPickCount], callback); ++currentFruitsToPickCount; } }
public DiceFieldType GetDiceNumberForFruitColor(FruitColor fruitColor) { DiceFieldType diceNumber = DiceFieldType.None; if ((int)fruitColor > 0) { for (int i = 0; i < imageColorList.Length; i++) { if (fruitColor == imageColorList[i]) { diceNumber = (DiceFieldType)(i + 1); } } } return(diceNumber); }
protected Fruit(FruitColor color) { Color = color; }
public FruitBin(FruitColor color) { _fruitColor = color; CreateDebugGraphics(); }
public Fruit(FruitType type, FruitColor color, int weight) { Type = type; Color = color; Weight = weight; }
// The things below are just for the debug, to give text feedback to the user // TODO: replace with actual logic and animations public void AddedFruitToTheBasket(FruitColor id) { // -- Count down the fruit amount -- fruitCount -= 1; int fruitCountIterator = GetSpecificFruitIndex(id); // --- Decrease added fruit --- if (fruitCountIterator > -1) { specificFruitCount[fruitCountIterator]--; if (specificFruitCount[fruitCountIterator] == 0) { if (fruitCount > 0) { DiceController.StartBlinking(0.0f); } } } if (OnFruitIsAddedToTheBasket != null) { OnFruitIsAddedToTheBasket(id); InputManager.UnblockInput(); } print(id.ToString() + " in the basket"); print("Fruits remaining: " + fruitCount); // -- Finish the Game -- if (fruitCount == 0) { // --- Debug Stuff --- DisablePointerAtColorWheelHint(); DisablePointerFingerSwipeAnimation(); // Disable Dice DiceController.HideColorWheel(); DiceController.Enable(false); DiceController.AllowToRoll(false); uiController.EnableDiceButton(false); // Debug InputManager.BlockInput(); InputManager.BlockDiceRole(); // Win Game Raven.transform.rotation = Quaternion.AngleAxis(180, Vector3.up); Raven.RavenLoss(WinTheGame); uiController.backButton.gameObject.SetActive(false); } else { // --- Normal GAME --- // Allow Only One fruit colourID = FruitColor.None; DiceController.StartBlinking(0.0f); DiceController.AllowToRoll(true); DiceController.Enable(true); uiController.diceButton.enabled = true; InputManager.UnblockDiceRole(); InputManager.blockGrabing = true; DiceController.UnHightLightSelected(); if (!tutorial) { //showPointerAtColorWheelTutorial = true; //StartCoroutine(DoFunctionWithDelay(ShowPointerAtColorWheel, 5.0f)); } } }
public int GetSpecificFruitIndex(FruitColor value) { return((int)(value - 1)); }
public FruitEntry(string fruitType, FruitColor fruitColor) { FruitType = fruitType; FruitColor = fruitColor; }
/// <summary> /// Function after dice role to set the result /// </summary> /// <param name="id">Identifier.</param> public void SetDiceResult(DiceFieldType id) { colourID = GetFruitColorToDiceNumber(id); DiceController.HightLightSelected(id); ActivateFruitHint(); if (OnDiceRoleComplete != null) { OnDiceRoleComplete(id, GetFruitColorToDiceNumber(id)); } if (id == DiceFieldType.Raven) { // Shuffle Dice Minigsame DiceController.AllowToRoll(false); DiceController.Enable(false); uiController.diceButton.enabled = false; //Handheld.Vibrate(); int index = ravenPositionsCount - ravenPosition; //CalculateRavenMiniGameLiklyhood(); bool miniGame = false; bool miniGameBubble = false; for (int i = 0; i < positionOfTheMinigame.Length; i++) { if (positionOfTheMinigame[i] == index) { miniGame = true; } } if (!tutorial && UnityEngine.Random.Range(0, 100) <= bubblePossibility) { for (int i = 0; i < positionOfTheBubble.Length; i++) { if (positionOfTheBubble[i] == index) { miniGameBubble = true; } } } if ((miniGame || miniGameBubble) && ravenMinigames != null && ravenMinigames.Length > 0) //index >= 0 && index < ravenMinigames.Length && ravenMinigames[index] != null) { // Start Animation, after completing run callback on method "StartMiniGame" --ravenPosition; if (miniGameBubble) { // Bubble Game currentRavenGameIndex = 0; } else { // Random Game currentRavenGameIndex = tutorial ? 0 : UnityEngine.Random.Range(0, ravenMinigames.Length); } RavenHide(StartMiniGame); } else { if (ravenPosition > 0) { Debug.Log("No Minigame implementent for Position " + (index)); currentRavenGameIndex = -1; MoveRaven(); --ravenPosition; } else { RavenWinGame(); } } } else { DiceController.AllowToRoll(false); InputManager.UnblockInput(); InputManager.BlockDiceRole(); InputManager.blockGrabing = false; uiController.diceButton.enabled = false; } }
/// <summary> /// Adds the node. /// </summary> /// <param name="fruitType">Fruit type.</param> /// <param name="fruitColor">Fruit color.</param> public void AddNode(string fruitType, FruitColor fruitColor) { fruitEntries.Add(new FruitEntry(fruitType, fruitColor)); }
public bool Equals(FruitColor other) { return string.Equals(ColorString, other.ColorString); }
public FruitDescription(FruitSize size, FruitColor color) { _size = size; _color = color; }