Exemple #1
0
        public MatchState PlayerMove(Guid matchId, Guid playerId, MovePosition move)
        {
            var match = _onlineMatches.FirstOrDefault(x => x.id == matchId);
            MatchState nextState = null;

            if (match == null)
            {
                throw new EmptyResultsException();
            }

            if (match.operationState == GameOperationState.WaitingForPlayers)
            {
                throw new WaitingForPlayersException();
            }
            if (match.operationState == GameOperationState.Completed)
            {
                throw new GameIsOverException();
            }

            if (!match.players.Contains(playerId))
            {
                throw new PlayerNotInSpecifiedGameException();
            }

            nextState = TicTacToeLogic.CalculateNextState(match, playerId, move);

            if (nextState.operationState == GameOperationState.Completed)
            {
                _dataController.StoreMatch(nextState);
            }

            return nextState;
        }
Exemple #2
0
        public MatchState PlayerMove(Guid matchId, Guid playerId, MovePosition move)
        {
            var        match     = _onlineMatches.FirstOrDefault(x => x.id == matchId);
            MatchState nextState = null;

            if (match == null)
            {
                throw new EmptyResultsException();
            }

            if (match.operationState == GameOperationState.WaitingForPlayers)
            {
                throw new WaitingForPlayersException();
            }
            if (match.operationState == GameOperationState.Completed)
            {
                throw new GameIsOverException();
            }

            if (!match.players.Contains(playerId))
            {
                throw new PlayerNotInSpecifiedGameException();
            }

            nextState = TicTacToeLogic.CalculateNextState(match, playerId, move);

            if (nextState.operationState == GameOperationState.Completed)
            {
                _dataController.StoreMatch(nextState);
            }

            return(nextState);
        }
Exemple #3
0
 public MatchState PlayerMove(Guid matchId, Guid playerId, MovePosition move)
 {
     try
     {
         return(_gameController.PlayerMove(matchId, playerId, move));
     }
     catch (WaitingForPlayersException e)
     {
         throw new FaultException <WaitingForPlayersFault>(new WaitingForPlayersFault());
     }
     catch (GameIsOverException e)
     {
         throw new FaultException <GameIsOverFault>(new GameIsOverFault());
     }
     catch (PlayerNotInSpecifiedGameException e)
     {
         throw new FaultException <PlayerNotInSpecifiedGameFault>(new PlayerNotInSpecifiedGameFault());
     }
     catch (NotPlayersTurnException e)
     {
         throw new FaultException <NotPlayersTurnFault>(new NotPlayersTurnFault());
     }
     catch (InvalidPlayerMoveException e)
     {
         throw new FaultException <InvalidPlayerMoveFault>(new InvalidPlayerMoveFault());
     }
     catch (EmptyResultsException e)
     {
         throw new FaultException <EmptyResultsFault>(new EmptyResultsFault());
     }
 }
Exemple #4
0
        private MovePosition GetMovePositionForDirection(MovePosition position, MoveDirection direction)
        {
            var positionIndex     = _positionsMap.IndexOf(position);
            var nextPositionIndex = 0;

            switch (direction)
            {
            case MoveDirection.Forward:
                nextPositionIndex = positionIndex;
                break;

            case MoveDirection.Right:
                nextPositionIndex = (positionIndex + 1) % 4;
                break;

            case MoveDirection.Backward:
                nextPositionIndex = (positionIndex + 2) % 4;
                break;

            case MoveDirection.Left:
                nextPositionIndex = (positionIndex + 3) % 4;
                break;
            }

            return(_positionsMap[nextPositionIndex]);
        }
Exemple #5
0
        public void Perft()
        {
            var bWTM = MovePosition.WTM();

            Bound.Clear(bWTM);
            StartTask((state) => startSearch((Position?)state, SearchMode.Perft), MovePosition);
        }
Exemple #6
0
 private void Awake()
 {
     MakeSingleton();
     playerMover = GetComponent <PlayerMover>();
     playerInput = GetComponent <PlayerInput>();
     finder      = GetComponent <BoxCollider2D>();
     swapBtn     = Object.FindObjectOfType <MovePosition>().GetComponent <MovePosition>();
 }
Exemple #7
0
        bool DoPathFind()
        {
            Dynamic targetObj = null;

            {
                RTSUnitAI ai = Intellect as RTSUnitAI;
                if (ai != null)
                {
                    targetObj = ai.CurrentTask.Entity;
                }
            }

            //remove this unit from the pathfinding grid
            GetNavigationSystem().RemoveObjectFromMotionMap(this);

            float radius     = Type.Radius;
            Rect  targetRect = new Rect(
                MovePosition.ToVec2() - new Vec2(radius, radius),
                MovePosition.ToVec2() + new Vec2(radius, radius));

            //remove target unit from the pathfinding grid
            if (targetObj != null && targetObj != this)
            {
                GetNavigationSystem().RemoveObjectFromMotionMap(targetObj);
            }

            //TO DO: really need this call?
            GetNavigationSystem().AddTempClearMotionMap(targetRect);

            const int maxFieldsDistance = 1000;
            const int maxFieldsToCheck  = 100000;
            bool      found             = GetNavigationSystem().FindPath(
                Type.Radius * 2 * 1.1f,
                Position.ToVec2(),
                MovePosition.ToVec2(),
                maxFieldsDistance,
                maxFieldsToCheck,
                true,
                false,
                path);

            GetNavigationSystem().DeleteAllTempClearedMotionMap();

            //add target unit to the pathfinding grid
            if (targetObj != null && targetObj != this)
            {
                GetNavigationSystem().AddObjectToMotionMap(targetObj);
            }

            //add this unit the the pathfinding grid
            GetNavigationSystem().AddObjectToMotionMap(this);

            return(found);
        }
Exemple #8
0
        internal static int MoveMemberUp(this IWpfTextView textView, IOleCommandTarget commandTarget, IEditorOperations editorOperations)
        {
            var          position     = textView.Caret.Position.BufferPosition.Position;
            var          syntaxRoot   = textView.TextSnapshot.GetOpenDocumentInCurrentContextWithChanges().GetSyntaxRootAsync().Result;
            MovePosition movePsoition = MovePosition.Top;

            // Find the Current member, and exit if it is outside the container
            var currMember = syntaxRoot.FindMemberDeclarationAt(position);

            if (!currMember.ContainsPosition(position))
            {
                currMember = currMember?.Parent.AncestorsAndSelf().OfType <MemberDeclarationSyntax>().FirstOrDefault();
            }
            if (currMember == null || currMember.Parent == null)
            {
                return(VSConstants.S_OK);
            }

            //Find Previous member
            var prevMember = syntaxRoot.FindMemberDeclarationAt(currMember.FullSpan.Start - 1);

            if (prevMember.IsContainerType())
            {
                if (prevMember.Equals(currMember.Parent))
                {
                    //Move Methods/Properties/Enum/Constructor/..
                    if (!currMember.IsContainerType())
                    {
                        while (prevMember.IsRootNodeof(currMember) || prevMember.IsKind(SyntaxKind.NamespaceDeclaration)) //untill valid
                        {
                            prevMember = syntaxRoot.FindMemberDeclarationAt(prevMember.FullSpan.Start - 1);
                            prevMember = prevMember.IsRootNodeof(currMember) ? prevMember : prevMember.GetNextChildMember(true);
                            if (prevMember == null)
                            {
                                return(VSConstants.S_OK);
                            }
                        }
                        movePsoition = prevMember.IsContainerType() ? MovePosition.MiddlefromBottom : MovePosition.Bottom;
                    }
                }
                else  //prev member is Sibling
                {
                    prevMember.GetNextChildMember(true);
                    movePsoition = prevMember.IsContainerType() ? MovePosition.MiddlefromBottom : MovePosition.Bottom;
                }
            }

            int newCaretPosn = textView.SwapMembers(currMember, prevMember, movePsoition, MoveDirection.Up, commandTarget, editorOperations);

            MakeCaretVisible(textView, newCaretPosn);
            return(VSConstants.S_OK);
        }
Exemple #9
0
 private void PlayerMove(MovePosition move)
 {
     try
     {
         Program.gameController.PlayerMove(
             _state.GetValue().id,
             Program.infoController.profile.id,
             move);
     }
     catch (FaultException<WaitingForPlayersFault>)
     {
         MessageBox.Show("Waiting for an opponent!");
     }
     catch (FaultException<GameIsOverFault>)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Game is over!");
         BackButton.Show();
     }
     catch (FaultException<PlayerNotInSpecifiedGameFault>)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Not in game!");
         ExitGame();
     }
     catch (FaultException<NotPlayersTurnFault>)
     {
         MessageBox.Show("Not Your Turn!");
     }
     catch (FaultException<InvalidPlayerMoveFault>)
     {
         MessageBox.Show("Bad Move!");
     }
     catch (FaultException<EmptyResultsFault>)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Game not found!");
         ExitGame();
     }
     catch (CommunicationException)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Unable to connect to server!\nPlease try again Later.");
         BackButton.Show();
     }
     catch (Exception ex)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Unforseen error!, " + ex.Message);
         BackButton.Show();
     }
 }
Exemple #10
0
 private void PlayerMove(MovePosition move)
 {
     try
     {
         Program.gameController.PlayerMove(
             _state.GetValue().id,
             Program.infoController.profile.id,
             move);
     }
     catch (FaultException <WaitingForPlayersFault> )
     {
         MessageBox.Show("Waiting for an opponent!");
     }
     catch (FaultException <GameIsOverFault> )
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Game is over!");
         BackButton.Show();
     }
     catch (FaultException <PlayerNotInSpecifiedGameFault> )
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Not in game!");
         ExitGame();
     }
     catch (FaultException <NotPlayersTurnFault> )
     {
         MessageBox.Show("Not Your Turn!");
     }
     catch (FaultException <InvalidPlayerMoveFault> )
     {
         MessageBox.Show("Bad Move!");
     }
     catch (FaultException <EmptyResultsFault> )
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Game not found!");
         ExitGame();
     }
     catch (CommunicationException)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Unable to connect to server!\nPlease try again Later.");
         BackButton.Show();
     }
     catch (Exception ex)
     {
         UpdateTimer.Enabled = false;
         MessageBox.Show("Unforseen error!, " + ex.Message);
         BackButton.Show();
     }
 }
Exemple #11
0
        internal static int MoveMemberDown(this IWpfTextView textView, IOleCommandTarget commandTarget, IEditorOperations editorOperations)
        {
            var          position     = textView.Caret.Position.BufferPosition.Position;
            var          syntaxRoot   = textView.TextSnapshot.GetOpenDocumentInCurrentContextWithChanges().GetSyntaxRootAsync().Result;
            MovePosition movePsoition = MovePosition.Bottom;

            // Find the Current member, and exit if it is outside the container
            var currMember = syntaxRoot.FindMemberDeclarationAt(position);

            if (!currMember.ContainsPosition(position))
            {
                currMember = currMember?.Parent.AncestorsAndSelf().OfType <MemberDeclarationSyntax>().FirstOrDefault();
            }
            if (currMember == null || currMember.Parent == null)
            {
                return(VSConstants.S_OK);
            }

            //Find next member
            var nextMember = syntaxRoot.FindMemberDeclarationAt(currMember.FullSpan.End + 1);

            if (nextMember.IsContainerType())
            {
                if (nextMember.Equals(currMember.Parent))
                {
                    //if Moving Methods,Properties,Enum,Constructor,.. (excludes class, interface, struct,..)
                    if (!currMember.IsContainerType())
                    {
                        while (nextMember.IsRootNodeof(currMember) || nextMember.IsKind(SyntaxKind.NamespaceDeclaration)) //untill valid
                        {
                            nextMember = syntaxRoot.FindMemberDeclarationAt(nextMember.FullSpan.End + 1);
                            nextMember = nextMember.IsRootNodeof(currMember) ? nextMember : nextMember.GetNextChildMember(false);
                            if (nextMember == null)
                            {
                                return(VSConstants.S_OK);
                            }
                        }
                        movePsoition = nextMember.IsContainerType() ? MovePosition.MiddlefromTop : MovePosition.Top;
                    }
                }
                else  //Next member is Sibling
                {
                    nextMember.GetNextChildMember(false);
                    movePsoition = nextMember.IsContainerType() ? MovePosition.MiddlefromTop : MovePosition.Top;
                }
            }

            int newCaretPosn = textView.SwapMembers(currMember, nextMember, movePsoition, MoveDirection.Down, commandTarget, editorOperations);

            MakeCaretVisible(textView, newCaretPosn);
            return(VSConstants.S_OK);
        }
Exemple #12
0
        public virtual void MoveRules(HttpContext context)
        {
            YZRequest    request      = new YZRequest(context);
            int          targetruleid = request.GetInt32("targetruleid");
            MovePosition position     = request.GetEnum <MovePosition>("position");
            JArray       post         = request.GetPostData <JArray>();
            List <int>   ruleids      = post.ToObject <List <int> >();
            string       uid          = YZAuthHelper.LoginUserAccount;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                TaskRule.MoveTaskRules(cn, uid, ruleids.ToArray(), targetruleid, position);
            }
        }
Exemple #13
0
        public static MatchState CalculateNextState(MatchState currentState, Guid playerId, MovePosition move)
        {
            var nextState = currentState;
            if (nextState.operationState == GameOperationState.Completed)
            {
                throw new GameIsOverException();
            }

            if (nextState.playerTurnId != playerId)
            {
                throw new NotPlayersTurnException();
            }

            if (nextState.inGameState.board[(int)move] != PlayerMark.Empty)
            {
                throw new InvalidPlayerMoveException();
            }

            if (playerId == nextState.inGameState.firstPlayer)
            {
                nextState.inGameState.board[(int)move] = PlayerMark.X;
            }
            else
            {
                nextState.inGameState.board[(int)move] = PlayerMark.O;
            }

            if (DoesGameHaveWinner(nextState.inGameState))
            {
                nextState.playerTurnId = Guid.Empty;
                nextState.winnerId = playerId;
                nextState.gameEndTime = DateTime.Now;
                nextState.operationState = GameOperationState.Completed;
            }
            else if (IsGameTie(nextState.inGameState))
            {
                nextState.playerTurnId = Guid.Empty;
                nextState.winnerId = Guid.Empty;
                nextState.gameEndTime = DateTime.Now;
                nextState.operationState = GameOperationState.Completed;
            }
            else
            {
                nextState.playerTurnId = AlternateTurn(nextState);
            }

            return nextState;
        }
Exemple #14
0
        private void MoveForward()
        {
            MovePosition previousPositionOnGrid = null;

            if (_movePositionList.Count > 0)
            {
                previousPositionOnGrid = _movePositionList[0];
            }

            var movePosition = new MovePosition(previousPositionOnGrid, _currentPositionOnGrid, _currentDirection);

            _movePositionList.Insert(0, movePosition);

            var gridMoveDirectionVector = ProcessMoveStep();

            _currentPositionOnGrid += gridMoveDirectionVector;

            var directionChange = _levelGrid.ValidateGridPosition(_currentPositionOnGrid);

            if (directionChange != null)
            {
                RemoveCurrentHero();
                if (_heroInCaravans.Count <= 0)
                {
                    TriggerGameOver();
                    PauseCaravan();
                    return;
                }

                _currentPositionOnGrid -= gridMoveDirectionVector;
                _currentDirection       = (Direction)directionChange;
                var changeDirectionStep = ProcessMoveStep();

                _currentPositionOnGrid += changeDirectionStep;

                CollisionChecks();

                AppliedPositionAndRotation(changeDirectionStep);
            }
            else
            {
                CollisionChecks();

                AppliedPositionAndRotation(gridMoveDirectionVector);
            }

            UpdateCaravanMemberPosition();
        }
Exemple #15
0
        public virtual void MoveObjects(HttpContext context)
        {
            YZRequest               request    = new YZRequest(context);
            StoreZoneType           zone       = request.GetEnum <StoreZoneType>("zone");
            string                  folder     = request.GetString("folder", null);
            string                  tergetname = request.GetString("tergetname", null);
            MovePosition            position   = request.GetEnum <MovePosition>("position");
            JArray                  post       = request.GetPostData <JArray>();
            BPMObjectNameCollection names      = post.ToObject <BPMObjectNameCollection>();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                cn.MoveObjects(zone, folder, names, tergetname, position);
            }
        }
Exemple #16
0
        public virtual void MoveFolders(HttpContext context)
        {
            YZRequest    request        = new YZRequest(context);
            int          targetfolderid = request.GetInt32("targetfolderid");
            MovePosition position       = request.GetEnum <MovePosition>("position");
            JArray       post           = request.GetPostData <JArray>();
            List <int>   folderids      = post.ToObject <List <int> >();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    DirectoryManager.MoveFolders(provider, cn, folderids.ToArray(), targetfolderid, position);
                }
            }
        }
Exemple #17
0
        public static bool IsLineAllEqual(List <PlayerMark> board, MovePosition first, MovePosition second, MovePosition third)
        {
            if (board.ElementAt((int)first) == PlayerMark.Empty)
            {
                return(false);
            }
            var line = new List <MovePosition> {
                first, second, third
            };

            if (line.All(x => board.ElementAt((int)first) == board.ElementAt((int)x)))
            {
                return(true);
            }
            return(false);
        }
Exemple #18
0
        public virtual void MoveFiles(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    root    = request.GetString("root");
            string    path    = request.GetString("path", null);
            BPMObjectNameCollection excludes = BPMObjectNameCollection.FromStringList(request.GetString("excludes", null), ',');
            string       tergetfilename      = request.GetString("tergetfilename");
            MovePosition position            = request.GetEnum <MovePosition>("position");

            string        rootPath   = OSDirectoryManager.GetRootPath(root);
            string        folderPath = Path.Combine(context.Server.MapPath(rootPath), path);
            JArray        post       = request.GetPostData <JArray>();
            List <string> filenames  = post.ToObject <List <string> >();

            OSDirectoryManager.MoveFiles(folderPath, excludes, filenames.ToArray(), tergetfilename, position);
        }
Exemple #19
0
        bool DoPathFind()
        {
            Dynamic targetObj = null;

            {
                //not true because use Intellect
                RTSUnitAI ai = Intellect as RTSUnitAI;
                if (ai != null)
                {
                    targetObj = ai.CurrentTask.Entity;
                }
            }

            GridPathFindSystem.Instance.RemoveObjectFromMotionMap(this);

            Bounds bounds = PhysicsModel.GetGlobalBounds();

            float radius     = Type.Radius;
            Rect  targetRect = new Rect(MovePosition.ToVec2() - new Vec2(radius, radius),
                                        MovePosition.ToVec2() + new Vec2(radius, radius));

            if (targetObj != null && targetObj != this)
            {
                GridPathFindSystem.Instance.RemoveObjectFromMotionMap(targetObj);
            }

            GridPathFindSystem.Instance.DoTempClearMotionMap(targetRect);

            const int maxFieldsDistance = 1000;
            const int maxFieldsToCheck  = 100000;

            bool found = GridPathFindSystem.Instance.DoFind(Type.Radius * 2 * 1.1f, Position.ToVec2(),
                                                            MovePosition.ToVec2(), maxFieldsDistance, maxFieldsToCheck, true, false, path);

            GridPathFindSystem.Instance.RestoreAllTempClearedMotionMap();

            if (targetObj != null && targetObj != this)
            {
                GridPathFindSystem.Instance.AddObjectToMotionMap(targetObj);
            }

            GridPathFindSystem.Instance.AddObjectToMotionMap(this);

            return(found);
        }
Exemple #20
0
        public virtual void MoveLibraries(HttpContext context)
        {
            YZRequest    request     = new YZRequest(context);
            string       uid         = YZAuthHelper.LoginUserAccount;
            string       libType     = request.GetString("libType");
            int          targetlibid = request.GetInt32("targetlibid");
            MovePosition position    = request.GetEnum <MovePosition>("position");
            JArray       post        = request.GetPostData <JArray>();
            List <int>   libids      = post.ToObject <List <int> >();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    LibraryManager.MoveLibraries(provider, cn, libType, libids.ToArray(), targetlibid, position);
                }
            }
        }
Exemple #21
0
        public virtual void MoveFavorites(HttpContext context)
        {
            YZRequest      request  = new YZRequest(context);
            string         uid      = YZAuthHelper.LoginUserAccount;
            YZResourceType resType  = request.GetEnum <YZResourceType>("resType");
            string         target   = request.GetString("target");
            MovePosition   position = request.GetEnum <MovePosition>("position");
            JArray         post     = request.GetPostData <JArray>();
            List <string>  ids      = post.ToObject <List <string> >();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    FavoriteManager.MoveFavorites(provider, cn, uid, resType, ids.ToArray(), target, position);
                }
            }
        }
Exemple #22
0
 public void OnMoveCommand()
 {
     if (IsSearchInProgress)
     {
         throw new ChessException("Search in progress");
     }
     else if (MovePosition is null)
     {
         throw new ChessException("Uninitialized Position");
     }
     else if (!MovePosition.IsValid(out string sInvalid))
     {
         throw new InvalidPositionException("Invalid Position");
     }
     else if (!MovePosition.IsLegal())
     {
         throw new ChessException("Illegal Move");
     }
 }
Exemple #23
0
        public Point GetNearPoint(MovePosition movePosition)
        {
            switch (movePosition)
            {
            case MovePosition.Top:
                return(Point.ShiftTop());

            case MovePosition.Right:
                return(Point.ShiftRight());

            case MovePosition.Bottom:
                return(Point.ShiftBottom());

            case MovePosition.Left:
                return(Point.ShiftLeft());
            }

            throw new Exception("something went wrong");
        }
Exemple #24
0
        private void herald(DateTime dtStarted, String sName)
        {
            var sb = new StringBuilder();

            sb.AppendLine();            // Following UCI prompt
            sb.AppendFormat($"{dtStarted:yyyy-MM-dd}");

            if (!IsNullOrEmpty(sName))
            {
                sb.Append(sSpace);
                sb.Append(sName);
            }

            Bound.AppendBounds(sb);
            appendOptions(sb);
#if DisplayPosition
            sb.AppendLine();
            MovePosition.Display(sb);
#endif
            sb.FlushLine();
        }
Exemple #25
0
        public Tuple <MovePosition, Point> GetNearPosition(MovePosition position, MoveDirection direction)
        {
            var movePosition = GetMovePositionForDirection(position, direction);

            switch (movePosition)
            {
            case MovePosition.Top:
                return(new Tuple <MovePosition, Point>(MovePosition.Top, Point.ShiftTop()));

            case MovePosition.Right:
                return(new Tuple <MovePosition, Point>(MovePosition.Right, Point.ShiftRight()));

            case MovePosition.Bottom:
                return(new Tuple <MovePosition, Point>(MovePosition.Bottom, Point.ShiftBottom()));

            case MovePosition.Left:
                return(new Tuple <MovePosition, Point>(MovePosition.Left, Point.ShiftLeft()));
            }

            throw new Exception("HasPoint.GetNearPosition: something went wrong");
        }
Exemple #26
0
        public virtual object MoveFolders(HttpContext context)
        {
            YZRequest               request    = new YZRequest(context);
            StoreZoneType           zone       = request.GetEnum <StoreZoneType>("zone");
            string                  targetPath = request.GetString("targetPath", null);
            MovePosition            position   = request.GetEnum <MovePosition>("position");
            JArray                  post       = request.GetPostData <JArray>();
            BPMObjectNameCollection paths      = post.ToObject <BPMObjectNameCollection>();

            List <string> rv = new List <string>();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                foreach (string path in paths)
                {
                    rv.Add(cn.MoveFolder(zone, path, targetPath, position));
                }
            }

            return(rv);
        }
Exemple #27
0
        public void SetCaravanMemberMovePosition(MovePosition movePosition)
        {
            transform.position = new Vector3(movePosition.GetGridPosition().x, movePosition.GetGridPosition().y);
            float angle;

            switch (movePosition.GetDirection())
            {
            default:
            case Direction.Up:
                switch (movePosition.GetPreviousDirection())
                {
                default:
                    angle = 0;
                    break;

                case Direction.Left:
                    angle = 0 + 45;
                    transform.position += new Vector3(.2f, .2f);
                    break;

                case Direction.Right:
                    angle = 0 - 45;
                    transform.position += new Vector3(-.2f, .2f);
                    break;
                }

                break;

            case Direction.Down:
                switch (movePosition.GetPreviousDirection())
                {
                default:
                    angle = 180;
                    break;

                case Direction.Left:
                    angle = 180 - 45;
                    transform.position += new Vector3(.2f, -.2f);
                    break;

                case Direction.Right:
                    angle = 180 + 45;
                    transform.position += new Vector3(-.2f, -.2f);
                    break;
                }

                break;

            case Direction.Left:
                switch (movePosition.GetPreviousDirection())
                {
                default:
                    angle = +90;
                    break;

                case Direction.Down:
                    angle = 180 - 45;
                    transform.position += new Vector3(-.2f, .2f);
                    break;

                case Direction.Up:
                    angle = 45;
                    transform.position += new Vector3(-.2f, -.2f);
                    break;
                }

                break;

            case Direction.Right:
                switch (movePosition.GetPreviousDirection())
                {
                default:
                    angle = -90;
                    break;

                case Direction.Down:
                    angle = 180 + 45;
                    transform.position += new Vector3(.2f, .2f);
                    break;

                case Direction.Up:
                    angle = -45;
                    transform.position += new Vector3(.2f, -.2f);
                    break;
                }

                break;
            }

            transform.eulerAngles = new Vector3(0, 0, angle);
        }
Exemple #28
0
        public static void MoveFavorites(IYZDbProvider provider, IDbConnection cn, string uid, YZResourceType resType, string[] resIds, string targetResId, MovePosition position)
        {
            FavoriteCollection favorites = GetFavorites(provider, cn, uid, resType);

            favorites.Move <string>("resId", resIds, targetResId, position);

            for (int i = 0; i < favorites.Count; i++)
            {
                Favorite favorite = favorites[i];
                favorite.orderIndex = i;
                FavoriteManager.UpdateOrderIndex(provider, cn, favorite);
            }
        }
    public Vector2 GetPosition(MovePosition movePosition)
    {
        try
        {
            RectTransform parent = rectTransform.parent.GetComponent <RectTransform>();  //We need to do this check because when we Instantiate a notification we need to use the uiContainer if the parent is null.
            if (parent == null)
            {
                parent = UIManager.UIContainer.GetComponent <RectTransform>();
            }

            Vector3 targetPosition = UIManager.startAnchoredPosition2D;

            Canvas tempCanvas = rectTransform.GetComponent <Canvas>();
            Canvas rootCanvas = null;

            if (tempCanvas == null) //this might be a button or an UIElement that does not have a Canvas component (this should not happen)
            {
                rootCanvas = rectTransform.root.GetComponentInChildren <Canvas>();
            }
            else
            {
                rootCanvas = tempCanvas.rootCanvas;
            }

            Rect  rootCanvasRect = rootCanvas.GetComponent <RectTransform>().rect;
            float xOffset        = rootCanvasRect.width / 2 + rectTransform.rect.width * rectTransform.pivot.x;
            float yOffset        = rootCanvasRect.height / 2 + rectTransform.rect.height * rectTransform.pivot.y;

            var positionAdjustment = Vector3.zero;
            var positionFrom       = Vector3.zero;

            switch (movePosition)
            {
            case MovePosition.ParentPosition:
                if (parent == null)
                {
                    return(targetPosition);
                }

                targetPosition = new Vector2(parent.anchoredPosition.x + positionAdjustment.x,
                                             parent.anchoredPosition.y + positionAdjustment.y);
                break;

            case MovePosition.LocalPosition:
                if (parent == null)
                {
                    return(targetPosition);
                }

                targetPosition = new Vector2(positionFrom.x + positionAdjustment.x,
                                             positionFrom.y + positionAdjustment.y);
                break;

            case MovePosition.TopScreenEdge:
                targetPosition = new Vector2(positionAdjustment.x + UIManager.startAnchoredPosition2D.x,
                                             positionAdjustment.y + yOffset);
                break;

            case MovePosition.RightScreenEdge:
                targetPosition = new Vector2(positionAdjustment.x + xOffset,
                                             positionAdjustment.y + UIManager.startAnchoredPosition2D.y);
                break;

            case MovePosition.BottomScreenEdge:
                targetPosition = new Vector2(positionAdjustment.x + UIManager.startAnchoredPosition2D.x,
                                             positionAdjustment.y - yOffset);
                break;

            case MovePosition.LeftScreenEdge:
                targetPosition = new Vector2(positionAdjustment.x - xOffset,
                                             positionAdjustment.y + UIManager.startAnchoredPosition2D.y);
                break;

            //case MovePosition.TopLeft:
            //    targetPosition = new Vector2(positionAdjustment.x - xOffset,
            //                                 positionAdjustment.y + yOffset);
            //    break;

            //case MovePosition.TopCenter:
            //    targetPosition = new Vector2(positionAdjustment.x,
            //                                 positionAdjustment.y + yOffset);
            //    break;

            //case MovePosition.TopRight:
            //    targetPosition = new Vector2(positionAdjustment.x + xOffset,
            //                                 positionAdjustment.y + yOffset);
            //    break;

            //case MovePosition.MiddleLeft:
            //    targetPosition = new Vector2(positionAdjustment.x - xOffset,
            //                                 positionAdjustment.y);
            //    break;

            //case MovePosition.MiddleCenter:
            //    targetPosition = new Vector2(positionAdjustment.x,
            //                                 positionAdjustment.y);
            //    break;

            //case MovePosition.MiddleRight:
            //    targetPosition = new Vector2(positionAdjustment.x + xOffset,
            //                                 positionAdjustment.y);
            //    break;

            //case MovePosition.BottomLeft:
            //    targetPosition = new Vector2(positionAdjustment.x - xOffset,
            //                                 positionAdjustment.y - yOffset);
            //    break;

            //case MovePosition.BottomCenter:
            //    targetPosition = new Vector2(positionAdjustment.x,
            //                                 positionAdjustment.y - yOffset);
            //    break;

            //case MovePosition.BottomRight:
            //    targetPosition = new Vector2(positionAdjustment.x + xOffset,
            //                                 positionAdjustment.y - yOffset);
            //break;

            default:
                Debug.LogWarning("[UIAnimaion] This should not happen! DoMoveIn in UIAnimator went to the default setting!");
                break;
            }

            //Debug.Log("[UIAnimaion] GetPosition: " + targetPosition);
            return(targetPosition);
        }
        catch (Exception ex)
        {
            Debug.LogError("[UIAnimaion] GetPosition: " + gameObject.name + " " + ex.Message + "\n" + ex.StackTrace);
            return(new Vector3());
        }
    }
Exemple #30
0
 public void PlayerMove(Guid matchId, Guid playerId, MovePosition move)
 {
     var matchState = _service.PlayerMove(matchId, playerId, move);
     gameState.Update(matchState);
 }
Exemple #31
0
        private static int SwapMembers(this IWpfTextView textView, SyntaxNode member1, SyntaxNode member2, MovePosition position, MoveDirection direction, IOleCommandTarget commandTarget, IEditorOperations editorOperations)
        {
            if (member1 == null || member2 == null)
            {
                return(-1);
            }
            int    caretIndent  = textView.Caret.Position.BufferPosition.Position - member1.FullSpan.Start;
            int    movePosition = 0;
            string moveText     = member1.GetText().ToString();

            //Find the position to Move the Current method (i.e. member1)
            if (position == MovePosition.Top)
            {
                movePosition = member2.FullSpan.Start;
            }
            else if (position == MovePosition.Bottom)
            {
                movePosition = member2.FullSpan.End;
            }
            else if (position == MovePosition.MiddlefromBottom)
            {
                movePosition = member2.ChildTokens().FirstOrDefault(t => t.IsKind(SyntaxKind.CloseBraceToken)).SpanStart - 1;
            }
            else if (position == MovePosition.MiddlefromTop)
            {
                movePosition = member2.ChildTokens().FirstOrDefault(t => t.IsKind(SyntaxKind.OpenBraceToken)).SpanStart + 1;
            }

            var editor = textView.TextSnapshot.TextBuffer.CreateEdit();

            editor.Delete(member1.FullSpan.Start, member1.FullSpan.Length);
            editor.Insert(movePosition, moveText);
            editor.Apply();

            int newCaretPosition = direction == MoveDirection.Up ? (movePosition + caretIndent) : (movePosition + caretIndent - moveText.Length);

            textView.Caret.MoveTo(new SnapshotPoint(textView.TextSnapshot, newCaretPosition));
            textView.Selection.Select(new SnapshotSpan(textView.TextSnapshot, (direction == MoveDirection.Up) ? movePosition : movePosition - moveText.Length, moveText.Length), false);
            FormatDocument(commandTarget);
            textView.Selection.Clear();

            return(newCaretPosition);
        }
Exemple #32
0
 public static bool IsLineAllEqual(List<PlayerMark> board, MovePosition first, MovePosition second, MovePosition third)
 {
     if (board.ElementAt((int)first) == PlayerMark.Empty)
     {
         return false;
     }
     var line = new List<MovePosition> { first, second, third };
     if (line.All(x => board.ElementAt((int)first) == board.ElementAt((int)x)))
     {
         return true;
     }
     return false;
 }
Exemple #33
0
        public static void MoveFiles(string folderPath, BPMObjectNameCollection excludes, string[] filenames, string targetfilename, MovePosition position)
        {
            OSFileInfoCollection fileInfos = GetFiles(folderPath, excludes);

            fileInfos.Move <string>("Name", filenames, targetfilename, position);

            for (int i = 0; i < fileInfos.Count; i++)
            {
                OSFileInfo fileInfo = fileInfos[i];
                fileInfo.OrderIndex = i;
                fileInfo.SaveExtensionInfo();
            }
        }
Exemple #34
0
 public MatchState PlayerMove(Guid matchId, Guid playerId, MovePosition move)
 {
     try
     {
         return _gameController.PlayerMove(matchId, playerId, move);
     }
     catch (WaitingForPlayersException e)
     {
         throw new FaultException<WaitingForPlayersFault>(new WaitingForPlayersFault());
     }
     catch (GameIsOverException e)
     {
         throw new FaultException<GameIsOverFault>(new GameIsOverFault());
     }
     catch (PlayerNotInSpecifiedGameException e)
     {
         throw new FaultException<PlayerNotInSpecifiedGameFault>(new PlayerNotInSpecifiedGameFault());
     }
     catch (NotPlayersTurnException e)
     {
         throw new FaultException<NotPlayersTurnFault>(new NotPlayersTurnFault());
     }
     catch (InvalidPlayerMoveException e)
     {
         throw new FaultException<InvalidPlayerMoveFault>(new InvalidPlayerMoveFault());
     }
     catch (EmptyResultsException e)
     {
         throw new FaultException<EmptyResultsFault>(new EmptyResultsFault());
     }
 }
Exemple #35
0
        void TickMove()
        {
            //path find control
            {
                if (pathFindWaitTime != 0)
                {
                    pathFindWaitTime -= TickDelta;
                    if (pathFindWaitTime < 0)
                    {
                        pathFindWaitTime = 0;
                    }
                }

                if (pathFoundedToPosition != MovePosition.ToVec2() && pathFindWaitTime == 0)
                {
                    path.Clear();
                }

                if (path.Count == 0)
                {
                    if (pathFindWaitTime == 0)
                    {
                        if (DoPathFind())
                        {
                            pathFoundedToPosition = MovePosition.ToVec2();
                            pathFindWaitTime      = .5f;
                        }
                        else
                        {
                            pathFindWaitTime = 1.0f;
                        }
                    }
                }
            }

            if (path.Count == 0)
            {
                return;
            }

            //line movement to path[ 0 ]
            {
                Vec2 destPoint = path[0];

                Vec2 diff = destPoint - Position.ToVec2();

                if (diff == Vec2.Zero)
                {
                    path.RemoveAt(0);
                    return;
                }

                Radian dir = MathFunctions.ATan16(diff.Y, diff.X);

                float halfAngle = dir * 0.5f;
                Quat  rot       = new Quat(new Vec3(0, 0, MathFunctions.Sin16(halfAngle)),
                                           MathFunctions.Cos16(halfAngle));
                Rotation = rot;

                Vec2 dirVector = diff.GetNormalizeFast();
                Vec2 dirStep   = dirVector * (Type.MaxVelocity * TickDelta);

                Vec2 newPos = Position.ToVec2() + dirStep;

                if (Math.Abs(diff.X) <= Math.Abs(dirStep.X) && Math.Abs(diff.Y) <= Math.Abs(dirStep.Y))
                {
                    //unit at point
                    newPos = path[0];
                    path.RemoveAt(0);
                }

                GridPathFindSystem.Instance.RemoveObjectFromMotionMap(this);

                bool free;
                {
                    float radius     = Type.Radius;
                    Rect  targetRect = new Rect(newPos - new Vec2(radius, radius), newPos + new Vec2(radius, radius));

                    free = GridPathFindSystem.Instance.IsFreeInMapMotion(targetRect);
                }

                GridPathFindSystem.Instance.AddObjectToMotionMap(this);

                if (free)
                {
                    float newZ = GridPathFindSystem.Instance.GetMotionMapHeight(newPos) + Type.Height * .5f;
                    Position = new Vec3(newPos.X, newPos.Y, newZ);
                }
                else
                {
                    path.Clear();
                }
            }
        }
Exemple #36
0
        public void PlayerMove(Guid matchId, Guid playerId, MovePosition move)
        {
            var matchState = _service.PlayerMove(matchId, playerId, move);

            gameState.Update(matchState);
        }