예제 #1
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
        /// <summary>
        /// Move the specified tile from its current square to the empty square;
        /// returns true if the tile moves, false if tile can't be moved.
        /// </summary>

        public bool MoveTile(int tileId)
        {
            // Can't move the "empty" tile:
            if (tileId == 0)
            {
                return(false);
            }

            // Find specified tile:
            SquareIndex selectedSquare = Tiles[tileId];

            // Calculate required movement from current square
            // to the empty square:
            MoveVector movement = SquareIndex.Subtract(EmptySquare, selectedSquare);

            // See if movement is an orthogonal step:
            foreach (MoveVector orthogonalStep in MoveVector.OrthogonalSteps)
            {
                if (movement == orthogonalStep)
                {
                    ExchangeTiles(selectedSquare, EmptySquare);
                    return(true);
                }
            }

            // Can't move the tile from the specified square
            // to the empty square in a single orthogonal step:
            return(false);
        }
        protected override void Movement()
        {
            MoveVector = Route.GetMoveVector();
            if (!_triggerUsed && _takeItemTrigger != null && MoveVector.Length < 1)
            {
                _takeItemTrigger.IsActive = true;
                _waitTrigger = true;
                _takeItemTrigger.TriggerEvent += OnTakeItemTrigger;
                IsMove = false;
            }

            if (_changeSceneTrigger != null && MoveVector.Length < 1)
            {
                _changeSceneTrigger.IsActive = true;
            }

            if (MoveVector.Length == 0)
            {
                IsMove = false;
            }
            ScaleTransform.ScaleX = MoveVector.X > 0 ? 1d : -1d;
            if (MoveVector.Length > 0)
            {
                MoveVector.Normalize();
            }
            SceneObject.PositionPoint += (MoveVector / 1000) * Speed;
        }
예제 #3
0
    // Function to move the character.
    void ProcessMotion()
    {
        // Transform MoveVector to World Space.
        MoveVector = transform.TransformDirection(MoveVector);

        // Normalise MoveVector if Magnitude > 1
        if (MoveVector.magnitude > 1)
        {
            MoveVector.Normalize();
        }

        // Apply sliding if applicable.
        ApplySlide();

        // Multiply MoveVector by MoveSpeed.
        MoveVector *= MoveSpeed();

        // Reapply vertical velocity to the player.
        MoveVector = new Vector3(MoveVector.x, VerticalVelocity, MoveVector.z);

        // Apply Gravity.
        ApplyGravity();

        // Rotate the character if it's moving diagonally.
//		RotateCharacter ();
        // Move the character in WorldSpace.
        TP_Controller.characterController.Move(MoveVector * Time.deltaTime);
    }
예제 #4
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
        public bool CanMove(Move move)
        {
            bool fCanMove = false;

            SquareIndex selectedSquare = this.EmptySquare.Plus(MoveVector.OrthogonalSteps[(int)move]);
            int         tileId         = this[selectedSquare];

            if (SquareIsOnTheBoard(selectedSquare))
            {
                // Can't move the "empty" tile:
                if (tileId != 0)
                {
                    // Find specified tile:
                    SquareIndex currentSquare = Tiles[tileId];

                    // Calculate required movement from current square
                    // to the empty square:
                    MoveVector movement = SquareIndex.Subtract(EmptySquare, currentSquare);

                    // See if movement is an orthogonal step:
                    foreach (MoveVector orthogonalStep in MoveVector.OrthogonalSteps)
                    {
                        if (movement == orthogonalStep)
                        {
                            fCanMove = true;
                            break;
                        }
                    }
                }
            }

            return(fCanMove);
        }
        protected virtual void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                TriggerJump();
            }

            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D))
            {
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    Sprint = true;
                }
                else
                {
                    Sprint = false;
                }

                RotationOffset = 0f;
                if (Input.GetKey(KeyCode.A))
                {
                    RotationOffset = -90;
                }
                if (Input.GetKey(KeyCode.D))
                {
                    RotationOffset = 90;
                }
                if (Input.GetKey(KeyCode.S))
                {
                    RotationOffset = 180;
                }

                MoveVector = Vector3.forward;
            }
            else
            {
                Sprint     = false;
                MoveVector = Vector3.zero;
            }

            if (Input.GetKey(KeyCode.X))
            {
                MoveVector -= Vector3.forward;
            }
            if (Input.GetKey(KeyCode.Q))
            {
                MoveVector += Vector3.left;
            }
            if (Input.GetKey(KeyCode.E))
            {
                MoveVector += Vector3.right;
            }

            MoveVector.Normalize();

            controller.Sprint         = Sprint;
            controller.MoveVector     = MoveVector;
            controller.RotationOffset = RotationOffset;
        }
예제 #6
0
 public Snake(List <Point> points, MoveVector vector)
 {
     body    = points;
     vectors = new List <MoveVector>();
     for (int i = 0; i < 3; i++)
     {
         vectors.Add(vector);
     }
 }
예제 #7
0
        // конструктор з параметрами
        public UserTank()
        {
            coordinate.Row     = rowStartPosition;
            coordinate.Column  = columnStartPosition;
            previousCoordinate = coordinate;

            CurrentMoveVector = MoveVector.up;
            IsAlive           = true;
            IsJustCreate      = true;
            Look = 'W';
        }
예제 #8
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
        /// <summary>
        /// Place tiles on board such that resulting configuration is solvable
        /// and that the number of moves required to reach the solution is
        /// proportional to the specified "entropy" value:
        /// </summary>

        public void NewGame(int entropy)
        {
            if (entropy <= 0 || entropy > MaxEntropy)
            {
                throw new ArgumentOutOfRangeException("entropy");
            }

            // Place tiles in solved positions:
            Reset();

            // Randomize the tile positions by "moving" the empty square
            // about the board without retracing steps:

            Random randGen = new Random();

            MoveVector lastMove = MoveVector.None;

            MoveVector[] possibleMoves = new MoveVector[MoveVector.OrthogonalSteps.Length];

            for (int e = entropy; e != 0; --e)
            {
                // Find all possible moves from current square that are single
                // orthogonal steps that lead to on-board squares and that do
                // not retrace the last move:

                int maxPossibleMoves = 0;

                for (int stepIdx = 0; stepIdx < possibleMoves.Length; ++stepIdx)
                {
                    MoveVector possibleMove = MoveVector.OrthogonalSteps[stepIdx];

                    if (!SquareIsOnTheBoard(EmptySquare.Plus(possibleMove)) ||
                        possibleMove.IsInverse(lastMove))
                    {
                        continue;
                    }

                    possibleMoves[maxPossibleMoves++] = possibleMove;
                }

                // Select a possible move at random and move the empty square:
                MoveVector randomMove =
                    possibleMoves[randGen.Next(0, maxPossibleMoves)];

                ExchangeTiles(EmptySquare.Plus(randomMove), EmptySquare);

                lastMove = randomMove;
            }
        }
예제 #9
0
        // конструктор з параметрами
        public Enemy(int row, int column)
        {
            // встановлюємо координати
            coordinate.Row     = row;
            coordinate.Column  = column;
            previousCoordinate = coordinate;

            // задаємо напрямок руху - вниз
            CurrentMoveVector = MoveVector.down;
            // "живий"
            IsAlive = true;
            // щойно створений
            IsJustCreate = true;
            //вигляд на карті
            Look = 'U';
        }
예제 #10
0
 /// <summary>
 /// Move snake
 /// </summary>
 /// <param name="vector">Vector of move</param>
 public void Move(MoveVector vector)
 {
     try
     {
         for (int i = vectors.Count - 1; i > 0; i--)
         {
             body[i].Move(vectors[i - 1]);
             vectors[i] = vectors[i - 1];
         }
         body[0].Move(vector);
         vectors[0] = vector;
     }
     catch (ArgumentOutOfRangeException)
     {
         return;
     }
 }
예제 #11
0
 // конструктор з параметрами
 public Bullet(int row, int column, MoveVector vector, char look)
 {
     // встановлення координат кулі
     coordinate.Row    = row;
     coordinate.Column = column;
     // у точці створення кулі попередні координати і поточні координати збігаються
     previousCoordinate = coordinate;
     // задаємо напрям руху кулі
     CurrentMoveVector = vector;
     // куля "жива"
     IsAlive = true;
     // куля щойно створена
     IsJustCreate = true;
     // вигляд кулі
     Look = look;
     // наносимо кулю на карту
     OverwritingMap();
 }
예제 #12
0
    /// <summary>
    /// Creates a new MoveVector based on the specified input text.
    /// </summary>
    /// <param name="input">The input text to get a match for. For example, "a + b".</param>
    /// <returns>Returns the new MoveVector, or null if a no matches were found for the specified input.</returns>
    public static MoveVector Create(string input)
    {
        const string pattern = @"^(?<vector1>\w+)\s*\+\s*(?<vector2>\w+)$";

        Regex           regex   = new Regex(pattern);
        MatchCollection matches = regex.Matches(input);

        if (matches.Count == 0)
        {
            return(null);
        }

        MoveVector moveVector = new MoveVector();

        moveVector.vector1 = RegexHelper.GetValue <string>(matches, "vector1");
        moveVector.vector2 = RegexHelper.GetValue <string>(matches, "vector2");
        return(moveVector);
    }
예제 #13
0
        public override Topic GetNextNode(Topic from, MoveVector vector)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from");
            }

            switch (Vector)
            {
            case MindMapLayoutType.OrganizationUp:
                return(GetNextNodeUp(from, vector));

            case MindMapLayoutType.OrganizationDown:
                return(GetNextNodeDown(from, vector));

            default:
                throw new Exception("Invalid Layout Vector");
            }
        }
예제 #14
0
        //public override void AdjustLineRect(TopicLine line, Topic fromTopic, ref Rectangle rectFrom, ref Rectangle rectTo)
        //{
        //    base.AdjustLineRect(line, fromTopic, ref rectFrom, ref rectTo);

        //    if (line.Target != null && !line.Target.Children.IsEmpty)
        //    {
        //        int foldBtnSize = line.Target.FoldingButton.Width;
        //        switch (line.EndSide)
        //        {
        //            case Vector4.Left:
        //                rectTo.X -= foldBtnSize;
        //                rectTo.Width += foldBtnSize;
        //                break;
        //            case Vector4.Right:
        //                rectTo.Width += foldBtnSize;
        //                break;
        //        }
        //    }
        //}

        public override Topic GetNextNode(Topic from, MoveVector vector)
        {
            if (from == null)
            {
                throw new ArgumentNullException("from");
            }

            switch (Vector)
            {
            case MindMapLayoutType.TreeLeft:
                return(GetNextNodeLeft(from, vector));

            case MindMapLayoutType.TreeRight:
                return(GetNextNodeRight(from, vector));

            default:
                throw new Exception("Invalid Layout Vector");
            }
        }
예제 #15
0
        Topic GetNextNodeRight(Topic from, MoveVector vector)
        {
            switch (vector)
            {
            case MoveVector.Left:
                return((from.ParentTopic != null) ? from.ParentTopic : null);

            case MoveVector.Right:
                return((from.HasChildren) ? from.Children[0] : null);

            case MoveVector.Up:
                return(from.GetSibling(false, false, true));

            case MoveVector.Down:
                return(from.GetSibling(true, false, true));
            }

            return(null);
        }
예제 #16
0
        void SelectNextTopic(MoveVector vector)
        {
            Topic topic = SelectedTopic;

            if (topic == null)
            {
                return;
            }

            if (topic != null && ChartLayouter != null)
            {
                Topic next = ChartLayouter.GetNextNode(topic, vector);

                if (next != null)
                {
                    //SelectTopic(next, true);
                    Select(next, true);
                }
            }
        }
예제 #17
0
        public void Move(MoveVector vector)
        {
            switch (vector)
            {
            case MoveVector.BOTTOM:
                y++;
                break;

            case MoveVector.TOP:
                y--;
                break;

            case MoveVector.LEFT:
                x--;
                break;

            case MoveVector.RIGHT:
                x++;
                break;
            }
        }
예제 #18
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
            /// <summary>
            /// Produce vector difference of two moves.
            /// </summary>

            public static MoveVector Subtract(MoveVector a, MoveVector b)
            {
                return(new MoveVector(a.DeltaRowValue - b.DeltaRowValue,
                                      a.DeltaColValue - b.DeltaColValue));
            }
예제 #19
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
            /// <summary>
            /// Two moves are inverse if their displacements sum to zero.
            /// </summary>

            public bool IsInverse(MoveVector other)
            {
                return((this + other) == MoveVector.None);
            }
예제 #20
0
        // один рух(крок)
        public void Move()
        {
            // перевіряємо чи ще "живий"
            CheckIsAlive();
            // якщо "мертвий" виходимо
            if (IsAlive == false)
            {
                return;
            }
            // перезаписуємо попередні координати
            previousCoordinate = coordinate;
            // для вибору напрямку руху
            MoveVector tryMove;
            // створюємо лічильник, щоб не зациклився
            int counterForLoop = 0;

            while (counterForLoop != 10)
            {
                // якщо є можливість танк рухається в одному напрямку
                if (counterForLoop == 0)
                {
                    tryMove = CurrentMoveVector;
                }
                // якщо нема можливості рухатися міняємо напрямок
                else
                {
                    tryMove           = (MoveVector)rand.Next(4);
                    CurrentMoveVector = tryMove;
                }
                // збільшуємо лічильник
                ++counterForLoop;

                // перевіряємо можливості руху
                if (tryMove == MoveVector.up && Game.map[coordinate.Row - 1, coordinate.Column] == ' ')
                {
                    --coordinate.Row;
                    break;
                }
                else if (tryMove == MoveVector.down && Game.map[coordinate.Row + 1, coordinate.Column] == ' ')
                {
                    ++coordinate.Row;
                    break;
                }
                else if (tryMove == MoveVector.left && Game.map[coordinate.Row, coordinate.Column - 1] == ' ')
                {
                    --coordinate.Column;
                    break;
                }
                else if (tryMove == MoveVector.right && Game.map[coordinate.Row, coordinate.Column + 1] == ' ')
                {
                    ++coordinate.Column;
                    break;
                }
                // якщо натикається на кулю юзера "вмирає"
                else if (tryMove == MoveVector.up && Game.map[coordinate.Row - 1, coordinate.Column] == '+')
                {
                    IsAlive = false;
                    --coordinate.Row;
                    break;
                }
                else if (tryMove == MoveVector.down && Game.map[coordinate.Row + 1, coordinate.Column] == '+')
                {
                    IsAlive = false;
                    ++coordinate.Row;
                    break;
                }
                else if (tryMove == MoveVector.left && Game.map[coordinate.Row, coordinate.Column - 1] == '+')
                {
                    IsAlive = false;
                    --coordinate.Column;
                    break;
                }
                else if (tryMove == MoveVector.right && Game.map[coordinate.Row, coordinate.Column + 1] == '+')
                {
                    IsAlive = false;
                    ++coordinate.Column;
                    break;
                }
            }
            // перезапис карти
            OverwritingMap();
        }
        public override void Update2(GameTime gameTime)
        {
            base.Update2(gameTime);
            Position.set(Vector2.Clamp(Position.get(), Parent2DScene.MinBoundary.get(), Parent2DScene.MaxBoundary.get()));

            if (CrystalWall.SortedWalls.ContainsKey(WaveManager.ActiveTeam))
            {
                foreach (CrystalWall n in CrystalWall.SortedWalls[WaveManager.ActiveTeam])
                {
                    if (!n.Dead)
                    {
                        foreach (CrystalWallConnection n2 in n.ConnectedWalls)
                        {
                            if (!n2.wall.Dead)
                            {
                                float MoveAmount = (Size.X() + n.getSize().X * 0.75f) / 2 - Logic.DistanceLineSegmentToPoint(n.Position.get(), n2.wall.Position.get(), Position.get());

                                if (MoveAmount > 0)
                                {
                                    Vector2 MoveVector;

                                    if (!n2.LineIsVertical)
                                    {
                                        if (n2.LineSlope == 0)
                                        {
                                            MoveVector = new Vector2(0, -1);
                                            if (Position.Y() > n2.LineSlope * Position.X() + n2.LineIntercept)
                                            {
                                                MoveAmount = -MoveAmount;
                                            }
                                        }
                                        else
                                        {
                                            MoveVector = new Vector2(1, -1 / n2.LineSlope);
                                            if (!(Position.Y() > n2.LineSlope * Position.X() + n2.LineIntercept ^ n2.LineSlope > 0))
                                            {
                                                MoveAmount = -MoveAmount;
                                            }
                                        }

                                        MoveVector.Normalize();
                                    }
                                    else
                                    {
                                        MoveVector = new Vector2(Position.X() > n.Position.X() ? 1 : -1, 0);
                                    }

                                    Position.set(Position.get() + MoveVector * MoveAmount);


                                    float d1 = Vector2.Distance(Position.get(), n.Position.get());
                                    float d2 = 0;
                                    if (!PathFindingManager.CollisionLine(Position.get(), n.Position.get()))
                                    {
                                        Vector2.Distance(Position.get(), n2.wall.Position.get());
                                    }

                                    CurrentAttackTarget = d1 > d2 ? n : n2.wall;
                                    AngerTime           = MaxAngerTime;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #22
0
        // функціонал танка або рух або постріл
        public void MoveOrShoot()
        {
            if (Game.health <= 0)
            {
                Game.isGame = false;
                return;
            }
            previousCoordinate = coordinate;

            char moveOrShoot;

            using (var temp = ReadCharTimeout(timeDelay))
            {
                moveOrShoot = temp.Result;
                temp.Dispose();
            }
            // на випадок включеного Caps Lock
            switch (moveOrShoot)
            {
            case 'W':
                moveOrShoot = 'w';
                break;

            case 'S':
                moveOrShoot = 's';
                break;

            case 'A':
                moveOrShoot = 'a';
                break;

            case 'D':
                moveOrShoot = 'd';
                break;

            default:
                break;
            }

            switch (moveOrShoot)
            {
            case 'w':
                CurrentMoveVector = MoveVector.up;
                break;

            case 's':
                CurrentMoveVector = MoveVector.down;
                break;

            case 'a':
                CurrentMoveVector = MoveVector.left;
                break;

            case 'd':
                CurrentMoveVector = MoveVector.right;
                break;

            default:
                break;
            }

            if (moveOrShoot == 'w' && Game.map[coordinate.Row - 1, coordinate.Column] == ' ')
            {
                --coordinate.Row;
            }
            else if (moveOrShoot == 's' && Game.map[coordinate.Row + 1, coordinate.Column] == ' ')
            {
                ++coordinate.Row;
            }
            else if (moveOrShoot == 'a' && Game.map[coordinate.Row, coordinate.Column - 1] == ' ')
            {
                --coordinate.Column;
            }
            else if (moveOrShoot == 'd' && Game.map[coordinate.Row, coordinate.Column + 1] == ' ')
            {
                ++coordinate.Column;
            }
            else if (moveOrShoot == 'w' && Game.map[coordinate.Row - 1, coordinate.Column] == '*')
            {
                Game.health -= 20;
                --coordinate.Row;
            }
            else if (moveOrShoot == 's' && Game.map[coordinate.Row + 1, coordinate.Column] == '*')
            {
                Game.health -= 20;
                ++coordinate.Row;
            }
            else if (moveOrShoot == 'a' && Game.map[coordinate.Row, coordinate.Column - 1] == '*')
            {
                Game.health -= 20;
                --coordinate.Column;
            }
            else if (moveOrShoot == 'd' && Game.map[coordinate.Row, coordinate.Column + 1] == '*')
            {
                Game.health -= 20;
                ++coordinate.Column;
            }
            else if (moveOrShoot == ' ')
            {
                Shoot();
            }
            else if (moveOrShoot == 'q' || moveOrShoot == 'Q')
            {
                Game.isGame = false;
            }

            OverwritingMap();
        }
예제 #23
0
        static void Main(string[] args)
        {
            try
            {
                if (args[0] == "results")
                {
                    using (TextReader reader = new StreamReader(new FileInfo("Resources/Results.txt").OpenRead()))
                    {
                        Console.Write(reader.ReadToEnd());
                    }
                    return;
                }
                else if (args[0] == "help" || args[0] == "-help" || args[0] == "--help")
                {
                    Process.Start("help.cmd");
                }
                else
                {
                    throw new Exception("Unknown argument");
                }
            }
            catch (Exception)
            {
                Console.Clear();                                                                              //clear console before game
                Console.Title = $"Console Snake v {Assembly.GetEntryAssembly().GetName().Version} by snaulX"; //set title
input:
                Console.Write("Input width (min 5, norm 35, very big 50) and height (min 6, norm 15, very big 30) of field:");
                try
                {
                    w     = int.Parse(Console.ReadLine()); //set width
                    h     = int.Parse(Console.ReadLine()); //set height
                    field = new char[w, h];                //create empty field
                    Console.Write("Input FPS (easy 4, medium 6, hard 9 (for 35x15)):");
                    fps = int.Parse(Console.ReadLine());   //set fps (frames per second)
                }
                catch (FormatException)
                {
                    Console.WriteLine("Non-right input. Please input again.");
                    goto input;
                }
                snake = new Snake(new List <Point>
                {
                    new Point(w / 2, h / 2 + 1),
                    new Point(w / 2, h / 2),
                    new Point(w / 2, h / 2 - 1)
                },
                                  MoveVector.BOTTOM);                                 //create snake and place by center
                Random random = new Random();
                food_place = new Point(random.Next(1, w - 2), random.Next(1, h - 2)); //generate place of food
                Thread createField = new Thread(new ThreadStart(CreateField));
                Console.WriteLine("Loading... (Create field)");
                createField.Start(); //create field
                createField.Join();  //wait when field creating
                Console.Title = $"Console Snake v {Assembly.GetEntryAssembly().GetName().Version} by snaulX";
                Console.WriteLine("Field was creating. Press any key to start");
                Console.ReadKey();
                game = true;
                TimerCallback tm    = new TimerCallback(RefreshField);    //make thread with refresh field
                Timer         timer = new Timer(tm, null, 0, 1000 / fps); //make Timer
                Console.CursorVisible = false;                            //off cursor

                while (game)                                              //main cycle
                {
                    ConsoleKey key = Console.ReadKey().Key;
                    if (key == ConsoleKey.UpArrow)
                    {
                        vector = MoveVector.TOP;                            //change vector of move to top
                    }
                    else if (key == ConsoleKey.DownArrow)
                    {
                        vector = MoveVector.BOTTOM;                                   //change vector of move to bottom
                    }
                    else if (key == ConsoleKey.RightArrow)
                    {
                        vector = MoveVector.RIGHT;                                    //change vector of move to right
                    }
                    else if (key == ConsoleKey.LeftArrow)
                    {
                        vector = MoveVector.LEFT;                                   //change vector of move to left
                    }
                    else if (key == ConsoleKey.Enter)
                    {
                        game = false;                               //break the game
                    }
                }

                timer.Change(Timeout.Infinite, 1000 / fps); //stop refresh field
                Console.CursorVisible = true;               //on cursor
                GameOver();
            }
        }
예제 #24
0
파일: Mobile.cs 프로젝트: karliky/wowwow
		public Mobile() : base( Server.Object.GUID++ )
		{
			if ( this is Corps )
				this.Guid += 0xE000A00000000000;
			if ( this is BaseCreature )
			{				
				localTime = DateTime.Now.Ticks;
				moveVector = new MoveVector( this, X, Y, Z );
				aiType = AITypes.Beast;
				this.Guid += 0xF000A00000000000;
				movementTimer = new MovementTimer( this );
			}
			else
				items = new Item[ 104 ];
		}
예제 #25
0
        //public override void AdjustLineRect(TopicLine line, Topic fromTopic, ref Rectangle rectFrom, ref Rectangle rectTo)
        //{
        //    base.AdjustLineRect(line, fromTopic, ref rectFrom, ref rectTo);

        //    if (fromTopic != null && !fromTopic.IsRoot)
        //    {
        //        int foldBtnSize = line.Target.FoldingButton.Width;
        //        switch (line.BeginSide)
        //        {
        //            case Vector4.Left:
        //                rectFrom.X -= foldBtnSize;
        //                rectFrom.Width += foldBtnSize;
        //                break;
        //            case Vector4.Right:
        //                rectFrom.Width += foldBtnSize;
        //                break;
        //            case Vector4.Top:
        //                rectFrom.Y -= foldBtnSize;
        //                rectFrom.Height += foldBtnSize;
        //                break;
        //            case Vector4.Bottom:
        //                rectFrom.Height += foldBtnSize;
        //                break;
        //        }
        //    }

        //    if (line.Target != null && line.Target.Style.Shape == Core.Styles.TopicShape.BaseLine)
        //    {
        //        rectTo.Y = rectTo.Bottom;
        //        rectTo.Height = 0;
        //    }
        //}

        public override Topic GetNextNode(Topic from, MoveVector vector)
        {
            Topic next = null;

            if (from.IsRoot)
            {
                switch (vector)
                {
                case MoveVector.Left:
                case MoveVector.Up:
                    foreach (Topic subTopic in from.Children)
                    {
                        if (subTopic.Vector == Vector4.Left)
                        {
                            next = subTopic;
                            break;
                        }
                    }
                    break;

                case MoveVector.Right:
                case MoveVector.Down:
                    foreach (Topic subTopic in from.Children)
                    {
                        if (subTopic.Vector == Vector4.Right)
                        {
                            next = subTopic;
                            break;
                        }
                    }
                    break;
                }
            }
            else
            {
                switch (vector)
                {
                case MoveVector.Left:
                    if (from.Vector == Vector4.Left)
                    {
                        next = from.HasChildren ? from.Children[0] : null;
                    }
                    else
                    {
                        next = from.ParentTopic;
                    }
                    break;

                case MoveVector.Right:
                    if (from.Vector == Vector4.Right)
                    {
                        next = from.HasChildren ? from.Children[0] : null;
                    }
                    else
                    {
                        next = from.ParentTopic;
                    }
                    break;

                case MoveVector.Up:
                    next = from.GetSibling(false, false, true);
                    break;

                case MoveVector.Down:
                    next = from.GetSibling(true, false, true);
                    break;
                }
            }

            return(next);
        }
예제 #26
0
    private void ExecuteCommandLine(string text)
    {
        SuperVector superVector = SuperVector.Create(text);

        if (superVector != null)
        {
            CreateOrUpdateSuperVector(superVector);
            return;
        }

        SetColor setColor = SetColor.Create(text);

        if (setColor != null)
        {
            ChangeVectorColor(setColor.vectorName, setColor.hexCode);
            return;
        }

        SetNamedColor setNamedColor = SetNamedColor.Create(text);

        if (setNamedColor != null)
        {
            string hexCode;
            if (colorLookups.ContainsKey(setNamedColor.colorName))
            {
                hexCode = colorLookups[setNamedColor.colorName];
                ChangeVectorColor(setNamedColor.vectorName, hexCode);
            }
            else
            {
                Debug.LogError($"\"{setNamedColor.colorName}\" needs to be defined first!!!");
            }
            return;
        }

        DefineColor defineColor = DefineColor.Create(text);

        if (defineColor != null)
        {
            DefineColorName(defineColor.colorName, defineColor.hexCode);
            return;
        }

        MoveVector moveVector = MoveVector.Create(text);

        if (moveVector != null)
        {
            MoveVectorTo(moveVector.vector1, moveVector.vector2);
            return;
        }

        SumVectors sumVectors = SumVectors.Create(text);

        if (sumVectors != null)
        {
            SumAllVectors(sumVectors.newVectorName, sumVectors.vector1, sumVectors.vector2, sumVectors.vector3, sumVectors.vector4, sumVectors.vector5);
            return;
        }

        NegativeVector negativeVector = NegativeVector.Create(text);

        if (negativeVector != null)
        {
            MakeVectorNegative(negativeVector.vectorName);
            return;
        }

        AssignNegativeVector assignNegativeVector = AssignNegativeVector.Create(text);

        if (assignNegativeVector != null)
        {
            CreateNegativeVector(assignNegativeVector.existingVectorName, assignNegativeVector.newVectorName);
            return;
        }

        VectorCommand vectorCommand = VectorCommand.Create(text);

        if (vectorCommand != null)
        {
            HandleVectorCommand(vectorCommand.command, vectorCommand.vectorName);
            return;
        }
        OffsetVector offsetVector = OffsetVector.Create(text);

        if (offsetVector != null)
        {
            OffsetVectorBy(offsetVector.vectorName, offsetVector.offsetX, offsetVector.offsetY, offsetVector.offsetZ);
            return;
        }
    }
예제 #27
0
 public void Add(Point point, MoveVector vector)
 {
     body.Add(point);     //add point to snake
     vectors.Add(vector); //add vector of added point
 }
        public void TestCollision(GameTime gameTime)
        {
            foreach (Basic2DObject o in Parent2DScene.quadGrids.First.Value.Enumerate(QuadGridXMin, QuadGridYMin, QuadGridXMax, QuadGridYMax))
            {
                if (o != this)
                {
                    if (o.GetType().IsSubclassOf(typeof(BasicShipGameObject)))
                    {
                        if (Vector2.Distance(Position.get(), o.Position.get()) < (Size.X() + o.Size.X()) / 2)
                        {
                            BasicShipGameObject s = (BasicShipGameObject)o;
                            Collide(gameTime, s.ReturnCollision());
                            if (Dead)
                            {
                                return;
                            }
                        }
                    }
                    else
                    {
                        WallNode n = (WallNode)o;

                        if (Vector2.Distance(Position.get(), o.Position.get()) < (Size.X() + o.Size.X()) / 2)
                        {
                            float MoveAmount = (Size.X() + o.getSize().X) / 2 - Vector2.Distance(o.Position.get(), Position.get());

                            if (Vector2.Distance(o.Position.get(), Position.get()) > 0.1f)
                            {
                                Position.set(Position.get() + Vector2.Normalize(Position.get() - o.Position.get()) * MoveAmount);
                            }
                            else
                            {
                                Position.set(Position.get() + Vector2.One * MoveAmount * 2);
                            }
                        }
                        if (n.wallConnector != null)
                        {
                            float MoveAmount = (Size.X() + o.getSize().X * 0.75f) / 2 - Logic.DistanceLineSegmentToPoint(n.Position.get(), n.wallConnector.PositionNext, Position.get());

                            if (MoveAmount > 0)
                            {
                                Vector2 MoveVector;
                                if (!n.wallConnector.LineIsVertical)
                                {
                                    if (n.wallConnector.LineSlope == 0)
                                    {
                                        MoveVector = new Vector2(0, -1);
                                        if (Position.Y() > n.wallConnector.LineSlope * Position.X() + n.wallConnector.LineIntercept)
                                        {
                                            MoveAmount = -MoveAmount;
                                        }
                                    }
                                    else
                                    {
                                        MoveVector = new Vector2(1, -1 / n.wallConnector.LineSlope);
                                        if (!(Position.Y() > n.wallConnector.LineSlope * Position.X() + n.wallConnector.LineIntercept ^ n.wallConnector.LineSlope > 0))
                                        {
                                            MoveAmount = -MoveAmount;
                                        }
                                    }

                                    MoveVector.Normalize();
                                }
                                else
                                {
                                    MoveVector = new Vector2(Position.X() > n.Position.X() ? 1 : -1, 0);
                                }

                                Position.set(Position.get() + MoveVector * MoveAmount);
                            }
                        }
                    }
                }
            }
        }
예제 #29
0
파일: Mobile.cs 프로젝트: karliky/wowwow
		public void ForcePosition( float x, float y, float z, float orientation )
		{
			X = x;
			Y = y;
			Z = z;
			Orientation = orientation;
			this.moveVector = new Server.Mobile.MoveVector(this,x,y,z,x-1,y-1,z-1);
			this.UpdateXYZ();
			
		}
예제 #30
0
파일: Mobile.cs 프로젝트: karliky/wowwow
		public override void Deserialize( GenericReader gr )
		{
			int version = gr.ReadInt();
			//	id = gr.ReadInt();
			UInt64 g = gr.ReadInt64();				
			SpawnerLink = null;//(BaseSpawner)MobileList.TempSpawner[ g ];

			int esu = 0;
			int ech = 0;
			
			esu = gr.ReadInt();
			ech = gr.ReadInt();
			name = gr.ReadString();
			if ( version > 0 )
				classe = (Classes)gr.ReadInt();
			talent = gr.ReadInt();
			Level = gr.ReadInt();
			model = gr.ReadInt();
			exp = (uint)gr.ReadInt();
			guildId = (uint)gr.ReadInt();
			petLevel = (uint)gr.ReadInt();
			petCreatureFamily = (uint)gr.ReadInt();
			petDisplayId = (uint)gr.ReadInt();
			speed  = gr.ReadFloat();
			size = gr.ReadFloat();					
			faction = (Factions)gr.ReadInt();
			str = gr.ReadInt();
			agility = gr.ReadInt();
			stamina = gr.ReadInt();
			iq = gr.ReadInt();
			spirit = gr.ReadInt();
			baseStr = gr.ReadFloat();
			baseAgility = gr.ReadFloat();
			baseStamina = gr.ReadFloat();
			baseIq = gr.ReadFloat();
			baseSpirit = gr.ReadFloat();
			walkSpeed = gr.ReadFloat();
			if ( walkSpeed == 0 )
				walkSpeed = 4.7777f;
			runSpeed = gr.ReadFloat();
			if ( runSpeed == 0 )
				runSpeed = 7f;
			swimSpeed = gr.ReadFloat();
			if ( swimSpeed == 0 )
				swimSpeed = 4.72f;
			swimBackSpeed = gr.ReadFloat();
			if ( swimBackSpeed == 0 )
				swimBackSpeed = 2.5f;
			hitPoints = gr.ReadInt();
			mana = gr.ReadInt();
			energy = gr.ReadInt();
			rage = gr.ReadInt();
			focus = gr.ReadInt();
			baseHitPoints = gr.ReadInt();
			baseMana = gr.ReadInt();
			baseEnergy = gr.ReadInt();
			baseRage = gr.ReadInt();
			baseFocus = gr.ReadInt();

			block = gr.ReadInt();
			armor = gr.ReadInt();
			resistHoly = gr.ReadInt();
			resistFire = gr.ReadInt();
			resistNature = gr.ReadInt();
			resistFrost = gr.ReadInt();
			resistShadow = gr.ReadInt();
			resistArcane = gr.ReadInt();

			int nSkills = gr.ReadInt();
			for(int t = 0;t < nSkills;t++ )
			{
				ushort skill = (ushort)gr.ReadShort();
				allSkills[ skill ] = Skill.Deserialize( gr, t );
			}

			int nSpells = gr.ReadInt();
			for(int t = 0;t < nSpells;t++ )
			{
				ushort spell = (ushort)gr.ReadShort();
				byte place = gr.ReadByte();
				knownAbilities[ (int)spell ] = (int)place;
				/*	if ( TalentDescription.IsTalent( (int)spell ) )
					{
						if ( onInitialiseTalent[ (int)spell ] != null )
						{
							( onInitialiseTalent[ (int)spell ] as TalentHandlers.TalentHandler )( Abilities.abilities[ (int)spell ], this );
						}
					//	this.AddPermanentAura( Abilities.abilities[ (int)spell ], new Aura() );
					//	permanentAura.Add( spell );
					}*/
			}

			int nTalentList = gr.ReadInt();
			for(int t = 0;t < nTalentList;t++ )
			{
				int spell = gr.ReadInt();
				int lev = gr.ReadInt();
				talentList[ spell ] = (int)lev;
			}
			
			if ( gr.ReadInt() != 0 )
				freeze = true;
			int nit = gr.ReadInt();
			for(int t = 0;t < nit;t++ )
			{
				int n = gr.ReadInt();
				if ( n == 1 )
					items[ t ] = Item.Load( gr );
				else
					items[ t ] = null;
			}
			if ( gr.ReadInt() != 0 )
				movementChange = true;

			manaType = gr.ReadInt();
			professions = gr.ReadByte();
			standState = (StandStates)gr.ReadInt();
			base.Deserialize( gr );
			moveVector = new MoveVector( this, X, Y, Z );
			//	if ( this is BaseSpawner )
			//		MobileList.TempSpawner[ Guid ] = this;
			if ( esu != 0 )
				MobileList.TempSummon[ Guid ] = this;
			if ( ech != 0 )
				MobileList.TempSummon[ Guid ] = this;
			//movementTimer = new MovementTimer( this );
		}
예제 #31
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
            /// <summary>
            /// Produce vector sum of two moves.
            /// </summary>

            public static MoveVector Add(MoveVector a, MoveVector b)
            {
                return(new MoveVector(a.DeltaRowValue + b.DeltaRowValue,
                                      a.DeltaColValue + b.DeltaColValue));
            }
예제 #32
0
파일: Layouter.cs 프로젝트: yfarm/Blumind
 public abstract Topic GetNextNode(Topic from, MoveVector vector);
예제 #33
0
파일: puzzle.cs 프로젝트: imiyu/DiscUsage
            /// <summary>
            /// Apply movement to a square index to get a new square index.
            /// </summary>

            public SquareIndex Plus(MoveVector move)
            {
                return(new
                       SquareIndex(this.RowValue + move.DeltaRow,
                                   this.ColValue + move.DeltaCol));
            }