예제 #1
0
 public void ToggleDirection(MoveDirections direction, bool value)
 {
     if (value && !Player.ActiveMoveDirections.Contains(direction))
         Player.ActiveMoveDirections.Add(direction);
     else if (!value)
         Player.ActiveMoveDirections.Remove(direction);
 }
예제 #2
0
        }         // Rotate(axis, angle)

        /*obs
         * /// <summary>
         * /// Rotate
         * /// </summary>
         * /// <param name="axis">Axis</param>
         * /// <param name="angle">Angle</param>
         * private void Rotate(Vector3 axis, float angle)
         * {
         *      quaternion *= Quaternion.CreateFromAxisAngle(axis, angle);
         * } // Rotate(axis, angle)
         */
        #endregion

        #region Translate method
        /// <summary>
        /// Translate into x, y or z axis with a specfic amount.
        /// </summary>
        /// <param name="amount">Amount</param>
        /// <param name="direction">Direction</param>
        private void Translate(float amount, MoveDirections direction)
        {
            Vector3 dir =
                direction == MoveDirections.X ? XAxis :
                direction == MoveDirections.Y ? YAxis : ZAxis;

            pos += dir * amount;
        }         // Translate(amount, direction)
예제 #3
0
    public void AddMovementDirection(MoveDirections newValue)
    {
        var index     = GameComponentsLookup.MovementDirection;
        var component = (MovementDirectionComponent)CreateComponent(index, typeof(MovementDirectionComponent));

        component.value = newValue;
        AddComponent(index, component);
    }
예제 #4
0
 private void StopMotion(object param)
 {
     if (IsVariableJog && _jogInProgress)
     {
         MoveDirections direction = (param == null) ? MoveDirections.None : (MoveDirections)param;
         TelescopeManager.StopJogScope(direction);
     }
 }
예제 #5
0
 public Move(MoveFlags flags, MoveDirections direction, Square startPosition, Square movePosition, Square capturePosition, PieceType conversionType = PieceType.PieceType_NB)
 {
     Flags           = flags;
     Direction       = direction;
     StartPosition   = startPosition;
     MovePosition    = movePosition;
     CapturePosition = capturePosition;
     ConversionType  = conversionType;
 }
예제 #6
0
    public void ReplaceFire(MoveDirections newDirections, int newRange, float newTime)
    {
        var index     = GameComponentsLookup.Fire;
        var component = (FireComponent)CreateComponent(index, typeof(FireComponent));

        component.directions = newDirections;
        component.range      = newRange;
        component.time       = newTime;
        ReplaceComponent(index, component);
    }
예제 #7
0
 private void MoveObjects(IEnumerable <Keys> keys, MoveDirections currentDirection)
 {
     MoveBullet();
     MoveBonus();
     MoveRocket();
     MoveBarriers();
     MoveAmmoBox();
     MovePlayer(keys);
     MoveEnemy(currentDirection);
 }
예제 #8
0
 private void Restart()
 {
     _model            = new GameModel();
     _time             = 0;
     _currentDirection = MoveDirections.None;
     _currentKeys.Clear();
     UnpauseGame();
     BackColor = Color.MidnightBlue;
     SetAnimators();
 }
예제 #9
0
 private void ToggleDirection()
 {
     if (Direction == MoveDirections.Right)
     {
         Direction = MoveDirections.Straight;
     }
     else
     {
         Direction = MoveDirections.Right;
     }
 }
예제 #10
0
 public void ToggleDirection(MoveDirections direction, bool value)
 {
     if (value && !Player.ActiveMoveDirections.Contains(direction))
     {
         Player.ActiveMoveDirections.Add(direction);
     }
     else if (!value)
     {
         Player.ActiveMoveDirections.Remove(direction);
     }
 }
예제 #11
0
        static void PlayerMove()
        {
            switch (playerDirection)
            {
            case MoveDirections.right:
                faceSprite.Position =
                    new Vector2f(faceSprite.Position.X + 30f * deltaTime,
                                 faceSprite.Position.Y);

                if (faceSprite.Position.X + 32 >= 960)
                {
                    playerDirection = MoveDirections.left;
                }

                break;

            case MoveDirections.left:
                faceSprite.Position =
                    new Vector2f(faceSprite.Position.X - 30f * deltaTime,
                                 faceSprite.Position.Y);

                if (faceSprite.Position.X <= 320)
                {
                    playerDirection = MoveDirections.right;
                }

                break;

            case MoveDirections.up:
                faceSprite.Position =
                    new Vector2f(faceSprite.Position.X,
                                 faceSprite.Position.Y - 30f * deltaTime);

                if (faceSprite.Position.Y <= 0)
                {
                    playerDirection = MoveDirections.down;
                }

                break;

            case MoveDirections.down:
                faceSprite.Position =
                    new Vector2f(faceSprite.Position.X,
                                 faceSprite.Position.Y + 30f * deltaTime);

                if (faceSprite.Position.Y + 32 >= 640)
                {
                    playerDirection = MoveDirections.up;
                }

                break;
            }
        }
예제 #12
0
        /// <summary>
        /// </summary>
        public void StopMovement()
        {
            // This should be used to stop the interpolating and save last interpolated value of movement before teleporting
            this.RawCoordinates.X = this.Coordinates.x;
            this.RawCoordinates.Y = this.Coordinates.y;
            this.RawCoordinates.Z = this.Coordinates.z;
            this.RawHeading       = this.Heading;

            this.spinDirection   = SpinOrStrafeDirections.None;
            this.strafeDirection = SpinOrStrafeDirections.None;
            this.moveDirection   = MoveDirections.None;
        }
예제 #13
0
 public void MovePaddle(MoveDirections direction)
 {
     if (direction == MoveDirections.Left && Paddle.LeftX <= Field.LeftX)
     {
         return;
     }
     if (direction == MoveDirections.Right && Paddle.RightX >= Field.RightX)
     {
         return;
     }
     Paddle.Position = Point.Add(Paddle.Position, new Size((direction == MoveDirections.Left ? -1 : 1) * 10, 0));
 }
예제 #14
0
    public ProtoFief Move(MoveDirections directions, TextTestClient client)
    {
        ProtoTravelTo protoTravel = new ProtoTravelTo();

        protoTravel.travelVia   = new[] { directions.ToString() };
        protoTravel.characterID = "Char_158";
        client.net.Send(protoTravel);
        var reply  = GetActionReply(Actions.TravelTo, client);
        var travel = (ProtoFief)reply.Result;

        return(travel);
    }
예제 #15
0
        private void MoveItems(MoveDirections direction, int amount)
        {
            int x = 0;
            int y = 0;

            switch (direction)
            {
            case MoveDirections.N:
                x = -1 * amount;
                y = -1 * amount;
                break;

            case MoveDirections.NE:
                x = 0;
                y = -1 * amount;
                break;

            case MoveDirections.E:
                x = 1 * amount;
                y = -1 * amount;
                break;

            case MoveDirections.SE:
                x = 1 * amount;
                y = 0;
                break;

            case MoveDirections.S:
                x = 1 * amount;
                y = 1 * amount;
                break;

            case MoveDirections.SW:
                x = 0;
                y = 1 * amount;
                break;

            case MoveDirections.W:
                x = -1 * amount;
                y = 1 * amount;
                break;

            case MoveDirections.NW:
                x = -1 * amount;
                y = 0;
                break;
            }

            if (OnMoveItems != null)
            {
                OnMoveItems((short)x, (short)y);
            }
        }
예제 #16
0
 public void MoveRobot(MoveDirections direction)
 {
     if (GameController.MoveRobot(direction))
     {
         RedrawGameField();
         ShowUserInfo();
         if (GameController.GameIsOver())
         {
             Console.Clear();
             ShowGameOverInfo();
         }
     }
 }
예제 #17
0
    private void CalculateMoveDirection()
    {
        Vector2 dif            = (nextMoveToLocation - (Vector2)this.transform.position);
        float   directionAngle = (float)(Mathf.Atan2(dif.x, dif.y)) * Mathf.Rad2Deg;

        //Debug.Log((Vector2)this.transform.position + " : " + nextMoveToLocation + " : " + directionAngle);

        //NORTH
        if (directionAngle == 0f)
        {
            moveDirection = MoveDirections.North;
        }
        //NORTHEAST
        else if (directionAngle > 60f && directionAngle < 65f)
        {
            moveDirection = MoveDirections.NorthEast;
        }
        //EAST
        else if (directionAngle == 90f)
        {
            moveDirection = MoveDirections.East;
        }
        //SOUTH EAST
        else if (directionAngle > 110f && directionAngle < 120f)
        {
            moveDirection = MoveDirections.SouthEast;
        }
        //SOUTH
        else if (directionAngle == 180f)
        {
            moveDirection = MoveDirections.South;
        }
        //SOUTH WEST
        else if (directionAngle < -110f && directionAngle > -120f)
        {
            moveDirection = MoveDirections.SouthWest;
        }
        //WEST
        else if (directionAngle == -90f)
        {
            moveDirection = MoveDirections.West;
        }
        //NORTH WEST
        else if (directionAngle < -60f && directionAngle > -65f)
        {
            moveDirection = MoveDirections.NorthWest;
        }

        MoveDirectionChangHandler(moveDirection);
    }
예제 #18
0
        private void DoFixedSlew(object param)
        {
            if (!IsVariableJog)
            {
                MoveDirections direction = (param == null) ? MoveDirections.None : (MoveDirections)param;

                if (direction != MoveDirections.None)
                {
                    TelescopeManager.StartFixedSlew(direction, SelectedSlewAmount.Amount);

                    _isFixedSlewInProgress = true;
                }
            }
        }
예제 #19
0
    public ProtoFief Move(MoveDirections directions)
    {
        ProtoTravelTo protoTravel = new ProtoTravelTo();

        protoTravel.travelVia   = new[] { directions.ToString() };
        protoTravel.characterID = "Char_158";
        tclient.net.Send(protoTravel);
        var reply  = GetActionReply(Actions.TravelTo, tclient);
        var travel = (ProtoFief)reply;

        if (mf.fiefID.Equals(travel.fiefID))
        {
            return(null);
        }
        return(travel);
    }
예제 #20
0
 private void SetKeyboardActions()
 {
     KeyDown += (sender, args) =>
     {
         if (args.KeyData != Keys.Space)
         {
             return;
         }
         if (_isPaused)
         {
             UnpauseGame();
             BackColor = Color.MidnightBlue;
         }
         else
         {
             PauseGame();
             BackColor = Color.DimGray;
         }
     };
     KeyDown += (sender, args) =>
     {
         if (args.KeyData == Keys.X)
         {
             _xPressed = true;
         }
     };
     KeyUp += (sender, args) =>
     {
         if (args.KeyData == Keys.X)
         {
             _xPressed = false;
         }
     };
     KeyDown += (sender, args) => _currentKeys.Add(args.KeyData);
     KeyDown += (sender, args) => { _currentDirection = ChooseDirection(args); };
     KeyUp   += (sender, args) =>
     {
         if (_currentKeys.Contains(args.KeyData))
         {
             _currentKeys.Remove(args.KeyData);
         }
         if (ChooseDirection(args) == _currentDirection)
         {
             _currentDirection = MoveDirections.None;
         }
     };
 }
예제 #21
0
 public static void AreEqual(
     int expTurns,
     Tile expSource,
     int expHealth,
     IMineOwnership expMines,
     MoveDirections expDirections,
     int expProfit,
     PotentialPath actual)
 {
     Assert.IsNotNull(actual);
     Assert.AreEqual(expTurns, actual.Turns, "Turns, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expSource, actual.Source, "Sources, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expHealth, actual.Health, "Health, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expMines, actual.Mines, "Mines, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expDirections, actual.Directions, "Directions, {0}", actual.DebuggerDisplay);
     Assert.AreEqual(expProfit, actual.Profit, "Profit, {0}", actual.DebuggerDisplay);
     //public List<PotentialOpponent> Opponents { get; set; }
 }
예제 #22
0
 private void MoveEnemy(MoveDirections direction)
 {
     CheckEnemyCollision();
     if (Enemy == null ||
         Enemy.X - Enemy.Speed < 0 && direction == MoveDirections.Left ||
         Enemy.X + Enemy.Speed > Width - Enemy.Height && direction == MoveDirections.Right)
     {
         return;
     }
     Enemy.Move(Player);
     if (Enemy.Y <= Height)
     {
         return;
     }
     Player.KickPlayer();
     Enemy = null;
     OnCollideBarrier(new ModelEventArgs());
 }
예제 #23
0
        private void StartMove(object param)
        {
            MoveDirections direction = (MoveDirections)param;

            if (IsVariableJog)
            {
                try
                {
                    TelescopeManager.StartJogScope(direction, SelectedJogRate);
                    _jogInProgress = true;
                }
                catch (Exception xcp)
                {
                    ShowMessage("Unable to use the requested Jog rate.\r\n\r\n"
                                + xcp.Message, "Unsupported Jog Rate Selected");
                }
            }
        }
예제 #24
0
        private Vector3 DetermineTargetTransform(MoveDirections moveEvent)
        {
            if (!foundOrigin)
            {
                origin      = new Vector2(0, transform.position.y);
                foundOrigin = true;
            }

            Vector3 ret             = Vector3.zero;
            Vector3 currentPosition = transform.position;
            float   xTravel;
            float   yTravel;

            // We want to pick a random travel distance out of the legal range. That way, the agent will tend to pick
            // movements that go towards the origin
            switch (moveEvent)
            {
            case MoveDirections.MoveLeft:
                xTravel =
                    Random.Range(Mathf.Max(-MinDirectionalMovementPerMove, XMin - currentPosition.x),
                                 Mathf.Min(-MaxDirectionalMovementPerMove, -MinDirectionalMovementPerMove));
                yTravel =
                    Random.Range(Mathf.Max(-MaxDirectionalMovementPerMove, YMin - currentPosition.y),
                                 Mathf.Min(MaxDirectionalMovementPerMove, YMax - currentPosition.y));
                ret = new Vector3(currentPosition.x + xTravel, currentPosition.y + yTravel);
                break;

            case MoveDirections.MoveRight:
                xTravel =
                    Random.Range(Mathf.Max(MinDirectionalMovementPerMove, MinDirectionalMovementPerMove),
                                 Mathf.Min(MaxDirectionalMovementPerMove, XMax - currentPosition.x));
                yTravel =
                    Random.Range(Mathf.Max(-MaxDirectionalMovementPerMove, YMin - currentPosition.y),
                                 Mathf.Min(MaxDirectionalMovementPerMove, YMax - currentPosition.y));
                ret = new Vector3(currentPosition.x + xTravel, currentPosition.y + yTravel);
                break;

            default:
                Assert.IsTrue(false);
                break;
            }

            return(ret);
        }
예제 #25
0
        protected static bool movePosition(ref Square pos, MoveDirections dir)
        {
            int startRow = (int)pos >> 3;
            int startCol = (int)pos & 7;
            int dir36    = (int)dir + 36;
            int dr       = (dir36 >> 3) - 4;
            int dc       = (dir36 & 7) - 4;
            int endRow   = startRow + dr;
            int endCol   = startCol + dc;

            //Console.WriteLine(dir + "," + endRow + "," + endCol);
            if (endRow < 0 || endRow > 7 || endCol < 0 || endCol > 7)
            {
                return(false);
            }

            pos = (Square)((int)pos + (int)dir);
            return(true);
        }
예제 #26
0
    private Vector3 GetMoveVector(MoveDirections direction)
    {
        switch (direction)
        {
        case MoveDirections.Straight:
            return(transform.position + transform.forward);

            break;

        case MoveDirections.Right:
            return(transform.position + transform.right);

            break;

        default:
            return(Vector3.zero);

            break;
        }
    }
예제 #27
0
        public bool MoveRobot(MoveDirections direction)
        {
            Coordinates newCoordinates = GetNewCoordinatesIfMovePossible(direction);

            if (newCoordinates.X != -1 && newCoordinates.Y != -1)
            {
                gameHistory.SaveCheckpoint(SaveState());
                GameMap.SetPlayerCoordinates(newCoordinates);
                if (GameMap.LoadsPosition.ContainsKey(GameMap.PlayerCurrentCoordinates))
                {
                    Load load = GameMap.LoadsPosition[GameMap.PlayerCurrentCoordinates];
                    if (Robot.TakeLoad(load))
                    {
                        GameMap.RemoveLoad(GameMap.PlayerCurrentCoordinates);
                    }
                }
                Robot.Move(1);
                return(true);
            }
            return(false);
        }
예제 #28
0
        static void Main(string[] args)
        {
            float pi = (float)Math.PI;

            Ellipsoid e = new Ellipsoid();

            Console.WriteLine($"Ellipsoid with sizes 1,1,1 \n Volume is equal to {e.Volume()} \n Area is equal to {e.Area()} \n Coordinates are ({e.point.x};{e.point.y};{e.point.z}) \n");

            e.MoveTo(2.3f, 4.3f, 1f);
            Console.Write($"After apply method MoveTo, ");
            e.PrintPosition();

            e.MoveBy(-2.3f, -4.3f, -1f);
            Console.Write($"After apply method MoveBy,");
            e.PrintPosition();

            MoveDirections md = new MoveDirections(0, pi / 2, pi / 2);

            e.MoveByAxis(md, 3);
            Console.Write($"After apply method MoveByAxis, moving ellipsoid by X axis ");
            e.PrintPosition();
        }
예제 #29
0
 public void SetMoveDirection(MoveDirections direction)
 {
     // we can call this to change the moving direction in real-time
     moveDirection = direction;
     // flip the facing side if it's needed
     if (moveDirection == MoveDirections.Left)
     {
         if (isFacingRight)
         {
             isFacingRight = !isFacingRight;
             enemyController.Flip();
         }
     }
     else
     {
         if (!isFacingRight)
         {
             isFacingRight = !isFacingRight;
             enemyController.Flip();
         }
     }
 }
예제 #30
0
        private Coordinates GetNewCoordinatesIfMovePossible(MoveDirections direction)
        {
            int currentX = GameMap.PlayerCurrentCoordinates.X;
            int currentY = GameMap.PlayerCurrentCoordinates.Y;

            switch (direction)
            {
            case MoveDirections.UP:
                if (currentY - 1 >= 0)
                {
                    return(new Coordinates(currentX, currentY - 1));
                }
                break;

            case MoveDirections.RIGHT:
                if (currentX + 1 < GameMap.Height)
                {
                    return(new Coordinates(currentX + 1, currentY));
                }
                ;
                break;

            case MoveDirections.DOWN:
                if (currentY + 1 < GameMap.Width)
                {
                    return(new Coordinates(currentX, currentY + 1));
                }
                break;

            case MoveDirections.LEFT:
                if (currentX - 1 >= 0)
                {
                    return(new Coordinates(currentX - 1, currentY));
                }
                break;
            }
            return(new Coordinates(-1, -1));
        }
예제 #31
0
        private bool getNewCoords(MoveDirections dir, ref int[] newCoord)
        {
            newCoord = new int[] { currentCoord [0], currentCoord [1] };

            if (dir == MoveDirections.Right)
            {
                newCoord [0]++;
            }
            else if (dir == MoveDirections.Left)
            {
                newCoord [0]--;
            }
            else if (dir == MoveDirections.Up)
            {
                newCoord [1]--;
            }
            else
            {
                newCoord [1]++;
            }

            return(GameBoard.validCoord(newCoord [0], newCoord [1]));
        }
예제 #32
0
파일: Character.cs 프로젝트: semirs/CellAO
        private MoveModes previousMoveMode = MoveModes.Run; // Run should be an appropriate default for now

        /// <summary>
        /// Stop movement (before teleporting for example)
        /// </summary>
        public void StopMovement()
        {
            // This should be used to stop the interpolating and save last interpolated value of movement before teleporting
            this.RawCoord = this.Coordinates;
            this.RawHeading = this.Heading;

            this.spinDirection = SpinOrStrafeDirections.None;
            this.strafeDirection = SpinOrStrafeDirections.None;
            this.moveDirection = MoveDirections.None;
        }
        private void UpdateTree(Task displayTask, MoveDirections dir)
        {
            TreeCanvas.Children.Clear();
            var children = displayTask.SelectChildrenTasks();
            var visual = new TaskVisual { Height = 150, Width = 150 };
            LevelUp.IsEnabled = displayTask.ParentId != -1;
            visual.Removing.IsEnabled = LevelUp.IsEnabled;
            visual.Desc.Text = displayTask.Description;
            visual.Date.Text = "С " + displayTask.BeginDate.ToShortDateString() + " по " +
                               displayTask.EndDate.ToShortDateString();
            TreeCanvas.Children.Add(visual);
            int i = children.Count + 1;
            _realCanvasWidth = visual.Width * i;
            OverflowCanvas();
            visual.SetValue(Canvas.LeftProperty, (TreeCanvas.MinWidth - visual.Width) / 2);
            visual.SetValue(Canvas.TopProperty, 20.0);
            visual.PreviewMouseLeftButtonDown += ClearStepChanger;
            _parent = visual;
            if (displayTask.ChildrenAreSteps())
            {
                visual.Add.Click += AddStep;
            }
            else
                visual.Add.Click += AddTask;
            bool evenCount = children.Count % 2 == 0;
            int center = children.Count / 2;
            var centerLeft = (double)visual.GetValue(Canvas.LeftProperty);
            int module = (i - 1) / 2;
            var anim = new ThicknessAnimation(dir == MoveDirections.Down ? new Thickness(0, -1000, 0, 200) : new Thickness(0, 200, 0, -1000), new Thickness(0, 0, 0, 0),
                                                  new Duration(TimeSpan.FromSeconds(1)));
            if (dir != MoveDirections.None)
                visual.BeginAnimation(MarginProperty, anim);
            visual.Background = !displayTask.HasUncomplitedTasks() ? Brushes.LimeGreen : Brushes.Orange;
            visual.Removing.Click += RemoveTask;
            visual.Edit.Click += EditTask;

            foreach (var task in children)
            {
                var child = new TaskVisual
                    {
                        Height = 150,
                        Width = 150,
                        Desc = { Text = task.Description },
                        Date =
                            {
                                Text = "С " + task.BeginDate.ToShortDateString() + " по " +
                                       task.EndDate.ToShortDateString()
                            },
                        Field = { Background = !task.HasUncomplitedTasks() ? Brushes.LimeGreen : Brushes.Orange }
                    };
                child.Removing.Visibility = Visibility.Collapsed;
                child.Edit.Visibility = Visibility.Collapsed;
                TreeCanvas.Children.Add(child);
                i--;
                double offset = !evenCount
                                    ? (i == center + 1
                                           ? centerLeft
                                           : (i > center + 1
                                                  ? centerLeft + (visual.Width + visual.Width / children.Count) * module
                                                  : centerLeft - (visual.Width + visual.Width / 2) * i))
                                    : (i > center
                                           ? centerLeft + visual.Width / 2 + visual.Width / children.Count / 2 +
                                             (visual.Width / children.Count + visual.Width) * (module - 1)
                                           : centerLeft - visual.Width / 2 - visual.Width / children.Count / 2 -
                                             (visual.Width / children.Count + visual.Width) * (i - 1));
                module--;

                child.SetValue(Canvas.LeftProperty, offset);
                child.SetValue(Canvas.TopProperty, visual.Height + 180);
                child.Add.Visibility = Visibility.Collapsed;
                var lane = new Line
                    {
                        StrokeThickness = 5,
                        Fill = Brushes.DarkCyan,
                        X1 = (double)visual.GetValue(Canvas.LeftProperty) + visual.Width / 2,
                        Y1 = 20 + visual.Height,
                        Stroke = Brushes.DarkCyan,
                        X2 = (double)child.GetValue(Canvas.LeftProperty) + child.Width / 2,
                        Y2 = (double)child.GetValue(Canvas.TopProperty),
                        SnapsToDevicePixels = true
                    };
                lane.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
                TreeCanvas.Children.Add(lane);

                if (dir != MoveDirections.None)
                {
                    child.BeginAnimation(MarginProperty, anim);
                    lane.BeginAnimation(MarginProperty, anim);
                }
                child.PreviewMouseLeftButtonUp += SelectChild;

            }
            if (TreeCanvas.Children.Count == 1)
            {
                visual.Width = visual.Height = 300;
            }
            if (displayTask.ChildrenAreSteps())
            {
                var steps = displayTask.SelectChildrenSteps();
                var list = new ListBox
                    {
                        Margin = new Thickness(10.0, 30, 20.0, 0.0),
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment = VerticalAlignment.Center,
                        Width = visual.Width - 100
                    };
                foreach (var step in steps)
                {
                    var item = new ListBoxItem
                        {
                            Content =
                                step.Description + "\n\n" + step.Criteria.Unit + "\t\t" + step.Criteria.CurrentValue +
                                "/" + step.Criteria.TargetValue,
                            BorderThickness = new Thickness(1),
                            BorderBrush = Brushes.LightBlue,
                            Name = "S" + step.Id
                        };
                    item.Selected += StepSelected;
                    list.Items.Add(item);
                }
                visual.Add.Click += AddStep;
                visual.Field.Children.Add(list);
            }
        }
예제 #34
0
 public override bool IsItemMovingAvailable(int col, int row, MoveDirections mdir)
 {
     if (!AvailableMoveDirections.ContainsKey(mdir)) return false;
     if (col < 0 || row < 0 || col >= FieldSize || row >= FieldSize)
         return false;
     var gameObject1 = Items[col][row] as GameObject;
     if (gameObject1 == null || gameObject1.GetComponent<GameItem>().MovingType == GameItemMovingType.Static) return false;
     var direction = AvailableMoveDirections[mdir];
     var newX = col + (int)direction.x;
     var newY = row - (int)direction.y;
     GameObject gobj;
     return newX >= 0 && newX <= (FieldSize - 1) && newY >= 0 && newY <= (FieldSize - 1) && Items[newX][newY] != DisabledItem && (gobj = Items[newX][newY] as GameObject)!= null &&
                                                                    gobj.GetComponent<GameItem>().MovingType != GameItemMovingType.Static && !gobj.GetComponent<GameItemMovingScript>().IsMoving;
 }
예제 #35
0
 protected void SpawnItemOnRandomPlace(GameItemType type, MoveDirections? area = null, Vector3? scaleTo = null)
 {
     int col;
     int row;
     int fromCol = 1;
     int toCol = FieldSize - 1;
     int fromRow = fromCol;
     int toRow = toCol;
     if(area != null)
     switch (area.Value)
     {
         case MoveDirections.Left:
             fromCol = 1;
             toCol = FieldSize/2;
             fromRow = 1;
             toRow = FieldSize - 1;
             break;
         case MoveDirections.Right:
             fromCol = FieldSize / 2 + FieldSize%2;
             toCol = FieldSize - 1;
             fromRow = 1;
             toRow = FieldSize - 1;
             break;
     }
     while (true)
     {
         col = RandomObject.Next(fromCol, toCol);
         row = RandomObject.Next(fromRow, toRow);
         if (Items[col][row] == null || Items[col][row] == DisabledItem) continue;
         var o = Items[col][row] as GameObject;
         if (o == null) continue;
         var gi = o.GetComponent<GameItem>();
         if (Items[col][row] != null && Items[col][row] != DisabledItem &&
             gi.Type < GameItemType._2x && gi.Type != (MaxType + 1) &&
             !o.GetComponent<GameItemScalingScript>().isScaling)
             break;
     }
     RemoveGameItem(col, row, (item, r) =>
     {
         Items[col][row] = GenerateGameItem(type, col, row, Vector2.zero, scaleTo == null ? GameItemScale : scaleTo, false, null, null);
     });
 }
예제 #36
0
        public virtual bool IsItemMovingAvailable(int col, int row, MoveDirections mdir)
        {
            if (!AvailableMoveDirections.ContainsKey(mdir)) return false;
            if (col < 0 || row < 0 || col >= FieldSize || row >= Items[col].Length)
                return false;

            var gameObject1 = Items[col][row] as GameObject;
            if (gameObject1 == null || gameObject1.GetComponent<GameItem>().MovingType == GameItemMovingType.Static) return false;

            switch (mdir)
            {
                case MoveDirections.Up:
                    if (row == 0 || Items[col][row - 1] == DisabledItem)
                        return false;
                    var objectUp = Items[col][row - 1] as GameObject;

                    if (objectUp == null || objectUp.GetComponent<GameItemMovingScript>().IsMoving || objectUp.GetComponent<GameItem>().MovingType == GameItemMovingType.Static)
                        return false;
                    break;
                case MoveDirections.Down:
                    if (row == (FieldSize - 1) || Items[col][row + 1] == DisabledItem)
                        return false;
                    var objectDown = Items[col][row + 1] as GameObject;

                    if (objectDown == null || objectDown.GetComponent<GameItemMovingScript>().IsMoving || objectDown.GetComponent<GameItem>().MovingType == GameItemMovingType.Static)
                        return false;
                    break;
                case MoveDirections.Left:
                    if (col == 0 || Items[col - 1][row] == DisabledItem)
                        return false;
                    var objectLeft = Items[col - 1][row] as GameObject;

                    if (objectLeft == null || objectLeft.GetComponent<GameItemMovingScript>().IsMoving || objectLeft.GetComponent<GameItem>().MovingType == GameItemMovingType.Static)
                        return false;
                    break;
                case MoveDirections.Right:
                    if (col == (FieldSize - 1) || Items[col + 1][row] == DisabledItem)
                        return false;
                    var objectRight = Items[col + 1][row] as GameObject;

                    if (objectRight == null || objectRight.GetComponent<GameItemMovingScript>().IsMoving || objectRight.GetComponent<GameItem>().MovingType == GameItemMovingType.Static)
                        return false;
                    break;
            }
            return true;
        }
예제 #37
0
 public void Move(MoveDirections dir)
 {
     switch (dir)
     {
         case MoveDirections.LEFT:
             VelocityX = -Acceleration.X;
             VelocityY = 0;
             break;
         case MoveDirections.UP:
             VelocityY = -Acceleration.Y;
             VelocityX = 0;
             break;
         case MoveDirections.RIGHT:
             VelocityX = Acceleration.X;
             VelocityY = 0;
             break;
         case MoveDirections.DOWN:
             VelocityY = Acceleration.Y;
             VelocityX = 0;
             break;
         case MoveDirections.NONE:
             Velocity = Vector2.Zero;
             break;
     }
     Velocity = engine.BlockManager.AdjustPlayer (this);
 }
예제 #38
0
 public override bool IsItemMovingAvailable(int col, int row, MoveDirections mdir)
 {
     var gobj = Items[col][row] as GameObject;
     if (gobj == null) return false;
     var gims = gobj.GetComponent<GameItemMovingScript>();
     if (gims == null) return false;
     if (!gims.IsMoving) return base.IsItemMovingAvailable(col, row, mdir);
     var target = GetCellCoordinates(col, row);
     var fourthPart = GameItemSize / 4;
     if (Math.Abs(target.y - gobj.transform.localPosition.y) < fourthPart)
         return false;
     switch (mdir)
     {
         case MoveDirections.Left:
             if (col == 0 || Items[col - 1][row] == null)
                 return false;
             for (var i = FieldSize - 1; i >= 0; i--)
                 if (Items[col - 1][i] == DisabledItem)
                 {
                     return GetCellCoordinates(col - 1, i).y < gobj.transform.localPosition.y - fourthPart;
                 }
             break;
         case MoveDirections.Right:
             if (col == (FieldSize - 1) || Items[col + 1][row] == null)
                 return false;
             for (var i = FieldSize - 1; i >= 0; i--)
                 if (Items[col + 1][i] == DisabledItem)
                 {
                     return GetCellCoordinates(col + 1, i).y < gobj.transform.localPosition.y - fourthPart;
                 }
             break;
     }
     return false;
 }
 /// <summary>
 /// Translate into x, y or z axis with a specfic amount.
 /// </summary>
 /// <param name="amount">Amount</param>
 /// <param name="direction">Direction</param>
 private void Translate(float amount, MoveDirections direction)
 {
     Vector3 dir =
         direction == MoveDirections.X ? XAxis :
         direction == MoveDirections.Y ? YAxis : ZAxis;
     pos += dir * amount;
 }
예제 #40
0
파일: Character.cs 프로젝트: semirs/CellAO
        /// <summary>
        /// Update move type
        /// </summary>
        /// <param name="moveType">new move type</param>
        public void UpdateMoveType(byte moveType)
        {
            this.predictionTime = DateTime.Now;

            /*
             * NV: Would be nice to have all other possible values filled out for this at some point... *Looks at Suiv*
             * More specifically, 10, 13 and 22 - 10 and 13 seem to be tied to spinning with mouse. 22 seems random (ping mabe?)
             * Also TODO: Tie this with CurrentMovementMode stat and persistance (ie, log off walking, log back on and still walking)
             * Values of CurrentMovementMode and their effects:
                0: slow moving feet not animating
                1: rooted cant sit
                2: walk
                3: run
                4: swim
                5: crawl
                6: sneak
                7: flying
                8: sitting
                9: rooted can sit
                10: same as 0
                11: sleeping
                12: lounging
                13: same as 0
                14: same as 0
                15: same as 0
                16: same as 0
             */
            switch (moveType)
            {
                case 1: // Forward Start
                    this.moveDirection = MoveDirections.Forwards;
                    break;
                case 2: // Forward Stop
                    this.moveDirection = MoveDirections.None;
                    break;

                case 3: // Reverse Start
                    this.moveDirection = MoveDirections.Backwards;
                    break;
                case 4: // Reverse Stop
                    this.moveDirection = MoveDirections.None;
                    break;

                case 5: // Strafe Right Start
                    this.strafeDirection = SpinOrStrafeDirections.Right;
                    break;
                case 6: // Strafe Stop (Right)
                    this.strafeDirection = SpinOrStrafeDirections.None;
                    break;

                case 7: // Strafe Left Start
                    this.strafeDirection = SpinOrStrafeDirections.Left;
                    break;
                case 8: // Strafe Stop (Left)
                    this.strafeDirection = SpinOrStrafeDirections.None;
                    break;

                case 9: // Turn Right Start
                    this.spinDirection = SpinOrStrafeDirections.Right;
                    break;
                case 10: // Mouse Turn Right Start
                    break;
                case 11: // Turn Stop (Right)
                    this.spinDirection = SpinOrStrafeDirections.None;
                    break;

                case 12: // Turn Left Start
                    this.spinDirection = SpinOrStrafeDirections.Left;
                    break;
                case 13: // Mouse Turn Left Start
                    break;
                case 14: // Turn Stop (Left)
                    this.spinDirection = SpinOrStrafeDirections.None;
                    break;

                case 15: // Jump Start
                    // NV: TODO: This!
                    break;
                case 16: // Jump Stop
                    break;

                case 17: // Elevate Up Start
                    break;
                case 18: // Elevate Up Stop
                    break;

                case 19: // ? 19 = 20 = 22 = 31 = 32
                    break;
                case 20: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 21: // Full Stop
                    break;

                case 22: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 23: // Switch To Frozen Mode
                    break;
                case 24: // Switch To Walk Mode
                    this.moveMode = MoveModes.Walk;
                    break;
                case 25: // Switch To Run Mode
                    this.moveMode = MoveModes.Run;
                    break;
                case 26: // Switch To Swim Mode
                    break;
                case 27: // Switch To Crawl Mode
                    this.previousMoveMode = this.moveMode;
                    this.moveMode = MoveModes.Crawl;
                    break;
                case 28: // Switch To Sneak Mode
                    this.previousMoveMode = this.moveMode;
                    this.moveMode = MoveModes.Sneak;
                    break;
                case 29: // Switch To Fly Mode
                    break;
                case 30: // Switch To Sit Ground Mode
                    this.previousMoveMode = this.moveMode;
                    this.moveMode = MoveModes.Sit;
                    this.stats.NanoDelta.CalcTrickle();
                    this.stats.HealDelta.CalcTrickle();
                    this.stats.NanoInterval.CalcTrickle();
                    this.stats.HealInterval.CalcTrickle();
                    break;

                case 31: // ? 19 = 20 = 22 = 31 = 32
                    break;
                case 32: // ? 19 = 20 = 22 = 31 = 32
                    break;

                case 33: // Switch To Sleep Mode
                    this.moveMode = MoveModes.Sleep;
                    break;
                case 34: // Switch To Lounge Mode
                    this.moveMode = MoveModes.Lounge;
                    break;

                case 35: // Leave Swim Mode
                    break;
                case 36: // Leave Sneak Mode
                    this.moveMode = this.previousMoveMode;
                    break;
                case 37: // Leave Sit Mode
                    this.moveMode = this.previousMoveMode;
                    this.stats.NanoDelta.CalcTrickle();
                    this.stats.HealDelta.CalcTrickle();
                    this.stats.NanoInterval.CalcTrickle();
                    this.stats.HealInterval.CalcTrickle();
                    break;
                case 38: // Leave Frozen Mode
                    break;
                case 39: // Leave Fly Mode
                    break;
                case 40: // Leave Crawl Mode
                    this.moveMode = this.previousMoveMode;
                    break;
                case 41: // Leave Sleep Mode
                    break;
                case 42: // Leave Lounge Mode
                    break;
                default:
                    //Console.WriteLine("Unknown MoveType: " + moveType);
                    break;
            }

            //Console.WriteLine((moveDirection != 0 ? moveMode.ToString() : "Stand") + "ing in the direction " + moveDirection.ToString() + (spinDirection != 0 ? " while spinning " + spinDirection.ToString() : "") + (strafeDirection != 0 ? " and strafing " + strafeDirection.ToString() : ""));
        }
예제 #41
0
        /*private void MoveModule(int index, MoveDirections dir)
        {
            int newIndex = index;
            if (dir == MoveDirections.Left)
            {
                newIndex -= 2;
            }
            else
            {
                newIndex += 2;
            }

            //MessageBox.Show(oldIndex.ToString() + " - " + newIndex.ToString());
            bool totalLeftMove = false;
            bool totalRightMove = false;
            int lastIndex = _parent.Panel.Controls.Count - 1;
            int temp;

            if (index > newIndex) // Left move
            {
                if (newIndex < 0) // Move as last module
                {                    
                    newIndex = lastIndex;
                    totalLeftMove = true;
                }
            }
            else // Right move
            {

                if (newIndex > lastIndex) // Move as first module
                {
                    newIndex = 0;
                    totalRightMove = true;
                }
            }

            //MessageBox.Show(index.ToString() + " - " + newIndex.ToString());

            if (totalLeftMove)
            {
                temp = _parent.Modules[index];
                for (int i = index; i < lastIndex; i += 2)
                {
                    UpdateIndex(ModuleType(i + 2), i);
                    _parent.Modules[i] = _parent.Modules[i + 2];
                }
                UpdateIndex(ModuleType(temp), newIndex);
                _parent.Modules[newIndex] = temp;
            }
            else if (totalRightMove)
            {
                temp = _parent.Modules[index];
                for (int i = index; i > newIndex; i -= 2)
                {
                    string ty = ModuleType(i - 2);
                    UpdateIndex(ty, i);
                    _parent.Modules[i] = _parent.Modules[i - 2];
                }
                UpdateIndex(ModuleType(temp), newIndex);
                _parent.Modules[newIndex] = temp;
            }
            else
            {
                UpdateIndex(ModuleType(index), newIndex);
                UpdateIndex(ModuleType(newIndex), index);

                temp = _parent.Modules[newIndex];
                _parent.Modules[newIndex] = _parent.Modules[index];
                _parent.Modules[index] = temp;
            }

            _parent.RunTick();
            //string asdf = "asdf";
        }*/

        private void MoveModule(ModuleType mod, MoveDirections dir)
        {
            int position = 99;
            int destination = 99;
            Type type = null;
            int lastIndex = _parent.Panel.Controls.Count - 1;
            bool totalLeftMove = false;
            bool totalRightMove = false;
            int temp = 99;

            switch (mod)
            {
                case ModuleType.BatteryMonitor:
                    type = typeof(BatteryMonitor);
                    break;
                case ModuleType.CPUMonitor:
                    type = typeof(CPUMonitor);
                    break;
                case ModuleType.MemoryMonitor:
                    type = typeof(MemoryMonitor);
                    break;
                case ModuleType.NetworkMonitor:
                    type = typeof(NetworkMonitor);
                    break;
                case ModuleType.Uptime:
                    type = typeof(Uptime);
                    break;
                case ModuleType.WinampControl:
                    type = typeof(WinampControl);
                    break;
                /*case ModuleType.RSSFeed:
                    break;
                case ModuleType.GoogleSearch:
                    break;*/
            }

            for (int i = 0; i < _parent.Panel.Controls.Count; i++)
            {
                if (_parent.Panel.Controls[i].GetType() == type)
                {
                    Module m = (Module)_parent.Panel.Controls[i];
                    position = m.Index;
                }
            }

            if (position != 99)
            {
                destination = position;
                if (dir == MoveDirections.Left)
                {
                    destination -= 2;
                }
                else
                {
                    destination += 2;
                }

                if (position > destination)         // Left move
                {
                    if (destination < 0)            // Move as last module
                    {
                        destination = lastIndex;
                        totalLeftMove = true;
                    }
                }
                else                                // Right move
                {
                    if (destination > lastIndex)    // Move as first module
                    {
                        destination = 0;
                        totalRightMove = true;
                    }
                }

                if (totalLeftMove)                  // Move module as last module
                {
                    Module module;
                    temp = _parent.Modules[position];
                    for (int i = position; i < lastIndex; i += 2)
                    {
                        module = (Module)_parent.Panel.Controls[i + 2];
                        module.Index = i;
                        _parent.Modules[i] = _parent.Modules[i + 2];
                    }
                    module = (Module)_parent.Panel.Controls[temp];
                    module.Index = lastIndex;
                    _parent.Modules[lastIndex] = temp;
                }
                else if (totalRightMove)            // Move module as first module
                {
                    Module module;
                    temp = _parent.Modules[position];
                    for (int i = lastIndex; i > 0; i -= 2)
                    {
                        module = (Module)_parent.Panel.Controls[i - 2];
                        module.Index = i;
                        _parent.Modules[i] = _parent.Modules[i - 2];
                    }
                    module = (Module)_parent.Panel.Controls[temp];
                    module.Index = 0;
                    _parent.Modules[0] = temp;
                }
                else                                // Move module
                {
                    temp = _parent.Modules[position];
                    Module mod1 = (Module)_parent.Panel.Controls[temp];
                    Module mod2 = (Module)_parent.Panel.Controls[_parent.Modules[destination]];
                    mod1.Index = destination;
                    mod2.Index = position;
                    _parent.Modules[position] = _parent.Modules[destination];
                    _parent.Modules[destination] = temp;
                }

                _parent.RunTick();
            }
        }