Пример #1
0
    public void checkBlock()
    {
        Blockdata main_block = GameObject.Find("main_block").GetComponent <Blockdata>();
        int       cnt        = 0;

        for (int y = 0; y < iBlockY; y++)
        {
            for (int x = 0; x < iBlockX; x++)
            {
                if (BlockBoard[y][x].GetComponent <block>().state == 1)
                {
                    BlockBoard[y][x].GetComponent <block>().state  = 3;
                    BlockBoard[y][x].GetComponent <block>().hp     = main_block.getHp();
                    BlockBoard[y][x].GetComponent <block>().resist = main_block.getResist();
                    BlockBoard[y][x].GetComponent <block>().speed  = main_block.getSpeed();
                    BlockBoard[y][x].GetComponent <block>().iType  = main_block.iType;
                    BlockBoard[y][x].GetComponent <Image>().sprite = blockManager.BlockType[main_block.iType];
                    BlockBoard[y][x].GetComponent <Image>().color  = new Color(1, 1, 1);
                }
                else if (BlockBoard[y][x].GetComponent <block>().state == 4)
                {
                    cnt++;
                    BlockBoard[y][x].GetComponent <block>().state  = 5;
                    BlockBoard[y][x].GetComponent <Image>().sprite = blockManager.mainBlockType[main_block.iType];
                    BlockBoard[y][x].GetComponent <Image>().color  = new Color(1, 1, 1);
                }
                else if (BlockBoard[y][x].GetComponent <block>().state == 6)
                {
                    print("겹침");
                    BlockBoard[y][x].GetComponent <block>().state   = 3;
                    BlockBoard[y][x].GetComponent <block>().hp     += main_block.getHp() + BlockBoard[y][x].GetComponent <block>().hp / 10;
                    BlockBoard[y][x].GetComponent <block>().resist += main_block.getResist() + BlockBoard[y][x].GetComponent <block>().resist / 10;
                    BlockBoard[y][x].GetComponent <block>().speed   = (main_block.getSpeed() + BlockBoard[y][x].GetComponent <block>().speed) / 2 + BlockBoard[y][x].GetComponent <block>().speed / 5;
                    BlockBoard[y][x].GetComponent <Image>().color  -= new Color(20 / 255f, 80 / 255f, 80 / 255f, 0);

                    if (ParticleBoard[y][x] == null && BlockBoard[y][x].GetComponent <block>().hp > 200)
                    {
                        ParticleBoard[y][x] = Instantiate(specialLight, new Vector3(0, 0, 0), Quaternion.identity);
                        ParticleBoard[y][x].transform.SetParent(blockParent.transform);
                        ParticleBoard[y][x].transform.localPosition = BlockBoard[y][x].transform.localPosition + new Vector3(0, 0, -10000);
                        ParticleBoard[y][x].transform.localScale    = new Vector3(100, 100, 178);
                        ParticleBoard[y][x].GetComponent <ParticleSystem>().startColor -= new Color(0, 80 / 255f, 80 / 255f, 0);
                    }
                }
            }
        }

        if (cnt > 0)
        {
            Transform[] childList = mainblock.GetComponentsInChildren <Transform>(true);
            if (childList != null)
            {
                for (int i = 0; i < childList.Length; i++)
                {
                    if (childList[i] != mainblock.transform)
                    {
                        Destroy(childList[i].gameObject);
                    }
                }
            }
        }
    }
Пример #2
0
    public void CreateAdBlock(string name)     //다른 모양의 block prefab을 생성하는 함수
    {
        Block.GetComponent <Image>().sprite = mainBlockType[int.Parse(name)];
        Blockdata blockstate = Block.GetComponent <Blockdata>();

        Debug.Log("createad");
        if (name == "0")
        {
            Debug.Log("나는 에이다");
            for (int x = 1; x < 3; x++)
            {
                //Debug.Log(x);
                // Debug.Log("OriginBlock:" + Origin0);
                GameObject a_block = Instantiate(OriginBlock, new Vector3(x, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3((x * 50), 0, 0);

                //Debug.Log("x:" + a_block.transform.position.x);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = x;
                sBlock.iY    = 0;
                sBlock.iType = 0;
                sBlock.SetBlockImg(BlockType[0]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[x][0] = 0;
            }
            for (int y = 1; y < 2; y++)
            {
                //Debug.Log(y);
                GameObject a_block = Instantiate(OriginBlock, new Vector3(0, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0, -(y * 50), 0);
                //Debug.Log("y:"+a_block.transform.position.y);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = 0;
                sBlock.iY    = y;
                sBlock.iType = 0;
                sBlock.SetBlockImg(BlockType[0]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[0][y] = 0;
            }
        }
        else if (name == "1")
        {
            //Debug.Log("나는 비다");
            for (int x = 1; x < 2; x++)
            {
                //Debug.Log("Ori x:"+OriginBlock.transform.position.x);
                GameObject a_block = Instantiate(OriginBlock, new Vector3(0, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3((x * 50), 0, 0);
                //Debug.Log("x:" + a_block.transform.position.x);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = x;
                sBlock.iType = 1;
                sBlock.SetBlockImg(BlockType[1]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[x][0] = 1;
            }
            for (int y = 1; y < 2; y++)
            {
                //Debug.Log(y);
                //Debug.Log("ori x:"+OriginBlock.transform.position.x);
                GameObject a_block = Instantiate(OriginBlock, new Vector3(0, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0, 0 - (y * 50), 0);
                //Debug.Log("x:" + a_block.transform.position.x);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iY    = y;
                sBlock.iType = 1;
                sBlock.SetBlockImg(BlockType[1]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[0][y] = 1;
            }
        }
        else if (name == "2")
        {
            //Debug.Log("나는 씨다");
            for (int x = 1; x < 2; x++)
            {
                GameObject a_block = Instantiate(OriginBlock, new Vector3(0 + x, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0 + (x * 50), 0, 0);

                GameObject b_block = Instantiate(OriginBlock, new Vector3(OriginBlock.transform.position.x + x, 0, 0), Quaternion.identity);
                b_block.transform.SetParent(Block.transform);
                b_block.transform.localScale    = new Vector3(1, 1, 1);
                b_block.transform.localPosition = new Vector3(0 - (x * 50), 0, 0);


                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = x;
                sBlock.iY    = 0;
                sBlock.iType = 2;
                sBlock.SetBlockImg(BlockType[2]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[x][0] = 2;

                Blockdata sbBlock = b_block.GetComponent <Blockdata>();
                sbBlock.iX    = x;
                sbBlock.iY    = 0;
                sbBlock.iType = 2;
                sbBlock.SetBlockImg(BlockType[2]);
                sbBlock.setHp(blockstate.getHp());
                sbBlock.setResist(blockstate.getResist());
                sbBlock.setSpeed(blockstate.getSpeed());
                sbBlock.iType    = blockstate.iType;
                BlockBoard[x][0] = 2;
            }
        }
        else if (name == "3")
        {
            //Debug.Log("나는 D다");
            for (int x = 1; x < 2; x++)
            {
                GameObject a_block = Instantiate(OriginBlock, new Vector3(OriginBlock.transform.position.x - x, 0, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0 + (x * 50), 0, 0);

                GameObject b_block = Instantiate(OriginBlock, new Vector3(OriginBlock.transform.position.x + x, 0, 0), Quaternion.identity);
                b_block.transform.SetParent(Block.transform);
                b_block.transform.localScale    = new Vector3(1, 1, 1);
                b_block.transform.localPosition = new Vector3(0 - (x * 50), 0, 0);



                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = x;
                sBlock.iY    = 0;
                sBlock.iType = 3;
                sBlock.SetBlockImg(BlockType[3]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[x][0] = 3;

                Blockdata sbBlock = b_block.GetComponent <Blockdata>();
                sbBlock.iX    = x;
                sbBlock.iY    = 0;
                sbBlock.iType = 3;
                sbBlock.SetBlockImg(BlockType[3]);
                sbBlock.setHp(blockstate.getHp());
                sbBlock.setResist(blockstate.getResist());
                sbBlock.setSpeed(blockstate.getSpeed());
                sbBlock.iType    = blockstate.iType;
                BlockBoard[x][0] = 3;
            }
            for (int y = 1; y < 2; y++)
            {
                GameObject a_block = Instantiate(OriginBlock, new Vector3(OriginBlock.transform.position.x, OriginBlock.transform.position.y + y, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0, 0 + (y * 50), 0);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = 0;
                sBlock.iY    = y;
                sBlock.iType = 3;
                sBlock.SetBlockImg(BlockType[3]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[0][y] = 3;
            }
        }
        else if (name == "4")
        {
            for (int y = 1; y < 2; y++)
            {
                GameObject a_block = Instantiate(OriginBlock, new Vector3(OriginBlock.transform.position.x, OriginBlock.transform.position.y + y, 0), Quaternion.identity);
                a_block.transform.SetParent(Block.transform);
                a_block.transform.localScale    = new Vector3(1, 1, 1);
                a_block.transform.localPosition = new Vector3(0, 0 - (y * 50), 0);

                Blockdata sBlock = a_block.GetComponent <Blockdata>();
                sBlock.iX    = 0;
                sBlock.iY    = y;
                sBlock.iType = 4;
                sBlock.SetBlockImg(BlockType[4]);
                sBlock.setHp(blockstate.getHp());
                sBlock.setResist(blockstate.getResist());
                sBlock.setSpeed(blockstate.getSpeed());
                sBlock.iType     = blockstate.iType;
                BlockBoard[0][y] = 4;
            }
        }
    }