Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        /*
         * 현상태에서 보드를 평가한다. 즉 보드를 구성하는 블럭에 게임규칙을 적용시킨다.
         * 매치된 블럭은 제거하고 빈자리에는 새로운 블럭을 생성한다.
         * matchResult : 실행 결과를 리턴받은 클래스
         *               true : 매치된 블럭 있는 경우, false : 없는 경우
         */
        IEnumerator EvaluateBoard(Returnable <bool> matchResult)
        {
            while (true)    //매칭된 블럭이 있는 경우 반복 수행한다.
            {
                //1. 매치 블럭 제거
                Returnable <bool> bBlockMatched = new Returnable <bool>(false);
                yield return(StartCoroutine(m_Stage.Evaluate(bBlockMatched)));

                //2. 3매치 블럭이 있는 경우 후처리 싱행 (블럭 드롭 등)
                if (bBlockMatched.value)
                {
                    matchResult.value = true;

                    SoundManager.instance.PlayOneShot(Clip.BlcokClear);

                    // 매칭 블럭 제거 후 빈블럭 드롭 후 새 블럭 생성
                    yield return(StartCoroutine(m_Stage.PostprocessAfterEvaluate()));
                }
                //3. 3매치 블럭이 없는 경우 while 문 종료
                else
                {
                    break;
                }
            }

            yield break;
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Returnable returnable = ConfigReader.readPortsFromConfig("managementConfigFile.xml");

            List <int> portList = returnable.portList;

            clientList         = new List <Router>();
            availableConteners = returnable.contenerList;
            availableModules   = returnable.moduleList;

            routerList = new List <Router>();


            if (portList == null)
            {
                appendConsole("Błąd odczytu pliku konfiguracyjnego, spróbuj ponownie.", null, null);
                return;
            }
            appendConsole("Obsługiwany moduł w sieci: " + availableModules[0], null, null);
            appendConsole("Obsługiwane kontenery:", null, null);
            foreach (string s in availableConteners)
            {
                appendConsole(s, null, null);
            }

            socketHandler          = new SocketHandler(portList, this, availableModules, availableConteners);
            actionBox.IsEnabled    = true;
            nodeBox.IsEnabled      = true;
            selectionBox.IsEnabled = true;
            button1.IsEnabled      = false;
            button2.IsEnabled      = true;
            addNewButton.IsEnabled = true;
            initialised            = true;
            Load_All.IsEnabled     = true;
        }
Ejemplo n.º 3
0
        public StringModel ToStringModel <BLModel, StringModel>()
        {
            Mapper.CreateMap <OrderExport, StringOrderExport>()
            .ForAllMembers(item => item.ToString().CutDownTo(50));

            var stringModel = Mapper.Map <OrderExport, StringOrderExport>(this);

            stringModel.UnitCost   = UnitCost.DecimalToString(2);
            stringModel.ExportDate = ExportDate.DateTimeToString();

            stringModel.ItemDescription  = ItemDescription.CutDownTo(50);
            stringModel.LeadTime         = LeadTime.DecimalToString(2);
            stringModel.EstimateOfDemand = EstimateOfDemand.DecimalToString(2);

            stringModel.Returnable = Returnable.CutDownTo(1);
            stringModel.Stocked    = Stocked.CutDownTo(1);
            stringModel.Hazardous  = Hazardous.CutDownTo(1);
            stringModel.DueDate    = DueDate.DateTimeToString();


            Mapper.CreateMap <StringOrderExport, StringModel>();
            var stringModelRet = Mapper.Map <StringOrderExport, StringModel>(stringModel);


            return(stringModelRet);
        }
Ejemplo n.º 4
0
        /*
         * 스와이프 액션을 수행하는 코루틴
         */
        IEnumerator CoDoSwipeAction(int nRow, int nCol, Swipe swipeDir)
        {
            if (!m_bRunning)       //다른 액션이 수행 중이면 PASS
            {
                m_bRunning = true; //액션 실행 상태 ON

                SoundManager.instance.PlayOneShot(Clip.Chomp);

                //1. swipe action 수행
                Returnable <bool> bSwipedBlock = new Returnable <bool>(false);
                yield return(m_Stage.CoDoSwipeAction(nRow, nCol, swipeDir, bSwipedBlock));

                //2. 스와이프 성공한 경우 브드를 평가(매치블럭삭제, 빈블럭 드롭, 새블럭 Spawn 등)한다.
                if (bSwipedBlock.value)
                {
                    Returnable <bool> bMatchBlock = new Returnable <bool>(false);
                    yield return(EvaluateBoard(bMatchBlock));

                    //스와이프한 블럭이 매치되지 않은 경우에 원상태 복귀
                    if (!bMatchBlock.value)
                    {
                        yield return(m_Stage.CoDoSwipeAction(nRow, nCol, swipeDir, bSwipedBlock));
                    }
                }

                m_bRunning = false;  //액션 실행 상태 OFF
            }
            yield break;
        }
Ejemplo n.º 5
0
        /**
         * 호출 결과 : 3 매칭된 블럭이 제거된다.
         */
        public IEnumerator Evaluate(Returnable <bool> matchResult)
        {
            //1. 모든 블럭의 매칭 정보(개수, 상태, 내구도)를 계산한 후, 3매치 블럭이 있으면 true 리턴
            bool bMatchedBlockFound = UpdateAllBlocksMatchedStatus();

            //2. 3매칭 블럭 없는 경우
            if (bMatchedBlockFound == false)
            {
                matchResult.value = false;
                yield break;
            }

            //3. 3매칭 블럭 있는 경우

            //3.1. 첫번째 phase
            //   매치된 블럭에 지정된 액션을 수행한.
            //   ex) 가로줄의 블럭 전체가 클리어 되는 블럭인 경우에 처리 등
            for (int nRow = 0; nRow < m_nRow; nRow++)
            {
                for (int nCol = 0; nCol < m_nCol; nCol++)
                {
                    Block block = m_Blocks[nRow, nCol];

                    block?.DoEvaluation(m_Enumerator, nRow, nCol);
                }
            }

            //3.2. 두번째 phase
            //   첫번째 Phase에서 반영된 블럭의 상태값에 따라서 블럭의 최종 상태를 반영한.
            List <Block> clearBlocks = new List <Block>();

            for (int nRow = 0; nRow < m_nRow; nRow++)
            {
                for (int nCol = 0; nCol < m_nCol; nCol++)
                {
                    Block block = m_Blocks[nRow, nCol];

                    if (block != null)
                    {
                        if (block.status == BlockStatus.CLEAR)
                        {
                            clearBlocks.Add(block);

                            m_Blocks[nRow, nCol] = null;    //보드에서 블럭 제거 (블럭 객체 제거 X)
                        }
                    }
                }
            }

            //3.3 매칭된 블럭을 제거한다.
            clearBlocks.ForEach((block) => block.Destroy());
            //3.3.1 블럭이 제거되는 동안 잠시 Delay, 블럭 제거가 순식간에 일어나는 것에 약간 지연을 시킴
            yield return(new WaitForSeconds(0.2f));

            //3.4 3매칭 블럭 있는 경우 true 설정
            matchResult.value = true;

            yield break;
        }
Ejemplo n.º 6
0
    private void Initialize(Transform t)
    {
        t.gameObject.AddComponent <Returnable>();
        Returnable f = t.gameObject.GetComponent <Returnable>();

        f.Initialize();

        pieces[count] = f;
        count++;
    }
Ejemplo n.º 7
0
        /*
         * 유효한 스와이프인 경우 : 스와이프 방향으로 블럭 위치가 교체된다.
         * 유효지 않는 스와이프 경우 : 화면에 스와이프 방향으로 액션을 보여주고, 원상태로 복구하는 액션 보여준다
         */
        public IEnumerator CoDoSwipeAction(int nRow, int nCol, Swipe swipeDir, Returnable <bool> actionResult)
        {
            actionResult.value = false; //코루틴 리턴값 RESET

            //1. 스와이프되는 상대 블럭 위치를 구한다. (using SwipeDir Extension Method)
            int nSwipeRow = nRow, nSwipeCol = nCol;

            nSwipeRow += swipeDir.GetTargetRow(); //Right : +1, LEFT : -1
            nSwipeCol += swipeDir.GetTargetCol(); //UP : +1, DOWN : -1

            Debug.Assert(nRow != nSwipeRow || nCol != nSwipeCol, "Invalid Swipe : ({nSwipeRow}, {nSwipeCol})");
            Debug.Assert(nSwipeRow >= 0 && nSwipeRow < maxRow && nSwipeCol >= 0 && nSwipeCol < maxCol, $"Swipe 타겟 블럭 인덱스 오류 = ({nSwipeRow}, {nSwipeCol}) ");

            //2. 스와이프 가능한 블럭인지 체크한다. (인덱스 Validation은 호출 전에 검증됨)
            if (m_Board.IsSwipeable(nSwipeRow, nSwipeCol))
            {
                //2.1 스와이프 대상 블럭(소스, 타겟)과 각 블럭의 이동전 위치를 저장한다.
                Block targetBlock = blocks[nSwipeRow, nSwipeCol];
                Block baseBlock   = blocks[nRow, nCol];
                Debug.Assert(baseBlock != null && targetBlock != null);

                Vector3 basePos   = baseBlock.blockObj.transform.position;
                Vector3 targetPos = targetBlock.blockObj.transform.position;

                //2.2 스와이프 액션을 실행한다.
                if (targetBlock.IsSwipeable(baseBlock))
                {
                    //2.2.1 상대방의 블럭 위치로 이동하는 애니메이션을 수행한다
                    baseBlock.MoveTo(targetPos, Constants.SWIPE_DURATION);
                    targetBlock.MoveTo(basePos, Constants.SWIPE_DURATION);

                    yield return(new WaitForSeconds(Constants.SWIPE_DURATION));

                    //2.2.2 Board에 저장된 블럭의 위치를 교환한다
                    blocks[nRow, nCol]           = targetBlock;
                    blocks[nSwipeRow, nSwipeCol] = baseBlock;

                    actionResult.value = true;
                }
            }

            yield break;
        }
Ejemplo n.º 8
0
    /// <summary>
    /// Get a preinitiated tile gameobject
    /// </summary>
    /// <returns></returns>
    public GameObject get()
    {
        //if(pool.Count > 1000)
        if (false)
        {
            //print("got from the pool");
            GameObject pref = pool[0];
            pool.RemoveAt(0);
            //pref.SetActive(true);
            return(pref);
        }

        GameObject newPrefab = Instantiate(prefab);
        Returnable ret       = newPrefab.AddComponent <Returnable>();

        newPrefab.AddComponent <Pingable>();
        ret.SetReturnTo(pool);
        newPrefab.name = identification;
        //print("another reprint");
        return(newPrefab);
    }
Ejemplo n.º 9
0
 /*
  * 스테이지를 구성하는 전체 보드를 평가한다.
  * 각 블럭에 지정된 상태/종류/카운터 등에 따라서 블럭의 다음 상태를 변경한다.
  * ex) Match된 블럭은 제거되고 카운터가 있는 경우 해당되는 경우만큼 감소하는 등
  *
  * 호출된 후의 상태 : Block 객체 제거, Block GameObject 제거
  *
  * @return 매치된 블럭이 있는 경우 true, 없으면 false
  */
 public IEnumerator Evaluate(Returnable <bool> matchResult)
 {
     yield return(m_Board.Evaluate(matchResult));
 }