Example #1
0
 // Use this for initialization
 void Start()
 {
     canMove     = false;
     moveForward = 0;
     Instance    = this;
     iBack       = 0;
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     canMove = false;
     moveForward = 0;
     Instance = this;
     iBack = 0;
 }
        public void testExploration()
        {
            NodeExpander       nodeExpander = new PropertyReflectionNodeExpander();
            TestData           testData     = new TestData();
            ObjectExplorerImpl explorer     = new ObjectExplorerImpl();

            explorer.NodeExpander = nodeExpander;
            Object   valueFound = null;
            int      depth      = 0;
            int?     depthFound = null;
            MoveBack up         = delegate(Object from, String propertyName, Object to, bool isIndexed)
            {
                depth--;
            };
            MoveAway down = delegate(Object from, String propertyName, Object to, bool isIndexed, int?index)
            {
                depth++;
                return(true);
            };
            OnLeaf leaf = delegate(Object from, String propertyName, Object to, int?index)
            {
                if (propertyName != null && propertyName.Equals("Greeting"))
                {
                    valueFound = to;
                    depthFound = depth + 1;
                }
            };

            explorer.explore(testData, down, up, leaf);
            Assert.AreEqual(testData.TheSub.TheSubSub.Greeting, valueFound, "expected greeting ");
            Assert.AreEqual(4, depthFound, "expected depth");
        }
        public List <InstancePathElement> findSingleObjectPath(object root, object object2Find)
        {
            bool found = false;
            ObjectExplorerImpl          explorer    = new ObjectExplorerImpl();
            Stack <InstancePathElement> currentPath = new Stack <InstancePathElement>();

            MoveAway down = delegate(Object from, string propertyName, Object to, bool isIndexed, int?index)
            {
                if (found)
                {
                    return(false);
                }
                InstancePathElement element;
                InstancePathElement thepeek = currentPath.Count > 0 ? currentPath.Peek() : null;
                bool parentIsIndexed        = currentPath.Count > 0 && currentPath.Peek().IsIndexed;
                if (parentIsIndexed)
                {
                    IndexPathElement ielement = new IndexPathElement();
                    ielement.Index = (int)index;
                    element        = ielement;
                }
                else
                {
                    NamePathElement nElement = new NamePathElement();
                    nElement.Name = propertyName;
                    element       = nElement;
                }
                element.IsIndexed = isIndexed;
                currentPath.Push(element);
                found = object2Find == to;
                return(!found);
            };
            MoveBack up = (from, propertyName, to, isIndexed) =>
            {
                if (!found)
                {
                    currentPath.Pop();
                }
            };

            OnLeaf onLeaf = (from, propertyName, to, index) =>
            {
            };

            PropertyReflectionNodeExpander expander = new PropertyReflectionNodeExpander();

            expander.ExcludeReadOnlyProperties = true;
            explorer.NodeExpander = expander;

            explorer.explore(root, down, up, onLeaf);
            List <InstancePathElement> result = null;

            if (found)
            {
                result = new List <InstancePathElement>(currentPath.ToArray().Reverse());
                // remove the first element because it is to the root
                result.RemoveAt(0);
            }
            return(result);
        }
Example #5
0
    private void Start()
    {
        prevMoves = new Stack <char>();
        pc        = new PlayerController(player);

        leftCommand    = new MoveLeft(pc);
        rightCommand   = new MoveRight(pc);
        backCommand    = new MoveBack(pc);
        forwardCommand = new MoveForward(pc);
    }
Example #6
0
 protected override void RenderContent(UnityEngine.Object undoRecordObject)
 {
     MoveForward.RenderEditorGUI(undoRecordObject);
     MoveBack.RenderEditorGUI(undoRecordObject);
     StrafeLeft.RenderEditorGUI(undoRecordObject);
     StrafeRight.RenderEditorGUI(undoRecordObject);
     MoveUp.RenderEditorGUI(undoRecordObject);
     MoveDown.RenderEditorGUI(undoRecordObject);
     Pan.RenderEditorGUI(undoRecordObject);
     LookAround.RenderEditorGUI(undoRecordObject);
     Orbit.RenderEditorGUI(undoRecordObject);
 }
    // Update is called per tick
    void FixedUpdate()
    {
        rb.AddForce(0, -9.8f * Time.deltaTime, 0);

        if (bIsReplaying)
        {
            return; //Running a replay, ignore active inputs
        }


        if (Input.GetKey("d")) //Move Right
        {
            //rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            Command moveRight = new MoveRight(rb, sidewaysForce);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(moveRight);
            invoker.ExecuteCommand();
        }


        if (Input.GetKey("a")) //Move Left
        {
            //rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            Command moveLeft = new MoveLeft(rb, sidewaysForce);
            Invoker invoker  = new Invoker();
            invoker.SetCommand(moveLeft);
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("w")) //Move Forward
        {
            //rb.AddForce(0, 0, sidewaysForce * Time.deltaTime, ForceMode.VelocityChange);
            Command moveForward = new MoveForward(rb, forwardForce);
            Invoker invoker     = new Invoker();
            invoker.SetCommand(moveForward);
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("s")) //Move Backwards
        {
            //rb.AddForce(0, 0, -sidewaysForce * Time.deltaTime, ForceMode.VelocityChange);
            Command moveBack = new MoveBack(rb, forwardForce);
            Invoker invoker  = new Invoker();
            invoker.SetCommand(moveBack);
            invoker.ExecuteCommand();
        }

        if (rb.position.y < -2f)
        {//Reset if off the map
            FindObjectOfType <game_manager>().GameEnd();
        }
    }
        public void explore(object root, MoveAway down, MoveBack up, OnLeaf leaf)
        {
            if (CheckPermissionByName==null)
            {
                //todo write test for this
                throw new SecurityException("cant check permissions no Check Permission By Name code");
            }
            if (UnderlyingExplorer == null)
            {
                throw new SecurityException("cant check permissions no UnderlyingExplorer");
            }

            OnLeaf filteredOnLeaf = (from, propertyName, to, index) =>
                {
                    if (!isDeniedByPermission(from, propertyName))
                    {
                        leaf(from, propertyName, to, index);
                    }
                };

            MoveAway filteredMoveAway = ( from, propertyName, to, isIndexed, index) =>
                {
                    if (!isDeniedByPermission(from, propertyName))
                    {
                        return down(from, propertyName, to, isIndexed, index);
                    }
                    else
                    {
                        return false;
                    }
                };

            MoveBack filteredMoveBack = (from,  propertyName,  to,  isIndexed) =>
            {
                if (!isDeniedByPermission(from, propertyName))
                {
                    up(from, propertyName, to, isIndexed);
                }
            };

            UnderlyingExplorer.explore(root, filteredMoveAway, filteredMoveBack, filteredOnLeaf);
        }
Example #9
0
        public void explore(object root, MoveAway down, MoveBack up, OnLeaf leaf)
        {
            if (CheckPermissionByName == null)
            {
                //todo write test for this
                throw new SecurityException("cant check permissions no Check Permission By Name code");
            }
            if (UnderlyingExplorer == null)
            {
                throw new SecurityException("cant check permissions no UnderlyingExplorer");
            }

            OnLeaf filteredOnLeaf = (from, propertyName, to, index) =>
            {
                if (!isDeniedByPermission(from, propertyName))
                {
                    leaf(from, propertyName, to, index);
                }
            };

            MoveAway filteredMoveAway = (from, propertyName, to, isIndexed, index) =>
            {
                if (!isDeniedByPermission(from, propertyName))
                {
                    return(down(from, propertyName, to, isIndexed, index));
                }
                else
                {
                    return(false);
                }
            };

            MoveBack filteredMoveBack = (from, propertyName, to, isIndexed) =>
            {
                if (!isDeniedByPermission(from, propertyName))
                {
                    up(from, propertyName, to, isIndexed);
                }
            };

            UnderlyingExplorer.explore(root, filteredMoveAway, filteredMoveBack, filteredOnLeaf);
        }
        //, TypeAliaser aliaser
        public LeafDefaultSet getDefaultsForAllLinkedObjects(Object root, NodeExpander nodeExpander)
        {
            LeafDefaultSet result = new LeafDefaultSet();

            ObjectExplorerImpl explorer = new ObjectExplorerImpl();
            MoveAway           down     = (from, propertyName, to, isIndexed, index) =>
            {
                return(isIndexed || (to != null && !result.Type2Defaults.ContainsKey(to.GetType())));
            };
            MoveBack up = (from, propertyName, to, isIndexed) =>
            {
            };

            OnLeaf leaf = (from, propertyName, to, index) =>
            {
                Defaults4Class defaults = null;
                if (from == null)
                {
                    return;
                }
                Type fromType = from.GetType();
                if (!result.Type2Defaults.ContainsKey(fromType))
                {
                    defaults = new Defaults4Class();
                    defaults.FullClassName         = fromType.FullName;
                    result.Type2Defaults[fromType] = defaults;
                }
                else
                {
                    defaults = result.Type2Defaults[fromType];
                }
                defaults.PropertyName2DefaultValue[propertyName] = to;
            };

            explorer.NodeExpander = nodeExpander;
            explorer.explore(root, down, up, leaf);
            return(result);
        }
Example #11
0
        private void MainViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(IsPlayMode):
            case nameof(IsReviewMode):
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(Title));

                    PlayTarget.RaiseCanExecuteChanged();
                    Pass.RaiseCanExecuteChanged();
                    UndoLastMove.RaiseCanExecuteChanged();

                    MoveToStart.RaiseCanExecuteChanged();
                    MoveBack.RaiseCanExecuteChanged();
                    MoveForward.RaiseCanExecuteChanged();
                    MoveToEnd.RaiseCanExecuteChanged();

                    SwitchToPlayMode.RaiseCanExecuteChanged();
                    ShowGameMetadata.RaiseCanExecuteChanged();
                    SwitchToReviewMode.RaiseCanExecuteChanged();

                    UpdateBoardHistory();
                });
                break;

            case nameof(ViewerConfig):
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(ShowBoardHistory));
                    RaisePropertyChanged(nameof(ShowMoveCommentary));
                });
                break;
            }
        }
        /** carries out exploration
         * if o is a leaf leaf is called
         * if o is a standard object down is called the item is expanded anf then up is called
         * if o is a dictionary or indexed object (e.g. array) every contained object is treated as a
         * leaf or standard object
         *
         * determination of leaf is in isLeaf and is based on c# properties
         *
         * determination if indexed type is in getEnumeratorIfIndexedType
         *
         * determination of map type is in toDictionary
         **/
        public void explore(object o, MoveAway down, MoveBack up, OnLeaf leaf)
        {
            if (NodeExpander == null)
            {
                throw new Exception("explore is not possible unless a node expander is specified");
            }
            OnChildNode onChildNode = null;

            onChildNode = delegate(Object from, String name, Object to)
            {
                IEnumerator           en           = null;
                Type                  toType       = to == null?null:to.GetType();
                IDictionaryNonGeneric asDictionary = null;
                if (isLeaf(to, toType))
                {
                    leaf(from, name, to);
                }
                else if (null != (asDictionary = toDictionary(to, toType)))
                {
                    bool doExpand =
                        down(from, name, to, false);
                    en = asDictionary.Keys.GetEnumerator();
                    for (int done = 0; doExpand && en.MoveNext(); done++)
                    {
                        Object oKey     = en.Current;
                        string strKey   = dictionaryKey2String(oKey);
                        Object oVal     = asDictionary[oKey];
                        Type   oValType = oVal == null ? null : oVal.GetType();
                        if (isLeaf(oVal, oValType))
                        {
                            leaf(to, strKey, oVal);
                        }
                        else
                        {
                            bool doSubExpand = down(to, strKey, oVal, false, done);
                            if (doSubExpand)
                            {
                                NodeExpander.expand(oVal, onChildNode);
                            }
                            up(from, strKey, oVal, false);
                        }
                    }
                    up(from, name, to, false);
                }
                else if (null != (en = getEnumeratorIfIndexedType(to)))
                {
                    bool doExpand =
                        down(from, name, to, true);

                    for (int done = 0; doExpand && en.MoveNext(); done++)
                    {
                        Object oVal = en.Current;
                        if (isLeaf(oVal, oVal == null?null:oVal.GetType()))
                        {
                            leaf(to, null, oVal);
                        }
                        else
                        {
                            bool doSubExpand = down(null, null, oVal, false, done);
                            if (doSubExpand)
                            {
                                NodeExpander.expand(oVal, onChildNode);
                            }
                            up(null, null, oVal, false);
                        }
                    }
                    up(from, name, to, true);
                }
                else
                {
                    bool doExpand = down(from, name, to, false);
                    if (doExpand)
                    {
                        NodeExpander.expand(to, onChildNode);
                    }
                    up(from, name, to, false);
                }
            };
            onChildNode(null, null, o);
        }
        /** carries out exploration
         if o is a leaf leaf is called
         if o is a standard object down is called the item is expanded anf then up is called
         if o is a dictionary or indexed object (e.g. array) every contained object is treated as a
         leaf or standard object
         *
         * determination of leaf is in isLeaf and is based on c# properties
         *
         * determination if indexed type is in getEnumeratorIfIndexedType
         *
         * determination of map type is in toDictionary
        **/
        public void explore(object o, MoveAway down, MoveBack up, OnLeaf leaf)
        {
            if (NodeExpander == null) throw new Exception("explore is not possible unless a node expander is specified");
            OnChildNode onChildNode = null;
            onChildNode = delegate(Object from, String name, Object to)
             {
                 IEnumerator en = null;
                 Type toType= to==null?null:to.GetType();
                 IDictionaryNonGeneric asDictionary=null;
                 if (isLeaf(to, toType))
                 {
                     leaf(from, name, to);
                 }
                 else if (null!=(asDictionary=toDictionary(to, toType)))
                 {
                     bool doExpand =
                     down(from, name, to, false);
                     en = asDictionary.Keys.GetEnumerator();
                     for (int done = 0; doExpand && en.MoveNext(); done++)
                     {
                         Object oKey = en.Current;
                         string strKey = dictionaryKey2String(oKey);
                         Object oVal = asDictionary[oKey];
                         Type oValType = oVal == null ? null : oVal.GetType();
                         if (isLeaf(oVal, oValType))
                             leaf(to, strKey, oVal);
                         else
                         {
                             bool doSubExpand = down(to, strKey, oVal, false, done);
                             if (doSubExpand) NodeExpander.expand(oVal, onChildNode);
                             up(from, strKey, oVal, false);
                         }
                     }
                     up(from, name, to, false);
                 }
                 else if (null!=(en=getEnumeratorIfIndexedType(to)))
                 {
                     bool doExpand =
                     down(from, name, to, true);

                     for  (int done=0;doExpand && en.MoveNext();done++)
                     {
                         Object oVal = en.Current;
                         if (isLeaf(oVal, oVal==null?null:oVal.GetType()))
                             leaf(to, null, oVal);
                         else
                         {
                             bool doSubExpand = down(null, null, oVal, false, done);
                             if (doSubExpand) NodeExpander.expand(oVal, onChildNode);
                             up(null, null, oVal, false);
                         }
                     }
                     up(from, name, to, true);
                 }
                 else
                 {
                     bool doExpand = down(from, name, to, false);
                     if (doExpand) NodeExpander.expand(to, onChildNode);
                     up(from, name, to, false);
                 }
             };
            onChildNode(null, null, o);
        }
Example #14
0
        public MainViewModel()
        {
            AppVM.EngineWrapper.BoardUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(Board));
                    SaveGame.RaiseCanExecuteChanged();

                    PlayTarget.RaiseCanExecuteChanged();
                    Pass.RaiseCanExecuteChanged();
                    UndoLastMove.RaiseCanExecuteChanged();

                    MoveToStart.RaiseCanExecuteChanged();
                    MoveBack.RaiseCanExecuteChanged();
                    MoveForward.RaiseCanExecuteChanged();
                    MoveToEnd.RaiseCanExecuteChanged();

                    FindBestMove.RaiseCanExecuteChanged();
                    RaisePropertyChanged(nameof(GameState));

                    if (AppVM.EngineWrapper.GameIsOver && AppVM.EngineWrapper.CurrentGameSettings.GameMode == GameMode.Play)
                    {
                        if (ViewerConfig.PlaySoundEffects)
                        {
                            SoundUtils.PlaySound(GameSound.GameOver);
                        }

                        switch (Board.BoardState)
                        {
                        case BoardState.WhiteWins:
                            Messenger.Default.Send(new InformationMessage("White has won the game.", "Game Over"));
                            break;

                        case BoardState.BlackWins:
                            Messenger.Default.Send(new InformationMessage("Black has won the game.", "Game Over"));
                            break;

                        case BoardState.Draw:
                            Messenger.Default.Send(new InformationMessage("The game is a draw.", "Game Over"));
                            break;
                        }
                    }

                    UpdateBoardHistory();
                });
            };

            AppVM.EngineWrapper.ValidMovesUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(ValidMoves));
                });
            };

            AppVM.EngineWrapper.TargetPieceUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(TargetMove));
                    PlayTarget.RaiseCanExecuteChanged();
                });
            };

            AppVM.EngineWrapper.TargetPositionUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    RaisePropertyChanged(nameof(TargetMove));
                    PlayTarget.RaiseCanExecuteChanged();

                    if (!ViewerConfig.RequireMoveConfirmation)
                    {
                        if (PlayTarget.CanExecute(null) && null != AppVM.EngineWrapper.TargetMove)
                        {
                            // Only fast-play if a move is selected
                            PlayTarget.Execute(null);
                        }
                        else if (Pass.CanExecute(null) && AppVM.EngineWrapper.CanPass)
                        {
                            // Only fast-pass if pass is available
                            Pass.Execute(null);
                        }
                    }
                });
            };

            AppVM.EngineWrapper.IsIdleUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    IsIdle = AppVM.EngineWrapper.IsIdle;
                });
            };

            AppVM.EngineWrapper.TimedCommandProgressUpdated += (sender, args) =>
            {
                AppVM.DoOnUIThread(() =>
                {
                    IsRunningTimedCommand = args.IsRunning;
                    TimedCommandProgress  = args.Progress;
                });
            };

            AppVM.EngineWrapper.MovePlaying += (sender, args) =>
            {
                if (ViewerConfig.PlaySoundEffects)
                {
                    SoundUtils.PlaySound(GameSound.Move);
                }
            };

            AppVM.EngineWrapper.MoveUndoing += (sender, args) =>
            {
                if (ViewerConfig.PlaySoundEffects)
                {
                    SoundUtils.PlaySound(GameSound.Undo);
                }
            };

            AppVM.EngineWrapper.GameModeChanged += (sender, args) =>
            {
                RaisePropertyChanged(nameof(IsPlayMode));
                RaisePropertyChanged(nameof(IsReviewMode));
            };

            PropertyChanged += MainViewModel_PropertyChanged;
        }
Example #15
0
        public void writeAsJson(Object o, TextWriter writer, TypeAliaser typeAliaser = null)
        {
            if (LeafDefaultSet != null && OmitDefaultLeafValuesInJs && OmitMarkAsArrayFunction)
            {
                throw new Exception("Leaf defaulting requires Array marker for js code");
            }


            ObjectIDGenerator idGenerator = null;

            if (UseReferences)
            {
                idGenerator = new ObjectIDGenerator();
            }
            Stack <ExploreStackFrame> exploreStack = new Stack <ExploreStackFrame>();
            Explorer explorerImpl = ExplorerFactory();

            ((Explorer)explorerImpl).NodeExpander = NodeExpander;
            MoveAway down = delegate(Object from, string propertyName, Object to, bool isIndexed, int?index)
            {
                ExploreStackFrame currentFrame = exploreStack.Count > 0 ? exploreStack.Peek():null;
                if (currentFrame != null)
                {
                    if (currentFrame.propertyCount > 0)
                    {
                        writer.Write(", ");
                    }
                    currentFrame.propertyCount++;
                }
                if (from != null && propertyName != null)
                {
                    writePropertyName(propertyName, writer);
                    writer.Write(":");
                }
                ExploreStackFrame childFrame = new ExploreStackFrame();
                exploreStack.Push(childFrame);
                writeIndent(writer, exploreStack);
                if (UseReferences)
                {
                    bool firstTime;
                    long objectid = idGenerator.GetId(to, out firstTime);
                    if (firstTime)
                    {
                        // could be done like this ! (function() {var x=[1,2]; x.id="uuu";return x;})()
                        if (!isIndexed)
                        {
                            writer.Write("{" + this.IdTag + ":" + objectid + ' ');
                            childFrame.propertyCount++;
                            childFrame.propertyCount += writeTypeAliasProperty(writer, to, typeAliaser, childFrame.propertyCount);
                        }
                        else
                        {
                            // no need for type alias
                            writer.Write(AttachId2ArrayFunctionName + "(" + objectid + ",[");
                        }
                    }
                    else
                    {
                        writer.Write("{" + this.ReferenceTag + ":" + objectid);
                        return(false);
                    }
                }
                else // !Use References
                {
                    if (!isIndexed)
                    {
                        writer.Write('{');
                        // todo -- check this out ............
                        childFrame.propertyCount += writeTypeAliasProperty(writer, to, typeAliaser, childFrame.propertyCount);
                    }
                    else
                    {
                        if (!OmitMarkAsArrayFunction)
                        {
                            writer.Write(markAsArrayFunctionName);
                            writer.Write("([");
                        }
                        else
                        {
                            writer.Write("[");
                        }
                    }
                }

                return(true);
            };

            MoveBack up = (from, propertyName, to, isIndexed) =>
            {
                if (!isIndexed)
                {
                    writer.Write('}');
                }
                else
                {
                    writer.Write(']');
                    // is there a function wrapper ?
                    if (!OmitMarkAsArrayFunction || UseReferences)
                    {
                        writer.Write(")");
                    }
                }
                exploreStack.Pop();
                writeIndent(writer, exploreStack);
            };

            OnLeaf leaf = (from, propertyName, to, index) =>
            {
                //check for default leaf values
                if (!this.OmitDefaultLeafValuesInJs ||
                    !isDefaultLeafValue(from, propertyName, to, LeafDefaultSet))
                {
                    ExploreStackFrame currentFrame = exploreStack.Peek();
                    if (currentFrame.propertyCount > 0)
                    {
                        writer.Write(", ");
                    }
                    currentFrame.propertyCount++;
                    if (propertyName != null)
                    {
                        writePropertyName(propertyName, writer);
                        writer.Write(":");
                    }
                    writeLeafValue(writer, to, propertyName);
                }
            };

            explorerImpl.explore(o, down, up, leaf);
        }
    // Update is called per tick
    void FixedUpdate()
    {
        rb.AddForce(0, -9.8f * Time.deltaTime, 0);

        if (rb.position.y < -2f)
        {//Reset if off the map
            if (bIsReplaying)
            {
                CommandLog.commands.Clear();
            }
            FindObjectOfType <game_manager>().GameEnd();
        }

        if (OnPlayerSpeedUpdate != null)//Prevent an empty list from causing errors
        {
            OnPlayerSpeedUpdate(rb.velocity.z);
        }

        if (OnPlayerZUpdate != null)//Prevent an empty list from causing errors
        {
            OnPlayerZUpdate(transform.position.z);
        }

        if (bIsReplaying)
        {
            return; //Running a replay, ignore active inputs
        }


        if (Input.GetKey("d")) //Move Right
        {
            //rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            Command moveRight = new MoveRight(rb, sidewaysForce);
            Invoker invoker   = new Invoker();
            invoker.SetCommand(moveRight);
            invoker.ExecuteCommand();
        }


        if (Input.GetKey("a")) //Move Left
        {
            //rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
            Command moveLeft = new MoveLeft(rb, sidewaysForce);
            Invoker invoker  = new Invoker();
            invoker.SetCommand(moveLeft);
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("w")) //Move Forward
        {
            //rb.AddForce(0, 0, sidewaysForce * Time.deltaTime, ForceMode.VelocityChange);
            Command moveForward = new MoveForward(rb, forwardForce);
            Invoker invoker     = new Invoker();
            invoker.SetCommand(moveForward);
            invoker.ExecuteCommand();
        }

        if (Input.GetKey("s")) //Move Backwards
        {
            //rb.AddForce(0, 0, -sidewaysForce * Time.deltaTime, ForceMode.VelocityChange);
            Command moveBack = new MoveBack(rb, forwardForce);
            Invoker invoker  = new Invoker();
            invoker.SetCommand(moveBack);
            invoker.ExecuteCommand();
        }
    }