コード例 #1
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
     audSource     = this.GetComponent <AudioSource>();
     objectGrabbed = false;
 }
コード例 #2
0
            public TurnAction GetNextDirection(IList <TurnAction> movements, Location loc)
            {
                LocationsTracker.Push(loc);//Register location as visited

                if (movements.Count == 1)
                {
                    try
                    {
                        var now = MovementTool.Reverse(ActionTracker.Pop());
                        StepTracker.Push(new TrackedLocation(loc, now));
                        return(now);
                    }catch (Exception e)
                    {
                        var now = movements[0];
                        StepTracker.Push(new TrackedLocation(loc, now));
                        ActionTracker.Push(now);
                        return(now);
                    }
                }

                var trimHasBeen = movements.Where(s => !BeenToTarget(loc, s)).ToList();

                if (trimHasBeen.Count == 0)
                {
                    var now = MovementTool.Reverse(ActionTracker.Pop());
                    StepTracker.Push(new TrackedLocation(loc, now));
                    return(now);
                }


                TurnAction dirToGoBias;

                try
                {
                    dirToGoBias = MovementTool.Leftify(ActionTracker.Peek());
                }
                catch (Exception)
                {
                    dirToGoBias = movements[new Random().Next(movements.Count)];
                }

                var value = trimHasBeen.Contains(dirToGoBias)
                    ? dirToGoBias
                    : trimHasBeen[new Random().Next(trimHasBeen.Count)];

                StepTracker.Push(new TrackedLocation(loc, value));
                ActionTracker.Push(value);

                return(value);
            }
コード例 #3
0
ファイル: OutputContext.cs プロジェクト: v2vivar/tye
        private void EndStep(StepTracker step)
        {
            if (!object.ReferenceEquals(step, steps.Peek()))
            {
                throw new InvalidOperationException($"Attempting to end a step that isn't running. Currently executing step: {steps.Peek()?.Title}");
            }

            indent -= IndentAmount;
            steps.Pop();

            if (step.Message != null)
            {
                WriteDebugLine(step.Message);
            }
        }
コード例 #4
0
ファイル: OutputContext.cs プロジェクト: v2vivar/tye
        public StepTracker BeginStep(string title)
        {
            if (title is null)
            {
                throw new ArgumentNullException(nameof(title));
            }

            WriteInfoLine(title);

            indent += IndentAmount;
            var currentStep = new StepTracker(this, title);

            steps.Push(currentStep);

            return(currentStep);
        }
コード例 #5
0
 public void RegisterMove(Location loc, bool isInter, TurnAction ac)
 {
     StepTracker.Push(new TrackedLocation(loc, ac));
     LocationsTracker.Push(loc);
     ActionTracker.Push(ac);
 }
コード例 #6
0
 public ScopedClassBindings(StepTracker stepTracker)
 {
     this.stepTracker = stepTracker;
 }
コード例 #7
0
ファイル: GeneralBindings.cs プロジェクト: nandrew/SpecFlow
 public GeneralBindings(StepTracker stepTracker)
 {
     this.stepTracker = stepTracker;
 }