Пример #1
0
    // 인덱스 초도 등록
    public void SetUp()
    {
        // 인 아웃 인덱스 등록
        for (int i = 0; i < BlockManager.script.blockCount; i++)
        {
            DynamicBlock temp = BlockManager.script.GetBlock(i).GetComponent <DynamicBlock>();

            // 인 등록
            if (temp.blockTypeDetail == BlockType.TypeDetail.shortcutIn)
            {
                shortCutIn = i;

                shortCutInObj = temp;

                transform.position = shortCutInObj.transform.position;
            }

            // 아웃 등록
            else if (temp.blockTypeDetail == BlockType.TypeDetail.shortcutOut)
            {
                shortCutOut = i;

                shortCutOutObj = temp;
            }
        }
    }
Пример #2
0
        public void DynBlockMoveTest()
        {
            World        world  = new World(new Vector2(0.0f, -10.0f), false);
            Rectangle    rect   = new Rectangle(32, 32, 32, 32);
            DynamicBlock target = new DynamicBlock(world, null, rect, 'D');

            Vector2 tmp = target.GetBody().GetPosition();

            for (int i = 0; i < 10; i++)
            {
                world.Step(1, 8, 3);
            }

            Assert.IsFalse(tmp.Equals(target.GetBody().GetPosition()), "Block has not moved, not a dynamic block!");
        }
Пример #3
0
        public void DynObjRotationTest()
        {
            World        world  = new World(new Vector2(0.0f, 0.0f), false);
            Rectangle    rect   = new Rectangle(32, 32, 32, 32);
            DynamicBlock target = new DynamicBlock(world, null, rect, 'D');


            target.GetBody().ApplyLinearImpulse(new Vector2(5, 0), new Vector2(0, 0));
            world.Step(2, 8, 3);
            float angle1 = target.GetBody().GetAngle();

            world.Step(3, 8, 3);
            float angle2 = target.GetBody().GetAngle();

            Assert.IsFalse(angle1.Equals(angle2), "the block still has the same angle 1: " + angle1 + " 2: " + angle2);
        }
Пример #4
0
        public void DynBlockImpulseTest()
        {
            World            world  = new World(new Vector2(0.0f, 0.0f), false);
            List <Texture2D> sprite = null;
            Rectangle        rect   = new Rectangle(32, 32, 32, 32);
            DynamicBlock     target = new DynamicBlock(world, sprite, rect, 'D');

            Vector2 tmp = target.GetBody().GetPosition();

            target.GetBody().ApplyLinearImpulse(new Vector2(-10.0f, 0.0f), new Vector2(0, 0));

            for (int i = 0; i < 10; i++)
            {
                world.Step(1, 8, 3);
            }

            Assert.IsFalse(tmp.Equals(target.GetBody().GetPosition()), "Block has not moved by impulse, not a dynamic block!");
        }
Пример #5
0
    /// <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);
    }
Пример #6
0
    /// <summary>
    /// 실제 효과 발동
    /// </summary>
    /// <param name="filteredTarget">효과를 받을 플레이어들</param>
    /// <param name="__blockIndex">위치</param>
    public IEnumerator GeneralEffect(Player user, List <Player> filteredTarget)
    {
        // 월드 이벤트 호출
        if (filteredTarget == null)
        {
            // 호출
            yield return(WorldEffect(this));
        }
        else
        {
            // 선택형 선택
            if (filteredTarget.Count == 0)
            {
                //=========== 미구현
                //yield return ;
            }


            Player current = null;
            int    blockIndex;
            bool   isExecute;

            for (int i = 0; i < filteredTarget.Count; i++)
            {
                // 퀵등록
                current = filteredTarget[i];

                // 이동 포인트 확보
                blockIndex = current.location;

                // 효과 적용 여부
                isExecute = true;



                // 사용자 불일치 경우
                if (current != user)
                {
                    // 인벤토리 스캔
                    for (int j = 0; j < current.inventoryCount; j++)
                    {
                        // 실드 체크
                        if (current.inventory[j].item.index == 19)
                        {
                            // 실드 자동 사용
                            //GameMaster.script.itemManager.ItemUse(current.inventory[j]);
                            current.inventory[j].count--;

                            // 차단 적용
                            isExecute = false;

                            // 스캔 중단
                            break;
                        }
                    }
                }



                // 효과 차단
                if (!isExecute)
                {
                    continue;
                }

                // 대상 없음
                if (what == What.None)
                {
                }

                // 캐릭터 (플레이어 아바타)
                else if (what == What.Character)
                {
                    // 미구현 ===================================
                }

                // 이동
                else if (what == What.Move)
                {
                    // 중단
                    current.movement.MoveStop();

                    // 이동 포인트 가공
                    if (where == -3)
                    {
                        //blockIndex *= where;
                        current.dice.SetValueTotal(current.dice.valueTotal * value);

                        // 이동 호출
                        current.movement.PlanMoveBy(current.dice.valueTotal);
                    }
                    else if (where == -2)
                    {
                        //blockIndex += where;
                        current.dice.SetValueTotal(current.dice.valueTotal + value);

                        // 이동 호출
                        current.movement.PlanMoveBy(current.dice.valueTotal);
                    }
                    else
                    {
                        blockIndex = where;
                        current.dice.SetValueTotal(0);
                        Debug.LogError(blockIndex);


                        // 오아시스 입장
                        if (blockIndex == -1)
                        {
                            current.movement.GotoJail();
                        }
                        // 이동 호출
                        else
                        {
                            current.movement.PlanMoveTo(blockIndex);
                        }
                    }
                }

                // 블록 타입 변경
                else if (what == What.Block)
                {
                    // 퀵등록
                    DynamicBlock dBlock = BlockManager.script.GetBlock(where).GetComponent <DynamicBlock>();

                    // 설정
                    dBlock.blockTypeDetail = (BlockType.TypeDetail)value;
                    dBlock.blockType       = BlockType.GetTypeByDetail(dBlock.blockTypeDetail);
                    dBlock.Refresh();
                }

                // 주사위 제어
                else if (what == What.Dice)
                {
                    if (value != 0)
                    {
                        // 주사위 추가
                        current.dice.count += value;
                    }
                    else
                    {
                        // 주사위 변경
                        current.dice.type = (Dice.SpecialDice) where;
                    }
                }

                // 라이프 획득
                else if (what == What.Life)
                {
                    current.life.Add(value);
                }

                // 코인 획득
                else if (what == What.Coin)
                {
                    current.coin.Add(value);
                }

                // 아이템 획득
                else if (what == What.Item)
                {
                    if (value > 1)
                    {
                        if (value < Item.table.Count)
                        {
                            current.AddItem(Item.table[value], count);
                        }
                    }
                }

                // 미니게임 수행
                else if (what == What.Minigame)
                {
                    // 미구현 ===================================

                    // value == 상금
                }
            }
        }


        // 사용된 효과 등록
        if (expiration == Expiration.Forever || expiration == Expiration.Cycle || expiration == Expiration.Turn)
        {
            // 소모처리
            _count--;

            // 효과 등록
            if (!activeEffects.Contains(this))
            {
                activeEffects.Add(this);
            }
        }
        // 즉시 만료
        else
        {
            _expiration = Expiration.Invalid;
        }

        Debug.Log("ioc effect :: 효과 작동됨");

        yield return(null);
    }