コード例 #1
0
    public void ResetForGameStart()
    {
        resetNotUseBlockType();

        ResetControlBlockParameter();
        m_blockID = SelectNextBlockType();
    }
コード例 #2
0
    private void GetEnemyTarget()
    {
        //get column
        FieldBlockType column = m_Position.m_ColumnType;

        //get primary target
        FieldBlock block = m_Field.GetBlockByPosition(m_Row, column);

        //check if extend
        if (m_EnemyExtend && block.m_Unit == null)
        {
            if (column != FieldBlockType.Middle)
            {
                block = m_Field.GetCouple(block);
            }
            else
            {
                block = m_Field.GetBlocksOfLine(FieldBlockType.Center)[0];
            }
        }

        //add block
        m_Blocks.Add(block);

        //check if include adjcent blocks
        if (m_Adjcent)
        {
            m_Blocks.AddRange(m_Field.GetBlockBeside(block));
        }
    }
コード例 #3
0
    public cTetrisManager(GameObject rendererObject)
    {
        m_blockManager = new ControlBlockManager();

        m_field = new FieldBlockType[cTetrisParam.MAP_HEIGHT, cTetrisParam.MAP_WIDTH];

        m_blockRenderer = rendererObject.GetComponent <BlockRenderer> ();
        m_blockRenderer.Initialize(cTetrisParam.MAP_WIDTH, cTetrisParam.MAP_HEIGHT);

        m_blockMoveModeChangeTime_s = 0.0f;
        m_blockMoveDeltaTime_s      = 0.0f;

        BLOCK_FALL_TIME_MAX_SEC = cTetrisParam.BLOCK_FALL_TIME_MAX_SEC_DEFAULT;

        m_blockFallDeltaTime = 0.0f;

        m_waitUpDownArrowKey = false;

        resetFieldState();

        setEnableGameObject();

        resetControlBlockParameter();

        m_blockManager.ResetForGameStart();

        m_blockRenderer.SetRenderNextBlock(
            m_blockManager.GetNextBlock(), m_blockManager.GetNextBlockType());
    }
コード例 #4
0
ファイル: BlockRenderer.cs プロジェクト: kuroneko3/tetris
    public void SetRenderBlockFallPosition(int blockLeft, int blockTop, Block block, FieldBlockType blockType)
    {
        Color cr = selectColor(blockType);

        cr.a = COLOR_ALPHA_FALL_ESTIMATE;

        SetRenderBlock(blockLeft, blockTop, block, cr);
    }
コード例 #5
0
    public static List <RankUpCondition> GetAllConditions(UnitData data1, UnitData data2, FieldBlock block)
    {
        List <RankUpCondition> conditions = new List <RankUpCondition>();

        if (data1.m_Owner.m_PlayerID != data2.m_Owner.m_PlayerID)
        {
            return(conditions);
        }

        //add all rank ups from Spirit 1
        conditions.AddRange(data1.m_RankUps);

        //add rank ups with sacrifice from Spirit 2
        foreach (RankUpCondition rankUp in data2.m_RankUps)
        {
            if (rankUp.m_Sacrifice)
            {
                conditions.Add(rankUp);
            }
        }

        PlayerID id     = data1.m_Owner.m_PlayerID;
        Player   player = PlayerManager.Instance.GetPlayer(id);

        int currentMana = player.m_Mana.currentMana;

        FieldBlockType type = block.m_RowType;

        for (int i = conditions.Count - 1; i >= 0; i--)
        {
            UnitData data = conditions[i].m_HighRankSpirit;

            //unique
            if (!player.CheckUniqueUnit(data))
            {
                conditions.RemoveAt(i);
            }
            //mana
            else if (data.m_Cost > currentMana)
            {
                conditions.RemoveAt(i);
            }
            //position
            else if ((type == FieldBlockType.Front && !data.CanBeFrontline) || (type == FieldBlockType.Back && !data.CanBeBackline))
            {
                conditions.RemoveAt(i);
            }
            //condition
            else if (!conditions[i].Check(data1, data2))
            {
                conditions.RemoveAt(i);
            }
        }

        return(conditions);
    }
コード例 #6
0
 public FieldBlock GetBlockByPosition(FieldBlockType row, FieldBlockType column)
 {
     foreach (FieldBlock block in m_blocks)
     {
         if (block.m_RowType == row && block.m_ColumnType == column)
         {
             return(block);
         }
     }
     return(null);
 }
コード例 #7
0
 private FieldBlock CheckLine(FieldBlock block, FieldBlockType lineToCheck, FieldBlockType lineToReturn)
 {
     FieldBlock[] blocks = m_lines[lineToCheck];
     for (int i = 0; i < blocks.Length; i++)
     {
         if (blocks[i] == block)
         {
             return(m_lines[lineToReturn][i]);
         }
     }
     return(null);
 }
コード例 #8
0
    protected override void ConcreteGather()
    {
        if (m_SameColumnAsSourceUnit && !m_SameRowAsSourceUnit)
        {
            m_LineType = m_Position.m_ColumnType;
        }
        else if (!m_SameColumnAsSourceUnit && m_SameRowAsSourceUnit)
        {
            m_LineType = m_Position.m_RowType;
        }

        m_Blocks.AddRange(m_Field.GetBlocksOfLine(m_LineType));
    }
コード例 #9
0
        private void GetEmptyBlock(FieldController field, FieldBlockType line, ref FieldBlock block)
        {
            List <FieldBlock> blocks = field.GetBlocksOfLine(line);

            foreach (FieldBlock b in blocks)
            {
                if (b.m_Unit == null)
                {
                    block = b;
                    return;
                }
            }
            block = null;
        }
コード例 #10
0
ファイル: BlockRenderer.cs プロジェクト: kuroneko3/tetris
    //	ブロックのタイプから色を選択する.
    private Color selectColor(FieldBlockType blockType)
    {
        switch (blockType)
        {
        case FieldBlockType.VANISH:

            if (m_vanishEffectTime_s < 0.0f)
            {
                return(new Color(1.0f, 1.0f, 1.0f, 0.0f));
            }
            //	return new Color( 1.0f, 1.0f, 1.0f, m_vanishEffectTime_s / EFFECT_VANISH_TIME_MAX_SEC );
            return(Color.white * m_vanishEffectTime_s / EFFECT_VANISH_TIME_MAX_SEC);

        case FieldBlockType.WALL:
            return(Color.gray);

        case FieldBlockType.LINE:
            return(Color.red);

        case FieldBlockType.BUMP:
            return(new Color(0.3f, 0.5f, 0.8f));

        case FieldBlockType.L_REVERSE:
            return(Color.blue);

        case FieldBlockType.L:
            return(new Color(0.8f, 0.5f, 0.3f));

        case FieldBlockType.S_REVERSE:
            return(Color.green);

        case FieldBlockType.S:
            return(new Color(0.8f, 0.3f, 0.5f));

        case FieldBlockType.SQUARE:
            return(Color.yellow);

        default:
            return(Color.white);
        }
    }
コード例 #11
0
    private FieldBlockType SelectNextBlockType()
    {
        if (m_notUsedBlockMax == 0)
        {
            resetNotUseBlockType();
        }

        int randValue = Random.Range(0, m_notUsedBlockMax);

        FieldBlockType retValue = m_notUsedBlockID [randValue];

        --m_notUsedBlockMax;

        for (int i = randValue; i < m_notUsedBlockMax; ++i)
        {
            m_notUsedBlockID[i] = m_notUsedBlockID[i + 1];
        }

        return(retValue);

        //	return (FieldBlockType)Random.Range( 0, (int)FieldBlockType.ENUM_FIELD_BLOCK_TYPE_END );
    }
コード例 #12
0
    public void SetRenderNextBlock(Block block, FieldBlockType blockType)
    {
        ResetRenderNextBlock();

        Color cr = selectColor(blockType);

        for (int i = 0; i < block.m_blockMapSize; ++i)
        {
            for (int j = 0; j < block.m_blockMapSize; ++j)
            {
                GameObject obj = m_nextControlBlockObject[j, i];

                if (block.m_blockMap[j, i])
                {
                    obj.SetActive(true);

                    obj.renderer.material.color = cr;
                }
            }
        }

        m_drawNext = true;
    }
コード例 #13
0
    public List <FieldBlock> GetBlockBeside(FieldBlock block)
    {
        if (m_PlayerID != block.m_PlayerID)
        {
            return(null);
        }

        List <FieldBlock> blocks = new List <FieldBlock>();

        FieldBlockType row = block.m_RowType;

        if (block.m_ColumnType == FieldBlockType.Middle)
        {
            blocks.Add(GetBlockByPosition(row, FieldBlockType.Left));
            blocks.Add(GetBlockByPosition(row, FieldBlockType.Right));
        }
        else
        {
            blocks.Add(GetBlockByPosition(row, FieldBlockType.Middle));
        }

        return(blocks);
    }
コード例 #14
0
    public static bool CheckPosition(UnitData data, FieldBlock block)
    {
        if (block.m_Unit != null)
        {
            return(false);
        }

        FieldBlockType type = block.m_RowType;

        if (type == FieldBlockType.Front && !data.CanBeFrontline)
        {
            return(false);
        }
        else if (type == FieldBlockType.Back && !data.CanBeBackline)
        {
            return(false);
        }
        else if (type == FieldBlockType.Center && !data.IsWarrior)
        {
            return(false);
        }

        return(true);
    }
コード例 #15
0
 public void ResetControlBlockParameter()
 {
     m_blockID     = m_nextBlockID;
     m_nextBlockID = SelectNextBlockType();
     m_blockSpinID = 0;
 }
コード例 #16
0
ファイル: BlockRenderer.cs プロジェクト: kuroneko3/tetris
 public void SetRenderBlock(int blockLeft, int blockTop, Block block, FieldBlockType blockType)
 {
     SetRenderBlock(blockLeft, blockTop, block, selectColor(blockType));
 }
コード例 #17
0
 public List <FieldBlock> GetBlocksOfLine(FieldBlockType line)
 {
     return(m_lines[line].ToList());
 }