Ejemplo n.º 1
0
    public void CreateBlock(BlockParameter block)
    {
        if (!m_fieldManager.CheckBlock(m_generatePoint))
        {
            // オブジェクト作成
            BlockParameter go = new BlockParameter();
            go = Instantiate(block, transform);
            go.transform.parent        = m_fieldManager.gameObject.transform;
            go.transform.localPosition = new Vector3(m_generatePoint.x, -m_generatePoint.y);
            go.FieldManager            = m_fieldManager;
            go.SetPosition(m_generatePoint.x, m_generatePoint.y);

            m_fieldManager.RegisterBlock(go, m_generatePoint.x, m_generatePoint.y);
        }
    }
Ejemplo n.º 2
0
    private void Start()
    {
        var firldManager = GetComponent <FieldManager>();

        for (int i = 0; i < m_field.Count; i++)
        {
            List <BlockParameter> blockLine = new List <BlockParameter>();
            for (int j = 0; j < m_field[i].Count; j++)
            {
                BlockParameter block = new BlockParameter();
                switch (m_field[i][j])
                {
                case 1:
                    // ショット砲作成
                    block = Instantiate(m_shot, transform);
                    block.transform.localPosition = new Vector3(j, -i);
                    block.FieldManager            = firldManager;
                    block.SetPosition(j, i);
                    blockLine.Add(block);
                    break;

                case 2:
                    // レーザー砲作成
                    block = Instantiate(m_laser, transform);
                    block.transform.localPosition = new Vector3(j, -i);
                    block.FieldManager            = firldManager;
                    block.SetPosition(j, i);
                    blockLine.Add(block);
                    break;

                case 3:
                    // シールド作成
                    block = Instantiate(m_shield, transform);
                    block.transform.localPosition = new Vector3(j, -i);
                    block.FieldManager            = firldManager;
                    block.SetPosition(j, i);
                    blockLine.Add(block);
                    break;

                case 4:
                    // プレイヤー作成
                    block = Instantiate(m_player, transform);
                    block.transform.localPosition = new Vector3(j, -i);
                    block.FieldManager            = firldManager;
                    block.SetPosition(j, i);
                    blockLine.Add(block);
                    break;

                case 9:
                    // 生成する座標を設定する
                    ServiceLocator.Locator.GetBlockGenerator().RegisterPoint(new Vector2Int(j, i));
                    break;

                default:
                    blockLine.Add(null);
                    break;
                }
            }
            firldManager.Blocks.Add(blockLine);
        }
    }