Example #1
0
        /// <summary>
        /// 방향 지정 복사)
        /// </summary>
        /// <param name="direction">결과물 복사 방향</param>
        /// <param name="td">결과물 블록 타입</param>
        void Copy(MoveDirection direction, BlockType.TypeDetail td)
        {
            if (direction == MoveDirection.None)
            {
                return;
            }

            Tool.Targeting();

            // 복사 대상이 없을 경우
            if (target == null)
            {
                return;
            }

            // 위치 및 회전값 설정
            Vector3 pos = target.transform.position;

            if (direction == MoveDirection.Left)
            {
                pos.x -= gridSpace.x;
            }
            else if (direction == MoveDirection.Right)
            {
                pos.x += gridSpace.x;
            }
            else if (direction == MoveDirection.Up)
            {
                pos.z += gridSpace.z;
            }
            else if (direction == MoveDirection.Down)
            {
                pos.z -= gridSpace.z;
            }


            // 타겟 방향 재설정
            int yRot = (int)direction - 1;

            target.GetComponent <DynamicBlock>().ReDirection(yRot);

            // 타겟 재설정 및 생성
            target = blockManager.Create(pos, yRot + 2, td).gameObject;

            // 네임박스 재설정
            targetName.text = target.name;

            // 카메라 이동
            MoveCamera(direction);
            MoveCamera(direction);
        }
    void SetMaterial(BlockType.TypeDetail td)
    {
        Material mat;

        switch (blockTypeDetail)
        {
        case BlockType.TypeDetail.plus:
            mat = Resources.Load <Material>("World/Block/Block_Plus");
            break;

        case BlockType.TypeDetail.minus:
            mat = Resources.Load <Material>("World/Block/Block_Minus");
            break;

        case BlockType.TypeDetail.lucky:
            mat = Resources.Load <Material>("World/Block/Block_Lucky");
            break;

        case BlockType.TypeDetail.boss:
        case BlockType.TypeDetail.trap:

            mat = Resources.Load <Material>("World/Block/Block_Event");
            break;

        case BlockType.TypeDetail.shop:
        case BlockType.TypeDetail.unique:
        case BlockType.TypeDetail.shortcutIn:
        case BlockType.TypeDetail.shortcutOut:
            mat = Resources.Load <Material>("World/Block/Block_Special");
            break;

        default:
            mat = Resources.Load <Material>("World/Block/BlockNone");
            break;
        }

        meshRenderer.material = mat;
    }
    /// <summary>
    /// 블록 생성
    /// </summary>
    /// <param name="copyTarget">원본 오브젝트</param>
    /// <param name="pos">결과물 오브젝트 position</param>
    /// <param name="direction"> L=-1, U=0, R=1, D=2,none=3</param>
    /// <param name="td">결과물 오브젝트 블록 타입</param>
    public Transform Create(Vector3 pos, int direction, BlockType.TypeDetail td)
    {
        // 복사 대상이 없을 경우
        if (blockPrefab == null)
        {
            return(null);
        }

        // 생성
        Transform copyObject = Instantiate(
            blockPrefab,                            // 복사할 Ga
            pos,                                    // position
            Quaternion.Euler(Vector3.zero),         // rotation
            blockMaster                             // 부모 지정
            ).transform;

        // 블록 속성 지정 및 적용
        DynamicBlock db = copyObject.GetComponent <DynamicBlock>();

        db.blockType       = BlockType.GetTypeByDetail(td);
        db.blockTypeDetail = td;
        db.Refresh();

        // 블록 방향 설정
        db.ReDirection(direction);

        //목록 추가
        gol.Add(copyObject.gameObject);

        // 오브젝트 이름 변경
        copyObject.name = string.Format("Block ({0})", gol.Count - 1);

        // 로그 출력
        Debug.Log(string.Format("create block :: {0}\n position=({1}, {2}, {3}) direction={4} blockType={5} blockTypeDetail{6}", copyObject.name, pos.x, pos.y, pos.z, direction * 90, db.blockType, db.blockTypeDetail));

        return(copyObject);
    }
Example #4
0
    /// <summary>
    /// 플레이어의 현재 위치를 기반으로 블록 작업 수행
    /// </summary>
    /// <param name="currentPlayer">플레이어</param>
    public static void Work(Player currentPlayer)
    {
        //Debug.Break();
        // 오류 차단
        if (currentPlayer == null)
        {
            return;
        }
        if (currentPlayer.avatar == null)
        {
            return;
        }
        if (currentPlayer.movement == null)
        {
            return;
        }


        // 초기화
        Clear();

        // 사용중 판정 처리
        isWork = true;


        // 위치 복사
        int location = currentPlayer.movement.location;

        // 블록 종류 파악
        BlockType.TypeDetail blockType = GetBlockType(location);

        Debug.LogWarning("블록 기능 :: " + currentPlayer.name + " 에 의해 작동됨 => " + blockType);
        //Debug.Break();

        // 블록 별 기능
        if (blockType == BlockType.TypeDetail.none)
        {
            return;
        }

        else if (blockType == BlockType.TypeDetail.plus)
        {
            BlockPlus(currentPlayer);
        }
        else if (blockType == BlockType.TypeDetail.minus)
        {
            BlockMinus(currentPlayer);
        }

        else if (blockType == BlockType.TypeDetail.trap)
        {
            BlockTrap(currentPlayer);
        }
        else if (blockType == BlockType.TypeDetail.lucky)
        {
            BlockLuckyBox(currentPlayer);
        }

        else if (blockType == BlockType.TypeDetail.shop)
        {
            BlockShop(currentPlayer);
        }
        else if (blockType == BlockType.TypeDetail.unique)
        {
            BlockUnique(currentPlayer);
        }
        else if (blockType == BlockType.TypeDetail.shortcutIn)
        {
            BlockshortcutIn(currentPlayer);
        }
        else if (blockType == BlockType.TypeDetail.shortcutOut)
        {
            BlockPlus(currentPlayer);
        }


        /*
         *
         * => 초도 구현 완료 : --
         * => 테스트 완료 : ++
         *
         *
         *
         ++none,
         *
         ++plus,
         ++minus,
         *
         * boss,               ============== 미구현
         ++trap,
         ++lucky,
         *
         ++shop,
         * unique,
         ++shortcutIn,
         ++shortcutOut,
         */
    }
 /// <summary>
 /// blockTypeDetail 값 재설정
 /// </summary>
 public void SetBlock(BlockType.TypeDetail td)
 {
     blockTypeDetail = td;
     Refresh();
 }