Пример #1
0
        /*public void OpenDeathMenu()
         * {
         *  new DeathMenu(this.mStateMgr);
         *  this.SwitchGUIVisibility(true);
         *  this.mTimeSinceGUIOpen.Reset();
         * }*/

        public void SwitchFreeCamMode()
        {
            VanillaPlayer mainPlayer = this.mStateMgr.MainState.CharacMgr.MainPlayer;

            if (mainPlayer == null)
            {
                return;
            }

            this.IsFreeCamMode = !this.IsFreeCamMode;

            mainPlayer.SwitchFreeCamMode();

            if (this.IsFreeCamMode)
            {
                Camera     cam         = this.mStateMgr.Camera;
                Vector3    position    = cam.RealPosition;
                Quaternion orientation = cam.RealOrientation;
                cam.DetachFromParent();
                cam.Position    = position;
                cam.Orientation = orientation;

                this.mCameraMan = new CameraMan(cam);
                mainPlayer.SetIsAllowedToMove(false);
            }
            else
            {
                this.InitCamera();
                mainPlayer.SetIsAllowedToMove(true);
                this.mCameraMan = null;
            }
        }
Пример #2
0
        public User(StateManager stateMgr, API.Geo.World world)
        {
            this.mStateMgr         = stateMgr;
            this.mWorld            = world;
            this.mTimeSinceGUIOpen = new Timer();

            this.mCameraMan         = null;
            this.IsAllowedToMoveCam = true;
            this.IsFreeCamMode      = true;
            Camera cam = this.mStateMgr.Camera;

            cam.Position         = new Vector3(-203, 633, -183);
            cam.Orientation      = new Quaternion(0.3977548f, -0.1096644f, -0.8781486f, -0.2421133f);
            this.mCameraMan      = new CameraMan(cam);
            this.mSelectedAllies = new HashSet <VanillaNonPlayer>();
            this.mRandom         = new Random();

            this.mFigures = new MOIS.KeyCode[10];
            for (int i = 0; i < 9; i++)
            {
                this.mFigures[i] = (MOIS.KeyCode)System.Enum.Parse(typeof(MOIS.KeyCode), "KC_" + (i + 1));
            }
            this.mFigures[9] = MOIS.KeyCode.KC_0;

            this.mWireCube = this.mStateMgr.SceneMgr.RootSceneNode.CreateChildSceneNode();
            this.mWireCube.AttachObject(StaticRectangle.CreateRectangle(this.mStateMgr.SceneMgr, Vector3.UNIT_SCALE * Cst.CUBE_SIDE));
            this.mWireCube.SetVisible(false);

            this.Inventory = new Inventory(10, 4, new int[] { 3, 0, 1, 2 }, true);
        }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     if (!manager)
     {
         manager = GetComponent <CameraMan>();
     }
     lastHit = new List <GameObject>();
 }
Пример #4
0
 /// <summary>
 /// If the game is not initializes,so creates GUI, MouseControl, GameObjectManager ,SoundPlayer and mission.
 /// Returns singleton instance.
 /// </summary>
 /// <param name="sceneManager">The Mogre SceneManager.</param>
 /// <param name="c">The game CameraMan for the MouseControl.</param>
 /// <param name="mWindow">The RednerWindow for sending the width and height of the window.</param>
 /// <param name="mouse">The Mogre Mouse for GUI.</param>
 /// <param name="keyboard">The Mogre Keyboard for GUI.</param>
 /// <returns>Returns initializes Game singleton instance.</returns>
 public static Game GetInstance(SceneManager sceneManager, CameraMan c, RenderWindow mWindow, Mouse mouse, Keyboard keyboard)
 {
     if (instance == null)
     {
         instance = new Game(sceneManager, c, mWindow, mouse, keyboard);
     }
     return(instance);
 }
Пример #5
0
 /// <summary>
 /// Initializes MouseControl and stores CameraMan reference.
 /// </summary>
 /// <param name="c">The reference to the game CameraMan.</param>
 /// <param name="sceneWidth">The width of the game window.</param>
 /// <param name="sceneHeight">The height of the game window.</param>
 /// <returns>Return initialized singleton instance.</returns>
 public static MouseControl GetInstance(CameraMan c, int sceneWidth, int sceneHeight)
 {
     if (instance == null)
     {
         instance = new MouseControl(c, sceneWidth, sceneHeight);
     }
     return(instance);
 }
Пример #6
0
 /// <summary>
 /// Initializes camera and cameraMan. Sets the near clip and far clip distance.
 /// </summary>
 protected override void CreateCamera()
 {
     mCamera          = mSceneMgr.CreateCamera("myCam");
     mCamera.Position = cameraStart;
     mCamera.LookAt(Mogre.Vector3.ZERO);
     mCamera.NearClipDistance = 1;
     mCamera.FarClipDistance  = 60000;
     mCameraMan = new Mogre.TutorialFramework.CameraMan(mCamera);
     cameraMan  = mCameraMan;
 }
Пример #7
0
 /// <summary>
 /// Initialzes the Game.
 /// </summary>
 /// <param name="sceneManager">The Mogre SceneManager.</param>
 /// <param name="camera">The game CameraMan for the MouseControl.</param>
 /// <param name="mWindow">The RednerWindow for sending the width and height of the window.</param>
 /// <param name="mouse">The Mogre Mouse for GUI.</param>
 /// <param name="keyboard">The Mogre Keyboard for GUI.</param>
 /// <returns>Returns initializes Game singleton instance.</returns>
 private Game(SceneManager sceneManager, CameraMan camera, RenderWindow mWindow, Mouse mouse, Keyboard keyboard)
 {
     sceneMgr      = sceneManager;
     gameObjectMgr = GameObjectManager.GetInstance();
     gameGUI       = new GameGUI.GameGUI((int)mWindow.Width, (int)mWindow.Height, mouse, keyboard);
     mouseControl  = MouseControl.GetInstance(camera, (int)mWindow.Width, (int)mWindow.Height);
     paused        = true;
     soundPlayer   = new SoundPlayer(mWindow);
     mission       = new Mission();
 }
Пример #8
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Пример #9
0
 /// <summary>
 /// This method create a new camera
 /// </summary>
 protected override void CreateCamera()
 {
     mCamera          = mSceneMgr.CreateCamera("PlayerCam");
     mCamera.Position = new Vector3(0, 100, -200);
     mCamera.LookAt(new Vector3(0, 0, 0));
     mCamera.NearClipDistance = 5;
     mCamera.FarClipDistance  = 1000;
     mCamera.FOVy             = new Degree(70);
     mCameraMan        = new CameraMan(mCamera);
     mCameraMan.Freeze = true;
 }
Пример #10
0
 public void Awake()
 {
     if (CameraMan.instance == null)
     {
         instance = this;
     }
     else if (this != instance)
     {
         Destroy(this.gameObject);
     }
 }
Пример #11
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Пример #12
0
        /// <summary>
        /// This method create a new camera
        /// </summary>
        protected override void CreateCamera()
        {
            mCamera          = mSceneMgr.CreateCamera("PlayerCam"); //create camera with name
            mCamera.Position = new Vector3(0, 40, -85);             //define camera position
            mCamera.LookAt(new Vector3(0, 0, 0));                   //position it is looking at
            mCamera.NearClipDistance = 5;
            mCamera.FarClipDistance  = 1000;                        //limits furthest distance camera can see
            mCamera.FOVy             = new Degree(90);              //field of view - how narrow or wide shot is

            mCameraMan        = new CameraMan(mCamera);             //required by tutorial framework
            mCameraMan.Freeze = true;                               //defines whether camera can move
        }
        public override void Initialize()
        {
            // TODO: Add your initialization logic here
            ranks = new RankManager();
            crosshair = new Crosshair(game.Content);
            h1 = new HUD();
            d1 = new DropBoxManager(game.Content);
            b1 = new background();

            cam = new CameraMan(new Vector2(0, 0));
            cam._pos.Y += service.GraphicsDevice.PresentationParameters.BackBufferHeight / 2;
            cam._pos.X += service.GraphicsDevice.PresentationParameters.BackBufferWidth / 2;
        }
Пример #14
0
        public override void Dispose()
        {
            if (!this.disposed)
            {
                this.disposed = true;
                this.SetupRenderPanelEvents(false);
                this.timer.Stop();
                this.timer.Dispose();

                this.cameraMan = null;
            }

            base.Dispose();
        }
Пример #15
0
        /// <summary>
        /// This method create a new camera
        /// </summary>
        protected override void CreateCamera()
        {
            //base.CreateCamera();
            #region Part 6
            mCamera          = mSceneMgr.CreateCamera("PlayerCam");
            mCamera.Position = new Vector3(000, 100, 250);
            mCamera.LookAt(new Vector3(000, 000, 000));
            mCamera.NearClipDistance = 5;
            mCamera.FarClipDistance  = 1000;
            mCamera.FOVy             = new Degree(70);

            mCameraMan        = new CameraMan(mCamera);
            mCameraMan.Freeze = true;
            #endregion
        }
Пример #16
0
        public override void setup()
        {
            base.setup();

            var root         = this.getRoot();
            var sceneManager = root.createSceneManager();

            var shaderGenerator = ShaderGenerator.getSingleton();

            shaderGenerator.addSceneManager(sceneManager); // must be done before we do anything with the scene

            sceneManager.setAmbientLight(new ColourValue(.1f, .1f, .1f));

            var light     = sceneManager.createLight("MainLight");
            var lightnode = sceneManager.getRootSceneNode().createChildSceneNode();

            lightnode.setPosition(0f, 10f, 15f);
            lightnode.attachObject(light);

            var camera = sceneManager.createCamera("myCam");

            camera.setAutoAspectRatio(true);
            camera.setNearClipDistance(5);
            var camnode = sceneManager.getRootSceneNode().createChildSceneNode();

            camnode.attachObject(camera);

            this.cameraMan = new CameraMan(camnode);
            this.cameraMan.setStyle(CameraStyle.CS_ORBIT);
            this.yaw      = 0;
            this.pitch    = 0.3f;
            this.distance = 15f;

            this.cameraMan.setYawPitchDist(new Radian(this.yaw), new Radian(this.pitch), this.distance);

            var viewport = this.getRenderWindow().addViewport(camera);

            viewport.setBackgroundColour(new ColourValue(.3f, .3f, .3f));

            var ent  = sceneManager.createEntity("Sinbad.mesh");
            var node = sceneManager.getRootSceneNode().createChildSceneNode();

            node.attachObject(ent);

            //var br = ent.getBoundingRadius();
            //br *= 1.25f;
            //this.zoomDistance = br * 0.1f;
        }
Пример #17
0
    public void Ending()
    {
        CameraMan cameraMan = FindObjectOfType <CameraMan>();

        cameraMan.IsCinematic = true; // lol.

        WhiteOutCanvas canvas = FindObjectOfType <WhiteOutCanvas>();

        canvas.GetComponent <Animator>().SetTrigger("FadeOut");

        CharacterMovement charMove = FindObjectOfType <CharacterMovement>();

        charMove.OverrideMovementVector = Vector2.left;
        StartCoroutine(RestoreCharacterControls(3.5f));

        StartCoroutine(RestartGame());
    }
Пример #18
0
        /// <summary>
        /// Creates SelectionRectangle which is used for plane selects and registers it at SceneManager.
        /// Also sets the borders (for camera man movement borders).
        /// </summary>
        /// <param name="c">The reference to the game CameraMan.</param>
        /// <param name="sceneWidth">The width of the game window.</param>
        /// <param name="sceneHeight">The height of the game window.</param>
        private MouseControl(CameraMan c, int sceneWidth, int sceneHeight)
        {
            var stopBoundX = sceneHeight / 20;
            var stopBoundY = sceneWidth / 15;

            upBorder         = sceneHeight / 6;;
            upBorderStop     = upBorder + stopBoundX;
            leftBorder       = sceneWidth / 15;
            leftBorderStop   = leftBorder + stopBoundY;
            rightBorder      = sceneWidth - sceneWidth / 15;
            rightBorderStop  = rightBorder - stopBoundY;
            bottomBorder     = sceneHeight * 7 / 10;
            bottomBorderStop = bottomBorder - stopBoundX;

            cameraMan = c;
            mRect     = new SelectionRectangle("RectangularSelect");
            Game.SceneManager.RootSceneNode.CreateChildSceneNode().AttachObject(mRect);
        }
Пример #19
0
    public override void setup()
    {
        base.setup();
        addInputListener(listener);

        var root   = getRoot();
        var scnMgr = root.createSceneManager();

        var shadergen = ShaderGenerator.getSingleton();

        shadergen.addSceneManager(scnMgr); // must be done before we do anything with the scene

        scnMgr.setAmbientLight(new ColourValue(.1f, .1f, .1f));

        var light     = scnMgr.createLight("MainLight");
        var lightnode = scnMgr.getRootSceneNode().createChildSceneNode();

        lightnode.setPosition(0f, 10f, 15f);
        lightnode.attachObject(light);

        var cam = scnMgr.createCamera("myCam");

        cam.setAutoAspectRatio(true);
        cam.setNearClipDistance(5);
        var camnode = scnMgr.getRootSceneNode().createChildSceneNode();

        camnode.attachObject(cam);

        var camman = new CameraMan(camnode);

        camman.setStyle(CameraStyle.CS_ORBIT);
        camman.setYawPitchDist(new Radian(0), new Radian(0.3f), 15f);
        addInputListener(camman);

        var vp = getRenderWindow().addViewport(cam);

        vp.setBackgroundColour(new ColourValue(.3f, .3f, .3f));

        var ent  = scnMgr.createEntity("Sinbad.mesh");
        var node = scnMgr.getRootSceneNode().createChildSceneNode();

        node.attachObject(ent);
    }
Пример #20
0
    public void DestroyStatue()
    {
        DestroyStatueTrigger.SetActive(true);

        CameraMan cameraMan = FindObjectOfType <CameraMan>();

        cameraMan.IsCinematic = true; // lol.

        GameObject thing = GameObject.Find("BrokenThingWeapon");

        thing.transform.parent = null;
        Animator thingAnim = thing.GetComponent <Animator>();

        thingAnim.SetTrigger("Shoot");

        WhiteOutCanvas canvas = FindObjectOfType <WhiteOutCanvas>();

        canvas.GetComponent <Animator>().SetTrigger("Explode");

        StartCoroutine(DestoryStatueAnimation());
    }
Пример #21
0
    public IEnumerator DestoryStatueAnimation()
    {
        // Time to impact (assuming everything lines up.
        yield return(new WaitForSeconds(2f));

        AudioSource sfx = FindObjectOfType <AudioSource>();

        sfx.PlayOneShot(ExplosionSoundEffect);

        // This is the time for the canvas to turn full white.
        yield return(new WaitForSeconds(0.5f));

        // Break Mr. Boulder while the screen is white
        MrBoulder.SetActive(false);
        BrokenMrBoulder.SetActive(true);

        // Let the visuals settle before undoing Cinema mode.
        yield return(new WaitForSeconds(5f));

        CameraMan cameraMan = FindObjectOfType <CameraMan>();

        cameraMan.IsCinematic = false;
    }
Пример #22
0
 void Awake()
 {
     instance          = this;
     thisCamera        = this.GetComponent <Camera> ();
     originalOrthoSize = thisCamera.orthographicSize;
 }
Пример #23
0
 void Awake()
 {
     instance = this;
 }
Пример #24
0
        public void Execute(CameraMan man)
        {
            if (man.Dirty || _dirty) {

                LookAt = man.LookAt;

                //
                // Distance from
                //
                var distanceToLookAt = (man.Pos3d - man.LookAt3d).Length;
                var near = distanceToLookAt - LandThickness/2;
                if (near < Nearest) {
                    near = Nearest;
                }
                var far = near + LandThickness;

                //
                // Regenerate the matrices
                //
                _projectionMatrix = Matrix4d.CreatePerspectiveFieldOfView (MathHelper.DegreesToRadians (45), _aspect, near, far);
                _projectionMatrixF = ToMatrix4 (_projectionMatrix);
                var pos = man.Pos3d;
                var lookAt = man.LookAt3d;
                var _up = pos;
                _up.Normalize ();
                _viewMatrix = Matrix4d.LookAt (pos, lookAt, _up);
                _viewMatrixF = ToMatrix4 (_viewMatrix);

                //
                // Calculate some spots on the screen so we know what's visible
                //
                ScreenLocations[0] = GetLocation(new PointF(Width, 0));
                ScreenLocations[1] = GetLocation(new PointF(Width, Height/8));
                ScreenLocations[2] = GetLocation(new PointF(Width, Height/3));
                ScreenLocations[3] = GetLocation(new PointF(Width, Height/2));
                ScreenLocations[4] = GetLocation(new PointF(Width, Height*7/8));
                ScreenLocations[5] = GetLocation(new PointF(Width, Height*2/3));
                ScreenLocations[6] = GetLocation(new PointF(Width, Height));

                ScreenLocations[7] = GetLocation(new PointF(0, 0));
                ScreenLocations[8] = GetLocation(new PointF(0, Height/8));
                ScreenLocations[9] = GetLocation(new PointF(0, Height/3));
                ScreenLocations[10] = GetLocation(new PointF(0, Height/2));
                ScreenLocations[11] = GetLocation(new PointF(0, Height*7/8));
                ScreenLocations[12] = GetLocation(new PointF(0, Height*2/3));
                ScreenLocations[13] = GetLocation(new PointF(0, Height));

                ScreenLocations[14] = GetLocation(new PointF(Width/2, 0));
                ScreenLocations[15] = GetLocation(new PointF(Width/2, Height/8));
                ScreenLocations[16] = GetLocation(new PointF(Width/2, Height/3));
                ScreenLocations[17] = GetLocation(new PointF(Width/2, Height/2));
                ScreenLocations[18] = GetLocation(new PointF(Width/2, Height*7/8));
                ScreenLocations[19] = GetLocation(new PointF(Width/2, Height*2/3));
                ScreenLocations[20] = GetLocation(new PointF(Width/2, Height));

                //
                // Calculate the rads per pixel X
                //
                var dp = 100;
                var left = new PointF(Width/2 - dp/2, 15*Height/24);
                var right = new PointF(Width/2 + dp/2, 15*Height/24);
                var leftLoc = GetLocation(left);
                var rightLoc = GetLocation(right);
                var leftPos = GetPosition(left);
                var rightPos = GetPosition(right);
                if (leftLoc != null && rightLoc != null) {
                    var ddegs = rightLoc.VectorTo(leftLoc).Length;
                    RadiansPerPixel = ddegs / dp * Math.PI / 180;

                    var dkm = (rightPos.Value - leftPos.Value).Length;
                    var kmPerPixel = dkm / dp;
                    UnitsPerPixel = (float)(kmPerPixel);
                    MetersPerPixel = kmPerPixel * 1000;

                    //
                    // Calculate the zoom level
                    //
                    var IdealZoom = Math.Log(2*Math.PI / 256 / RadiansPerPixel) / Math.Log(2);
                    Zoom = (int)(IdealZoom + 0.5); // Rounded to nearest
                    if (Zoom > 18) Zoom = 18;
                    else if (Zoom < 4) Zoom = 4;

                    //Console.WriteLine ("rpp = {0}; mpp = {1}; zoom = {2}", RadiansPerPixel, MetersPerPixel, IdealZoom);
                }

                _dirty = false;
                man.Dirty = false;
            }

            GL.MatrixMode (All.Projection);
            GL.LoadMatrix (ref _projectionMatrixF.Row0.X);
            GL.MatrixMode (All.Modelview);
            GL.LoadMatrix (ref _viewMatrixF.Row0.X);
        }
Пример #25
0
    internal IEnumerator PlayConversation(Dialogue dialogue, Transform cameraPosition = null, AfterDialogueEvent afterEvent = null)
    {
        // If a special camera position was provided, tell the camera man to use it.
        ConversationPause();

        CameraMan cameraMan = FindObjectOfType <CameraMan>();

        if (cameraPosition != null)
        {
            cameraMan.StartCinematicMode(cameraPosition);
        }

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        player.GetComponent <CharacterDialogueAnimator>().startTalking();

        DialogueBubbleUI.instance.init(dialogue);

        //Dictionary<string, DialogueAnimator> speakerDict = DialogueEngine.GetSpeakers(dialogue.text).ToDictionary(x => x, x => GameObject.Find(x).GetComponent<DialogueAnimator>());

        int lineTracker = 0;

        //string currentSpeaker = "";
        while (!dialogue.IsFinished)
        {
            ScriptLine line = dialogue.GetNextLine();
            line.PerformLine();
            while (!line.IsFinished())
            {
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    lineTracker--;
                    StartCoroutine(DialogueBubbleUI.instance.animateLogs(lineTracker));
                }
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    lineTracker++;
                    StartCoroutine(DialogueBubbleUI.instance.animateLogs(lineTracker));
                }
                yield return(null);
            }
            lineTracker++;

            /*
             * string currentLine = dialogueLines[lineTracker];
             * if (currentLine.StartsWith("[expression]"))
             * {
             *  print(currentLine);
             *  var expressionString = currentLine.Split(' ')[1];
             *  var expression = (CharacterExpressionAnimator.Expressions)Enum.Parse(typeof(CharacterExpressionAnimator.Expressions), expressionString);
             *  player.GetComponent<CharacterDialogueAnimator>().changeExpression(expression);
             * }
             * else
             * {
             *  string speaker = DialogueEngine.GetSpeaker(currentLine);
             *  string spokenLine = DialogueEngine.GetSpokenLine(currentLine);
             *  if (speaker != "")
             *      currentSpeaker = speaker;
             *  else if (currentSpeaker == "")
             *      Debug.LogWarning("Speaker not specified");
             *  Vector3 speakerPosition = speakerDict[currentSpeaker].getSpeechOrigin();
             *
             *  DialogueUIController.instance.displaySpeechBubble(spokenLine, speakerPosition);
             *  while (!DialogueUIController.instance.ready)
             *      yield return null;
             * }
             * lineTracker++;
             */
        }
        DialogueBubbleUI.instance.finishDialogue();
        player.GetComponent <CharacterDialogueAnimator>().stopTalking();

        while (!DialogueBubbleUI.instance.ready)
        {
            yield return(null);
        }

        ConversationUnpause();

        cameraMan.EndCinematicMode();

        afterEvent();
        yield return(null);
    }
        protected override void SetupCamera()
        {
            int cameraCount;
            int lastCameraCount = 0;
            List<CameraVideoFormat> formats;

            if (cameraManager != null)
                cameraManager.Dispose();
            try
            {
                cameraManager = new CameraMan(null);
            }
            catch { }

            cameraCount = (detectedCameras = cameraManager.Cameras).Count;
            if (cameraCount < 1)
            {
                SelectedCamera = null;
                Ready = false;
                Thread.Sleep(1000);
                return;
            }
            if (lastCameraCount != cameraCount)
            {
                OnCameraCollectionChanged();
                lastCameraCount = cameraCount;
            }
            if (NCamera == null)
            {
                if (cameraNumber < detectedCameras.Count)
                    NCamera = detectedCameras[cameraNumber];
                else
                    NCamera = detectedCameras[0];
                Console("Selecting camera: " + NCamera.ID + ". Availiable formats:");
                if (SelectedCamera.IsCapturing) NCamera.StopCapturing();
                // Set default resolution 320x240
                formats = new List<CameraVideoFormat>();
                foreach (CameraVideoFormat f in NCamera.GetAvailableVideoFormats())
                {
                    Console("\t" + f.FrameWidth.ToString() + " x " + f.FrameHeight.ToString() + " @" + f.FrameRate.ToString() + "fps");
                    //if ((f.FrameWidth == 320) || (f.FrameHeight == 240))
                    if ((f.FrameWidth == 320) || (f.FrameHeight == 240) || (f.FrameWidth == 640) || (f.FrameHeight == 480))
                    //if ((f.FrameWidth == 640) || (f.FrameHeight == 480))
                    {
                        formats.Add(f);
                        //selectedCamera.VideoFormat = f;
                        //break;
                    }
                }
                formats.Sort(new Comparison<CameraVideoFormat>(VideoFormatComparer));
                if (formats.Count > 0)
                {
                    NCamera.VideoFormat = formats[0];
                    Console("Selected Format: " + NCamera.VideoFormat.FrameWidth.ToString() + " x " + NCamera.VideoFormat.FrameHeight.ToString() + " @" + NCamera.VideoFormat.FrameRate.ToString() + "fps");
                }

                OnSelectedCameraChanged();
            }
        }
Пример #27
0
    // Use this for initialization
    void Start()
    {
        if (StartScreen)
        {
            this.CurrentlevelState = LevelState.MainMenu;
            this.InvokeRepeating("PunchTitle", 16.3f, .4f);
        }

        else
            this.CurrentlevelState = LevelState.Start;

        SoundManager.SetVolumeMusic(.25f);

        player = GameObject.Find("Player").GetComponent<Player>();
        cameraMan = Camera.main.GetComponent<CameraMan>();

        //Get all child gameobjects and add them to the checkpoint list
        for (var i = 0; i < transform.childCount; i++)
        {
            var c = transform.GetChild(i).gameObject;
            this.checkpoints.Add(c);
        }

        //Set active checkpoint to first in list
        this.SetActiveCheckpoint(this.checkpoints[0]);
    }
Пример #28
0
        public void Execute(CameraMan man)
        {
            if (man.Dirty || _dirty)
            {
                LookAt = man.LookAt;

                //
                // Distance from
                //
                var distanceToLookAt = (man.Pos3d - man.LookAt3d).Length;
                var near             = distanceToLookAt - LandThickness / 2;
                if (near < Nearest)
                {
                    near = Nearest;
                }
                var far = near + LandThickness;

                //
                // Regenerate the matrices
                //
                _projectionMatrix  = Matrix4d.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45), _aspect, near, far);
                _projectionMatrixF = ToMatrix4(_projectionMatrix);
                var pos    = man.Pos3d;
                var lookAt = man.LookAt3d;
                var _up    = pos;
                _up.Normalize();
                _viewMatrix  = Matrix4d.LookAt(pos, lookAt, _up);
                _viewMatrixF = ToMatrix4(_viewMatrix);

                //
                // Calculate some spots on the screen so we know what's visible
                //
                ScreenLocations[0] = GetLocation(new PointF(Width, 0));
                ScreenLocations[1] = GetLocation(new PointF(Width, Height / 8));
                ScreenLocations[2] = GetLocation(new PointF(Width, Height / 3));
                ScreenLocations[3] = GetLocation(new PointF(Width, Height / 2));
                ScreenLocations[4] = GetLocation(new PointF(Width, Height * 7 / 8));
                ScreenLocations[5] = GetLocation(new PointF(Width, Height * 2 / 3));
                ScreenLocations[6] = GetLocation(new PointF(Width, Height));

                ScreenLocations[7]  = GetLocation(new PointF(0, 0));
                ScreenLocations[8]  = GetLocation(new PointF(0, Height / 8));
                ScreenLocations[9]  = GetLocation(new PointF(0, Height / 3));
                ScreenLocations[10] = GetLocation(new PointF(0, Height / 2));
                ScreenLocations[11] = GetLocation(new PointF(0, Height * 7 / 8));
                ScreenLocations[12] = GetLocation(new PointF(0, Height * 2 / 3));
                ScreenLocations[13] = GetLocation(new PointF(0, Height));

                ScreenLocations[14] = GetLocation(new PointF(Width / 2, 0));
                ScreenLocations[15] = GetLocation(new PointF(Width / 2, Height / 8));
                ScreenLocations[16] = GetLocation(new PointF(Width / 2, Height / 3));
                ScreenLocations[17] = GetLocation(new PointF(Width / 2, Height / 2));
                ScreenLocations[18] = GetLocation(new PointF(Width / 2, Height * 7 / 8));
                ScreenLocations[19] = GetLocation(new PointF(Width / 2, Height * 2 / 3));
                ScreenLocations[20] = GetLocation(new PointF(Width / 2, Height));

                //
                // Calculate the rads per pixel X
                //
                var dp       = 100;
                var left     = new PointF(Width / 2 - dp / 2, 15 * Height / 24);
                var right    = new PointF(Width / 2 + dp / 2, 15 * Height / 24);
                var leftLoc  = GetLocation(left);
                var rightLoc = GetLocation(right);
                var leftPos  = GetPosition(left);
                var rightPos = GetPosition(right);
                if (leftLoc != null && rightLoc != null)
                {
                    var ddegs = rightLoc.VectorTo(leftLoc).Length;
                    RadiansPerPixel = ddegs / dp * Math.PI / 180;

                    var dkm        = (rightPos.Value - leftPos.Value).Length;
                    var kmPerPixel = dkm / dp;
                    UnitsPerPixel  = (float)(kmPerPixel);
                    MetersPerPixel = kmPerPixel * 1000;

                    //
                    // Calculate the zoom level
                    //
                    var IdealZoom = Math.Log(2 * Math.PI / 256 / RadiansPerPixel) / Math.Log(2);
                    Zoom = (int)(IdealZoom + 0.5);                     // Rounded to nearest
                    if (Zoom > 18)
                    {
                        Zoom = 18;
                    }
                    else if (Zoom < 4)
                    {
                        Zoom = 4;
                    }

                    //Console.WriteLine ("rpp = {0}; mpp = {1}; zoom = {2}", RadiansPerPixel, MetersPerPixel, IdealZoom);
                }

                _dirty    = false;
                man.Dirty = false;
            }

            GL.MatrixMode(All.Projection);
            GL.LoadMatrix(ref _projectionMatrixF.Row0.X);
            GL.MatrixMode(All.Modelview);
            GL.LoadMatrix(ref _viewMatrixF.Row0.X);
        }
        protected override void CreateScene() {
            // Set ambient light
            SceneMgr.AmbientLight = new ColourValue(0.7F, 0.7F, 0.7F);

            // Create a skydome
            //SceneMgr.SetSkyDome(true, "Examples/CloudySky", 5, 8);
            //SceneMgr.SetSkyBox(true, "Examples/StormySkyBox", 200f, true);
            SceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox", 200f, true);
            // Define a floor plane mesh
            Mogre.Plane p;
            p.normal = Vector3.UNIT_Y;
            p.d = 50f;
            MeshManager.Singleton.CreatePlane("FloorPlane", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, p, 1000F, 1000F, 20, 20, true, 1, 10F, 10F, Vector3.UNIT_Z);
            putMeshMat("FloorPlane", "Examples/GrassFloor", Vector3.ZERO, false);
            //
            // Create a light
            Light l = SceneMgr.CreateLight("MainLight");
            l.Type = (Light.LightTypes.LT_POINT);
            //l. = 200;
            l.Direction = (new Vector3(0, -1, 1).NormalisedCopy);
            l.DiffuseColour = (new ColourValue(0.5f, 0.5f, 0.5f));
            l.SpecularColour = (new ColourValue(0.1f, 0.1f, 0.1f));
            // Accept default settings: point light, white diffuse, just set position
            // NB I could attach the light to a SceneNode if I wanted it to move automatically with
            //  other objects, but I don't
            l.Position = new Vector3(20F, 30F, 20F);
            //SceneMgr.RootSceneNode.AttachObject(l);


            //throw new NotImplementedException();
            _cameraCtl = new CameraMan(base.Camera);
            _cameraCtl.FastMove = false;

            // Generates every type of primitive
            new PlaneGenerator().setNumSegX(20).setNumSegY(20).setSizeX(150f).setSizeY(150f).setUTile(5.0f).setVTile(5.0f).realizeMesh("planeMesh");
            putMesh2("planeMesh", new Vector3(0, 0, 0));
            new SphereGenerator().setRadius(2.0f).setUTile(5.0f).setVTile(5.0f).realizeMesh("sphereMesh");
            putMesh("sphereMesh", new Vector3(0, 10, 0));
            new CylinderGenerator().setHeight(3.0f).setRadius(1.0f).setUTile(3.0f).realizeMesh("cylinderMesh");
            putMesh("cylinderMesh", new Vector3(10, 10, 0));
            new TorusGenerator().setRadius(3.0f).setSectionRadius(1.0f).setUTile(10.0f).setVTile(5.0f).realizeMesh("torusMesh");
            putMesh("torusMesh", new Vector3(-10, 10, 0));
            new ConeGenerator().setRadius(2.0f).setHeight(3.0f).setNumSegBase(36).setNumSegHeight(2).setUTile(3.0f).realizeMesh("coneMesh");
            putMesh("coneMesh", new Vector3(0, 10, -10));
            new TubeGenerator().setHeight(3.0f).setUTile(3.0f).realizeMesh("tubeMesh");
            putMesh("tubeMesh", new Vector3(-10, 10, -10));
            new BoxGenerator().setSizeX(2.0f).setSizeY(4.0f).setSizeZ(6.0f).realizeMesh("boxMesh");
            putMesh("boxMesh", new Vector3(10, 10, -10));
            //         
            new CapsuleGenerator().setHeight(2.0f).realizeMesh("capsuleMesh");
            putMesh("capsuleMesh", new Vector3(0, 10, 10));
            TorusKnotGenerator tkg = (new TorusKnotGenerator().setRadius(2.0f).setSectionRadius(0.5f).setUTile(3.0f) as TorusKnotGenerator);
            tkg.setNumSegCircle(64).setNumSegSection(16).realizeMesh("torusKnotMesh");
            putMesh("torusKnotMesh", new Vector3(-10, 10, 10));
            //
            new IcoSphereGenerator().setRadius(2.0f).setNumIterations(3).setUTile(5.0f).setVTile(5.0f).realizeMesh("icoSphereMesh");
            putMesh("icoSphereMesh", new Vector3(10, 10, 10));
            new RoundedBoxGenerator().setSizeX(1.0f).setSizeY(5.0f).setSizeZ(5.0f).setChamferSize(1.0f).realizeMesh("roundedBoxMesh");
            putMesh("roundedBoxMesh", new Vector3(20, 10, 10));
            new SpringGenerator().setNumSegCircle(32).setNumSegPath(30).realizeMesh("springMesh");
            putMesh("springMesh", new Vector3(20, 10, 0));

        }
Пример #30
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CameraMan obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #31
0
		protected virtual void CreateCamera()
		{
			Camera = SceneMgr.CreateCamera("PlayerCam");

			Camera.Position = new Vector3(0, 100, 250);

			Camera.LookAt(new Vector3(0, 50, 0));
			Camera.NearClipDistance = 5;

			CameraMan = new CameraMan(Camera);
		}
Пример #32
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            var sz = new Size((int)Frame.Width, (int)Frame.Height);

            if (sz.Width != Size.Width)
            {
                Size = sz;
            }

            MakeCurrent();

            //
            // Initialize drawables
            //
            foreach (var d in _drawablesNeedingLoad)
            {
                d.LoadContent();
            }
            _drawablesNeedingLoad.Clear();

            //
            // Determine the current sim time
            //
            var t       = new NSDate().SecondsSinceReferenceDate;
            var wallNow = DateTime.UtcNow;

            var time = new SimTime()
            {
                Time            = wallNow,
                WallTime        = wallNow,
                TimeElapsed     = t - _lastT,
                WallTimeElapsed = t - _lastT
            };

            _lastT = t;

            //Console.WriteLine ("FPS {0:0}", 1.0 / time.WallTimeElapsed);

            GL.Viewport(0, 0, Size.Width, Size.Height);

            GL.ClearColor(158 / 255.0f, 207 / 255.0f, 237 / 255.0f, 1.0f);
            GL.Clear((int)(All.DepthBufferBit | All.ColorBufferBit));

            //
            // Set the common OpenGL state
            //
            GL.Enable(All.Blend);
            GL.BlendFunc(All.SrcAlpha, All.OneMinusSrcAlpha);
            GL.Enable(All.DepthTest);
            GL.EnableClientState(All.VertexArray);

            //
            // Render the background
            //
            _background.Render();

            //
            // Setup the 3D camera
            //
            Camera.SetViewport(Size.Width, Size.Height);
            CameraMan.Update(time);
            Camera.Execute(CameraMan);

            //
            // Enable the sun
            //
            if (ShowSun)
            {
                GL.Enable(All.Lighting);
                GL.Enable(All.ColorMaterial);

                GL.Enable(All.Light0);
                var sp = _sunLoc.ToPositionAboveSeaLevel(150000000);
                GL.Light(All.Light0, All.Position, new float[] { sp.X, sp.Y, sp.Z, 1 });
            }

            //
            // Draw all the layers
            //
            foreach (var d in _drawables)
            {
                d.Draw(Camera, time);
            }

            if (ShowSun)
            {
                GL.Disable(All.Lighting);
                GL.Disable(All.ColorMaterial);
            }

            SwapBuffers();

            frameCount++;
        }
Пример #33
0
        private Vector3 ProjectedPointToWorld(ProjectedPoint point, CameraMan cameraMan)
        {
            Vector3 v = new Vector3((float)point.Northing, (float)point.Height, (float)point.Easting);

            return(v);
        }
Пример #34
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            var sz = new Size((int)Frame.Width, (int)Frame.Height);

            if (sz.Width != Size.Width)
            {
                Size = sz;
            }

            MakeCurrent();
            GL.Viewport(0, 0, Size.Width, Size.Height);

            var t       = new NSDate().SecondsSinceReferenceDate;
            var wallNow = DateTime.UtcNow;

            var time = new SimTime()
            {
                Time            = wallNow,
                WallTime        = wallNow,
                TimeElapsed     = t - _lastT,
                WallTimeElapsed = t - _lastT
            };

            _lastT = t;

            //Console.WriteLine ("FPS {0:0}", 1.0 / time.WallTimeElapsed);

            GL.ClearColor(158 / 255.0f, 207 / 255.0f, 237 / 255.0f, 1.0f);
            GL.Clear((int)(All.DepthBufferBit | All.ColorBufferBit));

            //
            // Set the common OpenGL state
            //
            GL.Enable(All.Blend);
            GL.BlendFunc(All.SrcAlpha, All.OneMinusSrcAlpha);
            GL.Enable(All.DepthTest);
            GL.EnableClientState(All.VertexArray);

            //
            // Render the background
            //
            _background.Render();

            //
            // Setup the 3D camera
            //
            Camera.SetViewport(Size.Width, Size.Height);
            CameraMan.Update(time);
            Camera.Execute(CameraMan);

            //
            // Enable the sun
            //
            if (ShowSun)
            {
                GL.Enable(All.Lighting);
                GL.Enable(All.ColorMaterial);

                GL.Enable(All.Light0);
                var sp = _sunLoc.ToPositionAboveSeaLevel(150000000);
                GL.Light(All.Light0, All.Position, new float[] { sp.X, sp.Y, sp.Z, 1 });
            }

            //
            // Draw all the layers
            //
            foreach (var d in _draws)
            {
                d.Draw(Camera, time);
            }

            if (ShowSun)
            {
                GL.Disable(All.Lighting);
                GL.Disable(All.ColorMaterial);

//				if (_gesture == WorldView3d.GestureType.Rotating) {
//					var verts = new Vector3[2];
//					var ppp = Location.SunLocation(DateTime.UtcNow.AddHours(-12));
//					verts[0] = ppp.ToPositionAboveSeaLevel(0);
//					verts[1] = ppp.ToPositionAboveSeaLevel(1000);
//					GL.Color4(0, 1.0f, 0, 1.0f);
//					GL.VertexPointer(3, All.Float, 0, verts);
//					GL.DrawArrays(All.Lines, 0, 2);
//					Console.WriteLine (Camera.LookAt);
//					Console.WriteLine (ppp);
//				}
            }


            SwapBuffers();
        }
Пример #35
0
    internal IEnumerator PlayConversation(Dialogue dialogue, Vector3 focusPosition, Transform playerPosition = null, Transform cameraPosition = null, AfterDialogueEvent afterEvent = null)
    {
        // If a special camera position was provided, tell the camera man to use it.
        ConversationPause();

        //External library dependency
        CameraMan cameraMan = FindObjectOfType <CameraMan>();

        // Start Cinematic Mode right away
        if (cameraPosition != null)
        {
            cameraMan.StartCinematicMode(cameraPosition);
            // Don't wait for Camera yet. Let forced player movement start working.
        }

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        if (playerPosition != null)
        {
            // Locate the other speaker
            GameObject otherSpeaker = null;
            foreach (string speakerName in dialogue.speakers)
            {
                GameObject speakerObject = GameObject.Find(speakerName);
                if (speakerObject != player)
                {
                    otherSpeaker = speakerObject;
                }
            }

            SetNpcCollisionBoxes(otherSpeaker, false); // Disable NPC collision boxes while player is moving.
            yield return(player.GetComponent <CharacterMovement>().moveCharacter(playerPosition.position, focusPosition - playerPosition.position, 6f));

            SetNpcCollisionBoxes(otherSpeaker, true);

            // If no cinematic camera position was given, and there is another "speaker" (probably an NPC),
            // put the camera into a magic "dialogue angle"
            if (cameraPosition == null && otherSpeaker != null)
            {
                Vector3 cameraOffset            = new Vector3(0f, 2f, -4.5f); // Magical camera offset vector for 4:3 size.
                Vector3 midpointBetweenSpeakers = (otherSpeaker.transform.position + player.transform.position) * .5f;
                cameraMan.StartCinematicMode(midpointBetweenSpeakers + cameraOffset, Quaternion.identity);
            }
        }

        // Wait for Camera to be in place before we start initializing dialogue options.
        while (!cameraMan.InDesiredPosition())
        {
            yield return(null);
        }

        DialogueBubbleUI.instance.init(dialogue);

        //Dictionary<string, DialogueAnimator> speakerDict = DialogueEngine.GetSpeakers(dialogue.text).ToDictionary(x => x, x => GameObject.Find(x).GetComponent<DialogueAnimator>());

        int        lineTracker = 0;
        GameObject speaker     = null;

        //string currentSpeaker = "";
        while (!dialogue.IsFinished)
        {
            ScriptLine line       = dialogue.GetNextLine();
            GameObject newSpeaker = GameObject.Find(line.speaker);
            if (newSpeaker != null)
            {
                if (newSpeaker != speaker)
                {
                    speaker?.GetComponentInChildren <CharacterDialogueAnimator>()?.stopTalking();
                    speaker = newSpeaker;
                }
                speaker.GetComponentInChildren <CharacterDialogueAnimator>()?.startTalking();
                speaker.GetComponentInChildren <CharacterDialogueAnimator>()?.Turn(focusPosition.x - speaker.transform.position.x);
            }

            line.PerformLine();

            while (!line.IsFinished())
            {
                /* disabled for now
                 * if (Input.GetKeyDown(KeyCode.LeftArrow))
                 * {
                 *  lineTracker--;
                 *  StartCoroutine(DialogueBubbleUI.instance.animateLogs(lineTracker));
                 * }
                 * if (Input.GetKeyDown(KeyCode.RightArrow))
                 * {
                 *  lineTracker++;
                 *  StartCoroutine(DialogueBubbleUI.instance.animateLogs(lineTracker));
                 * }
                 */
                yield return(null);
            }
            lineTracker++;
        }
        DialogueBubbleUI.instance.finishDialogue();
        CharacterDialogueAnimator playerCda = player.GetComponent <CharacterDialogueAnimator>();

        playerCda.stopTalking();
        playerCda.changeExpression(CharacterExpression.normal);

        while (!DialogueBubbleUI.instance.ready)
        {
            yield return(null);
        }

        foreach (string speakerName in dialogue.speakers)
        {
            GameObject newSpeaker = GameObject.Find(speakerName);
            speaker?.GetComponentInChildren <CharacterDialogueAnimator>()?.stopTalking();
        }


        cameraMan.EndCinematicMode();
        // No need to wait for CameraMan

        ConversationUnpause();

        afterEvent();
        yield return(null);
    }