Ejemplo n.º 1
0
        public Player()
        {
            Camera = new GameCamera();

            Mysz          = new MOIS.MouseState_NativePtr();
            InventoryItem = null;
        }
Ejemplo n.º 2
0
        public Player()
        {
            Camera = new GameCamera();

            Mysz = new MOIS.MouseState_NativePtr();
            InventoryItem = null;
        }
Ejemplo n.º 3
0
        public virtual void CreateInput()
        {
            LogManager.Singleton.LogMessage("*** Initializing OIS ***");
            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr         windowHnd;

            window.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            if (this.IsMouseNonExclusive)
            {
                pl.Insert("w32_mouse", "DISCL_FOREGROUND");
                pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
            }

            inputManager = MOIS.InputManager.CreateInputSystem(pl);

            //Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
            inputKeyboard = (MOIS.Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, UseBufferedInput);
            inputMouse    = (MOIS.Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, UseBufferedInput);

            uint width;
            uint height;
            uint depth;
            int  left;
            int  top;

            window.GetMetrics(out width, out height, out depth, out left, out top);
            MOIS.MouseState_NativePtr cState = inputMouse.MouseState;
            cState.width  = (int)width;
            cState.height = (int)height;
        }
Ejemplo n.º 4
0
        public override void CreateInput()
        {
            base.CreateInput();

            IntPtr windowHnd;

            window.GetCustomAttribute("WINDOW", out windowHnd);
            textInputHandler = new MessageHook(windowHnd);
            textInputHandler.MessageReceived += new EventHandler(textInputHandler_MessageReceived);

            inputKeyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(inputKeyboard_KeyPressed);
            inputMouse.MouseMoved    += new MOIS.MouseListener.MouseMovedHandler(inputMouse_MouseMoved);
            inputMouse.MousePressed  += new MOIS.MouseListener.MousePressedHandler(inputMouse_MousePressed);
            inputMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(inputMouse_MouseReleased);

            MOIS.MouseState_NativePtr mouseState = inputMouse.MouseState;
            mouseState.width  = viewport.ActualWidth;
            mouseState.height = viewport.ActualHeight;
        }
Ejemplo n.º 5
0
        protected virtual void HandleInput(FrameEvent evt)
        {
            // Move about 100 units per second,
            float moveScale = camSpeed * evt.timeSinceLastFrame;
            // Take about 10 seconds for full rotation
            Degree rotScale = rotateSpeed * evt.timeSinceLastFrame;

            Vector3 translateVector = Vector3.ZERO;


            // set the scaling of camera motion
            Degree scaleRotate = rotateSpeed * evt.timeSinceLastFrame;

            Vector3 camVelocity = Vector3.ZERO;

            inputKeyboard.Capture();

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_ESCAPE))
            {
                // stop rendering loop
                shutDown = true;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                translateVector.x = -moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                translateVector.x = moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                translateVector.z = -moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                translateVector.z = moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_LEFT))
            {
                camera.Yaw(scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_RIGHT))
            {
                camera.Yaw(-scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_UP))
            {
                camera.Pitch(scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_DOWN))
            {
                camera.Pitch(-scaleRotate);
            }

            // subtract the time since last frame to delay specific key presses
            toggleDelay -= evt.timeSinceLastFrame;

            // toggle rendering mode
            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_R) && toggleDelay < 0)
            {
                if (camera.PolygonMode == PolygonMode.PM_POINTS)
                {
                    camera.PolygonMode = PolygonMode.PM_SOLID;
                }
                else if (camera.PolygonMode == PolygonMode.PM_SOLID)
                {
                    camera.PolygonMode = PolygonMode.PM_WIREFRAME;
                }
                else
                {
                    camera.PolygonMode = PolygonMode.PM_POINTS;
                }

                Console.WriteLine("Rendering mode changed to '{0}'.", camera.PolygonMode);

                toggleDelay = 1;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_T) && toggleDelay < 0)
            {
                // toggle the texture settings
                switch (filtering)
                {
                case TextureFilterOptions.TFO_BILINEAR:
                    filtering = TextureFilterOptions.TFO_TRILINEAR;
                    aniso     = 1;
                    break;

                case TextureFilterOptions.TFO_TRILINEAR:
                    filtering = TextureFilterOptions.TFO_ANISOTROPIC;
                    aniso     = 8;
                    break;

                case TextureFilterOptions.TFO_ANISOTROPIC:
                    filtering = TextureFilterOptions.TFO_BILINEAR;
                    aniso     = 1;
                    break;
                }

                Console.WriteLine("Texture Filtering changed to '{0}'.", filtering);

                // set the new default
                MaterialManager.Singleton.SetDefaultTextureFiltering(filtering);
                MaterialManager.Singleton.DefaultAnisotropy = aniso;

                toggleDelay = 1;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_SYSRQ))
            {
                string[] temp     = System.IO.Directory.GetFiles(Environment.CurrentDirectory, "screenshot*.jpg");
                string   fileName = string.Format("screenshot{0}.jpg", temp.Length + 1);

                TakeScreenshot(fileName);

                // show briefly on the screen
                mDebugText = string.Format("Wrote screenshot '{0}'.", fileName);

                // show for 2 seconds
                debugTextDelay = 2.0f;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_B))
            {
                sceneMgr.ShowBoundingBoxes = !sceneMgr.ShowBoundingBoxes;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_F))
            {
                // hide all overlays, includes ones besides the debug overlay
                viewport.OverlaysEnabled = !viewport.OverlaysEnabled;
            }

            inputMouse.Capture();
            MOIS.MouseState_NativePtr mouseState = inputMouse.MouseState;

            if (!mouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                Degree cameraYaw   = -mouseState.X.rel * .13f;
                Degree cameraPitch = -mouseState.Y.rel * .13f;

                camera.Yaw(cameraYaw);
                camera.Pitch(cameraPitch);
            }
            else
            {
                translateVector.x += mouseState.X.rel * 0.13f;
            }


            // move the camera based on the accumulated movement vector
            camera.MoveRelative(translateVector);

            // update performance stats once per second
            if (statDelay < 0.0f && showDebugOverlay)
            {
                UpdateStats();
                statDelay = 1.0f;
            }
            else
            {
                statDelay -= evt.timeSinceLastFrame;
            }

            // turn off debug text when delay ends
            if (debugTextDelay < 0.0f)
            {
                debugTextDelay = 0.0f;
                mDebugText     = "";
            }
            else if (debugTextDelay > 0.0f)
            {
                debugTextDelay -= evt.timeSinceLastFrame;
            }
        }
Ejemplo n.º 6
0
        public HumanController()
        {
            TargetLabel = Engine.Singleton.Labeler.NewTextLabel3D("Primitive", 0.04f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 0);
            ColLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.04f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            ColLabel.Caption = "Kolizja";
            ColLabel.SetColor(ColourValue.Green, ColourValue.Green);
            ColLabel.SetPosition(0.4f, 0.1f);

            TalkBox = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.05f, 0.85f, 0.9f, 0.1f, new ColourValue(1, 1, 1), 1);
            TalkBox.IsVisible = false;

            TalkLabels = new List<TextLabel>();
            for (int i = 0; i < 8; i++)
            {
                TalkLabels.Add(Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.04f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2));
                TalkLabels[i].SetPosition(0.07f, 0.63f + i * 0.037f);
            }
            ValidReplies = new List<TalkReply>();

            HUDInventory = new HUDInventory();
            HUDContainer = new HUDContainer();
            HUDShop = new HUDShop();
            HUD = new HUD();
            HUDMenu = new HUDMenu();

            Mysz = new MOIS.MouseState_NativePtr();

            light.Type = Light.LightTypes.LT_POINT;
            light.Direction = new Vector3(0, -1, 0).NormalisedCopy;
            light.DiffuseColour = new ColourValue(0.2f, 0.2f, 0.8f);
            light.SpecularColour = new ColourValue(0.3f, 0.3f, 0.9f);
               // light.SetAttenuation(10.0f, 0, 5.0f, 10.0f);
            light.PowerScale = 1.0f;

            l1.Type = Light.LightTypes.LT_POINT;
            l1.DiffuseColour = new ColourValue(1,0,0);
            l1.SpecularColour = new ColourValue(1,0,0);
            l1.PowerScale = 1.0f;
            l1.Visible = false;

            l2.Type = Light.LightTypes.LT_POINT;
            l2.DiffuseColour = new ColourValue(0, 1, 0);
            l2.SpecularColour = new ColourValue(0, 1, 0);
            l2.PowerScale = 1.0f;
            l2.Visible = false;

            l3.Type = Light.LightTypes.LT_POINT;
            l3.DiffuseColour = new ColourValue(0, 0, 1);
            l3.SpecularColour = new ColourValue(0, 0, 1);
            l3.PowerScale = 1.0f;
            l3.Visible = false;

            l4.Type = Light.LightTypes.LT_POINT;
            l4.DiffuseColour = new ColourValue(1, 1, 0);
            l4.SpecularColour = new ColourValue(1, 1, 0);
            l4.PowerScale = 1.0f;
            l4.Visible = false;

            l5.Type = Light.LightTypes.LT_POINT;
            l5.DiffuseColour = new ColourValue(1, 1, 1);
            l5.SpecularColour = new ColourValue(1, 1, 1);
            l5.PowerScale = 1.0f;
            l5.Visible = false;

            l6.Type = Light.LightTypes.LT_POINT;
            l6.DiffuseColour = new ColourValue(1, 0, 1);
            l6.SpecularColour = new ColourValue(1, 0, 1);
            l6.PowerScale = 1.0f;
            l6.Visible = false;

            l7.Type = Light.LightTypes.LT_POINT;
            l7.DiffuseColour = new ColourValue(0, 1, 1);
            l7.SpecularColour = new ColourValue(0, 1, 1);
            l7.PowerScale = 1.0f;
            l7.Visible = false;
        }
Ejemplo n.º 7
0
        public void Initialise()
        {
            Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!Root.RestoreConfig())
                if (!Root.ShowConfigDialog())
                    return;

            Root.RenderSystem.SetConfigOption("VSync", "Yes");
            RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg");  // @@@@@@@@@@@@@@@ Nazwa okna gry.

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC);
            Camera = SceneManager.CreateCamera("MainCamera");
            Viewport = RenderWindow.AddViewport(Camera);
            Camera.NearClipDistance = 0.1f;
            Camera.FarClipDistance = 1000.0f;
            Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height);

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            InputManager = MOIS.InputManager.CreateInputSystem(pl);

            Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            NewtonWorld = new World();
            NewtonDebugger = new Debugger(NewtonWorld);
            NewtonDebugger.Init(SceneManager);

            GameCamera = new GameCamera();
            ObjectManager = new ObjectManager();

            MaterialManager = new MaterialManager();
            MaterialManager.Initialise();

            Items = new Items();
            PrizeManager = new PrizeManager();  //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
            CharacterProfileManager = new CharacterProfileManager();
            Quests = new Quests();
            NPCManager = new NPCManager();

            Labeler = new TextLabeler(5);
            Random = new Random();
            HumanController = new HumanController();

            TypedInput = new TypedInput();

            SoundManager = new SoundManager();

            Dialog = new Dialog();
            Mysz = new MOIS.MouseState_NativePtr();
            Conversations = new Conversations();

            TriggerManager = new TriggerManager();

            Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed);
            Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased);

            IngameConsole = new IngameConsole();
            IngameConsole.Init();
            IngameConsole.AddCommand("dupa", "soundOddawajPiec");
            IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy");
            IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii");
            IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3");
            IngameConsole.AddCommand("map", "ChangeMap");
            IngameConsole.AddCommand("save", "SaveGame");
            IngameConsole.AddCommand("load", "LoadGame");
            IngameConsole.AddCommand("help", "ConsoleHelp");
            IngameConsole.AddCommand("h", "CommandHelp");
        }
Ejemplo n.º 8
0
        public void Initialise()
        {
            Root = new Root();
            ConfigFile cf = new ConfigFile();

            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair <string, string> pair in settings)
                {
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
                }
            }

            if (!Root.RestoreConfig())
            {
                if (!Root.ShowConfigDialog())
                {
                    return;
                }
            }

            Root.RenderSystem.SetConfigOption("VSync", "Yes");
            RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg");  // @@@@@@@@@@@@@@@ Nazwa okna gry.

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            SceneManager            = Root.CreateSceneManager(SceneType.ST_GENERIC);
            Camera                  = SceneManager.CreateCamera("MainCamera");
            Viewport                = RenderWindow.AddViewport(Camera);
            Camera.NearClipDistance = 0.1f;
            Camera.FarClipDistance  = 1000.0f;
            Camera.AspectRatio      = ((float)RenderWindow.Width / (float)RenderWindow.Height);

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr         windowHnd;

            RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            InputManager = MOIS.InputManager.CreateInputSystem(pl);

            Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            Mouse    = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            NewtonWorld    = new World();
            NewtonDebugger = new Debugger(NewtonWorld);
            NewtonDebugger.Init(SceneManager);

            GameCamera    = new GameCamera();
            ObjectManager = new ObjectManager();

            MaterialManager = new MaterialManager();
            MaterialManager.Initialise();


            Items                   = new Items();
            PrizeManager            = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
            CharacterProfileManager = new CharacterProfileManager();
            Quests                  = new Quests();
            NPCManager              = new NPCManager();

            Labeler         = new TextLabeler(5);
            Random          = new Random();
            HumanController = new HumanController();

            TypedInput = new TypedInput();


            SoundManager = new SoundManager();

            Dialog        = new Dialog();
            Mysz          = new MOIS.MouseState_NativePtr();
            Conversations = new Conversations();

            TriggerManager = new TriggerManager();

            Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed);
            Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased);

            IngameConsole = new IngameConsole();
            IngameConsole.Init();
            IngameConsole.AddCommand("dupa", "soundOddawajPiec");
            IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy");
            IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii");
            IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3");
            IngameConsole.AddCommand("map", "ChangeMap");
            IngameConsole.AddCommand("save", "SaveGame");
            IngameConsole.AddCommand("load", "LoadGame");
            IngameConsole.AddCommand("help", "ConsoleHelp");
            IngameConsole.AddCommand("h", "CommandHelp");
        }