コード例 #1
0
        public Game(Track track)
        {
            Track     = track;
            State     = GameState.CountDown;
            CountDown = TimeSpan.FromSeconds(3);

            Vector goal = (Vector)Track.GoalPosition;

            Vector startOffset1 = default(Vector);
            Vector startOffset2 = default(Vector);

            float startRotation = 0f;

            switch (Track.GetTileByIndex((int)goal.X, (int)goal.Y))
            {
            case TrackTile.GoalDown:
                startOffset1  = new Vector(0.75f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.25f);
                startRotation = 180f;
                break;

            case TrackTile.GoalLeft:
                startOffset1  = new Vector(0.75f, 0.75f);
                startOffset2  = new Vector(0.75f, 0.25f);
                startRotation = -90f;
                break;

            case TrackTile.GoalRight:
                startOffset1  = new Vector(0.25f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.75f);
                startRotation = 90f;
                break;

            case TrackTile.GoalUp:
                startOffset1 = new Vector(0.25f, 0.75f);
                startOffset2 = new Vector(0.75f, 0.75f);
                break;
            }

            Player1 = new Player()
            {
                Position  = (Point)((goal + startOffset1) * Track.CELLSIZE),
                Direction = startRotation
            };
        }
コード例 #2
0
        public Game()
        {
            State     = GameState.CountDown;
            CountDown = TimeSpan.FromSeconds(3);

            Track = Track.LoadFromTxt("./Tracks/Track1.txt");

            Vector goal          = Track.GetGoalPosition();
            Vector startOffset1  = new Vector();
            Vector startOffset2  = new Vector();
            float  startRotation = 0f;

            switch (Track.GetTileByIndex((int)goal.X, (int)goal.Y))
            {
            case TrackTile.GoalDown:
                startOffset1  = new Vector(0.75f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.25f);
                startRotation = 180f;
                break;

            case TrackTile.GoalLeft:
                startOffset1  = new Vector(0.75f, 0.75f);
                startOffset2  = new Vector(0.75f, 0.25f);
                startRotation = -90f;
                break;

            case TrackTile.GoalRight:
                startOffset1  = new Vector(0.25f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.75f);
                startRotation = 90f;
                break;

            case TrackTile.GoalUp:
                startOffset1  = new Vector(0.25f, 0.75f);
                startOffset2  = new Vector(0.75f, 0.75f);
                startRotation = 0f;
                break;
            }

            Player1 = new Player()
            {
                Position = (goal + startOffset1) * Track.CELLSIZE, Direction = startRotation
            };
        }
コード例 #3
0
ファイル: Game.cs プロジェクト: rs38/CasualRacer
        public Game(Track track)
        {
            Track = track;
            State = GameState.CountDown;
            CountDown = TimeSpan.FromSeconds(3);

            Vector goal = (Vector)Track.GoalPosition;

            Vector startOffset1 = default(Vector);
            Vector startOffset2 = default(Vector);

            float startRotation = 0f;

            switch (Track.GetTileByIndex((int)goal.X, (int)goal.Y))
            {
                case TrackTile.GoalDown:
                    startOffset1 = new Vector(0.75f, 0.25f);
                    startOffset2 = new Vector(0.25f, 0.25f);
                    startRotation = 180f;
                    break;
                case TrackTile.GoalLeft:
                    startOffset1 = new Vector(0.75f, 0.75f);
                    startOffset2 = new Vector(0.75f, 0.25f);
                    startRotation = -90f;
                    break;
                case TrackTile.GoalRight:
                    startOffset1 = new Vector(0.25f, 0.25f);
                    startOffset2 = new Vector(0.25f, 0.75f);
                    startRotation = 90f;
                    break;
                case TrackTile.GoalUp:
                    startOffset1 = new Vector(0.25f, 0.75f);
                    startOffset2 = new Vector(0.75f, 0.75f);
                    break;
            }

            Player1 = new Player()
            {
                Position = (Point)((goal + startOffset1) * Track.CELLSIZE),
                Direction = startRotation
            };
        }