Exemplo n.º 1
0
        private async Task <T> _AttemptPhase <T>(PhaseState state, Func <Task <T> > phase) where T : class
        {
            state.State = PhaseControl.State.Running;
            T result;

            try
            {
                var start = DateTime.UtcNow;
                var task  = phase();
                while (await Task.WhenAny(task, Task.Delay(100)) != task)
                {
                    state.Duration = DateTime.UtcNow - start;
                }
                result         = await task;
                state.Duration = DateTime.UtcNow - start;
            }
            catch (OperationCanceledException)
            {
                state.State = PhaseControl.State.Canceled;
                throw;
            }
            catch
            {
                state.State = PhaseControl.State.Error;
                throw;
            }
            state.State = PhaseControl.State.Success;
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads a phase object.
        /// </summary>
        public PhaseState ReadPhase(ISystemContext context, BaseObject source)
        {
            ushort namespaceIndex = (ushort)context.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

            PhaseState node = new PhaseState(null);

            node.Create(
                context,
                new NodeId("Phases/" + source.BrowseName, namespaceIndex),
                new QualifiedName(source.BrowseName, namespaceIndex),
                null,
                true);

            if (source.DisplayName != null && source.DisplayName.Length > 0)
            {
                node.DisplayName = Import(source.DisplayName);
            }

            if (source.Description != null && source.Description.Length > 0)
            {
                node.Description = Import(source.Description);
            }

            return(node);
        }
Exemplo n.º 3
0
    IEnumerator PrepCounter()
    {
        FindObjectOfType <WaveManager>().enabled = false;
        phaseUI.text = "Prep Phase";

        //While timer is not up and max units to move are up.
        for (float timer = prepTimer; timer >= 0; timer -= Time.deltaTime)
        {
            if (unitDeployed)
            {
                break;
            }
            else
            {
                timerText.text = ((int)timer).ToString();
                yield return(null);
            }
        }

        //Move over to action phase
        Debug.Log("Prep Phase is over, proceeding to Action Phase...");
        phaseUI.text   = "Action Phase";
        timerText.text = "";
        currentPhase   = PhaseState.Action;
        FindObjectOfType <WaveManager>().enabled = true;
    }
Exemplo n.º 4
0
 private async Task _AttemptPhase(PhaseState state, Func <Task> phase)
 {
     state.State = PhaseControl.State.Running;
     try
     {
         var start = DateTime.UtcNow;
         var task  = phase();
         while (await Task.WhenAny(task, Task.Delay(100)) != task)
         {
             state.Duration = DateTime.UtcNow - start;
         }
         await task;
         state.Duration = DateTime.UtcNow - start;
     }
     catch (OperationCanceledException)
     {
         state.State = PhaseControl.State.Canceled;
         throw;
     }
     catch
     {
         state.State = PhaseControl.State.Error;
         throw;
     }
     state.State = PhaseControl.State.Success;
 }
        /// <summary>
        /// Send a create operation to  the state of the specified phase on the specified job.
        /// </summary>
        /// <param name="job">The Job on which to operate</param>
        /// <param name="phaseName">The name of the phase whose state is to change</param>
        /// <param name="item">The PhaseState instance template</param>
        /// <param name="zoneId">The zone in which to perform the request.</param>
        /// <param name="contextId">The context in which to perform the request.</param>
        /// <returns>The current state of the phase.</returns>
        public virtual PhaseState CreateToState(Job job, string phaseName, PhaseState item, string zoneId = null, string contextId = null)
        {
            checkRegistered();

            checkJob(job, zoneId);

            string url  = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + "/states/state" + HttpUtils.MatrixParameters(zoneId, contextId);
            string body = SerialiseSingle <PhaseState, stateType>(item);
            string xml  = HttpUtils.PostRequest(
                url,
                RegistrationService.AuthorisationToken,
                body,
                ConsumerSettings.CompressPayload,
                ServiceType.FUNCTIONAL);

            if (log.IsDebugEnabled)
            {
                log.Debug("Guid from CREATE request to state on phase ...");
            }
            if (log.IsDebugEnabled)
            {
                log.Debug(xml);
            }
            return(DeserialiseSingle <PhaseState, stateType>(xml));
        }
Exemplo n.º 6
0
        //!check to see if we are currently in phase strike mode
        public bool CheckPhaseStrike()
        {
            AnimatorStateInfo StateInfo2 = X8Animator.GetCurrentAnimatorStateInfo(0);



            if (StateInfo2.IsName("Phase"))
            {
                //we might have starfed during a jump so stop the jump animation
                if (PlayerJumpState == JumpingState.IsJumping)
                {
                    StopJump();
                }


                pRidgidBody.useGravity = false;
                p_bFacePlayer          = true;

                X8Animator.SetBool("Phase", true);


                if (StateInfo2.normalizedTime > .01f && StateInfo2.normalizedTime < .65f)
                {
                    Vector3 TackleDirection = Vector3.zero;

                    p_Collider.enabled = false;
                    FaceMe(p_fCameraAngleTheta);
                    //player is in tackle mode
                    //the Direction of attack is the same as the direction of fire without the vertical direction
                    if (Controls != null) //if this is a real player an not an Enemy AI
                    {
                        TackleDirection = Controls.ShootDirection.normalized;
                    }
                    //zero out the y direction because the we dont want any vertical movement
                    TackleDirection.y = 0;
                    //add the tackle vector the player position
                    PlayerPhaseState = PhaseState.IsPhasing;
                    if (StateInfo2.normalizedTime > .30f && StateInfo2.normalizedTime < .65f)
                    {
                        this.transform.position += (TackleDirection * .75f);
                    }
                    return(true);
                }
                else
                {
                    p_Collider.enabled     = true;
                    pRidgidBody.useGravity = true;

                    PlayerPhaseState = PhaseState.IsNotPhasing; //player is no longer in tackle mode

                    if (StateInfo2.normalizedTime > .99f)
                    {
                        X8Animator.SetBool("Phase", false);
                    }
                    return(false);
                }
            }

            return(false);
        } //!stop phase mode
Exemplo n.º 7
0
 /// <summary>
 /// Set current state to the end of turn state
 /// </summary>
 void EnterStateEndOfTurn()
 {
     currentPhaseStateMethod = new CurrentPhaseState(StateEndOfTurn);
     CurrentlySelectedUnit.EndTurn();
     BoardManager.instance.EndTurn();
     CurrentPhase = PhaseState.EndOfTurn;
 }
Exemplo n.º 8
0
    public void ChangePhase(PhaseState phase)
    {
        currentPhase = phase;

        int layerDefault   = LayerMask.NameToLayer("Default");
        int layerEnemyRed  = LayerMask.NameToLayer("EnemyRed");
        int layerEnemyBlue = LayerMask.NameToLayer("EnemyBlue");

        if (phase == PhaseState.Red)
        {
            Physics2D.IgnoreLayerCollision(layerDefault, layerEnemyRed, true);
            Physics2D.IgnoreLayerCollision(layerDefault, layerEnemyBlue, false);
            phaseMusic.PlayRedTrack();
        }
        else if (phase == PhaseState.Blue)
        {
            Physics2D.IgnoreLayerCollision(layerDefault, layerEnemyRed, false);
            Physics2D.IgnoreLayerCollision(layerDefault, layerEnemyBlue, true);
            phaseMusic.PlayBlueTrack();
        }

        foreach (PhasedGameObject phasedObject in FindPhasedGameObjects())
        {
            phasedObject.PlayerPhaseSwitched(phase);
        }
    }
Exemplo n.º 9
0
 void FlushAll()
 {
     FlushForUnfinishedGroup();
     groupState = GroupingState.None;
     phaseState = PhaseState.None;
     field      = null;
 }
Exemplo n.º 10
0
        void BoundaryValues()
        {
            if (groupState == GroupingState.Finished && phase == string.Empty)
            {
                groupState = GroupingState.None;
                phase      = settings.GroupModificator.ToString() + settings.GroupModificator;
            }
            if (field != null && phase == string.Empty)
            {
                phase = field + settings.SpecificFieldModificator;
                field = null;
            }
            if (phase != string.Empty)
            {
                return;
            }
            switch (phaseState)
            {
            case PhaseState.Include:
                phase += settings.IncludeModificator;
                break;

            case PhaseState.Exclude:
                phase += settings.ExcludeModificator;
                break;
            }
            phaseState = PhaseState.None;
        }
Exemplo n.º 11
0
            public Task <HandOverToPhase1> Phase0Async()
            {
                //this.parent.Prime = CryptoHelper.GeneratePrime();
                if (this.Phase != PhaseState.Phase0)
                {
                    throw new InvalidOperationException();
                }
                this.Phase = PhaseState.Phase1;

                return(Task.Run(() =>
                {
                    var result = new HandOverToPhase1()
                    {
                        Nodes = new NodeToPhase1[this.parent.generatedCryptoNodes.Length], Map = this.parent.PrototypeMap
                    };
                    for (int i = 0; i < result.Nodes.Length; i++)
                    {
                        var item = this.parent.generatedCryptoNodes[i];
                        result.Nodes[i] = new NodeToPhase1()
                        {
                            Value = item.TrueNode.Initilize.Phase0(), PrototypeIdNode = item.PrototypeNode.id
                        };
                    }
                    return result;
                }));
            }
Exemplo n.º 12
0
            public Task <HandOverToPhase2> Phase1Async(HandOverToPhase1 fromPhaseOne)
            {
                if (this.Phase != PhaseState.Phase1)
                {
                    throw new InvalidOperationException();
                }
                this.Phase = PhaseState.Phase2;

                return(Task.Run(() =>
                {
                    if (!fromPhaseOne.Map.DeepEquals(this.parent.PrototypeMap))
                    {
                        throw new ArgumentException("Using diferent Maps");
                    }

                    var result = new HandOverToPhase2()
                    {
                        Nodes = new NodeToPhase2[fromPhaseOne.Nodes.Length]
                    };

                    for (int i = 0; i < result.Nodes.Length; i++)
                    {
                        var item = fromPhaseOne.Nodes[i];
                        var cn = this.parent.prototypeIdLookup[item.PrototypeIdNode];
                        var ownExponented = cn.TrueNode.Initilize.Phase1(item.Value);
                        result.Nodes[i] = new NodeToPhase2()
                        {
                            OtherExponented = ownExponented, PrototypeIdNode = cn.PrototypeNode.id
                        };
                    }
                    return result;
                }));
            }
 public void SetPhaseState(PhaseState state)
 {
     m_currentState = state;
     foreach (StoplightController s in m_stoplights)
     {
         s.ChangeLight(m_currentState);
     }
 }
Exemplo n.º 14
0
    private IEnumerator SwitchToTwoThree()
    {
        yield return(new WaitForSeconds(secBeforeHurtAnim));

        bossAnim.SetTrigger("Hurt");
        currentPhase = PhaseState.TwoThree;
        yield return(new WaitForSeconds(secondsBetweenStateChange));
    }
Exemplo n.º 15
0
    /// <summary>
    /// Set the current state to select an attack
    /// </summary>
    void EnterStateTargetAttack()
    {
        currentPhaseStateMethod = new CurrentPhaseState(StateTargetAttack);

        CombatUIManager.instance.StartTargetAttackPhase();

        CurrentPhase = PhaseState.TargetAttack;
    }
Exemplo n.º 16
0
        //
        // Constructors.
        //

		public StBarrier(int partners, Action<object> ppha, object pphaCtx) {
            if (partners < 1 || partners > MAX_PARTNERS) {
                throw new ArgumentOutOfRangeException("\"partners\" is non-positive or greater 32767");
            }
            pphAction = ppha;
            pphActionContext = pphaCtx;
            phState = new PhaseState(partners << PARTNERS_SHIFT);
        }
Exemplo n.º 17
0
    /// <summary>
    /// Set current state to performing a QTE
    /// </summary>
    void EnterStateAttackQTE()
    {
        currentPhaseStateMethod = new CurrentPhaseState(StateAttackQTE);

        CurrentlySelectedUnit.AbilityActivator.FinishAbility();

        CurrentPhase = PhaseState.AttackQTE;
    }
Exemplo n.º 18
0
 public void InitializeExploration()
 {
     Debug.Log("탐사 초기화");
     phaseState = PhaseState.FinishingExploration;
     ChangeRegion(null, "도시");
     SelectEvent(startingEvent);
     AppearEvent(_currentEvent);
 }
Exemplo n.º 19
0
 public TraySection ConnectFeed(MaterialStream stream, int stage, PhaseState phase = PhaseState.LiquidVapor)
 {
     _feeds.Add(new TrayConnectivity()
     {
         Stage = stage, Stream = stream, Phase = phase
     });
     Connect("Feeds", stream);
     return(this);
 }
Exemplo n.º 20
0
        //
        // Start a new phase.
        //

        private void NewPhase()
        {
            phNumber++;
            PhaseState phs = phState;

            phState = new PhaseState(phs.state & PARTNERS_MASK);
            phs.waitEvent.Set();
            return;
        }
Exemplo n.º 21
0
    /// <summary>
    /// Enter state while waiting for enemy team to go
    /// </summary>
    void EnterStateEnemyTurn()
    {
        currentPhaseStateMethod = new CurrentPhaseState(StateEnemyTurn);

        CombatUIManager.instance.StartEnemyTurnPhase();
        CurrentlySelectedUnit = null;
        AIManager.StartEnemyTurn();

        CurrentPhase = PhaseState.EnemyTurn;
    }
Exemplo n.º 22
0
        //
        // Constructors.
        //

        public StBarrier(int partners, Action <object> ppha, object pphaCtx)
        {
            if (partners < 1 || partners > MAX_PARTNERS)
            {
                throw new ArgumentOutOfRangeException("\"partners\" is non-positive or greater 32767");
            }
            pphAction        = ppha;
            pphActionContext = pphaCtx;
            phState          = new PhaseState(partners << PARTNERS_SHIFT);
        }
Exemplo n.º 23
0
    /// <summary>
    /// Set the current state to select an attack
    /// </summary>
    void EnterStateSelectAttack()
    {
        currentPhaseStateMethod = new CurrentPhaseState(StateSelectAttack);

        CombatUIManager.instance.StartSelectAttackPhase();
        CurrentlySelectedUnit.AbilityActivator.FinishAbility();
        BoardManager.instance.FinishMovement();

        CurrentPhase = PhaseState.SelectAttack;
    }
        public void SetProjectionState(PhaseState state)
        {
            var starting = _state == PhaseState.Starting && state == PhaseState.Running;

            _state = state;
            _processingQueue.SetIsRunning(state == PhaseState.Running);
            if (starting)
            {
                NewCheckpointStarted(LastProcessedEventPosition);
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// 다음 탐사 State로 변경한다.
 /// </summary>
 private void ChangeToFollowingState()
 {
     if (phaseState == PhaseState.FinishingExploration)
     {
         phaseState = PhaseState.ItemDiscovery1;
     }
     else
     {
         phaseState += 1;
     }
 }
Exemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        normaiState          = new NormalPhase();
        fastState            = new FastPhase();
        buttonSwapState      = new ButtonSwapPhase();
        variatingSizesState  = new VariatingSizesPhase();
        differentShapesState = new DifferentShapesPhase();
        ghostState           = new GhostPhase();

        currentState = normaiState;
    }
Exemplo n.º 27
0
            /// <summary>
            /// Calculats Z using the other Partys Original Z ^ other Private exponent . After this Initialisation is Finished.
            /// </summary>
            /// <param name="exchange">Original Z ^ other Private exponent </param>
            public void Phase2(BigInteger exchange)
            {
                if (this.Phase != PhaseState.Phase2)
                {
                    throw new InvalidOperationException();
                }

                var combined = BigInteger.ModPow(exchange, this.parent.PrivateExponent, this.parent.Map.Prime);

                this.parent.Z = combined;
                this.Phase    = PhaseState.Finished;
            }
Exemplo n.º 28
0
 /// <summary>
 /// Set the current state to movement selection
 /// </summary>
 void EnterStateMovementSelection()
 {
     currentPhaseStateMethod = new CurrentPhaseState(StateMovementSelection);
     CombatUIManager.instance.StartMovementPhase();
     CurrentPhase        = PhaseState.SelectMovement;
     currentMoveDistance = CurrentlySelectedUnit.remainingMoveDistance;
     if (CurrentlySelectedUnit.CanMove())
     {
         BoardManager.instance.HighlightMovement(currentMoveDistance, CurrentlySelectedUnit.CurrentlyOccupiedHexagon);
     }
     CurrentlySelectedUnit.MovementIsDirty = false;
 }
Exemplo n.º 29
0
            /// <summary>
            /// First generate your part of Z and send it to the other Party
            /// </summary>
            /// <returns>Your part of Z</returns>
            public BigInteger Phase0()
            {
                if (this.Phase != PhaseState.Phase0)
                {
                    throw new InvalidOperationException();
                }
                (this.parent.PrivateExponent, this.parent.InverseExponent) = Generate.InversableExponent(parent.Map.Prime);

                this.initialZ = Generate.Random(this.parent.Map.Prime); // create our part of Z
                this.Phase    = PhaseState.Phase1;
                return(this.initialZ);
            }
Exemplo n.º 30
0
        //
        // Adds the specified number of partners to the current phase.
        //

        public long AddPartners(int count)
        {
            if (count < 1 || count > MAX_PARTNERS)
            {
                throw new ArgumentOutOfRangeException("\"count\" non-positive or greater than 32767");
            }
            PhaseState phs = phState;

            do
            {
                int s;
                int partners = (s = phs.state) >> PARTNERS_SHIFT;
                int arrived  = s & ARRIVED_MASK;

                //
                // Check if the maximum number of partners will be exceeded.
                //

                if (count + partners > MAX_PARTNERS)
                {
                    throw new ArgumentOutOfRangeException("Barrier partners overflow");
                }

                //
                // If the current phase is already closed, wait unconditionally
                // until the phase is started.
                //

                if (arrived == partners)
                {
                    phs.waitEvent.Wait(StCancelArgs.None);

                    //
                    // Get the new phase state and retry.
                    //

                    phs = phState;
                    continue;
                }

                //
                // Update the number of partners and return, if succeed.
                //

                int ns = s + (count << PARTNERS_SHIFT);
                if (Interlocked.CompareExchange(ref phs.state, ns, s) == s)
                {
                    return(phNumber);
                }
            } while (true);
        }
Exemplo n.º 31
0
        /// <see cref="IFunctionalService.CreateToState(Guid, string, stateType, string, string)"/>
        public virtual stateType CreateToState(Guid id, string phaseName, stateType item = null, string zone = null, string context = null)
        {
            Job   job   = repository.Retrieve(id);
            Phase phase = getPhase(job, phaseName);

            RightsUtils.CheckRight(phase.StatesRights, new Right(RightType.CREATE, RightValue.APPROVED));

            PhaseState state = MapperFactory.CreateInstance <stateType, PhaseState>(item);

            job.UpdatePhaseState(phaseName, state.Type, state.Description);
            repository.Save(job);

            return(MapperFactory.CreateInstance <PhaseState, stateType>(phase.GetCurrentState()));
        }
Exemplo n.º 32
0
		virtual protected void onComplete(){
			dispatchPhaseComplete(nextPhaseId);
			state = PhaseState.Inactive;
			Reset();
		}
Exemplo n.º 33
0
 void OnGamePhaseChanged( PhaseState newPhase )
 {
 }
Exemplo n.º 34
0
            static PhaseState()
            {
                Start = new PhaseState() { State = 0, Name = "开始" };

                Saving = new PhaseState() { State = 1, Name = "修改保存" };

                SetUp = new PhaseState() { State = 2, Name = "开启" };

                FirstVertifying = new PhaseState() { State = 3, Name = "一次审核" };

                SecondVertifying = new PhaseState() { State = 4, Name = "二次审核" };

                Examing = new PhaseState() { State = 5, Name = "评审" };

                Finishing = new PhaseState() { State = 6, Name = "评审结束" };

                End = new PhaseState() { State = 7, Name = "结束" };

                Dic = new Dictionary<int, PhaseState>();

                Dic.Add(Start.State, Start);
                Dic.Add(Saving.State, Saving);
                Dic.Add(SetUp.State, SetUp);
                Dic.Add(FirstVertifying.State, FirstVertifying);

                Dic.Add(SecondVertifying.State, SecondVertifying);
                Dic.Add(Examing.State, Examing);
                Dic.Add(Finishing.State, Finishing);
                Dic.Add(End.State, End);
            }
Exemplo n.º 35
0
		public void Start(DialoguerVariables localVars){
			Reset();
			_localVariables = localVars;
			state = PhaseState.Start;
		}
Exemplo n.º 36
0
        /// <summary>
        /// Reads a phase object.
        /// </summary>
        public PhaseState ReadPhase(ISystemContext context, BaseObject source)
        {
            ushort namespaceIndex = (ushort)context.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

            PhaseState node = new PhaseState(null);

            node.Create(
                context,
                new NodeId("Phases/" + source.BrowseName, namespaceIndex), 
                new QualifiedName(source.BrowseName, namespaceIndex),
                null,
                true);

            if (source.DisplayName != null && source.DisplayName.Length > 0)
            {
                node.DisplayName = Import(source.DisplayName);
            }

            if (source.Description != null && source.Description.Length > 0)
            {
                node.Description = Import(source.Description);
            }

            return node;
        }
Exemplo n.º 37
0
		virtual protected void onAction(){
			state = PhaseState.Complete;
		}
Exemplo n.º 38
0
		virtual protected void onStart(){
			state = PhaseState.Action;
		}
Exemplo n.º 39
0
        //
        // Start a new phase.
        //

        private void NewPhase() {
            phNumber++;
            PhaseState phs = phState;
            phState = new PhaseState(phs.state & PARTNERS_MASK);
            phs.waitEvent.Set();
            return;
        }
 public void SetProjectionState(PhaseState state)
 {
     _state = state;
 }