コード例 #1
0
    void MakeBlock(Ray ray)
    {
        if (Physics.Raycast(ray, out hit, 1000))
        {
            if (hit.transform.CompareTag("Indexer"))
            {
                Indexer indexer = hit.transform.GetComponent <Indexer>();

                if (indexer.placeable)
                {
                    int blockNumber_modification = blockNumber;
                    //blocknumber 조정 : cracker , parfait , cloud , obstacle , character
                    if (indexer.Floor == 1)
                    {
                        if (blockNumber >= BlockNumber.cloudUp && blockNumber <= BlockNumber.cracker_2)
                        {
                            blockNumber_modification += 10;
                        }
                    }
                    else if (indexer.Floor == 2)
                    {
                        blockNumber_modification += 10;
                    }
                    Debug.Log("make block number : " + blockNumber_modification);
                    Block newBlock = blockFactory.EditorCreateBlock(blockNumber_modification, styleNumber, new Vector3(indexer.X, indexer.Z));
                    indexer.AddBlock(newBlock);
                    indexer.CheckPlaceableIndex(block_floor: placeableFloor);
                    newBlock.transform.SetParent(holders[indexer.Floor].transform);

                    if (blockNumber >= BlockNumber.parfaitA && blockNumber <= BlockNumber.parfaitD)
                    {
                        parfait_count++;
                        selectedButton.interactable = false;
                        blockNumber = 999;//더 이상 배치할 수 없음
                    }
                    if (blockNumber == BlockNumber.character)
                    {
                        character_count++;
                        selectedButton.interactable = false;
                        blockNumber = 999;//더 이상 배치할 수 없음

                        if (styleNumber == 0)
                        {
                            positionA = new Vector3(indexer.X + 1, indexer.Floor, indexer.Z + 1);
                        }
                        else
                        {
                            positionB = new Vector3(indexer.X + 1, indexer.Floor, indexer.Z + 1);
                        }
                    }

                    if (moveBlock)//move block
                    {
                        moveBlock = false;

                        blockNumber = temp_blockNumber;
                        styleNumber = temp_styleNumber;

                        Update_Placeable_Floor(blockNumber);
                        StartCoroutine(ActiveClickTimer());
                    }


                    if (CheckCondition().Item1&& CheckCondition().Item2)
                    {
                        completeButton.interactable = true;
                    }
                    else
                    {
                        completeButton.interactable = false;
                    }
                    checkListPopup.SetCheckList(character_count, parfait_count);
                }
            }
        }
    }