Beispiel #1
0
    Dictionary <string, T> LoadTextResource <T>() where T : LoadableResource
    {
        Dictionary <string, T> Dictionary = new Dictionary <string, T>();
        string TypeName = typeof(T).Name + "s";
        //Debug.Log(TypeName);

        List <T> LoadedList = ResourcesMaster.JsonToList <T>(TypeName);
        string   liststring = ResourcesMaster.ListToJson <T>(LoadedList);

        ResourcesMaster.WriteUp(TypeName, liststring);

        string s = TypeName + " ";

        foreach (T item in LoadedList)
        {
            LoadableResource Resource = (LoadableResource)item;
            Dictionary.Add(Resource.Name, item);
            s += Resource.Name + " ";
        }
        Debug.Log(s);

        //facda5//fcd47e
        //f47200
        //ffffb4
        //e36c13
        //ffb313

        return(Dictionary);
    }
Beispiel #2
0
    private void Update()
    {
        float currentAmount = ResourcesMaster.GetResourceAmount(displayedResource);

        if (currentAmount != lastDisplayedAmount)
        {
            lastDisplayedAmount = currentAmount;
            UpdatePurpleLiquidScale();
        }
    }
Beispiel #3
0
    private void Update()
    {
        float currentAmount = ResourcesMaster.GetResourceAmount(displayedResource);

        if (currentAmount != lastDisplayedAmount)
        {
            lastDisplayedAmount = currentAmount;
            CreateNewBottles();
        }
    }
Beispiel #4
0
    private void CheckInput()
    {
        volume = GetAverageVolume() * MIC_SENSITIVITY;

        detectedClap = lastFrameVolume <= ambientVolume && volume >= clapVolume;
        if (detectedClap)
        {
            ResourcesMaster.AddResource(generatedResourceName, ResourcesMaster.instance.resourcePerMicThreshold);
        }

        lastFrameVolume = volume;
    }
Beispiel #5
0
    // Creates new bottles if enough resource was generated
    private void CreateNewBottles()
    {
        float resourcesPerBottle = ResourcesMaster.instance.resourcePerBottle;

        if ((lastDisplayedAmount - resourcesPerBottle * bottles.Count) >= resourcesPerBottle)
        {
            sfxAudioSource.PlayOneShot(bottlePopping);
            bottles.Add(Instantiate <GameObject>(bottlePrefab, bottlesParent));
            float color = FindObjectOfType <DanceMatActivity>().GetAverageColor();
            ResourcesMaster.AddBottle(color);
        }
    }
Beispiel #6
0
    private void CheckInput()
    {
        // If manager wasn't initialized or no button was pressed, do nothing.
        if (!DanceMatInputManager.isInitialized || !DanceMatInputManager.GetAnyInput())
        {
            return;
        }

        // Gets which button was pressed on current frame
        DanceMatInput pressedButton = GetDanceMatKeyDown();

        // If the pressed button is different than the last pressed button,
        //	increases the score
        if (pressedButton != lastPressedInput)
        {
            DoFootStep();
            Grape closestGrape = GetClosestGrape();
            if (closestGrape)
            {
                float hitRadius = ResourcesMaster.instance.hitRadius;
                if ((closestGrape.transform.position - target.position).sqrMagnitude < hitRadius * hitRadius)
                {
                    audioSource.PlayOneShot(grapeSquashing);
                    float resourcePerTap = ResourcesMaster.instance.resourcesPerTap;
                    ResourcesMaster.AddResource(generatedResourceName, resourcePerTap);

                    steppedGrapesColors.Add(closestGrape.colorSpectrumValue);
                    if (steppedGrapesColors.Count > 10)
                    {
                        steppedGrapesColors.RemoveAt(0);
                    }
                }
                else
                {
                    feedbackPanel.SetAlpha(0f);
                    feedbackPanel.DOFade(0.5f, 0.5f).From();
                    //float resourcePerTap = ResourcesMaster.instance.danceMatProperties.resourcesPerTap;
                    //float usedResources = ResourcesMaster.GetResourceData(generatedResourceName).requiredToGeneratedRatio * resourcePerTap;
                    //ResourcesMaster.RemoveRequiredResource(generatedResourceName, usedResources);
                }

                fallingGrapes.Remove(closestGrape);
                Destroy(closestGrape.gameObject);
                GameMaster.instance.collectActivity.RemoveGrapeByColor(closestGrape.colorSpectrumValue);
            }
        }

        // Saves current button as last pressed button for next frame.
        lastPressedInput = pressedButton;
    }
Beispiel #7
0
    void Start()
    {
        // PieceActionsDictionary = new Dictionary<string, PieceAction>();//LoadTextResource<PieceAction>();
        //  PieceEventsDictionary = new Dictionary<string, PieceEvent>();//LoadTextResource<PieceEvent>();
        //PieceModelObjectsDictionary = LoadTextResource<PieceModelObject>();
        //PieceModelTextPanelsDictionary = LoadTextResource<PieceModelTextPanel>();
        //TrackedTagsDictionary = LoadTextResource<TrackedTag>();

        //PieceModelTextPanelsDictionary.Values.ForEach(pm => pm.ModelType = "PieceModelTextPanel");

        PieceActions = ResourcesMaster.JsonToList <PieceAction>("PieceActions");
        string lcsp = ResourcesMaster.ListToJson <PieceAction>(PieceActions);

        foreach (PieceAction pa in PieceActions)
        {
            pa.FullyLoad();
            //PieceActionsDictionary.Add(pa.Name, pa);
        }
        //ResourcesMaster.WriteUp("PieceActions", lcsp);

        SceneSetup = ResourcesMaster.JsonToObject <SceneSetup>("SceneSetup_Torno");
        string sss = ResourcesMaster.ObjectToJson <SceneSetup>(SceneSetup);

        ResourcesMaster.WriteUp("SceneSetupBackup", sss);

        foreach (TrackedAnimationTag Tk in SceneSetup.TrackedAnimationTags)
        {
            foreach (PieceModel Panel in Tk.Panels)
            {
                Panel.FullyLoad();
            }
            foreach (PieceModel Model in Tk.Models)
            {
                Model.FullyLoad();
            }
        }



        //
    }
    private void CheckInput()
    {
        JoystickPosition currentDirection = GetCurrentJostickPosition();
        JoystickPosition lastDirection    = latestDirections.GetLast();

        // Waits for direction to change so it doesn't accumulate a bunch of equal directions
        if (currentDirection != lastDirection && currentDirection != JoystickPosition.None)
        {
            latestDirections.Add(currentDirection);

            // We are only interested in the latest 4 directions.
            if (latestDirections.Count > 4)
            {
                latestDirections.RemoveAt(0);
            }

            // Generates resources whenever player completed a full spin
            if (CounterClockwiseCheck() || ClockwiseCheck())
            {
                ResourcesMaster.AddResource(generatedResource, resourcePerSpin);
            }
        }
    }
Beispiel #9
0
    private void Update()
    {
        if (isCounting)
        {
            if (currentTime < 0f)
            {
                GameOver();
            }
            else
            {
                DecreaseTimer();
            }
        }

        if (!bottlingActivity.gameObject.activeSelf && ResourcesMaster.GetResourceAmount("juice") >= ResourcesMaster.GetResourceData("bottle").requiredToGeneratedRatio)
        {
            bottlingActivity.gameObject.SetActive(true);
            currentProgressionState = ActivitiesProgression.Bottling;
        }

        if (Input.GetButtonDown("Reset"))
        {
            System.GC.Collect();
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        else if (Input.GetButtonDown("Pause"))
        {
            if (isPaused)
            {
                ClosePauseMenu();
            }
            else
            {
                OpenPauseMenu();
            }
        }
    }
Beispiel #10
0
    private void GameOver()
    {
        isCounting = false;
        gameOverOverlay.SetActive(true);

        int wineIndex = GetWineIndex();

        float percentage;

        StartCoroutine(AddWine(wineIndex));

        if (USE_SPREADSHEET)
        {
            percentage = 100f * ((float)wineInfos[wineIndex].quantity) / (float)GetTotalWinesMade();
        }
        else if (USE_PHP)
        {
            percentage = 100f * ((float)wineQuantitiesFromWebhost[wineIndex] / (float)GetTotalWinesMade());
        }
        else
        {
            percentage = 100f * ((float)wineQuantitiesFromHeroku[wineIndex] / (float)GetTotalWinesMade());
        }

        string percentString = percentage.ToString("##.#");

        string wineDescription = string.Concat(ResourcesMaster.instance.bottlesColors.Count,
                                               " garrafas de um ", ResourcesMaster.GetColorDescription(),
                                               ", ", ResourcesMaster.GetDeviationDescription(),
                                               " e ", ResourcesMaster.GetQuantityDescription());

        descriptionDisplay.text = string.Concat("Parabéns!\n\nVocês produziram ", wineDescription, ", como ", percentString, "% dos vinhos produzidos");
        string tweet = string.Concat("Acabaram de produzir ", wineDescription, ". ", GetTotalWinesMade().ToString(), " vinhos já foram produzidos!");

        StartCoroutine(Twitter.API.PostTweet(tweet, CONSUMER_KEY, CONSUMER_SECRET, m_AccessTokenResponse, new Twitter.PostTweetCallback(this.OnPostTweet)));
    }
Beispiel #11
0
    private int GetWineIndex()
    {
        int quantityIndex  = ResourcesMaster.GetQuantityIndex();
        int colorIndex     = ResourcesMaster.GetColorIndex();
        int deviationIndex = ResourcesMaster.GetDeviationIndex();

        if (quantityIndex == 0 && colorIndex == 0 && deviationIndex == 0)
        {
            return(0);
        }
        else if (quantityIndex == 0 && colorIndex == 0 && deviationIndex == 1)
        {
            return(1);
        }
        else if (quantityIndex == 0 && colorIndex == 1 && deviationIndex == 0)
        {
            return(2);
        }
        else if (quantityIndex == 0 && colorIndex == 1 && deviationIndex == 1)
        {
            return(3);
        }
        else if (quantityIndex == 0 && colorIndex == 2 && deviationIndex == 0)
        {
            return(4);
        }
        else if (quantityIndex == 0 && colorIndex == 2 && deviationIndex == 1)
        {
            return(5);
        }
        else if (quantityIndex == 1 && colorIndex == 0 && deviationIndex == 0)
        {
            return(6);
        }
        else if (quantityIndex == 1 && colorIndex == 0 && deviationIndex == 1)
        {
            return(7);
        }
        else if (quantityIndex == 1 && colorIndex == 1 && deviationIndex == 0)
        {
            return(8);
        }
        else if (quantityIndex == 1 && colorIndex == 1 && deviationIndex == 1)
        {
            return(9);
        }
        else if (quantityIndex == 1 && colorIndex == 2 && deviationIndex == 0)
        {
            return(10);
        }
        else if (quantityIndex == 1 && colorIndex == 2 && deviationIndex == 1)
        {
            return(11);
        }
        else if (quantityIndex == 2 && colorIndex == 0 && deviationIndex == 0)
        {
            return(12);
        }
        else if (quantityIndex == 2 && colorIndex == 0 && deviationIndex == 1)
        {
            return(13);
        }
        else if (quantityIndex == 2 && colorIndex == 1 && deviationIndex == 0)
        {
            return(14);
        }
        else if (quantityIndex == 2 && colorIndex == 1 && deviationIndex == 1)
        {
            return(15);
        }
        else if (quantityIndex == 2 && colorIndex == 2 && deviationIndex == 0)
        {
            return(16);
        }
        else if (quantityIndex == 2 && colorIndex == 2 && deviationIndex == 1)
        {
            return(17);
        }

        Debug.Log("SHOULD NOT BE HERE!");
        return(17);
    }
Beispiel #12
0
 protected virtual void Awake()
 {
     generatedResource = ResourcesMaster.GetResourceData(generatedResourceName);
     requiredResource  = ResourcesMaster.GetResourceData(generatedResource.requiredResourceName);
 }