Example #1
0
 // Use this for initialization
 void Start()
 {
     _gameManager  = GameObject.Find("GameCtrl").GetComponent <GameManager>();
     _ballManager  = _gameManager._ballManager;
     _blockManager = _gameManager._blockManager;
     myType        = Const.ItemType.NONE;
 }
Example #2
0
    /// <summary>
    /// ItemTypeを決めるアルゴリズム
    /// </summary>
    /// <returns>The item type.</returns>
    Const.ItemType decideItemType()
    {
        int itemCounter = 0;

        Const.ItemType itemType = Const.ItemType.NONE;

        // 場に5個以上あるなら、アイテムを出さない。
        for (int i = 0; i < _blockList.Count; i++)
        {
            if (_blockList [i].getItemType() != Const.ItemType.NONE)
            {
                itemCounter++;
            }
            if (itemCounter >= ITEM_NUM)
            {
                return(itemType);
            }
        }

        // 確率でアイテムを出す
        float n          = Random.Range(0, total);
        float rate_value = 0;

        for (int i = 0; i < RATE_LIST.Count; i++)
        {
            rate_value += RATE_LIST [i];
            if (n <= rate_value)
            {
                itemType = (Const.ItemType)(i + 1);               // 0 : NONEなのでひとつずらす
                break;
            }
        }
        return(itemType);
    }
Example #3
0
    void setItemType(Block pBlock)
    {
        // ItemTypeを決定する
        Const.ItemType itemType = decideItemType();

        // ItemクラスにItemTypeを設定する
        pBlock.setItemType(itemType);

        // 色を変える
        pBlock.setBlockColor();
    }
Example #4
0
    /// <summary>
    /// ItemTypeの内容に応じて、ブロックの色を変更する
    /// </summary>
    public void setBlockColor()
    {
        Const.ItemType itemType = _item.getItemType();
        Color          color    = defColor;

        switch (itemType)
        {
        case Const.ItemType.ADD_BALL:
            color = Color.red;
            break;

        case Const.ItemType.HARD:
            color = Color.blue;
            break;

        case Const.ItemType.WIDER_RACKET:
            color = Color.cyan;
            break;

        case Const.ItemType.SHOT:
            color = Color.magenta;
            break;

        case Const.ItemType.SUPER_SHOT:
            color = Color.green;
            break;

        case Const.ItemType.FEVER:
            color = Color.black;
            break;

        case Const.ItemType.ADD_TIME:
            color = Color.yellow;
            break;

        default:
            color = defColor;
            break;
        }

        this.GetComponent <MeshRenderer> ().material.color = color;
    }
Example #5
0
 public void setItemType(Const.ItemType pItemType)
 {
     _item.setItemType(pItemType);
 }
Example #6
0
 public void setItemType(Const.ItemType pItemType)
 {
     myType = pItemType;
 }