Exemple #1
0
        public override void Init()
        {
            System.Diagnostics.Debug.WriteLine(Game.GetContentDirectory() + "/Sounds/ui/gameplay/cannot-build.wav");

            spawnFailSound = Game.soundPlayer.LoadSound(Game.GetContentDirectory() + "/Sounds/ui/gameplay/cannot-build.wav", FMOD.MODE._3D_LINEARROLLOFF);

            spawnPowerSource = Game.soundPlayer.LoadSound(Game.GetContentDirectory() + "/Sounds/ui/gameplay/wire-connect-pole.wav", FMOD.MODE._2D);

            spawnSuccess = Game.soundPlayer.LoadSound(Game.GetContentDirectory() + "/Sounds/ui/gameplay/build-large.wav", FMOD.MODE._3D_LINEARROLLOFF);

            woodBoxImpact = Game.soundPlayer.LoadSound(Game.GetContentDirectory() + "/Sounds/physics/wood/wood_box_impact_soft3.wav", FMOD.MODE._3D_LINEARROLLOFF);

            playerCamera = new Engine.Components.CameraComponent(Game, this, new Vector3(0, 0, 0), new Vector3(0, 0, 0));

            components.Add(playerCamera);

            foreach (var comp in components)
            {
                comp.Init();
            }
        }
Exemple #2
0
        protected void LoadMap(string mapName)
        {
            int sizeX = 0;
            int sizeY = 0;
            int resX  = 0;
            int resY  = 0;

            for (int i = 0; i < (_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).ChildrenCount; i++)
            {
                if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i).Id == "xSize")
                {
                    if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) is SpinButton)
                    {
                        if (((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value != null)
                        {
                            sizeX = (int)((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value.GetValueOrDefault();
                        }
                    }
                }
                else if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i).Id == "ySize")
                {
                    if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) is SpinButton)
                    {
                        if (((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value != null)
                        {
                            sizeY = (int)((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value.GetValueOrDefault();
                        }
                    }
                }
                else if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i).Id == "xResolution")
                {
                    if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) is SpinButton)
                    {
                        if (((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value != null)
                        {
                            resX = (int)((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value.GetValueOrDefault();
                        }
                    }
                }
                else if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i).Id == "yResolution")
                {
                    if ((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) is SpinButton)
                    {
                        if (((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value != null)
                        {
                            resY = (int)((_desktop.GetChild(0) as Myra.Graphics2D.UI.Grid).GetChild(i) as SpinButton).Value.GetValueOrDefault();
                        }
                    }
                }
            }

            //generate and init landscape
            foreach (var actor in GenerateLandscape(sizeX, sizeY, resX, resY))
            {
                AddActor(actor); actor.Init();
            }

            mouseDisplayActor = new Engine.Actor(this, "mousedisplay", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f);

            mouseDisplayActor.Components.Add(new Engine.Components.ImageDisplayComponent(this, mouseDisplayActor, "Textures/mouse/icons8-cursor-24"));
            mouseDisplayActor.Components.Add(new Engine.Components.MouseFollowComponent(this, mouseDisplayActor));
            mouseDisplayActor.Init();



            AddActor(new Actor(this, "ConcertHallReverb", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("ConcertHallReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("ConcertHallReverb"), new Vector3(0, 0, 0), FMOD.PRESET.CONCERTHALL(), 32, 32));
            GetActorByName("ConcertHallReverb").Init();

            AddActor(new Actor(this, "QUARRYReverb", new Vector3(128, 0, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("QUARRYReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("QUARRYReverb"), new Vector3(0, 0, 0), FMOD.PRESET.QUARRY(), 32, 32));
            GetActorByName("QUARRYReverb").Init();

            AddActor(new Actor(this, "UNDERWATEReverb", new Vector3(0, 128, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("UNDERWATEReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("UNDERWATEReverb"), new Vector3(0, 0, 0), FMOD.PRESET.UNDERWATER(), 32, 32));
            GetActorByName("UNDERWATEReverb").Init();

            AddActor(new Player(this, "player", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f));
            // GetActorByName("player").Components.Add(new Engine.Components.BasicMovementComponent(this, GetActorByName("player")));
            GetActorByName("player").Components.Add(new Engine.Components.ImageDisplayComponent(this, GetActorByName("player"), "Textures/solid"));



            GetActorByName("player").Init();
            currentCamera = (GetActorByName("player") as Player).playerCamera;
        }
Exemple #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            IsMouseVisible = true;
            #region phys

            //world bounds
            // if bodies reach the end of the world, but it will be slower or stops completly.
            Box2DX.Collision.AABB worldAABB = new Box2DX.Collision.AABB();
            worldAABB.LowerBound.Set(-100.0f, -100.0f);
            worldAABB.UpperBound.Set(100.0f, 100.0f);

            physicsWorld = new Engine.Physics.PhysicsWorld(new Vector2(0, 9.8f).ToBox2DVector(), worldAABB);

            // Define the ground body.
            BodyDef groundBodyDef = new BodyDef();
            groundBodyDef.Position.Set(0.0f / physicsScaleX, 256.0f / physicsScaleY);

            // Call the body factory which creates the ground box shape.
            // The body is also added to the world.
            Body groundBody = physicsWorld.CreateBody(groundBodyDef);

            // Define the ground box shape.
            PolygonDef groundShapeDef = new PolygonDef();

            // The extents are the half-widths of the box.
            groundShapeDef.SetAsBox(1000.0f / physicsScaleX, 10.0f / physicsScaleY);

            // Add the ground shape to the ground body.
            groundBody.CreateShape(groundShapeDef);



            #endregion

            //FMOD.VERSION.dll
            base.Initialize();
            System.Diagnostics.Debug.WriteLine(System.IO.Path.GetFullPath("FMOD/64/fmod.dll"));
            if (System.Environment.Is64BitProcess)
            {
                LoadLibrary(System.IO.Path.GetFullPath("FMOD/64/fmod.dll"));
            }
            else
            {
                LoadLibrary(System.IO.Path.GetFullPath("FMOD/32/fmod.dll"));
            }

            truck = Content.Load <Model>("Models/truck");

            soundPlayer = new Engine.Sound.SoundPlayer(this);
            soundPlayer.Init();


            //generate and init landscape
            foreach (var actor in GenerateLandscape(50, 50, 1, 1))
            {
                AddActor(actor); actor.Init();
            }

            mouseDisplayActor = new Engine.Actor(this, "mousedisplay", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f);

            mouseDisplayActor.Components.Add(new Engine.Components.ImageDisplayComponent(this, mouseDisplayActor, "Textures/mouse/icons8-cursor-24"));
            mouseDisplayActor.Components.Add(new Engine.Components.MouseFollowComponent(this, mouseDisplayActor));
            mouseDisplayActor.Init();



            AddActor(new Actor(this, "ConcertHallReverb", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("ConcertHallReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("ConcertHallReverb"), new Vector3(0, 0, 0), FMOD.PRESET.CONCERTHALL(), 32, 32));
            GetActorByName("ConcertHallReverb").Init();

            AddActor(new Actor(this, "QUARRYReverb", new Vector3(128, 0, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("QUARRYReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("QUARRYReverb"), new Vector3(0, 0, 0), FMOD.PRESET.QUARRY(), 32, 32));
            GetActorByName("QUARRYReverb").Init();

            AddActor(new Actor(this, "UNDERWATEReverb", new Vector3(0, 128, 0), new Vector3(0, 0, 0), 0.0f));
            GetActorByName("UNDERWATEReverb").Components.Add(new Engine.Components.ReverbComponent(this, GetActorByName("UNDERWATEReverb"), new Vector3(0, 0, 0), FMOD.PRESET.UNDERWATER(), 32, 32));
            GetActorByName("UNDERWATEReverb").Init();

            AddActor(new Player(this, "player", new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0.0f));
            // GetActorByName("player").Components.Add(new Engine.Components.BasicMovementComponent(this, GetActorByName("player")));
            GetActorByName("player").Components.Add(new Engine.Components.ImageDisplayComponent(this, GetActorByName("player"), "Textures/solid"));



            GetActorByName("player").Init();
            currentCamera = (GetActorByName("player") as Player).playerCamera;
        }