Exemplo n.º 1
0
    private void ComputeSurface(bool sort)
    {
        if (sort)
        {
            mSurfaceCache.Sort();
        }

        //recompute water surface level
        mBuoyancy.surfaceLevel = mSurfaceBaseLevel;

        for (int i = 0; i < mSurfaceCache.Count; i++)
        {
            mSurfaceCache[i].AddSurfaceLevel(this);
        }

        if (mBuoyancy.surfaceLevel > mColl.size.y)
        {
            mBuoyancy.surfaceLevel = mColl.size.y;
        }

        //apply top and fill telemetry
        if (topRoot)
        {
            Vector2 topPos = topRoot.localPosition;
            topPos.y = mBuoyancy.surfaceLevel;
            topRoot.transform.localPosition = topPos;
        }

        if (fillRoot)
        {
            Vector3 fillScale = fillRoot.localScale;
            fillScale.y         = mBuoyancy.surfaceLevel;
            fillRoot.localScale = fillScale;
        }
    }
Exemplo n.º 2
0
    void OnGameChangeMode(GameMapController.Mode mode)
    {
        switch (mode)
        {
        case GameMapController.Mode.Play:
            ClearDragging();

            //deploy active ghosts
            mGhostActives.Sort();

            for (int i = 0; i < mGhostActives.Count; i++)
            {
                var ghostBlock = mGhostActives[i];
                if (ghostBlock && !ghostBlock.isReleased)
                {
                    ghostBlock.dimensionChangedCallback -= OnGhostBlockDimensionChanged;
                    ghostBlock.releaseCallback          -= OnGhostBlockRelease;

                    if (ghostBlock.EditIsPlacementValid())
                    {
                        ghostBlock.mode = Block.Mode.Solid;
                    }
                    else
                    {
                        mGhostMatterCount -= ghostBlock.matterCount;

                        ghostBlock.Release();
                    }
                }
            }

            mGhostActives.Clear();

            GameMapController.instance.PaletteChange(blockName, -mGhostMatterCount);

            mGhostMatterCount = 0;
            //

            UpdateCount();
            break;
        }

        UpdateInteractible();
    }
Exemplo n.º 3
0
    private int GenerateSolution(int newNumber)
    {
        int num1, num2;

        switch (curRoundOp)
        {
        case OperatorType.Multiply:
            //check if any number is divisible by another
            for (int i = 0; i < mCheckNumbers.Count; i++)
            {
                num1 = mCheckNumbers[i];
                for (int j = 0; j < mCheckNumbers.Count; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }

                    num2 = mCheckNumbers[j];

                    if (IsWholeDivisible(num1, num2))
                    {
                        return(num1 / num2);
                    }
                    else if (IsWholeDivisible(num2, num1))
                    {
                        return(num2 / num1);
                    }
                }
            }

            //check if any numbers can be multiplied by any of tableNumbers
            for (int i = 0; i < mCheckNumbers.Count; i++)
            {
                num1 = mCheckNumbers[i];
                for (int j = 0; j < mCheckNumbers.Count; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }

                    num2 = mCheckNumbers[j];

                    var tableNumberInd = GetTableNumberIndexMultiple(num1, num2);
                    if (tableNumberInd != -1)
                    {
                        return(tableNumbers[tableNumberInd]);
                    }
                }
            }

            //spawn a solution to the multiples of two lowest number
            if (mCheckNumbers.Count >= 2)      //fail-safe
            {
                mCheckNumbers.Sort();
                return(mCheckNumbers[0] * mCheckNumbers[1]);
            }
            break;

        case OperatorType.Divide:
            //check if any number can be divisible by tableNumber
            for (int i = 0; i < mCheckNumbers.Count; i++)
            {
                num1 = mCheckNumbers[i];
                for (int j = 0; j < mCheckNumbers.Count; j++)
                {
                    if (j == i)
                    {
                        continue;
                    }

                    num2 = mCheckNumbers[j];

                    var tableNumberInd = GetTableNumberIndexDivisible(num1, num2);
                    if (tableNumberInd != -1)
                    {
                        return(tableNumbers[tableNumberInd]);
                    }
                }
            }

            //grab two lowest number, and multiply
            mCheckNumbers.Sort();
            num1 = mCheckNumbers[0];
            if (num1 <= 10)
            {
                for (int i = 1; i < mCheckNumbers.Count; i++)
                {
                    num2 = mCheckNumbers[i];
                    if (num2 <= 10)
                    {
                        return(num1 * num2);
                    }
                }
            }

            return(mCheckNumbers[0] * mCheckNumbers[1]);
        }

        return(newNumber);
    }