void Move()
    {
        int iCheckCol = m_Char.m_iCol;
        int iCheckRow = m_Char.m_iRow;

        switch (m_Direction) {
        case EDirection.left:
            iCheckCol -= 1;
            break;
        case EDirection.right:
            iCheckCol += 1;
            break;
        case EDirection.up:
            iCheckRow += 1;
            break;
        case EDirection.down:
            iCheckRow -= 1;
            break;
        }

        square checkSquare = m_Char.m_Board.GetSquare(iCheckCol, iCheckRow);

        // walkable
        if (checkSquare != null && checkSquare.GetAlive() == false)
        m_Char.Move(m_Direction);
        // not walkable
        else
        m_Direction = Foo.GetLeft(m_Direction);
    }
Beispiel #2
0
 void Start()
 {
     tPosWater = this.transform.position;
     m_Direction = EDirection.E_Tide_Low;
     mRender = this.GetComponent<Renderer>();
     tOffSet = mRender.material.GetTextureOffset("_MainTex");
 }
Beispiel #3
0
 public EnemyAttack(EDirection _direction)
 {
     direction = _direction;
     animState = EAnimState.Attacking;
     timer = 0;
     hitTime = 500;
 }
        protected override Object SpecialInputs(ConsoleKey cki, EDirection currentDirection, EGameState gameState) {
            switch (cki) {
                case ConsoleKey.Escape:
                    if (gameState == EGameState.Running)
                        return gameState == EGameState.Running ? EGameState.Over : EGameState.Running;
                    if (gameState == EGameState.Over || gameState == EGameState.Init)
                        Environment.Exit(0);
                    break;
                case ConsoleKey.Spacebar:
                    return gameState == EGameState.Running ? EGameState.Paused : EGameState.Running;
                case ConsoleKey.Q:
                    if (gameState == EGameState.Init)
                        Environment.Exit(0);
                    if (gameState == EGameState.Over)
                        StartupManager.Reset();
                    break;
                case ConsoleKey.P:
                    if (gameState == EGameState.Init)
                        return EGameState.Running;
                    break;
            }

            if (cki == ConsoleKey.UpArrow && currentDirection != EDirection.South)
                return EDirection.North;
            if (cki == ConsoleKey.RightArrow && currentDirection != EDirection.West)
                return EDirection.East;
            if (cki == ConsoleKey.DownArrow && currentDirection != EDirection.North)
                return EDirection.South;
            if (cki == ConsoleKey.LeftArrow && currentDirection != EDirection.East)
                return EDirection.West;
            return cki;
        }
Beispiel #5
0
 public Climby(CoordHelper.EProfile pt)
     : base(App.Game)
 {
     playerType = pt;
     if (playerType == CoordHelper.EProfile.ONEPLAYER)
         skin = SpriteManager.ESprite.CLIMBYBLUE;
     else
         skin = SpriteManager.ESprite.CLIMBYRED;
     pos = new Vector2(CoordHelper.Instance.getLeftMargin(playerType) + Constants.Measures.boardWidth / 2,
                           Constants.Measures.upBoardMargin + Constants.Measures.boardHeight - Constants.Measures.blockSize);
     actualPosition = new Rectangle((int)pos.X, (int)pos.Y, (int)Constants.Measures.blockSize, (int)Constants.Measures.blockSize);
     deadZone = new Rectangle((int)pos.X + (int)(Constants.Measures.blockSize / 3),
                              (int)pos.Y + (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3));
     actions = new Dictionary<EState, Action<GameTime>>();
     #region Actions
     actions.Add(EState.CLIMB, climb);
     actions.Add(EState.END_CLIMB, move);
     actions.Add(EState.FALL, move);
     actions.Add(EState.FREE_FALL, fall);
     actions.Add(EState.MOVE, move);
     actions.Add(EState.STOP, stop);
     #endregion
     state = EState.MOVE;
     direction = EDirection.RIGHT;
     rotation = 0f;
     setSpeedFromLevel(0);
     influence = 1f;
     minHeight = (int)((pos.Y - Constants.Measures.upBoardMargin) / Constants.Measures.blockSize);
     oldMinHeight = minHeight;
 }
 protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
 {
     if (tile.TileType == ETileType.SwitchMoveDirection && IsHeadingTowardsTile(tile) && Math.Abs(intersectionDepth.X) > tile.Dimensions.X/2)
     {
             ParentObject.Velocity = new Vector2(-ParentObject.Velocity.X, ParentObject.Velocity.Y);
     }
     base.ReactToTileCollision(tile, direction, intersectionDepth);
 }
Beispiel #7
0
 public void SetNeighbour(Tile neighbour, EDirection direction)
 {
     if (neighbour != null)
     {
         int neighbourIndex = (int) direction;
         Neighbours[neighbourIndex] = neighbour;
     }
 }
Beispiel #8
0
		public Arc(double OriginX, double OriginY,
			 double RadiusX, double RadiusY,
			 double Angle1, double Angle2,
			 EDirection Direction = EDirection.CounterClockWise,
			 double Scale = 1.0,
			 bool moveToStart = true)
		{
			init(OriginX, OriginY, RadiusX, RadiusY, Angle1, Angle2, Direction: Direction, Scale: Scale, moveToStart: moveToStart);
		}
Beispiel #9
0
 public void init(double OriginX, double OriginY,
            double RadiusX, double RadiusY,
            double Angle1, double Angle2,
            EDirection Direction)
 {
     m_OriginX = OriginX;
     m_OriginY = OriginY;
     m_RadiusX = RadiusX;
     m_RadiusY = RadiusY;
     normalize(Angle1, Angle2, Direction);
 }
        protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
        {
            var cart = (ParentObject as Cart);

            if (tile.TileType == ETileType.TunnelEnd)
            {
                cart.State = EMachineState.Dead;
            }

            base.ReactToTileCollision(tile, direction, intersectionDepth);
        }
Beispiel #11
0
        public MainViewModel()
        {
            this.leftCommand = new ActionCommand(this.LeftCommandReq);
            this.rightCommand = new ActionCommand(this.RightCommandReq);
            this.upCommand = new ActionCommand(this.UpCommandReq);
            this.downCommand = new ActionCommand(this.DownCommandReq);

            this.width = 300;
            this.height = 300;

            this.currentDirection = EDirection.Right;
        }
Beispiel #12
0
 public Arc(double OriginX, double OriginY,
      double RadiusX, double RadiusY,
      double Angle1, double Angle2,
      EDirection Direction)
 {
     m_OriginX = OriginX;
     m_OriginY = OriginY;
     m_RadiusX = RadiusX;
     m_RadiusY = RadiusY;
     m_Scale = 1.0;
     normalize(Angle1, Angle2, Direction);
 }
        public bool Collides(IBlock block, IField field, EDirection direction)
        {
            bool collides = false;
            foreach (var position in block.Positions) {
                var newPosition = position.MoveOneStep(direction);
                collides = !staysWithinBorders(newPosition, field.Width, field.Height, direction) || field.FixedPositions.ContainsKey(newPosition);
                if (collides) {
                    return collides;
                }
            }

            return collides;
        }
Beispiel #14
0
 public static EDirection GetLeft(EDirection _Direction)
 {
     switch (_Direction) {
     case EDirection.left:
         return EDirection.down;
     case EDirection.right:
         return EDirection.up;
     case EDirection.up:
         return EDirection.left;
     case EDirection.down:
         return EDirection.right;
     }
     return EDirection.right;
 }
 public static Vector2 MoveOneStep(this Vector2 vector, EDirection direction)
 {
     switch (direction) {
         case EDirection.Up:
             return vector + new Vector2(0, -1);
         case EDirection.Down:
             return vector + new Vector2(0, 1);
         case EDirection.Left:
             return vector + new Vector2(-1, 0);
         case EDirection.Right:
             return vector + new Vector2(1, 0);
         default:
             throw new ArgumentException(string.Format("{0} is not a valid direction", direction));
     }
 }
 private bool staysWithinBorders(Vector2 position, int width, int height, EDirection direction)
 {
     switch (direction) {
         case EDirection.Up:
             return position.Y >= 0;
         case EDirection.Down:
             return position.Y <= height - 1;
         case EDirection.Left:
             return position.X >= 0;
         case EDirection.Right:
             return position.X <= width -1;
         default:
             throw new ArgumentException(string.Format("{0} is not a valid direction", direction));
     }
 }
Beispiel #17
0
		public void init(double OriginX, double OriginY,
				   double RadiusX, double RadiusY,
				   double Angle1, double Angle2,
				   EDirection Direction = EDirection.CounterClockWise,
				   double Scale = 1.0,
				   bool moveToStart = true)
		{
			originX = OriginX;
			originY = OriginY;
			radiusX = RadiusX;
			radiusY = RadiusY;
			m_Scale = Scale;
			this.moveToStart = moveToStart;
			normalize(Angle1, Angle2, Direction);
		}
Beispiel #18
0
        /// <summary>
        /// Sprawdza z której strony nastąpiła kolizja
        /// </summary>
        /// <param name="collisionDepth">Głębokość kolizji</param>
        /// <param name="direction">Kierunek - pion lub poziom</param>
        /// <returns></returns>
        public static ESide GetCollisionOrigin(Vector2 collisionDepth, EDirection direction)
        {
            ESide side = ESide.NotAssigned;

            if (direction==EDirection.Vertical)
            {
                if (collisionDepth.Y < 0) side = side | ESide.Top;
                else if (collisionDepth.Y > 0) side = side | ESide.Bottom;
            }
            else
            {
                if (collisionDepth.X < 0) side = side | ESide.Left;
                else if (collisionDepth.Y > 0) side = side | ESide.Right;
            }
            return side;
        }
Beispiel #19
0
 public void Move(EDirection _Dir)
 {
     switch (_Dir)
     {
         case EDirection.left:
             SetPos(m_iCol-1, m_iRow);
             break;
         case EDirection.right:
             SetPos(m_iCol+1, m_iRow);
             break;
         case EDirection.up:
             SetPos(m_iCol, m_iRow+1);
             break;
         case EDirection.down:
             SetPos(m_iCol, m_iRow-1);
             break;
     }
 }
Beispiel #20
0
 //Рухаємо змію. Якщо вона себе кусає, повертаємо true;
 public bool Move(EDirection direction, out List<Visualizer.Terrain> coordsToRepaint)
 {
     coordsToRepaint = new List<Visualizer.Terrain> { new Visualizer.Terrain(Visualizer.TerrainInfo.Backcolor, _snake.Peek()),
                                                      new Visualizer.Terrain(Visualizer.TerrainInfo.Snake, _head) };
     var s = _head + _dictionary[direction];
     if (_snake.Contains(s) || _head.X <= 0 || _head.X >= _size.Width - 1 || _head.Y <= 0 || _head.Y >= _size.Height - 1)
         return true;
     _head = s;
     _snake.Enqueue(_head);
     coordsToRepaint.Add(new Visualizer.Terrain(Visualizer.TerrainInfo.Head, _head));
     if (_head == Food) //Якщо змійка потрапила на клітинку з їжею, ми заповнюемо випадкову клітинку їжею.
     {
         Score += ScoreForFood;
         PlaceFood();
     }
     else _snake.Dequeue(); //Інакше, щоб змія не збільшилась, прибираемо останній сегмент
     coordsToRepaint.Add(new Visualizer.Terrain(Visualizer.TerrainInfo.Food, Food));
     return false; //Ми себе не вкусили, значить false
 }
 // reads key and returns object based on key, object is handled by game manager
 internal Object PollKey(EDirection currentDirection) {
     if (!Console.KeyAvailable) return null;
     var cki = Console.ReadKey(true);
     switch (cki.Key){
         case ConsoleKey.Escape:
             return cki;
         case ConsoleKey.Spacebar:
             return cki;
         default:
             if (cki.Key == ConsoleKey.UpArrow && currentDirection != EDirection.South)
                 return EDirection.North;
             if (cki.Key == ConsoleKey.RightArrow && currentDirection != EDirection.West)
                 return EDirection.East;
             if (cki.Key == ConsoleKey.DownArrow && currentDirection != EDirection.North)
                 return EDirection.South;
             if (cki.Key == ConsoleKey.LeftArrow && currentDirection != EDirection.East)
                 return EDirection.West;
             return null;
     }
 }
Beispiel #22
0
    void Update()
    {
		if (GetComponentInParent<GestureScript>().GestureStart("Forward"))
        {
            Direction = EDirection.Up;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Middle"))
        {
            Direction = EDirection.Left;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Wide"))
        {
            Direction = EDirection.Right;
        }
		else if (GetComponentInParent<GestureScript>().GestureStart("Down"))
        {
            Direction = EDirection.Forward;
        }

        UpdateRotation();
    }
        protected override void ReactToTileCollision(Tile tile, EDirection direction, Vector2 intersectionDepth)
        {
            var player = (ParentObject as Player);

            if (direction == EDirection.Vertical && player.Velocity.Y > player.MinDeathSpeed &&
                (tile.CollisionType == ETileCollisionType.Platform || tile.CollisionType == ETileCollisionType.Impassable))
            {
                player.OnDied();
            }

            player.IsCollidingWithLadder = false;
            if (tile.TileType == ETileType.LadderMiddle || tile.TileType==ETileType.LadderTop)
            {
                player.IsCollidingWithLadder = true;
            }

            if ((tile.TileType == ETileType.LadderTop && player.IsClimbing))
            {
                return;
            }

            base.ReactToTileCollision(tile, direction, intersectionDepth);
        }
Beispiel #24
0
 protected abstract void SetPressedGraphics(EDirection dir, bool pressed);
Beispiel #25
0
    // sets the pressed state for a direction, which includes both
    // the data state and the graphical state.
    protected virtual void SetPressed(EDirection dir, bool pressed)
    {
        // do nothing if setting to the same value
        if (Pressed(dir) == pressed)
            return;

        SetBitfield(dir, pressed);

        SetPressedGraphics(dir, pressed);
    }
Beispiel #26
0
    // sets the bitfield's pressed state for the specified direction
    protected void SetBitfield(EDirection dir, bool pressed)
    {
        // clear the bit
        _pressedField &= ~((int)dir);

        if (pressed)
        {
            // set it
            _pressedField |= (int)dir;
        }
    }
Beispiel #27
0
    // utility to get the opposite direction of a specified direction
    protected EDirection GetOpposite(EDirection dir)
    {
        switch (dir)
        {
            case EDirection.Up: return EDirection.Down;
            case EDirection.Down: return EDirection.Up;
            case EDirection.Left: return EDirection.Right;
            case EDirection.Right: return EDirection.Left;
        }

        return EDirection.None;
    }
Beispiel #28
0
 /// <summary>
 /// Returns true if the specified EDirection is currently pressed, otherwise, false.
 /// </summary>
 public bool Pressed(EDirection dir)
 {
     return (_pressedField & (int)dir) != 0;
 }
    protected override void SetPressedGraphics(EDirection dir, bool pressed)
    {
        // only change pressed state if we're in joystick mode (and thus collision detection is off).
        // otherwise, the buttons handle the pressed graphics state themselves (during their collision detection).
        if (!JoystickMode)
            return;

        if (dir == EDirection.Left && LeftButton != null)
            LeftButton.ForcePressed = pressed;

        if (dir == EDirection.Right && RightButton != null)
            RightButton.ForcePressed = pressed;

        if (dir == EDirection.Up && UpButton != null)
            UpButton.ForcePressed = pressed;

        if (dir == EDirection.Down && DownButton != null)
            DownButton.ForcePressed = pressed;
    }
    public void SetDirection(EDirection i_eNewDirection)
    {
        m_eMovementDirection = i_eNewDirection;

        if (animator)
        {
            // Set the animation
            switch (GetDirection ())
            {
            case EDirection.DOWN:
                animator.SetInteger("Direction", 0);
                break;
            case EDirection.LEFT:
                animator.SetInteger("Direction", 1);
                break;
            case EDirection.UP:
                animator.SetInteger("Direction", 2);
                break;
            case EDirection.RIGHT:
                animator.SetInteger("Direction", 3);
                break;
            }
        }
    }