Exemple #1
0
 public static void AirState(AbstractFighter actor)
 {
     StateTransitions.AirControl(actor);
     if (actor.KeyBuffered("Shield") && actor.GetIntVar(TussleConstants.FighterVariableNames.AIR_DODGES_REMAINING) >= 1)
     {
         //actor.doAction("AirDodge");
     }
     if (actor.KeyBuffered("Attack"))
     {
         actor.doAirAttack();
     }
     if (actor.KeyBuffered("Special"))
     {
         actor.doAirSpecial();
     }
     if (actor.KeyBuffered("Jump") && actor.GetIntVar(TussleConstants.FighterVariableNames.JUMPS_REMAINING) > 0)
     {
         actor.doAction("AirJump");
     }
     actor.SendMessage("CheckForGround");
     if (actor.GetBoolVar(TussleConstants.FighterVariableNames.IS_GROUNDED) && actor.ground_elasticity == 0 && actor.GetIntVar("tech_window") == 0)
     {
         actor.BroadcastMessage("ChangeXPreferred", 0.0f, SendMessageOptions.RequireReceiver);
         actor.BroadcastMessage("ChangeYPreferred", actor.GetFloatVar(TussleConstants.FighterAttributes.MAX_FALL_SPEED));
         actor.doAction("Land");
     }
     //TODO fastfal
 }
Exemple #2
0
        public ByteTreeSearchBenchmarks()
        {
            var comparator       = new Comparator();
            var brancher         = new Brancher();
            var evaluator        = new Evaluator();
            var stateTransitions = new StateTransitions();

            _serial = new SerialAlfaBetaSearch <ByteNode, sbyte, sbyte>(
                evaluator,
                brancher,
                comparator,
                stateTransitions,
                sbyte.MaxValue,
                sbyte.MinValue);

            _serialTree = TreeGenerator.ReadTree();

            _dynamic = new DynamicTreeSplitting <AlfaBetaByteNode, sbyte, sbyte>(
                evaluator,
                brancher,
                comparator,
                stateTransitions
                );

            _dynamicTree = TreeGenerator.ReadAlfaBetaTree();

            _cts = new CancellationTokenSource();
        }
Exemple #3
0
 public override void stateTransitions()
 {
     base.stateTransitions();
     //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
     if (isInBuilder)
     {
         return;
     }
     //if (actor.GetControllerButton("Shield"))
     //actor.doAction("AirDodge");
     //if (actor.GetControllerButton("Attack")) //&& actor.CheckSmash("Up")
     //actor.doAction("UpSmash")
     //if (actor.GetControllerButton("Special")) //&& actor.CheckSmash("Up")
     //actor.doAction("UpSpecial")
     if (current_frame <= jump_frame)
     {
         StateTransitions.JumpState(actor.GetAbstractFighter());
     }
     if (current_frame > jump_frame)
     {
         StateTransitions.AirState(actor.GetAbstractFighter());
     }
     if (current_frame > last_frame)
     {
         actor.BroadcastMessage("DoAction", "Fall");
     }
 }
Exemple #4
0
 public override void stateTransitions()
 {
     base.stateTransitions();
     //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
     if (isInBuilder)
     {
         return;
     }
     StateTransitions.CheckGround(actor.GetAbstractFighter());
     StateTransitions.MoveState(actor.GetAbstractFighter());
     if (current_frame > 0)
     {
         if (actor.GetInputBuffer().DirectionHeld("Backward"))
         {
             PassVariable("direction", -1 * GetIntVar("direction"));
             PassVariable("accel", false);
         }
         else if (actor.GetInputBuffer().DirectionHeld("Forward"))
         {
             PassVariable("direction", GetIntVar("direction"));
             PassVariable("accel", false);
         }
     }
     //Check for dashing
     if (current_frame > last_frame)
     {
         current_frame -= 1;
     }
 }
Exemple #5
0
 public StoryStageLogic(string strProjectStage, bool bHasIndependentConsultant)
 {
     ProjectStage = GetProjectStageFromString(strProjectStage);
     if ((stateTransitions == null) ||
         (stateTransitions.RewroteCitAsIndependentConsultant != bHasIndependentConsultant))
     {
         stateTransitions = new StateTransitions(bHasIndependentConsultant);
     }
 }
Exemple #6
0
 public override void stateTransitions()
 {
     base.stateTransitions();
     //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
     if (isInBuilder)
     {
         return;
     }
     StateTransitions.LedgeState(actor.GetAbstractFighter());
 }
Exemple #7
0
        internal bool AddTransition(Transition <S, T, G> transition, State <S, T, G> state)
        {
            if (StateTransitions.ContainsKey(transition))
            {
                return(false);
            }

            StateTransitions.Add(transition, state);
            return(true);
        }
Exemple #8
0
        /// <summary>
        ///   NOTE 1: http://cs.hubfs.net/blogs/hell_is_other_languages/archive/2008/01/16/4565.aspx
        /// </summary>
        public void TriggerTransition(TState targetState,
                                      dynamic args = default(dynamic))
        {
            Ensure.That <ArgumentException>(targetState != null, "targetState not supplied.");

            try
            {
                if (CurrentState == targetState && !PermitSelfTransition)
                {
                    throw new Exception(); //refactor to refine exception
                }

                if (CurrentState == FinalState)
                {
                    throw new Exception(); //refactor to refine exception
                }

                if ((CurrentState != targetState || (CurrentState == targetState && !BypassTransitionBehaviorForSelfTransition)))
                {
                    var matches = StateTransitions.Where(t =>
                                                         t.InitialStates.Where(s => s == CurrentState).Any() &&
                                                         t.EndStates.Where(e => e == targetState).Any());
                    if (matches.Any())
                    {
                        using (var t = new TransactionScope())
                        //this could be in-memory transactionalised using the memento pattern, or information could be sent to F# (see NOTE 1)
                        {
                            OnRaiseBeforeEveryTransition();
                            CurrentState.ExitAction(args);
                            matches.First().TransitionAction(targetState, this, args);
                            targetState.EntryAction(args);
                            CurrentState = targetState;
                            OnRaiseAfterEveryTransition();
                            t.Complete();
                        }
                    }
                    else
                    {
                        if (Parent == null)
                        {
                            throw new Exception(); //to be caught below, refactor
                        }

                        Parent.TriggerTransition(targetState, args);
                    }
                }
            }
            catch (Exception e)
            {
                throw new InvalidStateTransitionException <TState>(CurrentState, targetState, innerException: e);
            }
        }
Exemple #9
0
    public override void stateTransitions()
    {
        base.stateTransitions();
        //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
        if (isInBuilder)
        {
            return;
        }
        StateTransitions.StopState(actor.GetAbstractFighter());
        StateTransitions.CheckGround(actor.GetAbstractFighter());

        //(key, invkey) = _actor.getForwardBackwardKeys()
        //if (self.direction == 1 and _actor.sprite.flip == "left") or(self.direction == -1 and _actor.sprite.flip == "right"):
        //    _actor.sprite.flipX()

        AbstractFighter fighter = actor.GetAbstractFighter();

        if (current_frame == last_frame)
        {
            if (fighter.KeyHeld("Forward"))
            {
                if (fighter.CheckSmash("ForwardSmash"))
                {
                    actor.SendMessage("doAction", "Dash");
                }
                else
                {
                    actor.SendMessage("doAction", "Move");
                }
            }
            else if (fighter.KeyHeld("Backward"))
            {
                actor.SendMessage("flip");
                if (fighter.CheckSmash("BackwardSmash"))
                {
                    actor.SendMessage("doAction", "Dash");
                }
                else
                {
                    actor.SendMessage("doAction", "Move");
                }
            }
            else
            {
                actor.SendMessage("doAction", "NeutralAction");
            }
        }
    }
Exemple #10
0
 public override void stateTransitions()
 {
     base.stateTransitions();
     //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
     if (isInBuilder)
     {
         return;
     }
     StateTransitions.StopState(actor.GetAbstractFighter());
     StateTransitions.CheckGround(actor.GetAbstractFighter());
     //TODO more moonwalking
     if (current_frame >= last_frame)
     {
         actor.BroadcastMessage("DoAction", "NeutralAction");
     }
 }
        internal static ISearch <GameNode, sbyte, BoardMinified> CreateDynamicTreeSplittingGameTreeSearch()
        {
            var rules = new CheckersRules();

            var comparator       = new Comparator();
            var evaluator        = new Evaluator();
            var stateTransitions = new StateTransitions(rules);
            var brancher         = new Brancher(rules, evaluator, stateTransitions);

            return(new DynamicTreeSplitting <GameNode, sbyte, BoardMinified>(
                       evaluator,
                       brancher,
                       comparator,
                       stateTransitions
                       ));
        }
Exemple #12
0
        private static StateMachine TimerStateMachine()
        {
            var ready   = new State("Ready");
            var running = new State("Running");
            var paused  = new State("Paused");

            var possibleStates = new StateList {
                ready, running, paused
            };

            var possibleTransitions = new StateTransitions();

            possibleTransitions.Add(new SimpleStateTransition(ready, "Start", running, 1, () => true));

            return(new StateMachine(possibleStates, ready, possibleTransitions));
        }
Exemple #13
0
        public DynamicTreeSearchTest()
        {
            var comparator       = new Comparator();
            var brancher         = new Brancher();
            var evaluator        = new Evaluator();
            var stateTransitions = new StateTransitions();

            _search = new DynamicTreeSplitting <AlfaBetaByteNode, sbyte, sbyte>(
                evaluator,
                brancher,
                comparator,
                stateTransitions
                );

            _cts = new CancellationTokenSource();
        }
Exemple #14
0
 public override void stateTransitions()
 {
     base.stateTransitions();
     //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
     if (isInBuilder)
     {
         return;
     }
     if (current_frame >= last_frame)
     {
         actor.SetVar("landing_lag", 0);
         actor.BroadcastMessage("DoAction", "NeutralAction");
         //platform phase reset
         actor.BroadcastMessage("ChangeXPreferred", 0.0f, SendMessageOptions.RequireReceiver);
     }
     StateTransitions.CheckGround(actor.GetAbstractFighter());
 }
Exemple #15
0
        public Store(TState initialState, Func <TState, TEvent, TState> reducer)
        {
            var initialStateTransition = StateTransition.NewInitial(initialState);

            StateTransitions =
                Events
                .Scan(initialStateTransition, StateTransition.LiftReducer(reducer))
                .StartWith(initialStateTransition)
                .Publish()
                .AutoConnect();

            States =
                StateTransitions
                .Select(StateTransition.StateOf)
                .DistinctUntilChanged()
                .Replay(1)
                .AutoConnect(0);
        }
        public SearchWithoutBranchingTest()
        {
            var comparator       = new Comparator();
            var brancher         = new Brancher();
            var evaluator        = new Evaluator();
            var stateTransitions = new StateTransitions();

            _search = new SerialAlfaBetaSearch <ByteNode, sbyte, sbyte>(
                evaluator,
                brancher,
                comparator,
                stateTransitions,
                sbyte.MaxValue,
                sbyte.MinValue
                );

            _cts = new CancellationTokenSource();
        }
        internal static ISearch <GameNode, sbyte, BoardMinified> CreateSerialGameTreeSearch()
        {
            var rules = new CheckersRules();

            var comparator       = new Comparator();
            var evaluator        = new Evaluator();
            var stateTransitions = new StateTransitions(rules);
            var brancher         = new Brancher(rules, evaluator, stateTransitions);

            return(new SerialAlfaBetaSearch <GameNode, sbyte, BoardMinified>(
                       evaluator,
                       brancher,
                       comparator,
                       stateTransitions,
                       sbyte.MaxValue,
                       sbyte.MinValue
                       ));
        }
Exemple #18
0
 public TestWorkflowAdmin(xWorkflowAdmin wfa)
 {
     Description     = wfa.Description;
     Permissions     = new TestAccessControlList(wfa.Permissions);
     SemanticAliases = new SemanticAliases {
         Value = string.Join(";", wfa.SemanticAliases)
     };
     States = new StatesAdmin();
     foreach (xStateAdmin stateAdmin in wfa.States)
     {
         States.Add(-1, new TestStateAdmin(stateAdmin));
     }
     StateTransitions = new StateTransitions();
     foreach (xStateTransition transition in wfa.StateTransitions)
     {
         StateTransitions.Add(-1, new TestStateTransition(transition));
     }
     Workflow = new TestWorkflow(wfa.Workflow);
 }
Exemple #19
0
        private void FindTransitions(SerializedObject _ownerObj, Dictionary <OTGCombatState, int> _stateRecord, int _currentLevel)
        {
            int amountOfTransitions = _ownerObj.FindProperty("m_stateTransitions").arraySize;

            for (int i = 0; i < amountOfTransitions; i++)
            {
                Object nextStateObj = _ownerObj.FindProperty("m_stateTransitions").GetArrayElementAtIndex(i).FindPropertyRelative("m_nextState").objectReferenceValue;
                if (nextStateObj != null)
                {
                    OTGCombatState state             = (OTGCombatState)nextStateObj;
                    bool           transitionRepeats = (_stateRecord.ContainsKey(state)) ? true : false;



                    StateNode           n      = new StateNode(state, _currentLevel + 1, _stateRecord, i);
                    StateNodeTransition nTrans = new StateNodeTransition(transitionRepeats, n);
                    if (!StateTransitions.ContainsKey(state))
                    {
                        StateTransitions.Add(state, nTrans);
                    }
                }
            }
        }
Exemple #20
0
    public override void stateTransitions()
    {
        base.stateTransitions();
        //These classes will be phased out as time goes on. Until then, we need to just exit early if we're in the builder since these don't actually use Subactions
        if (isInBuilder)
        {
            return;
        }
        StateTransitions.CrouchState(actor.GetAbstractFighter());
        StateTransitions.CheckGround(actor.GetAbstractFighter());
        //Platform Phase? See if it's better as it's own thing or better off here.

        /* Python code:
         * if self.frame > 0 and _actor.keyBuffered('down', _state = 1):
         *  blocks = _actor.checkGround()
         *  if blocks:
         #Turn it into a list of true/false if the block is solid
         *      blocks = map(lambda x:x.solid,blocks)
         #If none of the ground is solid
         *      if not any(blocks):
         *          _actor.doAction('PlatformDrop')
         */
    }
    public override void Execute(BattleObject obj, GameAction action)
    {
        string name = (string)GetArgument("transitionState", obj, action);

        StateTransitions.LoadTransitionState(name, obj.GetAbstractFighter());
    }
Exemple #22
0
    public static void executeSubaction(string subact, BattleObject actor, GameAction action)
    {
        string[] args = subact.Split(' ');

        switch (args[0])
        {
        // ====== CONTROL SUBACTIONS ======\\
        case "DoAction":
            /* doAction actionName:string
             *      Switches the fighter's action to actionName
             */
            actor.BroadcastMessage("DoAction", args[1]);
            break;

        case "DoTransition":
            /* doTransition transitionState:string
             *      Executes the named helper StateTransition
             */
            StateTransitions.LoadTransitionState(args[1], actor.GetAbstractFighter());
            break;

        case "SetFrame":
            /* setFrame frameNumber:int
             *      Sets the current frame to the given number
             */
            action.current_frame = int.Parse(args[1]);
            break;

        case "ChangeFrame":
            /* changeFrame frameNumber:int|1
             *      Changes the action frame by the specified amount.
             */
            action.current_frame += int.Parse(args[1]);
            break;

        case "SetVar":
            /* setVar source:string name:string type:string value:dynamic relative:bool|false
             *      Sets the variable from GameAction, Fighter, Global with the given name to the given value and type.
             *      If relative is set and type is something that can be relative, such as integer, it will increment
             *      the variable instead of changing it
             */
            //TODO
            break;

        case "IfVar":
            /* ifVar source:string name:string compare:string|== value:dynamic|true
             *      Sets the action condition to the result of the logical equation compare(source|name, value)
             */
            //TODO
            break;

        case "Else":
            /* else
             *      inverts the current action condition
             */
            //TODO
            break;

        case "Endif":
            /* endif
             *      unsets the current action condition
             */
            //TODO
            break;

        // ====== CONTROL SUBACTIONS ======\\
        case "ChangeSpeed":
            /* changeSpeed x:float|_ y:float|_ xpref:float|_ ypref:float|_ relative:bool|false
             *      changes the xSpeed, ySpeed, xPreferred, yPreferred speeds. If set to null, value will remain the same
             */
            if (args[1] != "_")
            {
                actor.SendMessage("ChangeXSpeed", float.Parse(args[1]));
            }
            if (args[2] != "_")
            {
                actor.SendMessage("ChangeYSpeed", float.Parse(args[2]));
            }
            if (args[3] != "_")
            {
                actor.SendMessage("ChangeXPreferred", float.Parse(args[3]));
            }
            if (args[4] != "_")
            {
                actor.SendMessage("ChangeYPreferred", float.Parse(args[4]));
            }
            break;

        case "ChangeXSpeed":
            /* changeXSpeed x:float rel:bool
             *      changes the xSpeed of the fighter
             */
            if (args.Length > 2)
            {
                actor.SendMessage("ChangeXSpeedBy", float.Parse(args[1]) * actor.GetIntVar(TussleConstants.FighterVariableNames.FACING_DIRECTION));
            }
            else
            {
                actor.SendMessage("ChangeXSpeed", float.Parse(args[1]) * actor.GetIntVar(TussleConstants.FighterVariableNames.FACING_DIRECTION));
            }
            break;

        case "ChangeYSpeed":
            /* changeYSpeed y:float rel:bool
             *      changes the ySpeed of the fighter
             */
            if (args.Length > 2)
            {
                actor.SendMessage("ChangeYSpeedBy", float.Parse(args[1]));
            }
            else
            {
                actor.SendMessage("ChangeYSpeed", float.Parse(args[1]));
            }
            break;

        case "ChangeXPreferred":
            /* changeXPreferred x:float rel:bool
             *      changes the preferred xSpeed of the fighter
             */
            if (args.Length > 2)
            {
                actor.SendMessage("ChangeXPreferredBy", float.Parse(args[1]) * actor.GetIntVar(TussleConstants.FighterVariableNames.FACING_DIRECTION));
            }
            else
            {
                actor.SendMessage("ChangeXPreferred", float.Parse(args[1]) * actor.GetIntVar(TussleConstants.FighterVariableNames.FACING_DIRECTION));
            }
            break;

        case "ChangeYPreferred":
            /* changeXPreferred y:float rel:bool
             *      changes the yPreferred of the fighter
             */
            if (args.Length > 2)
            {
                actor.SendMessage("ChangeYPreferredBy", float.Parse(args[1]));
            }
            else
            {
                actor.SendMessage("ChangeYPreferred", float.Parse(args[1]));
            }
            break;

        case "ShiftPosition":
            /* shiftPosition x:float|0 y:float|0 relative:bool|true
             *      Displaces the fighter by a certain amount in either direction
             */
            //TODO
            break;

        // ====== CONTROL SUBACTIONS ======\\
        case "ChangeAnim":
            /* changeAnim animName:string
             *      Changes to the specified animation.
             *      ALIAS: ChangeSprite
             */
            actor.BroadcastMessage("ChangeSprite", args[1]);
            break;

        case "ChangeSprite":
            /* changeSprite animName:string
             *      Changes to the specified animation.
             *      ALIAS: ChangeAnim
             */
            actor.BroadcastMessage("ChangeSprite", args[1]);
            break;

        case "ChangeSubimage":
            /* changeSpriteSubimage index:int
             *      SPRITE MODE ONLY
             *      Changes to the sprite subimage of the current animation with the given index
             */
            actor.BroadcastMessage("ChangeSubimage", int.Parse(args[1]));
            break;

        case "Flip":
            /* flipFighter
             *      Flips the fighter horizontally, so they are facing the other direction
             */
            actor.BroadcastMessage("flip");
            break;

        case "RotateSprite":
            /* rotateFighter deg:int
             *      Rotates the fighter by the given degrees
             */
            //TODO
            break;

        case "Unrotate":
            /* unrotateFighter
             *      Sets the fighter back to upright, no matter how many times it has been rotated
             */
            //TODO
            break;

        case "ShiftSprite":
            /* shiftSprite x:float y:float
             *      Shifts the sprite by the given X and Y without moving the fighter
             */
            //TODO
            break;

        case "PlaySound":
            /* Playsound sound:string
             *      Plays the sound with the given name from the fighter's sound library
             */
            actor.BroadcastMessage("PlaySound", args[1]);
            break;

        // ====== HITBOX SUBACTIONS ======\\
        case "CreateHitbox":
            /* createHitbox name:string [argumentName:string value:dynamic]
             *      Creates a hitbox with the given name. Every pair of arguments from then after is the name of a value, and what to set it to.
             *      Hitboxes will be able to parse the property name and extract the right value out.
             */
            string name = args[1];
            Dictionary <string, string> hbox_dict = new Dictionary <string, string>();
            for (int i = 2; i < args.Length; i = i + 2)
            {
                hbox_dict[args[i]] = args[i + 1];
            }
            Hitbox hbox = FindObjectOfType <HitboxLoader>().LoadHitbox(actor.GetAbstractFighter(), action, hbox_dict);
            action.hitboxes.Add(name, hbox);
            break;

        case "ActivateHitbox":
            /* activateHitbox name:string life:int
             *      Activates the named hitbox, if it exists, for the given number of frames.
             *      If life is -1, hitbox will persist until manually deactivated.
             */
            name = args[1];
            if (action.hitboxes.ContainsKey(args[1]))
            {
                action.hitboxes[args[1]].Activate(int.Parse(args[2]));
            }
            else
            {
                Debug.LogWarning("Current action has no hitbox named " + name);
            }
            break;

        case "DeactivateHitbox":
            /* activateHitbox name:string life:int
             *      Activates the named hitbox, if it exists, for the given number of frames.
             */
            name = args[1];
            if (action.hitboxes.ContainsKey(args[1]))
            {
                action.hitboxes[args[1]].Deactivate();
            }
            else
            {
                Debug.LogWarning("Current action has no hitbox names " + name);
            }
            break;

        case "ModifyHitbox":
            /* createHitbox name:string [argumentName:string value:dynamic]
             *      Creates a hitbox with the given name. Every pair of arguments from then after is the name of a value, and what to set it to.
             *      Hitboxes will be able to parse the property name and extract the right value out.
             */
            name      = args[1];
            hbox_dict = new Dictionary <string, string>();
            for (int i = 2; i < args.Length; i = i + 2)
            {
                hbox_dict[args[i]] = args[i + 1];
            }
            if (action.hitboxes.ContainsKey(name))
            {
                action.hitboxes[name].LoadValuesFromDict(hbox_dict);
            }
            break;

        default:
            //Debug.LogWarning("Could not load subaction " + args[0]);
            break;
        }
    }
Exemple #23
0
 private Transition FindTransition(InteractionStateEnum state, CommandEnum command)
 {
     return(StateTransitions.Find(tr => tr.CurState == state && tr.Command == command));
 }
Exemple #24
0
 public StateTransitionsTest()
 {
     _stateTransitions = new StateTransitions(new CheckersRules());
 }