Exemple #1
0
    private void buildCarrierClick()
    {
        button.enabled = false;
        ActionProgress actionProgress = progress.GetComponent <ActionProgress>();

        StartCoroutine(actionProgress.DisplayProgress(Time.realtimeSinceStartup, 5, button));
    }
        public ActionResult ProgressNew(MitigationActionModel ma)
        {
            ActionProgress    ap = new ActionProgress();
            MitigationsAction mc = new MitigationsAction();

            if (db.ActionProgresses.Count() == 0)
            {
                ap.ActionProgressID = 1;
            }
            else
            {
                var id = db.ActionProgresses.OrderByDescending(p => p.ActionProgressID).First();
                ap.ActionProgressID = id.ActionProgressID + 1;
            }

            ap.ActionID        = ma.actionId;
            ap.RecordDate      = DateTime.Now;
            ap.ActionProgress1 = ma.ActionProgress;
            db.ActionProgresses.Add(ap);
            db.SaveChanges();

            mc = db.MitigationsActions.Single(p => p.ActionID == ma.actionId);
            mc.TotalProgress = ma.ActionProgress;
            db.SaveChanges();

            return(RedirectToAction("ProgressIndex", new { id = ma.actionId }));
        }
Exemple #3
0
 // 생성자
 public Action(ActionType _type, int _count, float _speed)
 {
     type        = _type;
     progress    = ActionProgress.Ready;
     count       = _count;
     speed       = _speed;
     elapsedTime = 0.00f;
     isFinish    = false;
 }
Exemple #4
0
    public static void Clear()
    {
        // 초기화
        TurnAction     turnAction     = TurnAction.Wait;
        ActionProgress actionProgress = ActionProgress.Ready;

        origin.Clear();
        queue.Clear();
        Player.order.Clear();
    }
    public void CallDice(Player __owner, Transform obj, Vector3 distance)
    {
        // 주사위 사용중이면 중단
        if (action != DiceAction.Wait)
        {
            if (actionProgress != ActionProgress.Ready)
            {
                return;
            }
        }

        // 주사위 소유권자 지정
        owner = __owner;
        //dice = owner.dice;
        Debug.LogWarning("주사위 :: 소유자 = " + owner.name);

        // 주사위 개수가 부족하면 중단
        if (dice.count < 1)
        {
            Debug.Log("주사위 개수 부족 :: " + dice.count);

            // 액션 설정
            action         = DiceAction.Finish;
            actionProgress = ActionProgress.Working;

            //Debug.Break();
            return;
        }

        // 굴림 시작
        dice.isRolling = true;

        // 액션 설정
        action         = DiceAction.Wait;
        actionProgress = ActionProgress.Start;

        // 오브젝트 이동
        Vector3 pos = new Vector3(obj.position.x, obj.position.y, obj.position.z);

        pos += distance;
        transform.position = pos;


        // 주사위 부착
        //transform.parent = obj;

        // 오브젝트 활성
        transform.GetComponent <MeshRenderer>().enabled = true;
        //gameObject.SetActive(true);
    }
Exemple #6
0
    /// <summary>
    /// 오브젝트 획득 리스트 전체 획득
    /// </summary>
    /// <returns></returns>
    IEnumerator GetObject()
    {
        // 습득 시작
        objectPickUpStep = ActionProgress.Start;

        // 전부 획득
        while (objectPickUpList.Count > 0)
        {
            // 개별 습득 대기
            yield return(GetObject(objectPickUpList[0]));
        }

        // 습득 종료 처리
        objectPickUpStep = ActionProgress.Finish;
    }
Exemple #7
0
        private async Task ExecuteAsync(BackgroundTransferEntry backgroundTransferEntry, CancellationToken cancellationToken)
        {
            using (_log?.BeginScope(
                       new Dictionary <string, object>
            {
                ["TransferId"] = backgroundTransferEntry.BackgroundTransfer.TransferId,
            }))
            {
                var backgroundTransfer = backgroundTransferEntry.BackgroundTransfer;
                _log?.LogInformation("Starting background transfer {0}", backgroundTransfer.TransferId);
                backgroundTransferEntry.Status = BackgroundTransferStatus.Transferring;

                // ReSharper disable once AccessToModifiedClosure
                var progress = new ActionProgress(sent => backgroundTransferEntry.Transferred = sent);
                try
                {
                    await backgroundTransfer.Start(progress, cancellationToken)
                    .ConfigureAwait(false);

                    _log?.LogInformation("Completed background transfer {0}", backgroundTransfer.TransferId);
                }
                catch (Exception ex) when(ex.Is <OperationCanceledException>())
                {
                    // Nothing to do
                    _log?.LogWarning("Background transfer {0} cancelled", backgroundTransfer.TransferId);
                }
                catch (Exception ex)
                {
                    // Show the error message
                    _log?.LogError(ex, "Background transfer {0} faulted", backgroundTransfer.TransferId);
                }
                finally
                {
                    lock (_pendingOrActiveEntries)
                    {
                        _pendingOrActiveEntries.Remove(backgroundTransferEntry.Id);
                    }

                    backgroundTransferEntry.Status = BackgroundTransferStatus.Finished;
                    backgroundTransfer.Dispose();
                }
            }
        }
    /// <summary>
    ///  주사위의 눈을 가져오고 초기화 진행
    /// </summary>
    /// <returns></returns>
    public int UseDice()
    {
        int result = 0;

        // 인풋 초기화
        doForceClick   = false;
        doForceClickUp = false;

        // 주사위 남았으면 추가 진행
        if (dice.count > 1)
        {
            Debug.Log("주사위 굴림 :: 다시 시작");

            // 다시 처음으로 초기화
            action         = DiceAction.Wait;
            actionProgress = ActionProgress.Start;

            // 시간 관련값 리셋
            rotAccel    = 0f;
            elapsedTime = 0f;
        }
        else
        {
            Debug.Log("주사위 굴림 :: 종료");

            // 굴림 종료
            dice.isRolling = false;
            dice.isRolled  = true;

            // 결과값 백업
            result = dice.value;

            // 초기화 시작
            ResetDice();

            // 시점 변경
            cm.CamMoveTo(cm.controller.cam, CameraManager.CamAngle.Top);
        }


        return(result);
    }
Exemple #9
0
    /// <summary>
    /// 오브젝트 단일 습득
    /// </summary>
    /// <param name="current"></param>
    /// <returns></returns>
    IEnumerator GetObject(DynamicObject current)
    {
        // 습득중 처리
        objectPickUpStep = ActionProgress.Working;

        // 아이템일 경우
        if (current.type == DynamicObject.Type.Item)
        {
            DynamicItem di = (DynamicItem)current;

            Debug.LogWarning("아이템 오브젝트 :: 습득 => " + di.item.index);

            // 획득
            di.GetItem(owner);

            // 연출 명령
            yield return(null);
        }

        // 아이템일 경우
        else if (current.type == DynamicObject.Type.Event)
        {
            DynamicEvent de = (DynamicEvent)current;

            Debug.LogWarning("이벤트 오브젝트 :: 습득 => " + de.iocEvent.index);

            // 획득
            //de.GetEvent(owner, de.location);
            de.GetEvent(owner);

            // 연출 명령
            yield return(null);
        }

        // 습득 리스트에서 제거
        objectPickUpList.Remove(current);

        // 습득중 완료 처리
        objectPickUpStep = ActionProgress.Start;
    }
    /// <summary>
    /// 강제 초기화 수행
    /// </summary>
    public void ResetDice()
    {
        // 주사위 소유권 초기화
        owner = null;
        //dice = null;

        // 액션상태 초기화
        action         = DiceAction.Wait;
        actionProgress = ActionProgress.Ready;

        // AI 관련 초기화
        if (owner != null)
        {
            owner.ai.mainGame.dice.Ready();
        }
        doForceClick   = false;
        doForceClickUp = false;

        // 시간 관련값 리셋
        rotAccel    = 0f;
        elapsedTime = 0f;

        // 중력 비활성화
        transform.GetComponent <Rigidbody>().isKinematic = true;
        transform.GetComponent <Rigidbody>().useGravity  = false;

        // 주사위 부착 해제
        transform.parent = transform.root;

        // 안보이도록 땅속에 숨김
        transform.position = new Vector3(0, -10, 0);

        // 오브젝트 비활성
        transform.GetComponent <MeshRenderer>().enabled = false;
        //gameObject.SetActive(false);
    }
Exemple #11
0
        private void ProcessQueue(CancellationToken cancellationToken)
        {
            var handles = new[]
            {
                cancellationToken.WaitHandle,
                _event,
            };

            _log?.LogDebug("Starting background transfer worker.");
            try
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    var handleIndex = WaitHandle.WaitAny(handles);
                    if (handleIndex == 0)
                    {
                        break;
                    }

                    HasData = true;

                    try
                    {
                        BackgroundTransferEntry backgroundTransferEntry;
                        while ((backgroundTransferEntry = GetNextEntry()) != null)
                        {
                            var log = backgroundTransferEntry.Log;
                            var backgroundTransfer = backgroundTransferEntry.BackgroundTransfer;
                            try
                            {
                                var bt = backgroundTransfer;
                                log?.LogInformation("Starting background transfer {0}", bt.TransferId);
                                backgroundTransferEntry.Status = BackgroundTransferStatus.Transferring;

                                // ReSharper disable once AccessToModifiedClosure
                                var progress      = new ActionProgress(sent => backgroundTransferEntry.Transferred = sent);
                                var task          = bt.Start(progress, cancellationToken);
                                var cancelledTask = task
                                                    .ContinueWith(
                                    t =>
                                {
                                    // Nothing to do
                                    log?.LogWarning("Background transfer {0} cancelled", bt.TransferId);
                                },
                                    TaskContinuationOptions.OnlyOnCanceled);
                                var faultedTask = task
                                                  .ContinueWith(
                                    t =>
                                {
                                    log?.LogError(t.Exception, "Background transfer {0} faulted", bt.TransferId);
                                },
                                    TaskContinuationOptions.OnlyOnFaulted);
                                var completedTask = task
                                                    .ContinueWith(
                                    t =>
                                {
                                    // Nothing to do
                                    log?.LogInformation("Completed background transfer {0}", bt.TransferId);
                                },
                                    TaskContinuationOptions.NotOnCanceled);

                                try
                                {
                                    Task.WaitAll(cancelledTask, faultedTask, completedTask);
                                }
                                catch (AggregateException ex) when(ex.InnerExceptions.All(x => x is TaskCanceledException))
                                {
                                    // Ignore AggregateException when it only contains TaskCancelledException
                                }

                                log?.LogTrace("Background transfer {0} finished", bt.TransferId);
                            }
                            catch (Exception ex)
                            {
                                log?.LogError(ex, "Error during execution of background transfer {0}", backgroundTransfer.TransferId);
                            }
                            finally
                            {
                                backgroundTransfer.Dispose();
                            }

                            backgroundTransferEntry.Status = BackgroundTransferStatus.Finished;
                            CurrentEntry = null;
                        }
                    }
                    finally
                    {
                        HasData = false;
                    }
                }
                _log?.LogInformation("Cancellation requested - stopping background transfer worker.");
            }
            finally
            {
                _log?.LogDebug("Background transfer worker stopped.");
                Queue.Dispose();
            }
        }
Exemple #12
0
        public async Task PreloadFromNominer()
        {
            Swarm <DumbAction> minerSwarm    = CreateSwarm();
            Swarm <DumbAction> receiverSwarm = CreateSwarm();
            var fxForNominers = new StoreFixture[2];
            var policy        = new BlockPolicy <DumbAction>(new MinerReward(1));

            fxForNominers[0] =
                new DefaultStoreFixture(memory: true, blockAction: policy.BlockAction);
            fxForNominers[1] =
                new DefaultStoreFixture(memory: true, blockAction: policy.BlockAction);
            var blockChainsForNominers = new[]
            {
                TestUtils.MakeBlockChain(
                    policy,
                    fxForNominers[0].Store,
                    fxForNominers[0].StateStore),
                TestUtils.MakeBlockChain(
                    policy,
                    fxForNominers[1].Store,
                    fxForNominers[1].StateStore),
            };
            var nominerSwarm0 = CreateSwarm(blockChainsForNominers[0]);
            var nominerSwarm1 = CreateSwarm(blockChainsForNominers[1]);

            BlockChain <DumbAction> minerChain    = minerSwarm.BlockChain;
            BlockChain <DumbAction> receiverChain = receiverSwarm.BlockChain;

            foreach (int i in Enumerable.Range(0, 10))
            {
                await minerChain.MineBlock(minerSwarm.Address);
            }

            var actualStates = new List <PreloadState>();
            var progress     = new ActionProgress <PreloadState>(state =>
            {
                lock (actualStates)
                {
                    actualStates.Add(state);
                }
            });

            try
            {
                await StartAsync(minerSwarm);
                await StartAsync(nominerSwarm0);
                await StartAsync(nominerSwarm1);

                minerSwarm.FindNextHashesChunkSize    = 2;
                nominerSwarm0.FindNextHashesChunkSize = 2;
                nominerSwarm1.FindNextHashesChunkSize = 2;

                await nominerSwarm0.AddPeersAsync(new[] { minerSwarm.AsPeer }, null);

                await nominerSwarm0.PreloadAsync();

                await nominerSwarm1.AddPeersAsync(new[] { nominerSwarm0.AsPeer }, null);

                await nominerSwarm1.PreloadAsync();

                await receiverSwarm.AddPeersAsync(new[] { nominerSwarm1.AsPeer }, null);

                await receiverSwarm.PreloadAsync(TimeSpan.FromSeconds(15), progress);

                // Await 1 second to make sure all progresses is reported.
                await Task.Delay(1000);

                Assert.Equal(minerChain.BlockHashes, receiverChain.BlockHashes);

                var expectedStates = new List <PreloadState>();

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var state = new BlockHashDownloadState
                    {
                        EstimatedTotalBlockHashCount = 10,
                        ReceivedBlockHashCount       = i,
                        SourcePeer = nominerSwarm1.AsPeer as BoundPeer,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var state = new BlockDownloadState
                    {
                        ReceivedBlockHash  = minerChain[i].Hash,
                        TotalBlockCount    = 10,
                        ReceivedBlockCount = i,
                        SourcePeer         = nominerSwarm1.AsPeer as BoundPeer,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var state = new BlockVerificationState
                    {
                        VerifiedBlockHash  = minerChain[i].Hash,
                        TotalBlockCount    = 10,
                        VerifiedBlockCount = i,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var state = new ActionExecutionState
                    {
                        ExecutedBlockHash  = minerChain[i].Hash,
                        TotalBlockCount    = 10,
                        ExecutedBlockCount = i,
                    };
                    expectedStates.Add(state);
                }

                // FIXME: this test does not ensures block download in order
                Assert.Equal(
                    expectedStates.ToHashSet(),
                    actualStates.ToHashSet()
                    );
            }
            finally
            {
                await StopAsync(minerSwarm);
                await StopAsync(nominerSwarm0);
                await StopAsync(nominerSwarm1);
                await StopAsync(receiverSwarm);

                nominerSwarm0.Dispose();
                nominerSwarm1.Dispose();

                fxForNominers[0].Dispose();
                fxForNominers[1].Dispose();
            }
        }
Exemple #13
0
        public async Task Preload()
        {
            Swarm <DumbAction> minerSwarm    = CreateSwarm();
            Swarm <DumbAction> receiverSwarm = CreateSwarm();

            BlockChain <DumbAction> minerChain    = minerSwarm.BlockChain;
            BlockChain <DumbAction> receiverChain = receiverSwarm.BlockChain;

            var blocks = new List <Block <DumbAction> >();

            foreach (int i in Enumerable.Range(0, 11))
            {
                Block <DumbAction> block = TestUtils.MineNext(
                    previousBlock: i == 0 ? minerChain.Genesis : blocks[i - 1],
                    difficulty: 1024)
                                           .AttachStateRootHash(
                    minerChain.StateStore,
                    minerChain.Policy.BlockAction);
                blocks.Add(block);
                if (i != 10)
                {
                    minerChain.Append(blocks[i]);
                }
            }

            var actualStates = new List <PreloadState>();
            var progress     = new ActionProgress <PreloadState>(state =>
            {
                _logger.Information("Received a progress event: {@State}", state);
                lock (actualStates)
                {
                    actualStates.Add(state);

                    if (actualStates.Count == 9)
                    {
                        minerChain.Append(blocks[10]);
                    }
                }
            });

            try
            {
                await StartAsync(minerSwarm);

                await receiverSwarm.AddPeersAsync(new[] { minerSwarm.AsPeer }, null);

                _logger.Verbose("Both chains before synchronization:");
                _logger.CompareBothChains(
                    LogEventLevel.Verbose,
                    "Miner chain",
                    minerChain,
                    "Receiver chain",
                    receiverChain
                    );

                minerSwarm.FindNextHashesChunkSize = 2;
                await receiverSwarm.PreloadAsync(TimeSpan.FromSeconds(15), progress);

                // Await 1 second to make sure all progresses is reported.
                await Task.Delay(1000);

                _logger.Verbose(
                    $"Both chains after synchronization ({nameof(receiverSwarm.PreloadAsync)}):"
                    );
                _logger.CompareBothChains(
                    LogEventLevel.Verbose,
                    "Miner chain",
                    minerChain,
                    "Receiver chain",
                    receiverChain
                    );
                Assert.Equal(minerChain.BlockHashes, receiverChain.BlockHashes);

                var expectedStates = new List <PreloadState>();

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var b     = minerChain[i];
                    var state = new BlockHashDownloadState
                    {
                        EstimatedTotalBlockHashCount = 10,
                        ReceivedBlockHashCount       = 1,
                        SourcePeer = minerSwarm.AsPeer as BoundPeer,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var b     = minerChain[i];
                    var state = new BlockDownloadState
                    {
                        ReceivedBlockHash  = b.Hash,
                        TotalBlockCount    = i == 9 || i == 10 ? 11 : 10,
                        ReceivedBlockCount = i,
                        SourcePeer         = minerSwarm.AsPeer as BoundPeer,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var b     = minerChain[i];
                    var state = new BlockVerificationState
                    {
                        VerifiedBlockHash  = b.Hash,
                        TotalBlockCount    = i == 9 || i == 10 ? 11 : 10,
                        VerifiedBlockCount = i,
                    };
                    expectedStates.Add(state);
                }

                for (var i = 1; i < minerChain.Count; i++)
                {
                    var b     = minerChain[i];
                    var state = new ActionExecutionState
                    {
                        ExecutedBlockHash  = b.Hash,
                        TotalBlockCount    = 11,
                        ExecutedBlockCount = i,
                    };
                    expectedStates.Add(state);
                }

                _logger.Debug("Expected preload states: {@expectedStates}", expectedStates);
                _logger.Debug("Actual preload states: {@actualStates}", actualStates);

                Assert.Equal(expectedStates.Count, actualStates.Count);
                foreach (var states in expectedStates.Zip(actualStates, ValueTuple.Create))
                {
                    Assert.Equal(states.Item1, states.Item2);
                }
            }
            finally
            {
                await StopAsync(minerSwarm);
                await StopAsync(receiverSwarm);
            }
        }
    void ActUpdate()
    {
        if (action == DiceAction.Wait)
        {
            if (actionProgress == ActionProgress.Ready)
            {
                // 스킵
                //actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                isTimeCountWork = true;

                // AI 관련 초기화
                if (owner != null)
                {
                    owner.ai.mainGame.dice.Ready();
                }
                doForceClick   = false;
                doForceClickUp = false;

                // 스킵
                actionProgress = ActionProgress.Working;
            }
            else if (actionProgress == ActionProgress.Working)
            {
                // 시점 변경
                cm.CamMoveTo(owner.avatar.transform, CameraManager.CamAngle.Middle);

                // 스킵
                actionProgress = ActionProgress.Finish;
            }
            else if (actionProgress == ActionProgress.Finish)
            {
                // 스킵
                actionProgress = ActionProgress.Ready;
                action         = DiceAction.Hovering;
            }
            return;
        }
        else if (action == DiceAction.Hovering)
        {
            if (actionProgress == ActionProgress.Ready)
            {
                // 회전 가속 초기화
                rotAccel = 1.0f;

                // 주사위 페이드 인 구현 예정 ===============

                // 스킵
                actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                // 스킵
                actionProgress = ActionProgress.Working;
                return;
            }
            else if (actionProgress == ActionProgress.Working)
            {
                // 오토 플레이
                if (owner.isAutoPlay)
                {
                    // AI 초도 작동
                    if (!owner.ai.mainGame.dice.isStart)
                    {
                        //AI 활성화
                        owner.ai.mainGame.dice.Work();
                    }
                }


                // 강제 클릭처리된 경우
                if (doForceClick || doForceClickUp)
                {
                    // 꾹 눌렀을때
                    if (doForceClick)
                    {
                        // 가속도
                        if (rotAccel < rotAccelMax)
                        {
                            rotAccel += 0.1f + Time.deltaTime * 5.0f + rotAccel * Time.deltaTime * 0.5f;
                        }
                        else if (rotAccel > rotAccelMax)
                        {
                            rotAccel = rotAccelMax;
                        }
                    }
                    // 클릭 종료될 때
                    else if (doForceClickUp)
                    {
                        //Debug.Break();
                        actionProgress = ActionProgress.Finish;
                    }
                }

                // 턴 제어자일 경우
                else if (Player.me == Turn.now)
                {
                    // 입력 가능 상태일 경우
                    if (!isInputBlock)
                    {
                        // UI 클릭 아닐 경우
                        if (UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject == null)
                        {
                            // 꾹 눌렀을때
                            if (Input.GetMouseButton(0))
                            {
                                // 가속도
                                if (rotAccel < rotAccelMax)
                                {
                                    rotAccel += 0.1f + Time.deltaTime * 5.0f + rotAccel * Time.deltaTime * 0.5f;
                                }
                                else if (rotAccel > rotAccelMax)
                                {
                                    rotAccel = rotAccelMax;
                                }
                            }
                            // 클릭 종료될 때
                            else if (Input.GetMouseButtonUp(0))
                            {
                                //Debug.Break();
                                actionProgress = ActionProgress.Finish;
                            }
                        }
                    }
                }


                // 최소, 최대 높이 보정
                Tool.HeightLimit(transform, minHeight, maxHeight);

                // 스핀
                Tool.Spin(transform, rotSpeed);


                // 사용 중단
                if (false)
                {
                    // 시간 제한
                    if (elapsedTime > 15.0f)
                    {
                        actionProgress = ActionProgress.Finish;

                        Debug.Log("호버링 타임 오버");
                    }

                    // 시간 카운트
                    if (isTimeCountWork)
                    {
                        elapsedTime += Time.deltaTime;
                    }
                }
            }
            else if (actionProgress == ActionProgress.Finish)
            {
                // 시간 초기화
                elapsedTime = 0f;

                // 스킵
                actionProgress = ActionProgress.Ready;
                action         = DiceAction.Rising;
            }
            return;
        }
        else if (action == DiceAction.Rising)
        {
            // 스핀
            Tool.Spin(transform, rotSpeed);

            // 회전 가속도 -  한계치까지
            if (rotAccel < rotAccelMax)
            {
                rotAccel += 1f + Time.deltaTime * 5.0f + rotAccel * Time.deltaTime * 0.5f;
            }
            else if (rotAccel > rotAccelMax)
            {
                rotAccel = rotAccelMax;
            }

            if (actionProgress == ActionProgress.Ready)
            {
                // 중력 활성화
                transform.GetComponent <Rigidbody>().useGravity = true;

                // 스킵
                actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                // 시점 변경
                cm.CamMoveTo(owner.avatar.transform, CameraManager.CamAngle.Top);

                // 상승 처리
                transform.GetComponent <Rigidbody>().isKinematic = false;
                transform.GetComponent <Rigidbody>().AddForce(Vector3.up * 50f * transform.GetComponent <Rigidbody>().mass, ForceMode.Impulse);

                // 좌표 저장
                //_posSpeed = transform.position.y;

                // 스킵
                actionProgress = ActionProgress.Working;
            }
            else if (actionProgress == ActionProgress.Working)
            {
                // 상승 인식
                if (transform.GetComponent <Rigidbody>().velocity.y > 0)
                {
                    // 상승 마감
                    actionProgress = ActionProgress.Finish;
                }
            }
            else if (actionProgress == ActionProgress.Finish)
            {
                // 스킵
                actionProgress = ActionProgress.Ready;
                action         = DiceAction.Spinning;
            }
            return;
        }
        else if (action == DiceAction.Spinning)
        {
            // 스핀
            Tool.Spin(transform, rotSpeed);

            // 회전 가속도 -  한계치까지
            if (rotAccel < rotAccelMax)
            {
                rotAccel += 1f + Time.deltaTime * 5.0f + rotAccel * Time.deltaTime * 0.5f;
            }
            else if (rotAccel > rotAccelMax)
            {
                rotAccel = rotAccelMax;
            }

            if (actionProgress == ActionProgress.Ready)
            {
                // 스킵
                actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                // 주사위 값 설정
                dice.Rolling();
                Debug.Log("주사위 값 :: " + dice.value);

                // 스킵
                actionProgress = ActionProgress.Working;
            }
            else if (actionProgress == ActionProgress.Working)
            {
                // 가속 중지하고 다음으로
                if (rotAccel == rotAccelMax)
                {
                    actionProgress = ActionProgress.Finish;
                }
            }
            else if (actionProgress == ActionProgress.Finish)
            {
                // 스킵
                actionProgress = ActionProgress.Ready;
                action         = DiceAction.Landing;
            }
            return;
        }
        else if (action == DiceAction.Landing)
        {
            if (actionProgress == ActionProgress.Ready)
            {
                // 스킵
                actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                // 스킵
                actionProgress = ActionProgress.Working;
            }
            else if (actionProgress == ActionProgress.Working)
            {
                // 스핀
                Tool.Spin(transform, rotSpeed);

                // 회전 감속
                if (rotAccel > 0.0f)
                {
                    rotAccel -= Time.deltaTime * 5.0f - rotAccel * Time.deltaTime * 0.5f;
                }
                else if (rotAccel < 0.0f)
                {
                    rotAccel = 0.0f;
                }

                // 하강 인식
                if (transform.GetComponent <Rigidbody>().velocity.y < 0)
                {
                    if (transform.position.y <= minHeight)
                    {
                        // 중력 비활성화
                        transform.GetComponent <Rigidbody>().isKinematic = true;
                        transform.GetComponent <Rigidbody>().useGravity  = false;

                        // 최소, 최대 높이 보정
                        Tool.HeightLimit(transform, minHeight, maxHeight);

                        // 하강 마감
                        actionProgress = ActionProgress.Finish;
                    }
                }
            }
            else if (actionProgress == ActionProgress.Finish)
            {
                // 스킵
                actionProgress = ActionProgress.Ready;
                action         = DiceAction.Finish;
            }
            return;
        }
        else if (action == DiceAction.Finish)
        {
            if (actionProgress == ActionProgress.Ready)
            {
                // 시간 카운터 리셋
                elapsedTime = 0f;

                // 스킵
                actionProgress = ActionProgress.Start;
            }
            else if (actionProgress == ActionProgress.Start)
            {
                // 눈에 따른 각도 지정
                Quaternion lastRot;
                if (dice.value == 1)
                {
                    lastRot = eye1;
                }
                else if (dice.value == 2)
                {
                    lastRot = eye2;
                }
                else if (dice.value == 3)
                {
                    lastRot = eye3;
                }
                else if (dice.value == 4)
                {
                    lastRot = eye4;
                }
                else if (dice.value == 5)
                {
                    lastRot = eye5;
                }
                else //(dice.value == 6)
                {
                    lastRot = eye6;
                }

                // 최종 회전 처리
                if (
                    Mathf.Abs(transform.rotation.x) != Mathf.Abs(lastRot.x) &&
                    Mathf.Abs(transform.rotation.y) != Mathf.Abs(lastRot.y) &&
                    Mathf.Abs(transform.rotation.z) != Mathf.Abs(lastRot.z) &&
                    Mathf.Abs(transform.rotation.w) != Mathf.Abs(lastRot.w)
                    )
                {
                    // 회전량 계산 (선형 보간)
                    transform.rotation = Quaternion.Lerp(transform.rotation, lastRot, Time.deltaTime * Mathf.Abs(_rotSpeed - rotAccel));
                }
                // 최동 회전 완료시 스킵
                else
                {
                    // 보정
                    transform.rotation = lastRot;

                    actionProgress = ActionProgress.Working;
                }
            }
            else if (actionProgress == ActionProgress.Working)
            {
                if (dice.value == 1)
                {
                    Tool.SpinZ(transform, _rotSpeed);
                }
                else if (dice.value == 2)
                {
                    Tool.SpinY(transform, _rotSpeed);
                }
                else if (dice.value == 3)
                {
                    Tool.SpinY(transform, _rotSpeed);
                }
                else if (dice.value == 4)
                {
                    Tool.SpinY(transform, _rotSpeed);
                }
                else if (dice.value == 5)
                {
                    Tool.SpinY(transform, _rotSpeed);
                }
                else // (dice.value == 6)
                {
                    Tool.SpinZ(transform, _rotSpeed);
                }

                // 시간 경과 시 넘김
                if (elapsedTime > 3.0f)
                {
                    elapsedTime    = 0f;
                    actionProgress = ActionProgress.Finish;
                }

                // 시간 카운트
                elapsedTime += Time.deltaTime;
            }
            else if (actionProgress == ActionProgress.Finish)
            {
            }
            return;
        }
    }
Exemple #15
0
 protected virtual void OnActionProgress(string filename, string actionName, string message)
 {
     ActionProgress?.Invoke(this, new XCOMActionProgressEventArgs(filename, actionName, message));
 }
Exemple #16
0
    public void CheckBarricade(ref Action act)
    {
        // 위치
        int loc = act.count;

        if (act.progress == ActionProgress.Ready)
        {
            Debug.LogWarning("오브젝트 습득 :: 액션 위치 = " + act.count);

            // 오브젝트 : 초기화
            objectPickUpList.Clear();
            objectPickUpStep = ActionProgress.Ready;


            //// 아이템 : 초기화
            //itemList.Clear();
            //isPickingUpItem = false;
            //itemFinish = false;

            //// 이벤트 : 초기화
            //eventList.Clear();
            //isPickingUpEvent = false;
            //eventFinish = false;

            // 스킵
            act.progress = ActionProgress.Start;
        }
        else if (act.progress == ActionProgress.Start)
        {
            // 초기화
            objectPickUpList.Clear();

            // 위치의 오브젝트 목록 가져오기
            List <DynamicObject> localBarricade = DynamicObject.objectList[loc];

            // 오브젝트 : 리스트 작성
            for (int i = 0; i < localBarricade.Count; i++)
            {
                DynamicObject obj = localBarricade[i];

                // 획득 조건 충족
                if (obj.CheckCondition(owner))
                {
                    // 획득 대기열 추가
                    objectPickUpList.Add(obj);

                    // 로그
                    Debug.LogWarning(string.Format("{0} 오브젝트 :: 습득 목록 추가 => ", obj.type, obj.transform.name));

                    continue;
                }
                else
                {
                    Debug.LogWarning(string.Format("{0} 오브젝트 :: 습득 자격 미달 => ", obj.type, obj.transform.name));
                }
            }

            // 스킵
            act.progress = ActionProgress.Working;
        }
        else if (act.progress == ActionProgress.Working)
        {
            // 오브젝트 : 습득
            if (objectPickUpStep == ActionProgress.Ready)
            {
                objectPickUp = StartCoroutine(GetObject());
            }


            // 완료 체크
            //if (itemFinish && eventFinish)
            if (objectPickUpStep == ActionProgress.Finish)
            {
                // 스킵
                objectPickUpStep = ActionProgress.Ready;
                act.progress     = ActionProgress.Finish;
            }
        }
        else if (act.progress == ActionProgress.Finish)
        {
            // 종료 처리
            act.isFinish = true;
        }
    }