コード例 #1
0
ファイル: Bullet.cs プロジェクト: Zera7/BadBattleCity
 public Bullet(int team, MovableObject.Direction direction, Map.Point coords)
 {
     deltaCoords    = GetDeltaCoords(direction);
     this.team      = team;
     this.direction = direction;
     this.coords    = new Map.Point(coords.X, coords.Y);
     newCoords      = new Map.Point(coords.X, coords.Y);
     isAlive        = true;
     moveFrequency  = StartingSpeed;
 }
コード例 #2
0
ファイル: Client.cs プロジェクト: Zera7/BadBattleCity
        private static void ProcessPressedKeys()
        {
            if (thisPlayer.isShot)
            {
                if (thisPlayer.Fire())
                {
                    connector.Send("shot",
                                   connector.SenderDefaultEndPoint);
                }
            }

            if (thisPlayer.key != 0)
            {
                MovableObject.Direction direction = MovableObject.Direction.left;
                bool moved = false;
                if (thisPlayer.key == ConsoleKey.UpArrow)
                {
                    direction = MovableObject.Direction.up; moved = true;
                }
                if (thisPlayer.key == ConsoleKey.DownArrow)
                {
                    direction = MovableObject.Direction.down; moved = true;
                }
                if (thisPlayer.key == ConsoleKey.LeftArrow)
                {
                    direction = MovableObject.Direction.left; moved = true;
                }
                if (thisPlayer.key == ConsoleKey.RightArrow)
                {
                    direction = MovableObject.Direction.right; moved = true;
                }
                if (moved)
                {
                    if (thisPlayer.Move(direction))
                    {
                        connector.Send("move " +
                                       thisPlayer.newCoords.X + " " +
                                       thisPlayer.newCoords.Y + " " +
                                       (int)thisPlayer.direction,
                                       connector.SenderDefaultEndPoint);
                    }
                }
            }
        }
コード例 #3
0
        public bool Move(MovableObject.Direction direction)
        {
            if (beforeMoving == 0)
            {
                if (direction == this.direction)
                {
                    Map.Point deltaCoords = GetDeltaCoords(direction);
                    newCoords = new Map.Point(coords.X + deltaCoords.X, coords.Y + deltaCoords.Y);
                }
                else
                {
                    this.direction = direction;
                }

                beforeMoving = moveFrequency;
                key          = 0;
                return(true);
            }
            return(false);
        }