예제 #1
0
        /// <summary>
        /// Erlaubt die Ausführung der Steuerung.
        /// </summary>
        /// <param name="game">Referenz des Games aus dem XNA Framework.</param>
        /// <param name="gameTime">Bietet die aktuelle Spielzeit an.</param>
        /// <param name="state">Gibt den aktuellen State an von dem diese Funktion aufgerufen wurde.</param>
        public override void Update(Game game, GameTime gameTime, StateMachine.State state)
        {
            //Suche Tote GameItem und schreibe sie in Liste
            List <IGameItem> deadItems = new List <IGameItem>(this.Controllees.Where(x => x.IsAlive == false));

            //Entferne Tote GameItem
            foreach (var item in deadItems)
            {
                this.Controllees.Remove(item);
            }



            //modified by CK
            //foreach (IGameItem item in Controllees.ToArray())
            //{
            //    if (!(item.IsAlive))
            //    {
            //        Controllees.Remove(item);
            //    }

            //}

            base.Update(game, gameTime, state);
        }
예제 #2
0
    void Update()
    {
        if (StateMachine.CurrentState == StateMachine.State.Finished)
        {
            return;
        }

        State = StateMachine.CurrentState;

        if (StateMachine.CurrentState == StateMachine.State.Locked)
        {
            if (ButtonPress())
            {
                if (currentTarget == focusedTarget.gameObject)
                {
                    Misfire(focusedTarget);
                }
                else
                {
                    focusedTarget.DisableEffect();
                    Helper.Log(SessionName + "_" + Condition.ToString() + "_ACTIONS", "BUTTON PRESSED");
                    StateMachine.CurrentState = StateMachine.State.Unlocked;
                }
            }
        }
    }
예제 #3
0
 private void EnterStateStarting()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     this.mState = StateMachine.State.Starting;
     try
     {
         VBoxBridgeService.Instance.Connect();
     }
     catch (Exception ex1)
     {
         Logger.Info("Cannot connect VBoxBridge");
         Logger.Info(ex1.ToString());
         try
         {
             ComRegistration.Register();
             Logger.Info("Reconnecting to VBoxBridge");
             VBoxBridgeService.Instance.Connect();
         }
         catch (Exception ex2)
         {
             Logger.Info("Got exception {0} while re-registering COM", (object)ex2.ToString());
             AndroidBootUp.HandleBootError();
         }
     }
     if (VBoxBridgeService.Instance.StartMachineAsync(this.mVmName, (VBoxBridgeService.BooleanCallback)(success => this.mWorkQueue.DispatchAsync((SerialWorkQueue.Work)(() => this.StartMachineCompletion(success)))), (VBoxBridgeService.BooleanCallback)(success => this.mWorkQueue.DispatchAsync((SerialWorkQueue.Work)(() => this.StopMachineCompletion(success))))))
     {
         return;
     }
     Logger.Info("Cannot begin starting guest");
     this.EnterStateError();
     AndroidBootUp.HandleBootError();
 }
        /// <summary>
        /// Iteriert über die gesamte Liste <c>ViewItemList</c> und ruft die <c>Update()</c> bzw. <c>Draw()</c> Methoden auf.
        /// </summary>
        /// <param name="game">XNA Game Klasse</param>
        /// <param name="gameTime">Spielzeit</param>
        /// <param name="state">aktueller Zustand in dem sich die StateMachine befindet.</param>
        public void Update(GameManager game, GameTime gameTime, StateMachine.State state)
        {
            GameManager gameMngr = game;

            /*
             * RemoveAll entfernt alle Element die die Bedingung im Delegate erfüllen.
             * Dazu wird ein anonymes Deleaget erstellt welches die Bedingungen beinhaltet.
             * */
            this.ViewItemList.RemoveAll(delegate(IView item)
            {
                if (item is GameItemRepresentation)
                {
                    return(!((GameItemRepresentation)item).GameItem.IsAlive);
                }
                else
                {
                    return(false);
                }
            });

            foreach (IView item in this.ViewItemList)
            {
                if (item is Intro)
                {
                    ((Intro)item).Play(ViewContent.EffectContent.IntroVideo);
                }
                item.Draw(gameMngr.spriteBatch);
            }
        }
    protected virtual bool State_Walk(StateMachine.State state)
    {
        switch (state)
        {
        case StateMachine.State.Enter:
            this.Animator.SetBool("Walk", true);
            break;

        case StateMachine.State.Update:
            float yAxis = Input.GetAxis("Vertical");

            if (Mathf.Abs(yAxis) < 0.1F)
            {
                this.StateMachine.StateId = "Idle";
            }

            this.Animator.SetFloat("YAxis", yAxis);

            break;

        case StateMachine.State.Exit:
            this.Animator.SetBool("Walk", false);
            this.Animator.SetFloat("YAxis", 0.0F);
            break;
        }

        return(true);
    }
예제 #6
0
    /** SingleTapReaction
     *
     * Function for reactions to a single tap event
     *
     */
    public void SingleTapReaction(TappedEventArgs args)
    {
        StateMachine.State state = StateMachine.Instance.state;
        switch (state)
        {
        case StateMachine.State.Calibration:
            CaliTap c = this as CaliTap;
            if (c != null)
            {
                c.SingleTap(args);
            }
            break;

        case StateMachine.State.Interaction:
            InterTap i = this as InterTap;
            if (i != null)
            {
                i.SingleTap(args);
            }
            break;

        case StateMachine.State.Adjusting:
            AdjTap a = this as AdjTap;
            if (a != null)
            {
                a.SingleTap(args);
            }
            break;

        default:
            Debug.Log("Unkonwn State");
            break;
        }
    }
 /// <summary>
 /// Erstellt eine MenuUI-Objekt und fügt dieses in die ViewItemList ein.
 /// </summary>
 /// <returns>MenuUI-Objekt, welches das Menu darstellt.</returns>
 private MenuUI CreateMenuUI(StateMachine.State currentState, GraphicsDeviceManager graphics)
 {
     Debug.Assert(graphics != null, "Es gibt keine Referenz auf den GraphicsDeviceManager!");
     Debug.Assert(currentState != null, "Es gibt keine Referenz auf den aktuellen State!");
     //[Anji] Weiterreichen des currentstates an die MenuUI
     return(new MenuUI(((Menu)currentState.Model).Controls, graphics, currentState));
 }
예제 #8
0
    /** ManCompleteReaction
     *
     * Called when the Manipulation/move event is completed.
     *
     */
    public void ManCompleteReaction(ManipulationCompletedEventArgs args)
    {
        StateMachine.State state = StateMachine.Instance.state;
        switch (state)
        {
        case StateMachine.State.Calibration:
            CaliMan c = this as CaliMan;
            if (c != null)
            {
                c.ManComplete(args);
            }
            break;

        case StateMachine.State.Interaction:
            InterMan i = this as InterMan;
            if (i != null)
            {
                i.ManComplete(args);
            }
            break;

        case StateMachine.State.Adjusting:
            AdjMan a = this as AdjMan;
            if (a != null)
            {
                a.ManComplete(args);
            }
            break;

        default:
            Debug.Log("Unkonwn State");
            break;
        }
    }
예제 #9
0
    /** NavCompleteReaction
     *
     * Called when the Navigation event is completed.
     *
     */
    public void NavCompleteReaction(NavigationCompletedEventArgs args)
    {
        StateMachine.State state = StateMachine.Instance.state;
        switch (state)
        {
        case StateMachine.State.Calibration:
            CaliNav c = this as CaliNav;
            if (c != null)
            {
                c.NavComplete(args);
            }
            break;

        case StateMachine.State.Interaction:
            InterNav i = this as InterNav;
            if (i != null)
            {
                i.NavComplete(args);
            }
            break;

        case StateMachine.State.Adjusting:
            AdjNav a = this as AdjNav;
            if (a != null)
            {
                a.NavComplete(args);
            }
            break;

        default:
            Debug.Log("Unkonwn State");
            break;
        }
    }
예제 #10
0
    /** HoldCompleteReaction
     *
     * Called when the Manipulation/move event is completed.
     *
     */
    public void HoldCompleteReaction(HoldCompletedEventArgs args)
    {
        StateMachine.State state = StateMachine.Instance.state;
        switch (state)
        {
        case StateMachine.State.Calibration:
            CaliHold c = this as CaliHold;
            if (c != null)
            {
                c.HoldComplete(args);
            }
            break;

        case StateMachine.State.Interaction:
            InterHold i = this as InterHold;
            if (i != null)
            {
                i.HoldComplete(args);
            }
            break;

        case StateMachine.State.Adjusting:
            AdjHold a = this as AdjHold;
            if (a != null)
            {
                a.HoldComplete(args);
            }
            break;

        default:
            Debug.Log("Unkonwn State");
            break;
        }
    }
예제 #11
0
 private void EnterStateStopped()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     VBoxBridgeService.Instance.DisConnect();
     this.mState = StateMachine.State.Stopped;
 }
예제 #12
0
    private IEnumerator EnemyStopAndLaunch(Enemy enemy)
    {
        StateMachine.State <Enemy> previousState = enemy.followTypeStateController.currentState;
        enemy.followTypeStateController.ChangeState(IdleState.Instance);
        yield return(new WaitForSecondsRealtime(1f));

        enemy.followTypeStateController.ChangeState(previousState);
    }
예제 #13
0
 /*--------------------------------------------------------------------------------
 *   StateChange
 *  --------------------------------------------------------------------------------*/
 /// <summary>
 /// Whenever StateMaschine state change has happened.
 /// </summary>
 /// <param name="newState">StateMachine new state.</param>
 /// <param name="oldState">StateMachine previous state.</param>
 public override void StateChange(StateMachine.State newState, StateMachine.State oldState)
 {
     base.StateChange(newState, oldState);
     if (newState == stateVisible)
     {
         SetScores();
     }
 }
예제 #14
0
 /// <summary>
 /// Issue an event after changing the state. ステートを変更した後イベントを発行する
 /// </summary>
 /// <param name="state"></param>
 public void TransitionState(StateMachine.State state)
 {
     m_StateMachine.m_PreviousState = m_StateMachine.m_State; // ステート遷移前のステートを保存
     m_StateMachine.m_State         = state;                  // stateをセット
     // ==================================
     //                                          Event call.
     // ==================================
     m_BehaviourByState.Invoke(state);
 }
예제 #15
0
 public StateMachine(string vmName)
 {
     this.mVmName    = vmName;
     this.mWorkQueue = new SerialWorkQueue(nameof(StateMachine))
     {
         ExceptionHandler = new SerialWorkQueue.ExceptionHandlerCallback(this.HandleWorkQueueException)
     };
     this.mWorkQueue.Start();
     this.mTerminationEvent = new EventWaitHandle(false, EventResetMode.ManualReset);
     this.mState            = StateMachine.State.Init;
 }
예제 #16
0
 /*--------------------------------------------------------------------------------
 *   StateChange
 *  --------------------------------------------------------------------------------*/
 /// <summary>
 /// StateChange all components in the scene.
 /// </summary>
 /// <param name="array">Components to call.</param>
 /// <param name="newState">StateMachine new state.</param>
 /// <param name="oldState">StateMachine old state.</param>
 private static void StateChange(IStateChange[] array, StateMachine.State newState, StateMachine.State oldState)
 {
     if (array != null)
     {
         int count = array.Length;
         for (int i = 0; i < count; i++)
         {
             array[i].StateChange(newState, oldState);
         }
     }
 }
    protected virtual bool State_Jump(StateMachine.State state)
    {
        switch (state)
        {
        case StateMachine.State.Enter:
            this.Animator.SetTrigger("Jump");
            break;
        }

        return(true);
    }
예제 #18
0
 /*--------------------------------------------------------------------------------
 *   StateChange
 *  --------------------------------------------------------------------------------*/
 public virtual void StateChange(StateMachine.State newState, StateMachine.State oldState)
 {
     if (newState == stateVisible)
     {
         Visible(true);
     }
     else
     {
         Visible(false);
     }
 }
예제 #19
0
 private void EnterStateStopping()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     this.mState = StateMachine.State.Stopping;
     if (VBoxBridgeService.Instance.StopMachineAsync())
     {
         return;
     }
     Logger.Info("Cannot stop guest");
     this.EnterStateError();
 }
예제 #20
0
 private void EnterStateRunning()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     this.mState = StateMachine.State.Running;
     StateMachine.VoidCallback mRunningCallback = this.mRunningCallback;
     if (mRunningCallback == null)
     {
         return;
     }
     mRunningCallback();
 }
예제 #21
0
 private void EnterStateError()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     StateMachine.BooleanCallback mStartCallback = this.mStartCallback;
     if (mStartCallback != null)
     {
         mStartCallback(false);
     }
     this.mState = StateMachine.State.Error;
     this.mTerminationEvent.Set();
 }
예제 #22
0
        public static Int32 Evaluate(Object state, ref Boolean error)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(0);
            }

            StateMachine.State prevstate = character.StateManager.PreviousState;
            return((prevstate != null) ? prevstate.Number : 0);
        }
예제 #23
0
 private void EnterStateWaitingForNetwork()
 {
     Logger.Info("{0}", (object)MethodBase.GetCurrentMethod().Name);
     this.SerialQueueCheck();
     this.mState = StateMachine.State.WaitingForNetwork;
     this.mWorkQueue.DispatchAfter(1.0, (SerialWorkQueue.Work)(() =>
     {
         if (this.mState != StateMachine.State.WaitingForNetwork)
         {
             return;
         }
         this.EnterStateRunning();
     }));
 }
예제 #24
0
        private void StartFresh()
        {
            Action a1 = () =>
            {
                //Making the snake move every x milliseconds
                while (playing)
                {
                    MoveSnake(toMove);
                    Thread.Sleep(sleepTime);
                }
            };

            Action a2 = () =>
            {
                //Reading the input from the user and setting toMove to the new state
                while (playing)
                {
                    if (!Console.KeyAvailable)
                    {
                        continue;
                    }
                    ConsoleKey key = Console.ReadKey(true).Key;
                    if (key == ConsoleKey.A)
                    {
                        toMove = sm.Output(StateMachine.Input.Left);
                    }
                    else if (key == ConsoleKey.D)
                    {
                        toMove = sm.Output(StateMachine.Input.Right);
                    }
                    else if (key == ConsoleKey.W)
                    {
                        toMove = sm.Output(StateMachine.Input.Forward);
                    }
                }
            };

            playing       = true;
            snakePosition = (int[])startSnakePosition.Clone();
            toMove        = StateMachine.State.North;
            snakeTailPositions.Clear();
            snakeTailPositions.Add((int[])snakePosition.Clone());
            food.Clear();
            snakeLenght = 1;
            sm.ResetState();
            Task.Run(a1);
            Task.Run(a2);
        }
        /// <summary>
        /// Erlaubt die Ausführung der Steuerung.
        /// </summary>
        /// <remarks>
        /// Fügt der Base.Update die Erneuerung des Keyboardstates und den Pausemenüaufruf hinzu
        /// </remarks>
        /// <param name="game">Referenz des Games aus dem XNA Framework.</param>
        /// <param name="gameTime">Bietet die aktuelle Spielzeit an.</param>
        /// <param name="state">Gibt den aktuellen State an von dem diese Funktion aufgerufen wurde.</param>
        public override void Update(Game game, GameTime gameTime, StateMachine.State state)
        {
            kState = StateManager.newState;

            //Pausemenüaufruf
            if (MenuController.KeyPressed(KBconfig.Back) || MenuController.KeyPressed(Keys.Escape))
            {
                if (state is InGameState)
                {
                    ((InGameState)state).Break();
                }
            }

            //Ruft Movement und Shooting auf
            base.Update(game, gameTime, state);
        }
예제 #26
0
        /// <summary>
        /// Initialisiert die Menüoberfläche
        /// </summary>
        /// <param name="buttons">MenuControls bzw. Buttons</param>
        /// <param name="graphics">GraphicsDeviceManager</param>
        /// <param name="currentState">aktueller State</param>
        public MenuUI(MenuControl[] buttons, GraphicsDeviceManager graphics, StateMachine.State currentState)
        {
            this.background           = ViewContent.UIContent.MenuBackgroundImage;
            this.frame                = ViewContent.UIContent.SettingsBackground;
            this.graphics             = graphics;
            this.buttonRepresentation = new ButtonRepresentation[buttons.Length];
            this.currentState         = currentState;
            this.font      = ViewContent.UIContent.Font;
            this.gameTitle = ViewContent.UIContent.GameTitle;

            //Instanziiert ein ButtonRepresentation-Objekt für jedes MenuControl
            for (int i = 0; i < buttons.Length; i++)
            {
                buttonRepresentation[i] = new ButtonRepresentation(buttons[i]);
            }
        }
    protected override bool State_Idle(StateMachine.State state)
    {
        switch (state)
        {
        case StateMachine.State.Update:
            float yAxis = Input.GetAxis("Vertical");

            if (Mathf.Abs(yAxis) >= 0.1F)
            {
                this.StateMachine.StateId = "Walk";
            }

            break;
        }

        return(base.State_Idle(state));
    }
예제 #28
0
        /// <summary>
        /// 指定したステートに遷移させてBattleManagerのイベントを呼び出す
        /// </summary>
        /// <param name="state">State machine.</param>
        public void SetStateMachine(StateMachine.State state)
        {
            Debug.Log($"{state}がよばれたお!!!");
            // ステート遷移前のステートを保存
            m_StateMachine.m_PreviousState = m_StateMachine.m_State;
            if (state == StateMachine.State.Pause || state == StateMachine.State.Debugging || state == StateMachine.State.Tutorial) // 遷移先がPauseステートの時保存
            {
                m_StateMachine.m_StateBeforeWithoutSpecialState = m_StateMachine.m_State;
            }
            m_StateMachine.
            m_State = state;     // stateをセット

            Debug.Log(state);
            // ==================================
            // イベント呼び出し
            // ==================================
            m_BehaviourByState.Invoke(state);
        }
예제 #29
0
        public static Int32 Evaluate(Object state, ref Boolean error)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(0);
            }

            Combat.Player opponent = character.GetOpponent();
            if (opponent == null)
            {
                error = true;
                return(0);
            }

            StateMachine.State currentstate = opponent.StateManager.CurrentState;
            return((currentstate != null) ? currentstate.Number : 0);
        }
예제 #30
0
    /*--------------------------------------------------------------------------------
    *   StateMachine_OnStateChange
    *  --------------------------------------------------------------------------------*/
    private void StateMachine_OnStateChange(StateMachine.State currenState, StateMachine.State previousState)
    {
        switch (currenState)
        {
        case StateMachine.State.MainMenu:
            ScreenMenu();
            break;

        case StateMachine.State.Game:
            GameStart();
            break;

        case StateMachine.State.Score:
            ScreenScore();
            break;

        default:
            break;
        }
    }