void RandomCenter()
    {
        int totalBlues   = maxHeight / 2;
        int totalYellows = maxHeight / 2;
        int randNum;

        for (int i = 0; i < center.Length; i++)
        {
            randNum = MMath.GetRandomInt(1, 3);

            //Equal Random
            if (totalBlues <= 0)
            {
                randNum = 2;
            }
            else if (totalYellows <= 0)
            {
                randNum = 1;
            }

            if (randNum == 1)
            {
                totalBlues -= 1;
            }
            if (randNum == 2)
            {
                totalYellows -= 1;
            }

            center[i] = randNum;
        }
    }
예제 #2
0
    // Update is called once per frame
    public void OnUpdate()
    {
        if (failed == true)
        {
            float dt = FrameController.DT();
            failTime -= dt;

            if (failTime <= 1.0f)
            {
                if (failTime < 0.0f) // Time to reset to show starting button color
                {
                    failed      = false;
                    failTime    = 2.5f;
                    randomTimer = 0.0f;
                    Reset();
                }
                else // Flashing random button colors to animate resetting
                {
                    randomTimer += dt;
                    if (randomTimer >= timeToRandomise)
                    {
                        randomTimer -= timeToRandomise;

                        // Reset all to white
                        for (int i = 0; i < maxHeight; i++)
                        {
                            int color = MMath.GetRandomInt(1, 3); // [1,2]
                            center[i] = color;
                        }
                        RefreshColorsOnBlocks(false);
                    }
                }
            }
        }
    }
예제 #3
0
    public static float GetMovementZFloat()
    {
        if (MMath.GetRandomInt(0, 500) == 5)
        {
            mz_orient = !mz_orient;
        }

        if (mz_orient == false)
        {
            return(MMath.GetRandomLimitedFloat(-1.0f, 0.0f));
        }
        return(MMath.GetRandomLimitedFloat(0.0f, 1.0f));
    }
    public Vector3 SpawnZone(uint row, uint col)
    {
        if (col >= mCols || row >= mRows)
        {
            return(new Vector3());
        }
        else
        {
            List <uint> indices = new List <uint>();

            if (CheckIndex(row + 1, col))
            {
                indices.Add(GetIndex(row + 1, col));
            }
            if (CheckIndex(row, col + 1))
            {
                indices.Add(GetIndex(row, col + 1));
            }
            if (CheckIndex(row - 1, col))
            {
                indices.Add(GetIndex(row - 1, col));
            }
            if (CheckIndex(row, col - 1))
            {
                indices.Add(GetIndex(row, col - 1));
            }

            if (indices.Count == 0)
            {
                return(new Vector3());
            }
            else
            {
                int index         = MMath.GetRandomInt(0, indices.Count - 1);
                int deathPanelIdx = (int)indices[index];

                //faceTransform.LookAt(Common.GetStealthPlayer().transform.GetPosition(CTransform.TransformSpace.GLOBAL
                //Vector3 spawnPoint
                return(mDeathPanels[deathPanelIdx].gameObject.transform.GetPosition(CTransform.TransformSpace.GLOBAL));
            }
        }
    }
    void RandomizePanels()
    {
        mPanelNumbers.Clear();
        mPanelNumbers.Add(0); // always have first big panel safe
        for (int i = 0; i < mRows * mCols; ++i)
        {
            mPanelNumbers.Add(-1);                  // -1 means empty
        }
        mPanelNumbers.Add((int)mSequenceTotal + 1); // always have last big panel hold the last number

        // Must start with first row
        uint rowIndex = 0;
        uint colIndex = (uint)MMath.GetRandomInt(0, mCols);

        RecursiveSelectPanels(rowIndex, colIndex, 1, mSequenceTotal, ref mPanelNumbers);
        // Assign the numbers to the panels
        for (int i = 0; i < mDeathPanels.Count; ++i)
        {
            mDeathPanels[i].SetNumber(mPanelNumbers[i], i);
            //Logger.Log("num: " + mPanelNumbers[i].ToString());
        }
    }
    // Dead State
    public void State_Dead_Enter()
    {
        deadTimer          = totalTimeToDie;
        deadForwardVector  = gameObject.transform.GetForwardVector();
        deathAngleToRotate = MMath.GetRandomInt(0, 2) == 0 ? -80.0f : 80.0f; // randomise ccw or cw

        // Fade out Oculus screen to black
        fadeState   = 1;
        fadeOpacity = 0.0f;

        // deadX = gameObject.transform.position.x;
        // deadY = gameObject.transform.position.y;
        // deadR = gameObject.transform.rotation.Angles.z;

        // CLight cl = gameObject.RequireComponent<CLight>();
        // cl.SetLightType(0);
        // cl.SetRange(300.0f);
        // cl.SetSpot(10.0f);
        // cl.mInnerAngle = 10.0f;
        // cl.mOuterAngle = 200.0f;
        // cl.SetDiffuse(new Color(1.0f, 0.0f, 0.0f));
        // cl.SetAtt(20.0f);
    }
예제 #7
0
    void State_Stalking_Start()
    {
        //turn on the mesh and move him near the player
        //cmesh.setEnabled(true);
        //find somewhere near the player to spawn
        STALK_RANGE = DEFAULT_STALK_RANGE;
        for (int times_to_attempt_spawn = 0; times_to_attempt_spawn <= 5; ++times_to_attempt_spawn)
        {
            gameObject.transform.SetPosition(MMath.GetRandomPointInCircle(stealth_player.transform.position, STALK_RANGE));
            if (!helper.CheckLights(gameObject))
            {
                break;
            }
            STALK_RANGE += 5.0f;
            if (times_to_attempt_spawn == 5)
            {
                smc.SetState(resetting);
            }
        }

        stalk_dir = MMath.GetRandomInt(0, 2);

        sound.PlayIndependentEvent("C1_CLOSE_LOOP.vente", false, 2);
    }
    public void TriggerColumnLights(uint col)
    {
        // deactivating flicker
        foreach (CLight obj in _allLights)
        {
            obj.setEnabled(true);
            //LightFlickerTemp script = GetScript<LightFlickerTemp>(obj.gameObject);
            //
            //if(script != null)
            //    script.activated = false;
        }
        flickeringLights.Clear();

        switch (col)
        {
        case 0:

            // Flicker on col 1


            // Flicker on col 3

            _col1Lights[MMath.GetRandomInt(0, _col1Lights.Count - 1)].setEnabled(false);

            _col3Lights[MMath.GetRandomInt(0, _col3Lights.Count - 1)].setEnabled(false);
            break;


        case 1:

            // Flicker on col 0

            // Flicker on col 2

            _col0Lights[MMath.GetRandomInt(0, _col0Lights.Count - 1)].setEnabled(false);

            _col2Lights[MMath.GetRandomInt(0, _col2Lights.Count - 1)].setEnabled(false);

            break;

        case 2:

            // Flicker on col 3
            //flickeringLights.Add(_col3Lights[ MMath.GetRandomInt(0, _col3Lights.Count - 1) ] );
            // Flicker on col 0
            //flickeringLights.Add(_col0Lights[ MMath.GetRandomInt(0, _col0Lights.Count - 1) ] );
            _col3Lights[MMath.GetRandomInt(0, _col3Lights.Count - 1)].setEnabled(false);

            _col0Lights[MMath.GetRandomInt(0, _col0Lights.Count - 1)].setEnabled(false);
            break;

        case 3:

            // Flicker on col 1
            //flickeringLights.Add(_col1Lights[ MMath.GetRandomInt(0, _col1Lights.Count - 1) ] );
            // Flicker on col 2


            _col1Lights[MMath.GetRandomInt(0, _col1Lights.Count - 1)].setEnabled(false);

            _col2Lights[MMath.GetRandomInt(0, _col2Lights.Count - 1)].setEnabled(false);
            break;
        }

        foreach (CLight obj in flickeringLights)
        {
            obj.setEnabled(false);
            //LightFlickerTemp script = GetScript<LightFlickerTemp>(obj.gameObject);
            //if (script != null)
            //    script.activated = true;
        }
        distortScript.Trigger();
    }
 bool TriggerChance()
 {
     return(MMath.GetRandomInt(0, 10) < 10);
 }
    bool RecursiveSelectPanels(uint currRow, uint currCol, uint currSeq, uint totalSeq,
                               ref List <int> panelBoard)
    {
        panelBoard[(int)GetIndex(currRow, currCol)] = (int)currSeq++; // Set the curr tile to this number
        if (currSeq > totalSeq)                                       // Finished getting sequence
        {
            // Check if this last tile is at the last row (sequence must end at last row)
            if (currRow == mRows - 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }

        // Try all directions, and save those that are possible
        List <uint> availableDirections = new List <uint>();

        for (int i = 0; i < (int)DIRECTIONS.NUM_DIRECTIONS; ++i)
        {
            uint rowIndex = currRow;
            uint colIndex = currCol;

            switch (i)
            {
            case (int)DIRECTIONS.T: --rowIndex; break;

            case (int)DIRECTIONS.L: --colIndex; break;

            case (int)DIRECTIONS.R: ++colIndex; break;

            case (int)DIRECTIONS.B: ++rowIndex; break;
            }
            if (rowIndex >= mRows)
            {
                continue;
            }
            if (colIndex >= mCols)
            {
                continue;
            }
            if (panelBoard[(int)GetIndex(rowIndex, colIndex)] != -1) // If already occupied, try another direction
            {
                continue;
            }

            availableDirections.Add(GetIndex(rowIndex, colIndex));
        }
        if (availableDirections.Count == 0) // No available moves from this tile
        {
            return(false);
        }

        // Test all the possible moves
        for (int i = 0; i < availableDirections.Count;)  // Don't need to reduce i
        {
            int randomChoice = MMath.GetRandomInt(0, availableDirections.Count);

            uint positionIndex = availableDirections[randomChoice];
            uint nextRow       = GetRow(positionIndex);
            uint nextCol       = GetCol(positionIndex);

            // If this returned a good board
            if (RecursiveSelectPanels(nextRow, nextCol, currSeq, totalSeq, ref panelBoard))
            {
                return(true);
            }
            // Remove that move from the board
            panelBoard[(int)GetIndex(nextRow, nextCol)] = -1;

            availableDirections.RemoveAt(randomChoice); // Remove that move once tried
        }
        return(false);
    }