Exemple #1
0
    private void ApplyPrize(PrizeComponent prize, string userId)
    {
        int pointsUpdate = prize.GetPoints(userId);
        int puckUpdate   = prize.GetPucks(userId);

        ApplyPrize(pointsUpdate, puckUpdate, userId);
    }
Exemple #2
0
    private void CupCatchHandler(GameObject cup, GameObject puck)
    {
        PrizeComponent prize      = cup.GetComponent <PrizeComponent>();
        LaunchData     launchData = puck.GetComponent <LaunchData>();

        if (prize != null && launchData != null)
        {
            string userId = launchData.Player.Id;
            ApplyPrize(prize, userId);
        }
        else
        {
            Debug.LogError("UserManager - can't process cup catch because prize component or launch data was missing.");
        }
    }
Exemple #3
0
    private PrizeComponent GetNextBonus()
    {
        PrizeComponent[] prizes = GetComponents <PrizeComponent>();
        if (prizes.Length <= 0)
        {
            Debug.LogError("Slot box is missing prize components. Please attach prize components to slot box.");
            return(null);
        }

        if (prizes.Length <= ++bonusIdx || bonusIdx < 0)
        {
            bonusIdx = 0;
        }

        currentPrize = prizes[bonusIdx];
        return(currentPrize);
    }
Exemple #4
0
    private void DisplayPrize(PrizeComponent prize)
    {
        if (ImageDisplay != null && prize.optionalImage != null)
        {
            ImageDisplay.sprite = prize.optionalImage;
            TextDisplay.text    = "";
        }
        else
        {
            if (ImageDisplay != null)
            {
                ImageDisplay.sprite = null;
            }

            TextDisplay.text = prize.GenerateString();
        }
    }
    private void RandomizePrizeHandler(GameObject objWithPrize)
    {
        PrizeComponent prize = objWithPrize.GetComponent <PrizeComponent>();

        if (prize != null && prize.Randomize && prize.prizeTier == prizeTier)
        {
            if ((possiblePointValues != null && possiblePointValues.Length > 0) ||
                (possiblePuckValues != null && possiblePuckValues.Length > 0))
            {
                // set random value
                int points = -1;
                int pucks  = -1;
                SetRandomValue(possiblePointValues, ref points);
                SetRandomValue(possiblePuckValues, ref pucks);

                // make sure we don't get a result of 0 points and 0 pucks
                while (points == 0 && pucks == 0)
                {
                    if (UnityEngine.Random.Range(0, 1) == 0)
                    {
                        SetRandomValue(possiblePointValues, ref points);
                    }
                    else
                    {
                        SetRandomValue(possiblePuckValues, ref pucks);
                    }
                }

                if (points != -1)
                {
                    prize.Points = points;
                }

                if (pucks != -1)
                {
                    prize.Pucks = pucks;
                }
            }
        }
    }
    private void SlotBoxReleaseHandler(GameObject slotBoxObj, GameObject puckObj)
    {
        SlotBoxScript slotBox = slotBoxObj.GetComponentInChildren <SlotBoxScript>();

        if (slotBox != null)
        {
            PrizeComponent prize = slotBox.currentPrize;

            if (prize != null && prize.otherType == Constants.BUG_PRIZE_TYPE && remainingBugs > 0)
            {
                //objectiveText.text = string.Format(objectiveString, --remainingBugs, bugsGoal);

                if (--remainingBugs <= 0)
                {
                    //objectiveText.text = completedString;
                    if (EventList.AddRotatingText != null)
                    {
                        EventList.AddRotatingText(titleString, completedString);
                    }
                    string missionId = Constants.GetMissionId(missionName);
                    if (missionId == null)
                    {
                        Debug.LogError("Could not retrieve mission Id for mission name: " + missionName);
                        return;
                    }

                    if (EventList.MissionCompleted != null)
                    {
                        EventList.MissionCompleted(missionId);
                    }
                }
                else if (EventList.AddRotatingText != null)
                {
                    EventList.AddRotatingText(titleString, string.Format(objectiveString, remainingBugs, bugsGoal));
                }
            }
        }
    }
Exemple #7
0
    private void SlotBoxReleaseHandler(GameObject slotBox, GameObject puck)
    {
        SlotBoxScript slotScript = slotBox.GetComponentInChildren <SlotBoxScript>();

        if (slotScript == null)
        {
            Debug.LogError("UserManager - cannot process prize component because slot box did not have a slot box script.");
            return;
        }

        LaunchData launch = puck.GetComponent <LaunchData>();

        if (launch == null)
        {
            Debug.LogError("UserManager - cannot process prize component because the puck did not have an attached launch data object.");
            return;
        }

        PrizeComponent prize  = slotScript.GetPrize();
        string         userId = launch.Player.Id;

        ApplyPrize(prize, userId);
    }