예제 #1
0
    State2 getState2()
    {
        State2  s        = new State2();
        Vector2 left_pos = snake_pos + directions[(snake_dir_index + directions.Length - 1) % directions.Length];

        s.is_left_valid = map[(int)left_pos.x, (int)left_pos.y] == 'e' || map[(int)left_pos.x, (int)left_pos.y] == 'a';

        Vector2 fwd_pos = snake_pos + directions[snake_dir_index];

        try
        {
            s.is_fwd_valid = map[(int)fwd_pos.x, (int)fwd_pos.y] == 'e' || map[(int)fwd_pos.x, (int)fwd_pos.y] == 'a';
        }
        catch
        {
            s.is_fwd_valid = false;
        }


        Vector2 right_pos = snake_pos + directions[(snake_dir_index + 1) % directions.Length];

        s.is_right_valid = map[(int)right_pos.x, (int)right_pos.y] == 'e' || map[(int)right_pos.x, (int)right_pos.y] == 'a';

        s.x_diff = (int)snake_pos.x - (int)apple.transform.position.x;
        s.y_diff = (int)snake_pos.y - (int)apple.transform.position.y;
        return(s);
    }
예제 #2
0
            public IAutomaton Next(int i)
            {
                var n1 = State1.Next(i);
                var n2 = State2.Next(i);

                return(Create(n1, n2));
            }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of ObjectBinder class.
 /// </summary>
 public ObjectBinder()
 {
     state0 = new State0(this);
     state1 = new State1(this);
     state2 = new State2(this);
     state3 = new State3(this);
     state4 = new State4(this);
     state5 = new State5(this);
 }
예제 #4
0
        private void SetAdCompleted(object returnValue)
        {
            App.AdOpened = false;
            State2 expr_10 = App.State.Ext;

            expr_10.AdPoints = ++expr_10.AdPoints;
            App.State.Ext.AdsWatched++;
            App.State.Ext.TotalAdsWatched++;
            GuiBase.ShowToast("Thank you, you received 1 Ad point!");
        }
예제 #5
0
    private void WinMatch()
    {
        Rigidbody ERB = Enemy.GetComponent(typeof(Rigidbody)) as Rigidbody;

        WinText.SetActive(true);
        WhoseTurnisIt = State2.Noone;

        Enemy.transform.rotation = Quaternion.Euler(0, 0, 90);
        ERB.isKinematic          = false;
    }
예제 #6
0
    private void LoseMatch()
    {
        Rigidbody PRB = Player.GetComponent(typeof(Rigidbody)) as Rigidbody;

        LoseText.SetActive(true);
        WhoseTurnisIt = State2.Noone;

        Player.transform.rotation = Quaternion.Euler(0, 0, 90);
        PRB.isKinematic           = false;
    }
예제 #7
0
            public IAutomaton Next(int i)
            {
                var s1 = State1.Next(i);

                if (State1.Empty)
                {
                    var s2 = State2.Next(i);
                    return(OrState.Create(s2, SeqState.Create(s1, State2)));
                }
                else
                {
                    return(SeqState.Create(s1, State2));
                }
            }
예제 #8
0
파일: Form1.cs 프로젝트: Tjof/ProjectS
        static State2 Transit2(State2 s, char c)
        {
            switch (s)
            {
            case State2.Q0:
                if (c == 'a')
                {
                    return(State2.Q1);
                }
                else if (c == 'c')
                {
                    return(State2.Q4);
                }
                return(State2.Error);

            case State2.Q1:
                if (c == 'b')
                {
                    return(State2.Q2);
                }
                return(State2.Error);

            case State2.Q2:
                if (c == 'c')
                {
                    return(State2.Q3);
                }
                return(State2.Error);

            case State2.Q3:
                return(State2.Error);

            case State2.Q4:
                if (c == 'c')
                {
                    return(State2.Q5);
                }
                return(State2.Error);

            case State2.Q5:
                return(State2.Error);

            default:
                return(State2.Error);
            }
        }
예제 #9
0
        /// <summary>
        /// This class contains the following tree:
        /// RootState -> Sate2 -> State3 -> EndState
        /// </summary>
        public UnaryDeterministicTree(Player rootPlayer = Player.Max)
        {
            A.CallTo(() => RootState.ToString()).Returns(nameof(RootState));
            A.CallTo(() => State2.ToString()).Returns(nameof(State2));
            A.CallTo(() => State3.ToString()).Returns(nameof(State3));
            A.CallTo(() => EndState.ToString()).Returns(nameof(EndState));

            A.CallTo(() => RootState.Turn).Returns(rootPlayer);
            A.CallTo(() => State2.Turn).Returns(rootPlayer.GetReversePlayer());
            A.CallTo(() => State3.Turn).Returns(rootPlayer);
            A.CallTo(() => EndState.Turn).Returns(rootPlayer.GetReversePlayer());

            RootState.SetNeigbor(State2);
            State2.SetNeigbor(State3);
            State3.SetNeigbor(EndState);
            EndState.SetAsEndState();
        }
예제 #10
0
        protected override void Start()
        {
            Log.L("按下  A/D   切换状态");
            State1 s1 = new State1();
            State2 s2 = new State2();

            fsm.SubscribeState(s1);
            fsm.enterState = s1;
            fsm.SubscribeState(s2);
            // fsm.exitState = s2;
            var val = fsm.CreateConditionValue <bool>("bool", true);

            var t1 = fsm.CreateTransition(s1, s2);
            var t2 = fsm.CreateTransition(s2, s1);

            t1.BindCondition(fsm.CreateCondition <bool>("bool", false, CompareType.Equals));
            t2.BindCondition(fsm.CreateCondition <bool>(val, true, CompareType.Equals));

            fsm.Start();
        }
예제 #11
0
    /// <summary>
    /// Method om de state te wijzigen
    /// </summary>
    public void SetState(StateID2 stateID)
    {
        /** als we de stateID niet kennen als state: stop deze functie dan */
        if (!states.ContainsKey(stateID))
        {
            return;
        }

        /** als we ons al in een state bevinden: geef de state de mogelijkheid zich op te ruimen */
        if (currentState != null)
        {
            currentState.Leave();
        }

        /** we stellen de nieuwe currentState in */
        currentState = states[stateID];

        /** we geven de nieuwe state de mogelijkheid om zich zelf in te stellen */
        currentState.Enter();
    }
예제 #12
0
        public RepeatStateTree2(Player startPlayer = Player.Max)
        {
            A.CallTo(() => EndState1.ToString()).Returns(nameof(EndState1));
            A.CallTo(() => State1.ToString()).Returns(nameof(State1));
            A.CallTo(() => State2.ToString()).Returns(nameof(State2));
            A.CallTo(() => State2.ToString()).Returns(nameof(State3));
            A.CallTo(() => RootState.ToString()).Returns(nameof(RootState));


            A.CallTo(() => RootState.Turn).Returns(startPlayer);
            A.CallTo(() => State1.Turn).Returns(startPlayer.GetReversePlayer());
            A.CallTo(() => State2.Turn).Returns(startPlayer.GetReversePlayer());
            A.CallTo(() => State3.Turn).Returns(startPlayer);
            A.CallTo(() => EndState1.Turn).Returns(startPlayer.GetReversePlayer());

            RootState.SetNeigbors(State1, State2);
            EndState1.SetAsEndState();
            State1.SetNeigbor(State3);
            State2.SetNeigbor(State3);
            State3.SetNeigbor(EndState1);
        }
예제 #13
0
        private void Start()

        {
            fsm = Framework.env1.modules.CreateModule <FsmModule>();
            State1 s1 = new State1();
            State2 s2 = new State2();

            fsm.SubscribeState(s1);
            fsm.enterState = s1;
            fsm.SubscribeState(s2);
            // fsm.exitState = s2;
            var val = fsm.CreateConditionValue <bool>("bool", true);

            var t1 = fsm.CreateTransition(s1, s2);
            var t2 = fsm.CreateTransition(s2, s1);

            t1.BindCondition(fsm.CreateCondition <bool>("bool", false, CompareType.Equals));
            t2.BindCondition(fsm.CreateCondition <bool>(val, true, CompareType.Equals));

            fsm.Start();
        }
예제 #14
0
 public override int GetHashCode() => 100 + State1.GetHashCode() + 11 *State2.GetHashCode();
 public void DoTransition(State2 state)
 {
     currentState = state;
 }
예제 #16
0
 private static void UpdateState(State2 s1)
 {
     Console.WriteLine("State2 Updated.");
 }
예제 #17
0
        private static void addSpendPointsButton(ref int marginTop, KredOffersUi.Reward reward, string text, CDouble pointCost, string description = "")
        {
            GUI.Label(new Rect(GuiBase.Width(305f), GuiBase.Height((float)(marginTop + 5)), GuiBase.Width(400f), GuiBase.Height(30f)), new GUIContent(text, description));
            App.State.Ext.AdPoints.Round();
            if (GUI.Button(new Rect(GuiBase.Width(725f), GuiBase.Height((float)marginTop), GuiBase.Width(140f), GuiBase.Height(28f)), new GUIContent("Buy for " + pointCost.ToInt())))
            {
                if (App.State.Ext.AdPoints >= pointCost)
                {
                    switch (reward)
                    {
                    case KredOffersUi.Reward.physical:
                        App.State.Multiplier.DrawMultiPhysical = App.State.Multiplier.DrawMultiPhysical * 1.1;
                        GuiBase.ShowToast("Your Physical was increased by 10%!");
                        break;

                    case KredOffersUi.Reward.mystic:
                        App.State.Multiplier.DrawMultiMystic = App.State.Multiplier.DrawMultiMystic * 1.1;
                        GuiBase.ShowToast("Your Mystic was increased by 10%!");
                        break;

                    case KredOffersUi.Reward.battle:
                        App.State.Multiplier.DrawMultiBattle = App.State.Multiplier.DrawMultiBattle * 1.1;
                        GuiBase.ShowToast("Your Battle was increased by 10%!");
                        break;

                    case KredOffersUi.Reward.creating:
                        App.State.Multiplier.DrawMultiCreating = App.State.Multiplier.DrawMultiCreating * 1.1;
                        GuiBase.ShowToast("Your Creating was increased by 10%!");
                        break;

                    case KredOffersUi.Reward.all:
                        App.State.Multiplier.DrawMultiPhysical = App.State.Multiplier.DrawMultiPhysical * 1.1;
                        App.State.Multiplier.DrawMultiMystic   = App.State.Multiplier.DrawMultiMystic * 1.1;
                        App.State.Multiplier.DrawMultiCreating = App.State.Multiplier.DrawMultiCreating * 1.1;
                        App.State.Multiplier.DrawMultiBattle   = App.State.Multiplier.DrawMultiBattle * 1.1;
                        GuiBase.ShowToast("All 4 stats were increased by 10%!");
                        break;

                    case KredOffersUi.Reward.div1:
                    {
                        CDouble cDouble = App.State.DivinityGainSec(true) * 1200;
                        App.State.Money += cDouble;
                        GuiBase.ShowToast("You received " + cDouble.GuiText + " divinity!");
                        break;
                    }

                    case KredOffersUi.Reward.div2:
                    {
                        CDouble cDouble = App.State.DivinityGainSec(true) * 1200 * 2.5;
                        App.State.Money += cDouble;
                        GuiBase.ShowToast("You received " + cDouble.GuiText + " divinity!");
                        break;
                    }

                    case KredOffersUi.Reward.creatingSpeed:
                        App.State.CreatingSpeedBoniDuration += 600000L;
                        GuiBase.ShowToast("Your creating speed is increased to 300% for another 10 minutes!");
                        break;

                    case KredOffersUi.Reward.puny:
                    {
                        State2 expr_3A8 = App.State.Ext;
                        expr_3A8.PunyFood = ++expr_3A8.PunyFood;
                        GuiBase.ShowToast("You received one Puny Food!");
                        break;
                    }

                    case KredOffersUi.Reward.strong:
                    {
                        State2 expr_3D1 = App.State.Ext;
                        expr_3D1.StrongFood = ++expr_3D1.StrongFood;
                        GuiBase.ShowToast("You received one Strong Food!");
                        break;
                    }

                    case KredOffersUi.Reward.mighty:
                    {
                        State2 expr_3FA = App.State.Ext;
                        expr_3FA.MightyFood = ++expr_3FA.MightyFood;
                        GuiBase.ShowToast("You received one Mighty Food!");
                        break;
                    }

                    case KredOffersUi.Reward.lucky:
                    {
                        Premium expr_423 = App.State.PremiumBoni;
                        expr_423.LuckyDraws = ++expr_423.LuckyDraws;
                        GuiBase.ShowToast("You received one Lucky Draw!");
                        break;
                    }
                    }
                    App.State.Ext.AdPoints -= pointCost;
                }
                else
                {
                    GuiBase.ShowToast("You don't have enough Ad points!");
                }
            }
            marginTop += 30;
        }
        private void UpdateAllStats()
        {
            long num = UpdateStats.CurrentTimeMillis() - this.lastUpdateStats;

            this.timerStack     += num;
            this.lastUpdateStats = UpdateStats.CurrentTimeMillis();
            if (this.timerStack < 30L || OfflineCalc.IsCalculating)
            {
                return;
            }
            num              = 30L;
            this.timerStack -= num;
            if (App.State == null)
            {
                return;
            }
            if (UpdateStats.TimeLeftForEvent > 0L)
            {
                App.State.Statistic.TimeUntilNextChocolate -= num;
                if (App.State.Statistic.TimeUntilNextChocolate < 0L)
                {
                    App.State.Statistic.TimeUntilNextChocolate = 1200000L;
                    State2 expr_B4 = App.State.Ext;
                    expr_B4.Chocolate = ++expr_B4.Chocolate;
                    GuiBase.ShowToast("You received 1 chocolate!");
                }
            }
            App.State.Ext.AfkGame.Update(num);
            foreach (Training current in App.State.AllTrainings)
            {
                current.UpdateDuration(num);
            }
            foreach (Skill current2 in App.State.AllSkills)
            {
                current2.UpdateDuration(num);
            }
            foreach (Fight current3 in App.State.AllFights)
            {
                current3.UpdateDuration(num);
            }
            foreach (Creation current4 in App.State.AllCreations)
            {
                current4.UpdateDuration(num);
            }
            foreach (Might current5 in App.State.AllMights)
            {
                current5.UpdateDuration(num);
            }
            App.State.RecoverHealth(num);
            App.State.PremiumBoni.UpdateDuration(num);
            App.State.Generator.UpdateDuration(num);
            App.State.PrinnyBaal.Fight(num);
            App.State.Battle.UpdateData(num);
            SpecialFightUi.UpdateAutoMode(num);
            App.State.CreatingSpeedBoniDuration -= num;
            if (App.State.CreatingSpeedBoniDuration < 0L)
            {
                App.State.CreatingSpeedBoniDuration = 0L;
            }
            if (!App.State.PremiumBoni.TotalMightIsUnlocked)
            {
                App.State.PremiumBoni.TotalMightIsUnlocked = (App.State.AllTrainings[App.State.AllTrainings.Count - 1].IsAvailable && App.State.AllSkills[App.State.AllSkills.Count - 1].IsAvailable);
                if (App.State.PremiumBoni.TotalMightIsUnlocked && !App.State.Statistic.HasStartedArtyChallenge && !App.State.Statistic.HasStartedUltimateBaalChallenge)
                {
                    foreach (Might current6 in App.State.AllMights)
                    {
                        CDouble cDouble = App.State.Statistic.DoubleRebirthChallengesFinished;
                        if (cDouble > 50)
                        {
                            cDouble = 50;
                        }
                        current6.Level += cDouble;
                        App.State.PremiumBoni.TotalMight += (long)cDouble.ToInt();
                    }
                }
            }
            foreach (Monument current7 in App.State.AllMonuments)
            {
                current7.UpdateDuration(num);
                if (App.State.Statistic.HasStartedBlackHoleChallenge && current7.TypeEnum == Monument.MonumentType.black_hole)
                {
                    MonumentUpgrade upgrade = current7.Upgrade;
                    if (current7.Level > 0 && upgrade.Level > 0)
                    {
                        App.State.Statistic.HasStartedBlackHoleChallenge = false;
                        if (App.State.Statistic.FastestBHCallenge <= 0 || App.State.Statistic.FastestBHCallenge > App.State.Statistic.TimeAfterBHCStarted)
                        {
                            App.State.Statistic.FastestBHCallenge = App.State.Statistic.TimeAfterBHCStarted;
                            Leaderboards.SubmitStat(LeaderBoardType.FastestBHCallenge, (int)(App.State.Statistic.FastestBHCallenge.ToLong() / 1000L), false);
                        }
                        App.State.Statistic.TimeAfterBHCStarted = 0;
                        Statistic expr_542 = App.State.Statistic;
                        expr_542.BlackHoleChallengesFinished = ++expr_542.BlackHoleChallengesFinished;
                        App.SaveGameState();
                        GuiBase.ShowToast("You finished your black hole challenge!");
                    }
                }
            }
            foreach (Pet current8 in App.State.Ext.AllPets)
            {
                current8.UpdateDuration(num);
            }
            App.State.HomePlanet.UpdateDuration(num);
            if (HeroImage.ShouldInitRessources)
            {
                //base.StartCoroutine(this.InitAvatarImages());
            }
        }
예제 #19
0
 public void ChangeToEnemyRound()
 {
     WhoseTurnisIt    = State2.Enemy;
     AID.CanBeDamaged = true;
 }
예제 #20
0
 public override int GetHashCode() => 953 + State1.GetHashCode() + 61 *State2.GetHashCode();
 // Start is called before the first frame update
 void Start()
 {
     state2 = startingState2;
     textComponent.text = state2.GetStoryText2();
 }
예제 #22
0
 public Translate(State2 state)
 {
     this.state = state;
 }
 private static void UpdateState(SomeAction act, State2 s1)
 {
     Console.WriteLine("State2 SomeAction Updated.");
 }
예제 #24
0
 public void ChangeToPlayerRound()
 {
     RoundNumber  += 1;
     WhoseTurnisIt = State2.Player;
     CanBeDamaged  = true;
 }
예제 #25
0
 public override bool Equals(object obj)
 {
     return(obj is SeqState seq && State1.Equals(seq.State1) && State2.Equals(seq.State2));
 }
예제 #26
0
 /// <summary>
 /// Voeg een state toe aan de state machine
 /// LET OP! Alle components die de Class State.cs extenden (inheritance) die mogen in de Dictionary
 /// Daarom mogen AlertState.cs, AlertState.cs en FleeState.cs in de dictionary, aangezien zij State.CS extenden
 /// </summary>
 /// <param name="stateID">Een integer die komt uit de ENUM StateID (zie StateID in Guard.cs)</param>
 /// <param name="state">Een component die State.cs extend (inheritance)</param>
 public void AddState(StateID2 stateID, State2 state)
 {
     states.Add(stateID, state);
 }