Exemplo n.º 1
0
    public override void GameInit()
    {
        this.mode  = (MODE)(Random.Range(1, 3));
        this.limit = Random.Range(3, 6);
        List <int> intList = new List <int> ();

        for (int i = 1; i <= GRID_COUNT; i++)
        {
            if (i <= this.limit)
            {
                intList.Add(i);
            }
            else
            {
                intList.Add(0);
            }
        }

        int[] intArr = this.Shuffle(intList.ToArray());


        // instance
        foreach (int number in intArr)
        {
            GMButtonCommon btn = Util.InstantiateComponent <GMButtonCommon>(this.prefabNumber, this.gridNumbers.transform);
            if (number.Equals(0))
            {
                btn.gameObject.SetActive(false);
                continue;
            }
            btn.InitCallBack(this.OnClickItem);
            btn.SetLabel(number.ToString());
            btn.SetParam(number);
            if (this.mode.Equals(MODE.HIGH))
            {
                btn.SetColor(DEFINE.COLOR_ID.GREEN);
            }
            else
            {
                btn.SetColor(DEFINE.COLOR_ID.RED);
            }
        }
        if (this.mode.Equals(MODE.HIGH))
        {
            this.currentNum = this.limit + 1;
        }
        else
        {
            this.currentNum = 0;
        }
        base.GameInit();
    }
Exemplo n.º 2
0
    public override void GameInit()
    {
        int listCount = 9;
        int randomMin = 1;
        int randomMax = 9;
        int resultMin = 10;

        randomMin    = Mgrs.gameMgr.gameSpeed;
        resultMin    = 10 - DEFINE.SPEED_MAX - Mgrs.gameMgr.gameSpeed;
        this.intList = new List <int> ();
        for (int i = 0; i < listCount; i++)
        {
            int random = Random.Range(randomMin, randomMax);
            intList.Add(random);
        }

        // 和の抽選
        int lotteryCount = Random.Range(2, 3);

        this.resultSum = 0;
        List <int> lotteryIdxList = new List <int> ();

        do
        {
            int idx = Random.Range(0, listCount);
            if (!lotteryIdxList.Contains(idx))
            {
                lotteryIdxList.Add(idx);
                this.resultSum += intList[idx];
            }
        }while(lotteryIdxList.Count < lotteryCount || this.resultSum <= resultMin);

        // instance
        foreach (int number in this.intList)
        {
            GMButtonCommon btn = Util.InstantiateComponent <GMButtonCommon>(this.prefabNumber, this.gridNumbers.transform);
            btn.InitCallBack(this.OnClickItem);
            btn.SetLabel(number.ToString());
            btn.SetParam(number);
            btn.SetColor(DEFINE.COLOR_ID.RED);
        }
        this.currentSum = 0;
        base.GameInit();
    }