Beispiel #1
0
 private static void Bot(ValueKeeper <int> grounded, Collider target, int duration)
 {
     if (target.Parent.Identifier == Identifier.Block)
     {
         grounded.SetValue(duration);
     }
 }
Beispiel #2
0
 public static void Try(ValueKeeper <State> state, GameObject obj, ValueKeeper <int> hittingHead)
 {
     if (hittingHead > 0 && obj.Velocity.Y < 0)
     {
         state.SetValue(State.HeadBump);
     }
 }
Beispiel #3
0
 public static void Try(
     InputController input
     , ValueKeeper <int> grounded
     , ValueKeeper <State> state)
 {
     if (grounded > 0 && (input.Jump.IsPressStaring || input.Jump.Heat > 0))
     {
         state.SetValue(State.JumpStart);
     }
 }
Beispiel #4
0
 public static void Try(
     InputController input
     , ValueKeeper <int> grounded
     , ValueKeeper <State> state)
 {
     if (!input.Left.IsPressed && !input.Right.IsPressed && grounded == Const.Grounded_Timer)
     {
         state.SetValue(State.Idle);
     }
 }
Beispiel #5
0
        public static CollisionHandler Create(ValueKeeper <int> keeper, int duration)
        {
            handler = CollisionHandler.Create();

            handler.Left            =
                handler.Right       =
                    handler.Bot     =
                        handler.Top = (source, target) => Bot(keeper, target, duration);

            return(handler);
        }
Beispiel #6
0
 public static void Try(
     InputController input
     , ValueKeeper <int> grounded
     , ValueKeeper <State> state
     , GameObject obj)
 {
     if ((input.Left || input.Right) && grounded == Const.Grounded_Timer && obj.Velocity.Y >= 0)
     {
         state.SetValue(State.Walking);
     }
 }
Beispiel #7
0
 public static void Try(
     GameObject obj
     , InputController input
     , ValueKeeper <int> grounded
     , ValueKeeper <State> state)
 {
     if (!input.Jump.IsPressed && obj.Velocity.Y < 0 && obj.Velocity.Y < -Const.stoppingGravity)
     {
         state.SetValue(State.JumpBreak);
     }
 }
Beispiel #8
0
 public static void Change(
     InputController input
     , ValueKeeper <bool> facingRight)
 {
     if (input.Left)
     {
         facingRight.SetValue(false);
     }
     else if (input.Right)
     {
         facingRight.SetValue(true);
     }
 }
Beispiel #9
0
        void IShielded.Commit()
        {
            if (!_locals.HasValue)
            {
                return;
            }
            var newCurrent = _locals.Value;

            newCurrent.Older   = _current;
            newCurrent.Version = _writerStamp.Version.Value;
            _current           = newCurrent;
            _writerStamp       = null;
            _locals.Release();
        }
Beispiel #10
0
 public static void Try(
     GameObject obj
     , ValueKeeper <int> grounded
     , ValueKeeper <int> hittingHead
     , ValueKeeper <State> state)
 {
     if (grounded == 0 && obj.Velocity.Y > 0)
     {
         state.SetValue(State.Fall);
     }
     else if (hittingHead > 0 && obj.Velocity.Y > -1000)
     {
         state.SetValue(State.Fall);
     }
 }
Beispiel #11
0
        private ValueKeeper PrepareForWriting(bool prepareOld)
        {
            CheckLockAndEnlist(true);
            if (_current.Version > Shield.ReadStamp)
            {
                throw new TransException("Write collision.");
            }
            if (_locals.HasValue)
            {
                return(_locals.Value);
            }

            var v = new ValueKeeper();

            if (prepareOld)
            {
                v.Value = CurrentTransactionOldValue().Value;
            }
            _locals.Value = v;
            return(v);
        }
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        SetGameObjectForInitialization();

        if (GameObject.Find("ValueKeeper"))
        {
            GameObject  valueKeeperObject = GameObject.Find("ValueKeeper").gameObject;
            ValueKeeper valueKeeper       = valueKeeperObject.GetComponent <ValueKeeper>();

            Dictionary <string, UserState> userStateList = valueKeeper.UserStateList;
            foreach (KeyValuePair <string, UserState> eachUserState in userStateList)
            {
                if (eachUserState.Key.Contains("Player"))
                {
                    playerStateList.Add(eachUserState.Key, eachUserState.Value);
                }
            }
            playerScreenshotList = valueKeeper.PlayerScreenshotList;

            if (playerStateList.Count > 0)
            {
                Dictionary <string, bool> checks = playerStateList.First().Value.CheckList;
                foreach (string check in checks.Keys)
                {
                    checkTextList.Add(check);
                }
            }

            nextScene = valueKeeper.SceneAfterEvaluation;

            Destroy(valueKeeperObject);

            total.GetComponent <Text>().text = GetTotalComment();

            MoveCheckBoxes(-1);
        }

        SoundController.instance.StartEvaluationSound();
    }
Beispiel #13
0
 /// <summary>
 /// Constructs a new Shielded container, containing the given initial value.
 /// </summary>
 /// <param name="initial">Initial value to contain.</param>
 /// <param name="owner">If this is given, then in WhenCommitting subscriptions
 /// this shielded will report its owner instead of itself.</param>
 public Shielded(T initial, object owner = null)
 {
     _current       = new ValueKeeper();
     _current.Value = initial;
     _owner         = owner ?? this;
 }
Beispiel #14
0
 /// <summary>
 /// Constructs a new Shielded container, containing default value of type T.
 /// </summary>
 /// <param name="owner">If this is given, then in WhenCommitting subscriptions
 /// this shielded will report its owner instead of itself.</param>
 public Shielded(object owner = null)
 {
     _current = new ValueKeeper();
     _owner   = owner ?? this;
 }
Beispiel #15
0
 public static void Try(ValueKeeper <State> state)
 {
     state.SetValue(State.Jump);
 }