コード例 #1
0
ファイル: cScenes.cs プロジェクト: Rerbun/rcdvk
 public void SetActive(cScene scene)
 {
     activeScene = scene.sceneId;
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: Rerbun/rcdvk
        public override void Start()
        {
            Console.WriteLine("Starting game...");

            //Create the "intro" scene
            intro = _cScenes.CreateScene();
            intro.SetCameraPos(0, 0, 0);
            _cScenes.SetActive(intro);

            cObject logo = intro.CreateObject();
            logo.SetImage(Properties.Resources.bluebarryracer);
            logo.SetPosition(-259, 150);

            cObject instruct = intro.CreateObject();
            instruct.SetImage(Properties.Resources.instruction);
            instruct.SetPosition(-243, -250);

            _cKeyboard.SubscribeKeySingle(new Func<bool>(OpenGame), 32);
            player = new SoundPlayer(Properties.Resources.barryracer);
            player.PlayLooping();

            //Create the "pause" scene
            double oriw = 8000, orih = 8000;
            double ratio = 0.07;

            pause = _cScenes.CreateScene();
            pause.SetCameraPos((oriw / 2) * ratio, (orih / 2) * ratio, 0);
            pause.clearColor = Color.FromArgb(255, 117, 148, 167);

            cObject logo2 = pause.CreateObject();
            logo2.SetImage(Properties.Resources.worldmapsmall);

            double newh = orih * ratio;

            logo2.SetPosition(0, newh - (500 * ratio));

            _cKeyboard.SubscribeKeySingle(new Func<bool>(TogglePauseMenu), 27);

            //Create the "world" scene
            world = _cScenes.CreateScene();
            world.SubscribeUpdater(new Func<bool>(WorldUpdater));
            world.DivideViewport(2);

            //Create all enviroment objects from sceneObjectArray
            foreach (GameObjects.sceneObject obj in GameObjects.sceneObjectArray)
            {
                cObject _obj = world.CreateObject();
                _obj.SetPosition(obj.x, obj.y);
                _obj.SetImage(obj.image);
                _obj.collision = obj.c;
                _obj.collisionType = obj.colType;
            }

            skidmarks = new cObject[200];
            for (int i = 0; i < skidmarks.Length; i++) skidmarks[i] = world.CreateObject();

            CreateFuelPoints();

            for (int i = 0; i < racesobj.Length; i++) racesobj[i] = world.CreateObject();

            //Create a new checkpoint to guide this car though races
            players[0].cp = world.CreateObject();
            players[0].cp.SkipViewport.Add(2);
            players[0].cp.collision = new PointF[] { new PointF(71, 0), new PointF(114, 15), new PointF(137, 49), new PointF(138, 90), new PointF(120, 120), new PointF(95, 137), new PointF(55, 139), new PointF(21, 121), new PointF(4, 93), new PointF(2, 52), new PointF(12, 31), new PointF(36, 8) };
            players[0].cp.collisionType = (int)CollisionType.Checkpoint;
            //Create a new car object
            players[0].car = world.CreateObject();
            players[0].car.SetPosition(2000, 2000);
            players[0].car.SetImage(Cengine.Properties.Resources.car_3);
            players[0].car.collisionCheck = true;
            players[0].car.collisionType = (int)CollisionType.Car;
            players[0].car.collision = new PointF[] { new PointF(8, 4), new PointF(16, 2), new PointF(22, 2), new PointF(31, 2), new PointF(41, 2), new PointF(47, 2), new PointF(47, 0), new PointF(50, 2), new PointF(63, 2), new PointF(74, 2), new PointF(79, 3), new PointF(83, 5), new PointF(86, 8), new PointF(88, 11), new PointF(89, 15), new PointF(89, 19), new PointF(89, 24), new PointF(89, 29), new PointF(87, 32), new PointF(84, 35), new PointF(80, 38), new PointF(73, 38), new PointF(63, 39), new PointF(50, 38), new PointF(48, 41), new PointF(47, 38), new PointF(36, 38), new PointF(27, 39), new PointF(17, 38), new PointF(11, 37), new PointF(7, 35), new PointF(4, 33), new PointF(2, 30), new PointF(3, 22), new PointF(3, 15), new PointF(3, 9) };
            players[0].car.SubscribeCollisionHandler(new Func<PointF, cObject, bool>(CarCollision));
            Car cmod = new Car(this);
            cmod.ConfigControls((int)'W', (int)'S', (int)'A', (int)'D', 32);
            players[0].car.SubscribeCustomModule(cmod);
            players[0].color = Color.FromArgb(255, 217, 68, 59);
            world.FollowObject(players[0].car, 0);

            //Create a new checkpoint to guide this car though races
            players[1].cp = world.CreateObject();
            players[1].cp.SkipViewport.Add(1);
            players[1].cp.collision = new PointF[] { new PointF(71, 0), new PointF(114, 15), new PointF(137, 49), new PointF(138, 90), new PointF(120, 120), new PointF(95, 137), new PointF(55, 139), new PointF(21, 121), new PointF(4, 93), new PointF(2, 52), new PointF(12, 31), new PointF(36, 8) };
            players[1].cp.collisionType = (int)CollisionType.Checkpoint;
            //Create a new car object
            players[1].car = world.CreateObject();
            players[1].car.SetPosition(2000, 2100);
            players[1].car.SetImage(Cengine.Properties.Resources.car_4);
            players[1].car.collisionCheck = true;
            players[1].car.collisionType = (int)CollisionType.Car;
            players[1].car.collision = new PointF[] { new PointF(8, 4), new PointF(16, 2), new PointF(22, 2), new PointF(31, 2), new PointF(41, 2), new PointF(47, 2), new PointF(47, 0), new PointF(50, 2), new PointF(63, 2), new PointF(74, 2), new PointF(79, 3), new PointF(83, 5), new PointF(86, 8), new PointF(88, 11), new PointF(89, 15), new PointF(89, 19), new PointF(89, 24), new PointF(89, 29), new PointF(87, 32), new PointF(84, 35), new PointF(80, 38), new PointF(73, 38), new PointF(63, 39), new PointF(50, 38), new PointF(48, 41), new PointF(47, 38), new PointF(36, 38), new PointF(27, 39), new PointF(17, 38), new PointF(11, 37), new PointF(7, 35), new PointF(4, 33), new PointF(2, 30), new PointF(3, 22), new PointF(3, 15), new PointF(3, 9) };
            players[1].car.SubscribeCollisionHandler(new Func<PointF, cObject, bool>(Car2Collision));
            Car cmod2 = new Car(this);
            cmod2.ConfigControls(38, 40, 37, 39, 17);
            players[1].car.SubscribeCustomModule(cmod2);
            players[1].color = Color.FromArgb(255, 72, 129, 200);
            world.FollowObject(players[1].car, 1);

            //Create all trees from treeArray
            foreach (GameObjects.sceneObject obj in GameObjects.treeArray)
            {
                cObject _obj = world.CreateObject();
                _obj.SetPosition(obj.x, obj.y);
                _obj.SetImage(obj.image);
                _obj.collision = obj.c;
                _obj.collisionType = obj.colType;
            }

            uis[0].speedo = world.CreateObject();
            uis[0].speedo.inScene = false;
            uis[0].count = world.CreateObject();
            uis[0].count.inScene = false;

            uis[1].speedo = world.CreateObject();
            uis[1].speedo.inScene = false;
            uis[1].count = world.CreateObject();
            uis[1].count.inScene = false;

            //Subroutine race initialization
            CreateRaces();
        }
コード例 #3
0
ファイル: cScenes.cs プロジェクト: Rerbun/rcdvk
 public cScene CreateScene()
 {
     cScene s = new cScene(scenes.Count);
     scenes.Add(s);
     return s;
 }