Exemplo n.º 1
0
    // Update a Carafe at the defined position (update volume and color)
    private void UpdateCarafeInPosition(carafeObject carafeToUpdate, int xx, int yy)
    {
        GameObject go;
        GameObject currentCarafe;

        currentCarafe = allTheCarafes[xx, yy];
        go            = (GameObject)Instantiate(getCorrectObjWithVolume(carafeToUpdate.getCarafeVolume(), carafeToUpdate.getCarafeType()), currentCarafe.transform.position, transform.rotation);
        DestroyObject(currentCarafe);
        allTheCarafes[xx, yy] = go;

        // Set the correct color to the object
        sr       = (SpriteRenderer)go.GetComponentsInChildren <SpriteRenderer>()[1];
        sr.color = getSpriteColor(carafeToUpdate.getCarafeColor());
    }
Exemplo n.º 2
0
    // Initialization
    void Start()
    {
        GameObject   myLocalCarafeObject;
        carafeObject theCarafe;
        Vector2      vect2;
        bool         bAcidAlready = false;

        // Set the start time according to difficulty level
        myUniqueController.InitializeStarTime();

        // Load the images
        spriteObject = (Sprite[])Resources.LoadAll <Sprite>("carafe-map-final");

        // Create the carafeFinalTarget
        int targetVolume;

        if (myUniqueController.getGameMode() == AllGameParameters.GAME_MODE_UNLIMITED)
        {
            do
            {
                targetVolume = getRandomVolume();
            } while (targetVolume == AllGameParameters.VOLUME_0);

            theFinalCarafeTarget = new carafeFinalObject(getRandomColorRGB(), targetVolume, AllGameParameters.LIQUID_TYPE_WATER);
        }
        else
        {
            theFinalCarafeTarget = myLevelsData.theFinalCarafeLevel[myUniqueController.getCurrenLevel()];
        }
        if (theFinalCarafeTarget == null)
        {
            Debug.LogError("theFinalCarafeTarget=" + theFinalCarafeTarget);
        }

        // Set the correct sprite for Final Carafe Target
        UpdateFinalCarafeTarget();

        // Create all the cases
        theCases = new caseObject[AllGameParameters.ECHIQUIER_COLUMNS, AllGameParameters.ECHIQUIER_LINES];

        // Create all the Carafe objects (one per each case)
        allTheCarafes = new GameObject[AllGameParameters.ECHIQUIER_COLUMNS, AllGameParameters.ECHIQUIER_LINES];

        // If UNLIMITED mode, all is random
        for (int column = 0; column < AllGameParameters.ECHIQUIER_COLUMNS; column++)
        {
            for (int line = 0; line < AllGameParameters.ECHIQUIER_LINES; line++)
            {
                posInEchiquier_t pos;

                pos.x = column;
                pos.y = line;

                if (myUniqueController.getGameMode() == AllGameParameters.GAME_MODE_UNLIMITED)
                {
                    int rndType   = getRandomType();
                    int rndColor  = getRandomColor();
                    int rndVolume = getRandomVolume();

                    // Type cannot be wall if position is next to Target Carafe (otherwise, the game is blocked)
                    if (column == (AllGameParameters.ECHIQUIER_COLUMNS - 1) && (line == (AllGameParameters.ECHIQUIER_LINES - 1)))
                    {
                        rndType = AllGameParameters.LIQUID_TYPE_WATER;
                    }

                    // There can be only 1 acid in the game
                    if (rndType == AllGameParameters.LIQUID_TYPE_ACID)
                    {
                        if (bAcidAlready == true)
                        {
                            rndType = AllGameParameters.LIQUID_TYPE_WATER;
                        }
                        else
                        {
                            bAcidAlready = true;
                            rndColor     = AllGameParameters.CARAFE_WHITE;
                            rndVolume    = AllGameParameters.VOLUME_NEGATIF;
                        }
                    }

                    // determine random carafe
                    theCarafe = new carafeObject(rndColor, rndType, rndVolume, pos, AllGameParameters.GRAPHICAL_TYPE_STANDARD);
                }
                else
                {
                    // Set objects according to level
                    theCarafe = myLevelsData.theLevelCases[myUniqueController.getCurrenLevel(), column, line].getCaseCarafe();
                    if (theCarafe == null)
                    {
                        Debug.LogError("theCarafe=" + theFinalCarafeTarget);
                    }
                }

                theCases[column, line] = new caseObject(true, theCarafe);

                // Instantiate the Liquid objects (according to their volume)
                vect2 = getRealPos(column, line);
                myLocalCarafeObject = (GameObject)Instantiate(getCorrectObjWithVolume(theCarafe.getCarafeVolume(), theCarafe.getCarafeType()), vect2, transform.rotation);
                if (myLocalCarafeObject == null)
                {
                    Debug.LogError("ERROR myLocalCarafeObject");
                }

                // Set the correct color to the object
                sr       = (SpriteRenderer)myLocalCarafeObject.GetComponentsInChildren <SpriteRenderer>()[1];
                sr.color = getSpriteColor(theCarafe.getCarafeColor());

                // Set the carafes
                allTheCarafes[column, line] = myLocalCarafeObject;
            }
        }

        // Check if there is at least one red, one green and one blue, if not start again
        if (checkGameColors() == false)
        {
            //goto setEachCarafeInTheGame;
            SceneManager.LoadScene("Main");
        }

        // Set the FinaleCarafe Object (empty)
        theFinalCarafe = new carafeFinalObject(AllGameParameters.CARAFE_RED, AllGameParameters.VOLUME_0, AllGameParameters.LIQUID_TYPE_WATER);

        // Initialize positions outside the Echiquier
        clickPosDown = resetPosition();
        clickPosUp   = resetPosition();

        // Set the start time
        myUniqueController.InitializeT0();

        // Start the time
        Time.timeScale = 1f;
    }
Exemplo n.º 3
0
 //////////////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////////////
 ///
 public caseObject(bool bOccupied, carafeObject theCarafe)
 {
     this.bOccupied = bOccupied;
     this.theCarafe = theCarafe;
 }