Inheritance: MonoBehaviour
コード例 #1
0
    public void ShiftPerspective()
    {
        OrbitCamera oc = shiftCamera.GetComponent <OrbitCamera>();

        if (!isThirdPerson)
        {
            // Switching to third person mode, this will disable/enable the appropriate scripts
            oc.enabled = true;
            shiftCamera.transform.position = player.transform.position + thirdPerson;
            isThirdPerson = true;
            player.GetComponent <RelativeMovement>().enabled = true;
            player.GetComponent <FPSController>().enabled    = false;

            // TODO - get crosshair to deactivate on third person mode
            //crosshair.SetActive(false);
        }
        else
        {
            // Switching to first person mode, this will disable/enable the appropriate scripts
            oc.enabled = false;
            shiftCamera.transform.position = player.transform.position;
            isThirdPerson = false;
            player.GetComponent <RelativeMovement>().enabled = false;
            player.GetComponent <FPSController>().enabled    = true;


            //crosshair.SetActive(true);
        }
    }
コード例 #2
0
        public FKGameState(List <string> modelNames, List <Chunk> modelChunks)
        {
            m_RenderState            = new RenderState();
            m_RenderState.RenderType = RenderState.ENUM_RenderType.eRS_SimpleRender;
            m_CameraState            = new CameraState();
            m_CameraState.CameraType = CameraState.ENUM_CameraType.eCT_Static;
            m_RasterizerState        = new RasterizerState {
                CullMode = CullMode.CullCounterClockwiseFace,
                FillMode = FillMode.WireFrame
            };
            m_ModelNameList  = modelNames;
            m_ModelChunkList = modelChunks;

            // 创建基本图元
            m_DefaultGeoPrimitiveNameList = Utils.GetDefaultGeoPrimitiveNameList();

            m_DefaultGeoPrimitiveList = new List <GeometricPrimitive>();
            m_DefaultGeoPrimitiveList.Add(new CubePrimitive(GraphicsDevice()));
            m_DefaultGeoPrimitiveList.Add(new SpherePrimitive(GraphicsDevice()));
            m_DefaultGeoPrimitiveList.Add(new TorusPrimitive(GraphicsDevice()));
            m_DefaultGeoPrimitiveList.Add(new TeapotPrimitive(GraphicsDevice()));

            // 设置默认对象
            m_nCurrentGeoPrimitiveIndex = 0;
            m_nCurrentChunkIndex        = int.MaxValue;
            m_WorldMatrix = Matrix.Identity;

            // 重计算
            m_Camera = new OrbitCamera(Program.s_GameInstance);
            m_Camera.Update();
        }
コード例 #3
0
    void Start()
    {
        // Initialization
        ApplicationManager.s_instance.ChangeMouseMode((int)ApplicationManager.MouseMode.Pointer);
        UIManager.s_instance.ToggleToolsActive(true, true, true, true);
        UIManager.s_instance.ToggleSidePanel(false, false);
        UIManager.s_instance.hintButton.gameObject.SetActive(false);
        orbitCam = sceneCamera.GetComponent <OrbitCamera>();

        // Init Toggles
        toggles = new bool[15];
        for (int i = 0; i < toggles.Length; i++)
        {
            toggles[i] = false;
        }

        toggles[(int)VToggles.WeighContainerOutside] = true;
        toggles[(int)VToggles.WeightOutside]         = true;

        rightDoorOpenState   = Animator.StringToHash("Base Layer.SMB_RightGlass_Open");
        rightDoorClosedState = Animator.StringToHash("Base Layer.SMB_RightGlass_Closed");
        foreach (ValidateStep step in moduleSteps)
        {
            step.InitToggles();
        }

        // Start Module
        currentStep = -1;
        //GoToNextStep(); This is now being called by closing the intro popup window.
    }
コード例 #4
0
        public D3DApp(IntPtr handleIntPtr)
        {
            this.handleIntPtr = handleIntPtr;

            this.m4XMsaaState     = false;
            this.swapChainBuffers = new Resource[SwapChainBufferCount];
            this.frameResources   = new List <FrameResource>(NumFrameResources);
            this.fenceEvents      = new List <AutoResetEvent>(NumFrameResources);
            this.mainPassCb       = PassConstants.Default;
            this.meshes           = new List <Mesh>();

            this.InitDirect3D();

            this.commandObjects        = new CommandObjects(device);
            this.swapChain             = SwapChainObject.New(this.handleIntPtr, this.factory, this.commandObjects.GetCommandQueue, BackBufferFormat, SwapChainBufferCount, MsaaCount, MsaaQuality);
            this.descriptorHeapObjects = new DescriptorHeapObjects(device, SwapChainBufferCount, 1);
            this.rootSignature         = RootSignatureObject.New(device);

            this.BuildMesh();
            this.BuildFrameResources();
            this.BuildConstantBuffers();
            this.pso = PipelinesStateObject.New(device, rootSignature, MsaaCount, MsaaQuality, DepthStencilFormat, BackBufferFormat);

            this.FlushCommandQueue();

            this.camera = new OrbitCamera();
        }
コード例 #5
0
 private void Awake()
 {
     flyCamera           = Camera.main.GetComponent <FlyCamera> ();
     flyCamera.enabled   = false;
     orbitCamera         = Camera.main.GetComponent <OrbitCamera> ();
     orbitCamera.enabled = true;
 }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HoloStudio" /> class.
        /// </summary>
        public HoloStudio()
        {
            // Creates a graphics manager. This is mandatory.
            _graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";

            // Initialize input keyboard system
            _keyboardManager = new KeyboardManager(this);
            Services.AddService(_keyboardManager);

            // Add service for tweaking
            _tweakableManager = new TweakableManager(this);
            Services.AddService(_tweakableManager);
            _tweakableManager.TextColor = Color.Yellow;

            CenterX = 0;
            CenterY = 0;
            CenterZ = 1;
            Radius  = 1;

            _orbitCamera           = new OrbitCamera();
            _orbitCamera.Radius    = 1.0f;
            _orbitCamera.Speed     = 2.0f;
            _orbitCamera.ZoomSpeed = 0.1f;
            Floor   = -1;
            Ceiling = 2;
        }
コード例 #7
0
    public void ShiftPerspective()
    {
        OrbitCamera oc = shiftCamera.GetComponent <OrbitCamera>();

        if (!isThirdPerson)
        {
            //Debug.Log("Shifted to third person");
            oc.enabled = true;
            shiftCamera.transform.position = player.transform.position + thirdPerson;
            //shiftCamera.transform.rotation = Quaternion.Euler(0, 0, 0)*Quaternion.Euler(0,0,0);
            isThirdPerson = true;
            player.GetComponent <RelativeMovement>().enabled = true;
            player.GetComponent <FPSController>().enabled    = false;

            // TODO - get crosshair to deactivate on third person mode
            //crosshair.SetActive(false);
        }
        else
        {
            //Debug.Log("Shifted to first person");
            oc.enabled = false;
            shiftCamera.transform.position = player.transform.position;
            isThirdPerson = false;
            player.GetComponent <RelativeMovement>().enabled = false;
            player.GetComponent <FPSController>().enabled    = true;


            //crosshair.SetActive(true);
        }
    }
コード例 #8
0
 public override void _Ready()
 {
     _camera    = (OrbitCamera)GetNode <OrbitCamera>(Camera);
     _rigidBody = this;
     _collider  = GetNode <CollisionShape>("CollisionShape");
     Radius     = _collider.Scale.x / 2;
 }
コード例 #9
0
        private void HandleRotation()
        {
            var cameraComponent = OrbitCamera.GetComponent <Camera>();

            if (Input.GetKey(MoveLeft))
            {
                cameraComponent.transform.Rotate(0, TrueSpinRate, 0);
            }
            else if (Input.GetKey(MoveRight))
            {
                cameraComponent.transform.Rotate(0, -TrueSpinRate, 0);
            }

            if (Input.GetKey(MoveForward))
            {
                cameraComponent.transform.Rotate(TrueSpinRate, 0, 0);
            }
            else if (Input.GetKey(MoveBackward))
            {
                cameraComponent.transform.Rotate(-TrueSpinRate, 0, 0);
            }

            if (Input.GetKey(MoveUp))
            {
                cameraComponent.transform.Rotate(0, 0, -TrueSpinRate);
            }
            else if (Input.GetKey(MoveDown))
            {
                cameraComponent.transform.Rotate(0, 0, TrueSpinRate);
            }
        }
コード例 #10
0
        protected override void OnLoad()
        {
            base.OnLoad();

            _frameTimeText = "Frame Time: ";

            _fontRenderer = new FontRenderer(ClientSize.X, ClientSize.Y);

            _shader = Shader.Load("Color", 2, "Assets/Shaders/color.vert", "Assets/Shaders/color.frag");
            _shader.Use();
            _shader.SetupUniforms(new string[] { "model", "viewproj", "color" });

            _projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), (float)ClientSize.X / (float)ClientSize.Y, 0.1f, 1000.0f);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);

            debugDraw = new DebugDraw();

            _plane = new Plane(10, 10, 2.0f);
            _plane.Load();

            _camera = new OrbitCamera(new Vector3(0.0f, 20.0f, 0.0f), new Vector3(5.0f, 0.0f, 5.0f));
        }
コード例 #11
0
        public void Update()
        {
            if (OrbitCamera?.GetComponent <Camera>() == null)
            {
                return;
            }

            if (FirstUpdate)
            {
                var cameraComponent = OrbitCamera.GetComponent <Camera>();
                OriginalPosition = OrbitCamera.target.position;
                OriginalRotation = cameraComponent.transform.rotation;
                DefaultDistance  = OrbitCamera.distance;

                if (FOV > 0)
                {
                    cameraComponent.fieldOfView = FOV;
                }
                DefaultFOV = cameraComponent.fieldOfView;
                Console.WriteLine("Setting FOV: " + cameraComponent.fieldOfView);
                FirstUpdate = false;
            }

            HandleHotkeys();

            if (Input.GetKey(Modifier))
            {
                HandleRotation();
            }
            else
            {
                HandleMovement();
            }
        }
コード例 #12
0
        private void HandleMovement()
        {
            var pos = OrbitCamera.target.position;
            var rot = OrbitCamera.transform.rotation;

            if (Input.GetKey(MoveLeft))
            {
                pos += rot * Vector3.left * TrueMoveRate;
            }
            else if (Input.GetKey(MoveRight))
            {
                pos += rot * Vector3.right * TrueMoveRate;
            }

            if (Input.GetKey(MoveForward))
            {
                pos += rot * Vector3.forward * TrueMoveRate;
            }
            else if (Input.GetKey(MoveBackward))
            {
                pos += rot * Vector3.back * TrueMoveRate;
            }

            if (Input.GetKey(MoveUp))
            {
                pos += Vector3.up * TrueMoveRate;
            }
            else if (Input.GetKey(MoveDown))
            {
                pos += Vector3.down * TrueMoveRate;
            }
            OrbitCamera.SetTargetPos(pos);
        }
コード例 #13
0
ファイル: SnapManager.cs プロジェクト: SunixDev/WoodshopGame
 void Awake()
 {
     DragPieceIndex        = -1;
     PieceSnapping.enabled = false;
     cameraTransform       = GameCamera.transform;
     cameraControl         = GameCamera.GetComponent <OrbitCamera>();
     ActivatePieceSnapping();
 }
コード例 #14
0
    void Start()
    {
        if (freeCamera == null && character.isLocalPlayer)
        {
            freeCamera = GameObject.Instantiate(FreeCamera, this.transform.position, Quaternion.identity);
        }

        ViewUpdate();
    }
コード例 #15
0
 public void OnPlayerAuthorized()
 {
     if (freeCamera == null)
     {
         freeCamera        = GameObject.Instantiate(FreeCamera, this.transform.position, Quaternion.identity);
         freeCamera.Target = this.transform.root.gameObject;
     }
     ViewUpdate();
 }
コード例 #16
0
    // Use this for initialization
    void Start()
    {
        mainCamera = Camera.main.GetComponent <OrbitCamera>();

        towerCenter = new GameObject("Center");
        towerCenter.transform.parent = transform;
        towerCenter.AddComponent <CenterMaintainer>();

        BuildTower();
    }
コード例 #17
0
ファイル: Game1.cs プロジェクト: CartBlanche/MGVoxelViewer
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            graphics.IsFullScreen = false;
            m_cam = new OrbitCamera(this);

            Content.RootDirectory = "Content";
        }
コード例 #18
0
 void Awake()
 {
     GluingPieces                  = new List <GameObject>();
     glue.enabled                  = false;
     selectedPieceIndex            = 0;
     selectedPiecePreviousPosition = Vector3.zero;
     cameraTransform               = GameCamera.transform;
     orbitCameraControl            = GameCamera.GetComponent <OrbitCamera>();
     panCameraControl              = GameCamera.GetComponent <PanCamera>();
     distancePadding               = 2.2f;
 }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: rpenido/obstavoid
        public MainForm()
        {
            InitializeComponent();
            _world = Matrix.CreateWorld(Vector3.Zero, Vector3.Forward, Vector3.Up);

            _camera = new OrbitCamera();
            _camera.cameraAngleX = -90f;

            _robot = new NArticulatedPlanar(spinningTriangleControl.Services, new Vector3(100, 0, 0), 2, _world,
                _camera);
        }
コード例 #20
0
    public override void InitializeGUI()
    {
        if (base._mIsLoaded)
        {
            return;
        }
        base._mIsLoaded        = true;
        _mMainUI               = this.gameObject.transform;
        _mMainUI.parent        = Globals.Instance.MGUIManager.MGUICamera.transform;
        _mMainUI.localPosition = new Vector3(0, 0, 800);
        base.GUILevel          = 25;
        RegisterInfoChange();
        taskConfig = Globals.Instance.MDataTableManager.GetConfig <TaskConfig>();

        UIEventListener.Get(RoleInfo.gameObject).onClick += OnClickPlayerInfoBtn;

        OrbitCamera camera = Globals.Instance.MSceneManager.mMainCamera.transform.parent.GetComponent <OrbitCamera>();

        camera.enabled = true;

        mPlayerDate  = Globals.Instance.MGameDataManager.MActorData;
        mLastLineDay = mPlayerDate.starData.nLineDay;
        mFaintState  = mPlayerDate.BasicData.CountryID;

        UIEventListener.Get(ButtonClothShop.gameObject).onClick   += OnClickButtonFuzhaungdian;
        UIEventListener.Get(ButtonChangeCloth.gameObject).onClick += OnClickButtonHuanzhuang;
        UIEventListener.Get(KTPlay.gameObject).onClick            += OnClickKTPlay;
        UIEventListener.Get(ButtonRanking.gameObject).onClick     += OnClickButtonRanking;
        UIEventListener.Get(ButtonMemory.gameObject).onClick      += OnClickButtonMemory;
        UIEventListener.Get(TrainingBtn.gameObject).onClick       += OnClickTrainingBtn;
        UIEventListener.Get(JobBtn.gameObject).onClick            += OnClickJobBtn;
        UIEventListener.Get(TravelBtn.gameObject).onClick         += OnClickTravelBtn;
        UIEventListener.Get(RestBtn.gameObject).onClick           += OnClickRestBtn;
        UIEventListener.Get(GotoBtn.gameObject).onClick           += OnClickGotoBtn;

        UIEventListener.Get(AutomaticBtn.gameObject).onClick        += OnClickAutomaticBtn;
        UIEventListener.Get(FastBtn.gameObject).onClick             += OnClickFastBtn;
        UIEventListener.Get(SuperFansBtn.gameObject).onClick        += OnClickSuperFansBtn;
        UIEventListener.Get(ChestBtn.gameObject).onClick            += OnClickChestBtn;
        UIEventListener.Get(PromotionalGiftBtn.gameObject).onClick  += OnClickPromotionalGiftBtn;
        UIEventListener.Get(FollowBtn.gameObject).onClick           += OnClickFollowBtn;
        UIEventListener.Get(BorrowTrainingBtn.gameObject).onClick   += OnClickTrainingBtn;
        UIEventListener.Get(BorrowJobBtn.gameObject).onClick        += OnClickJobBtn;
        UIEventListener.Get(BorrowStarPathBtn.gameObject).onClick   += OnClickBorrowStarPathBtn;
        UIEventListener.Get(BorrowExitBtn.gameObject).onClick       += OnClickBorrowExitBtn;
        UIEventListener.Get(AddTimeBorrowingBtn.gameObject).onClick += OnClickAddTimeBorrowingBtn;


        UpdateMainTask();
        UpdateMainTime();
        FaintTreatment(mFaintState);

        Globals.Instance.MTeachManager.NewDateChangeEvent(mPlayerDate.starData.nLineDay);
    }
コード例 #21
0
 public void Start()
 {
     if (cam == null)
     {
         cam = FindObjectOfType <OrbitCamera>();
     }
     if (target == null)
     {
         target = this.transform;
     }
 }
コード例 #22
0
 void windowsPlatformInputs()
 {
     if (Input.GetMouseButton(0))
     {
         OrbitCamera oCamera = mainCamera.GetComponent <OrbitCamera>();
         if (oCamera.enabled)
         {
             oCamera.horizonalAngle += Input.GetAxis("Mouse X") * 5;
             oCamera.verticalAngle  -= Input.GetAxis("Mouse Y") * 5;
         }
     }
 }
コード例 #23
0
ファイル: CameraController.cs プロジェクト: Aaron-Lott/CCTP
    void Start()
    {
        freeCam  = GetComponent <FreeCamera>();
        orbitCam = GetComponent <OrbitCamera>();

        SetOrbitCamera(false);

        if (GameDataController.Instance != null)
        {
            DisableCameraMovement(true);
        }
    }
コード例 #24
0
    void mobilePlatformInputs()
    {
        Camera mainCameraComponent = mainCamera.GetComponent <Camera>();

        Touch[] fingers = Input.touches;
        if (mainCameraComponent.isOrthoGraphic)
        {
            if (Input.touchCount == 1)
            {
                Touch   touch_0 = fingers[0];
                Vector3 currentFingerPosition = getViewPositionFromTouch(mainCameraComponent, touch_0.position);
                if (Input.touchCount != fingerCountPrevious)
                {
                    cameraStartPoint  = mainCamera.transform.localPosition;
                    firstTouchPoint_0 = currentFingerPosition;
                }

                Vector3 delta = firstTouchPoint_0 - currentFingerPosition;
                mainCamera.transform.localPosition = cameraStartPoint + delta;
            }
            else if (Input.touchCount == 2)
            {
                Touch touch_0 = fingers[0];
                Touch touch_1 = fingers[1];

                Vector3 vp_0 = getViewPositionFromTouch(mainCameraComponent, touch_0.position);
                Vector3 vp_1 = getViewPositionFromTouch(mainCameraComponent, touch_1.position);
                if (Input.touchCount != fingerCountPrevious)
                {
                    firstTouchPoint_0 = vp_0;
                    firstTouchPoint_1 = vp_1;
                }

                float firstDeltaDistance   = Mathf.Abs((firstTouchPoint_0 - firstTouchPoint_1).magnitude);
                float currentDeltaDistance = Mathf.Abs((vp_0 - vp_1).magnitude);
                mainCameraComponent.orthographicSize = mainCameraComponent.orthographicSize * (firstDeltaDistance / currentDeltaDistance);
            }
        }
        else
        {
            if (Input.touchCount == 1)
            {
                Touch       touch_0 = fingers[0];
                OrbitCamera oCamera = mainCamera.GetComponent <OrbitCamera>();
                if (oCamera.enabled)
                {
                    oCamera.horizonalAngle += touch_0.deltaPosition.x;
                    oCamera.verticalAngle  -= touch_0.deltaPosition.y;
                }
            }
        }
    }
コード例 #25
0
    void Start()
    {
        ApplicationManager.s_instance.ChangeMouseMode((int)ApplicationManager.MouseMode.Pointer);
        UIManager.s_instance.ToggleToolsActive(true, true, true, true);
        UIManager.s_instance.ToggleSidePanel(true, false);
        UIManager.s_instance.hintButton.gameObject.SetActive(false);
        //HACK remove this line
        //UIManager.s_instance.nextButton.gameObject.SetActive( true );
        submoduleManager = BasePracticeSubmodule.s_instance;
        orbitCam         = sceneCamera.GetComponent <OrbitCamera>();

        currentStepIndex = -1;
    }
コード例 #26
0
 private void Start()
 {
     if (instance != null)
     {
         Destroy(this);
     }
     else
     {
         instance      = this;
         playerControl = GameObject.Find("Player").GetComponent <PlayerControl>();
         orbitCamera   = GameObject.Find("Main Camera").GetComponent <OrbitCamera>();
     }
 }
コード例 #27
0
    private void OnSceneFinishedLoading(Scene scene, LoadSceneMode mode)
    {
        // switch UI
        MainMenuUI.SetActive(false);
        SceneUI.SetActive(true);

        InitializeWorld();

        _orbitCamera = FindObjectOfType <OrbitCamera>();
        _orbitCamera.Initialize(WorldApi);

        // start new scene in camera mode
        ChangeMode((int)GameMode.Camera);
    }
コード例 #28
0
    void Start()
    {
        inputLock = false;

        //カメラコンポーネントの取得
        flyThroughCamera = this.gameObject.GetComponent <FlyThroughCamera>();
        pinchZoomCamera  = this.gameObject.GetComponent <PinchZoomCamera>();
        orbitCamera      = this.gameObject.GetComponent <OrbitCamera>();

        //初期値を保存
        defaultPos = this.gameObject.transform.position;

        ResetInput();
    }
コード例 #29
0
        public MinimapRenderer(int width, int height, WorldManager world, Texture2D colormap)
        {
            ColorMap = colormap;

            RenderWidth  = width;
            RenderHeight = height;
            RenderTarget = new RenderTarget2D(GameState.Game.GraphicsDevice, RenderWidth, RenderHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            World        = world;

            Camera = new OrbitCamera(World, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 2.5f, 1.0f, 0.1f, 1000.0f)
            {
                Projection = global::DwarfCorp.Camera.ProjectionMode.Orthographic
            };
        }
コード例 #30
0
 public virtual void LateUpdate()
 {
     if (this.target)
     {
         this.x = this.x + ((Input.GetAxis("Mouse X") * this.xSpeed) * 0.02f);
         this.y = this.y - ((Input.GetAxis("Mouse Y") * this.ySpeed) * 0.02f);
         this.y = OrbitCamera.ClampAngle(this.y, this.yMinLimit, this.yMaxLimit);
         Quaternion rotation       = Quaternion.Euler(this.y, this.x, 0);
         Vector3    targetPos      = this.target.position + this.targetOffset;
         Vector3    direction      = rotation * -Vector3.forward;
         float      targetDistance = this.AdjustLineOfSight(targetPos, direction);
         this.currentDistance    = Mathf.SmoothDamp(this.currentDistance, targetDistance, ref this.distanceVelocity, this.closerSnapLag * 0.3f);
         this.transform.rotation = rotation;
         this.transform.position = targetPos + (direction * this.currentDistance);
     }
 }
コード例 #31
0
    public override void InitializeGUI()
    {
        if (_mIsLoaded)
        {
            return;
        }
        _mIsLoaded     = true;
        base.GUILevel  = 4;
        camera         = Globals.Instance.MSceneManager.mMainCamera.transform.parent.GetComponent <OrbitCamera>();
        camera.enabled = false;

        Globals.Instance.MSceneManager.mMainCamera.enabled = false;
        Globals.Instance.MSceneManager.mTaskCamera.enabled = false;

        Globals.Instance.MSoundManager.PlaySceneSound("Loading");
    }
コード例 #32
0
 void drawCamera(OrbitCamera aCamera)
 {
     EditorGUILayout.BeginHorizontal();
         EditorGUILayout.Space();
         GUILayout.Label("Unit Camera Variables");
     EditorGUILayout.EndHorizontal();
     aCamera.target = (Transform)EditorGUILayout.ObjectField("Target", aCamera.target, typeof(Transform), true);
     //Y Min max Limits
     EditorGUILayout.BeginHorizontal();
     GUILayout.Label("Y Limits:",GUILayout.MinWidth(150.0f));
     GUILayout.Label("Min");
     aCamera.yMinLimit = EditorGUILayout.FloatField(aCamera.yMinLimit);
     GUILayout.Label("Max");
     aCamera.yMaxLimit = EditorGUILayout.FloatField(aCamera.yMaxLimit);
     EditorGUILayout.EndHorizontal();
     aCamera.maxDistance = EditorGUILayout.FloatField("Max Distance", aCamera.maxDistance);
     aCamera.zoomSpeed = EditorGUILayout.FloatField("Zoom Speed", aCamera.zoomSpeed);
     aCamera.xRotationInputName = EditorGUILayout.TextField("X Rotation Input", aCamera.xRotationInputName);
     aCamera.yRotationInputName = EditorGUILayout.TextField("Y Rotation Input", aCamera.yRotationInputName);
     aCamera.zoomInputName = EditorGUILayout.TextField("Zoom Input", aCamera.zoomInputName);
 }
コード例 #33
0
ファイル: Main.cs プロジェクト: ShipuW/unity-study
        // Use this for initialization
        private void Start()
        {
            //
            if( Application.isEditor )
            {
                m_HideCursor = false;
            }

            //
            if( m_TouchButtonParent == null )
            {
                Debug.LogError( "The TouchButtonParent has not assigned.", this );
                return;
            }
            else
            {
                m_TouchButtons = m_TouchButtonParent.GetComponentsInChildren<TouchButton>( true );

                if( m_TouchButtons != null && m_TouchButtons.Length > 0 )
                {
                    foreach( var btn in m_TouchButtons )
                    {
                        btn.OnClicked = this.OnClicked;
                    }
                }
                else
                {
                    Debug.LogWarning( "The TouchButtons is Null or Length is Zero.", this );
                }

                //
                CustomSpring[] springs = m_TouchButtonParent.GetComponentsInChildren<CustomSpring>( true );

                if( springs != null && springs.Length > 0 )
                {
                    foreach( var spring in springs )
                    {
                        spring.OnHover = this.OnTouchButtonHover;
                    }
                }
                else
                {
                    Debug.LogWarning( "The CustomSprings is Null or Length is Zero.", this );
                }
            }

            //
            if( m_CloseButton == null )
            {
                Debug.LogError("The 'CloseButton' has not assigned!");
                return;
            }

            //
            if (m_SpriteHandLeft == null)
            {
                Debug.LogError("The 'SpriteHandLeft' has not assigned!");
                return;
            }

            if (m_SpriteHandRight == null)
            {
                Debug.LogError("The 'SpriteHandRight' has not assigned!");
                return;
            }

            if ( m_SpriteCursorLoading == null )
            {
                Debug.LogError("The 'SpriteCursorLoading' has not assigned!");
                return;
            }
            //
            //
            if( m_Camera == null )
                m_Camera = Camera.main;

            //
            if( m_Camera == null )
            {
                Debug.LogError( "The Camera has not assigned.", this );
                return;
            }

            //
            if( m_CameraDestination == null )
            {
                Debug.LogError( "The CameraDestination has not assigned.", this );
                return;
            }

            //
            if( m_OrbitCamera == null )
                m_OrbitCamera = m_Camera.GetComponent<OrbitCamera>();

            //
            if( m_OrbitCamera == null )
            {
                Debug.LogError( "The OrbitCamera has not assigned.", this );
                return;
            }

            //
            if( m_CameraMovePath == null || m_CameraMovePath.Length <= 0 )
            {
                Debug.LogError( "The CameraMovePath has not assigned or Length is Zero.", this );
                return;
            }

            //
            if( m_CameraLookPath == null || m_CameraLookPath.Length <= 0 )
            {
                Debug.LogError( "The CameraLookPath has not assigned or Length is Zero.", this );
                return;
            }

            //
            if( m_CameraLookTarget == null )
            {
                Debug.LogError( "The CameraLookTarget has not assigned.", this );
                return;
            }

            //
            if( m_SceneMask == null )
            {
                Debug.LogError( "The SceneMask has not assigned.", this );
                return;
            }

            //
            if(CKinect.KinectServices.Instance == null)
            {
                CKinect.KinectServices.Create(m_SpriteHandLeft,m_SpriteHandRight,m_SpriteCursorLoading);
            }
            else if(CKinect.CursorController.Instance != null)
            {
                CKinect.CursorController.Instance.SpriteHandLeft = m_SpriteHandLeft;
                CKinect.CursorController.Instance.SpriteHandRight = m_SpriteHandRight;
                CKinect.CursorController.Instance.SpriteCursorLoading = m_SpriteCursorLoading;

            }

            if( m_UserVisualPanel == null )
                m_UserVisualPanel = UserManager.Instance.UserVisaulPanel;
            //
            if( m_UserVisualPanel == null )
            {
                Debug.LogError( "The UserVisualPanel has not assigned.", this );
                return;
            }

            UserManager.Instance.OnLockUser = this.OnLockUser;
            //
            m_OrbitCamera.enabled = false;

            //
            m_OrbitCameraDistance = (m_CameraDestination.position - m_OrbitCamera.LookAt.position).magnitude;

            //
            m_CameraOriginLocation = new GameObject().transform;

            m_CameraOriginLocation.position = m_Camera.transform.position;
            m_CameraOriginLocation.rotation = m_Camera.transform.rotation;

            //
            HasInteractive = true;

            //
            m_CloseButton.SetActive( false );

            //
            if( m_HideCursor )
                Screen.showCursor = !m_HideCursor;

            //
            StartCoroutine( DelayInit() );
        }
コード例 #34
0
ファイル: PlayState.cs プロジェクト: chrisapril/dwarfcorp
        /// <summary>
        /// Creates the terrain that is immediately around the player's spawn point.
        /// If loading from a file, loads the existing terrain from a file.
        /// </summary>
        public void GenerateInitialChunks()
        {
            gameFile = null;

            bool fileExists = !string.IsNullOrEmpty(ExistingFile);

            // If we already have a file, we need to load all the chunks from it.
            // This is preliminary stuff that just makes sure the file exists and can be loaded.
            if (fileExists)
            {
                LoadingMessage = "Loading " + ExistingFile;
                gameFile = new GameFile(ExistingFile, true);
                Sky.TimeOfDay = gameFile.Data.Metadata.TimeOfDay;
                WorldOrigin = gameFile.Data.Metadata.WorldOrigin;
                WorldScale = gameFile.Data.Metadata.WorldScale;
                ChunkWidth = gameFile.Data.Metadata.ChunkWidth;
                ChunkHeight = gameFile.Data.Metadata.ChunkHeight;

                if (gameFile.Data.Metadata.OverworldFile != null && gameFile.Data.Metadata.OverworldFile != "flat")
                {
                    LoadingMessage = "Loading world " + gameFile.Data.Metadata.OverworldFile;
                    Overworld.Name = gameFile.Data.Metadata.OverworldFile;
                    DirectoryInfo worldDirectory =
                        Directory.CreateDirectory(DwarfGame.GetGameDirectory() + ProgramData.DirChar + "Worlds" +
                                                  ProgramData.DirChar + Overworld.Name);
                    OverworldFile overWorldFile =
                        new OverworldFile(
                            worldDirectory.FullName + ProgramData.DirChar + "world." + OverworldFile.CompressedExtension,
                            true);
                    Overworld.Map = overWorldFile.Data.CreateMap();
                    Overworld.Name = overWorldFile.Data.Name;
                    WorldWidth = Overworld.Map.GetLength(1);
                    WorldHeight = Overworld.Map.GetLength(0);
                }
                else
                {
                    LoadingMessage = "Generating flat world..";
                    Overworld.CreateUniformLand(Game.GraphicsDevice);
                }

                GameID = gameFile.Data.GameID;

            }
            else
            {
                GameID = Random.Next(0, 1024);
            }

            ChunkGenerator = new ChunkGenerator(VoxelLibrary, Seed, 0.02f, ChunkHeight/2.0f)
            {
                SeaLevel = SeaLevel
            };

            Vector3 globalOffset = new Vector3(WorldOrigin.X, 0, WorldOrigin.Y) * WorldScale;

            if(fileExists)
            {
                globalOffset /= WorldScale;
            }

            // If the file exists, we get the camera's pose from the file.
            // Otherwise, we set it to a pose above the center of the world (0, 0, 0)
            // facing down slightly.
            Camera = fileExists ? gameFile.Data.Camera :
                new OrbitCamera(0, 0, 10f, new Vector3(ChunkWidth, ChunkHeight - 1.0f, ChunkWidth) + globalOffset, new Vector3(0, 50, 0) + globalOffset, MathHelper.PiOver4, AspectRatio, 0.1f, GameSettings.Default.VertexCullDistance);

            Drawer3D.Camera = Camera;

            // Creates the terrain management system.
            ChunkManager = new ChunkManager(Content, (uint) ChunkWidth, (uint) ChunkHeight, (uint) ChunkWidth, Camera,
                GraphicsDevice, Tilesheet,
                TextureManager.GetTexture(ContentPaths.Terrain.terrain_illumination),
                TextureManager.GetTexture(ContentPaths.Gradients.sungradient),
                TextureManager.GetTexture(ContentPaths.Gradients.ambientgradient),
                TextureManager.GetTexture(ContentPaths.Gradients.torchgradient),
                ChunkGenerator, WorldSize.X, WorldSize.Y, WorldSize.Z);

            // Trying to determine the global offset from overworld coordinates (pixels in the overworld) to
            // voxel coordinates.
            globalOffset = ChunkManager.ChunkData.RoundToChunkCoords(globalOffset);
            globalOffset.X *= ChunkWidth;
            globalOffset.Y *= ChunkHeight;
            globalOffset.Z *= ChunkWidth;

            // If there's no file, we have to offset the camera relative to the global offset.
            if(!fileExists)
            {
                WorldOrigin = new Vector2(globalOffset.X, globalOffset.Z);
                Camera.Position = new Vector3(0, 10, 0) + globalOffset;
                Camera.Target = new Vector3(0, 10, 1) + globalOffset;
                Camera.Radius = 0.01f;
                Camera.Phi = -1.57f;
            }

            // If there's no file, we have to initialize the first chunk coordinate
            if(gameFile == null)
            {
                ChunkManager.GenerateInitialChunks(Camera, ChunkManager.ChunkData.GetChunkID(new Vector3(0, 0, 0) + globalOffset), ref LoadingMessage);
            }
            // Otherwise, we just load all the chunks from the file.
            else
            {
                LoadingMessage = "Loading Chunks from Game File";
                ChunkManager.ChunkData.LoadFromFile(gameFile, ref LoadingMessage);
            }

            // If there's no file, for some reason we modify the camera position...
            // TODO: Figure out why the camera keeps needing to be reset.
            if(!fileExists)
            {
                Camera.Radius = 0.01f;
                Camera.Phi = -1.57f / 4.0f;
                Camera.Theta = 0.0f;
            }

            // Finally, the chunk manager's threads are started to allow it to
            // dynamically rebuild terrain
            ChunkManager.RebuildList = new ConcurrentQueue<VoxelChunk>();
            ChunkManager.StartThreads();
        }
コード例 #35
0
ファイル: TowerManager.cs プロジェクト: ruci00/qurmaq
    // Use this for initialization
    void Start()
    {
        mainCamera = Camera.main.GetComponent<OrbitCamera>();

        towerCenter = new GameObject("Center");
        towerCenter.transform.parent = transform;
        towerCenter.AddComponent<CenterMaintainer>();

        BuildTower();
    }
コード例 #36
0
ファイル: OrbitCamera.cs プロジェクト: ShipuW/unity-study
 //
 private void Awake()
 {
     //
     s_Instance = this;
 }
コード例 #37
0
    void Start()
    {
        //設定ファイルより入力タイプを取得
        if(ApplicationSetting.Instance.GetBool("UseMouse"))
            win7touch = true;

        //カメラコンポーネントの取得
        flyThroughCamera = this.gameObject.GetComponent<FlyThroughCamera>();
        orbitCamera = this.gameObject.GetComponent<OrbitCamera>();

        //ズーム位置のルートを設定する
        pinchZoomRoot = new GameObject(this.gameObject.name + " PinchZoom Root");
        pinchZoomRoot.transform.position = this.gameObject.transform.position;
        pinchZoomRoot.transform.rotation= this.gameObject.transform.rotation;
        pinchZoomRoot.transform.localScale = this.gameObject.transform.localScale;
        pinchZoomRoot.transform.parent = this.gameObject.transform.parent;
        this.gameObject.transform.parent = pinchZoomRoot.transform;

        //初期値を保存
        switch(zoomType)
        {
            case PINCH_ZOOM_TYPE.POSITION_Z: defaultZoom = this.gameObject.transform.localPosition.z; break;
            case PINCH_ZOOM_TYPE.FOV: defaultZoom = this.gameObject.camera.fieldOfView; break;
            case PINCH_ZOOM_TYPE.ORTHOSIZE: defaultZoom = this.gameObject.camera.orthographicSize; break;
            default: break;
        }

        //ピンチセンターへのズーム設定
        if(zoomToPinchCenter)
        {
            Camera[] cameras = this.gameObject.camera.GetComponentsInChildren<Camera>();
            foreach(Camera cam in cameras)
            {
                CameraShifter cameraShifter = cam.gameObject.GetComponent<CameraShifter>();
                if(cameraShifter == null)
                    cameraShifter = cam.gameObject.AddComponent<CameraShifter>();
                cameraShifter.calcAlways = true;

                cameraShifterListForZtoPC.Add(cameraShifter);
            }
        }

        ResetInput();
    }
コード例 #38
0
ファイル: OrbitCamera.cs プロジェクト: jshamash/psalmon-xcom
 public ActionTest(OrbitCamera oc)
 {
     _oc = oc;
 }
コード例 #39
0
    void Start()
    {
        inputLock = false;

        //カメラコンポーネントの取得
        flyThroughCamera = this.gameObject.GetComponent<FlyThroughCamera>();
        pinchZoomCamera = this.gameObject.GetComponent<PinchZoomCamera>();
        orbitCamera = this.gameObject.GetComponent<OrbitCamera>();

        //初期値を保存
        defaultPos = this.gameObject.transform.position;

        ResetInput();
    }
コード例 #40
0
ファイル: OutDoor.cs プロジェクト: ShipuW/unity-study
        // Use this for initialization
        private void Start()
        {
            //
            if( m_ButtonClose == null )
            {
                Debug.LogError( "The ButtonClose has not assigned.", this );
                return;
            }

            //
            if( m_ButtonLighting == null )
            {
                Debug.LogError( "The ButtonLighting has not assigned.", this );
                return;
            }

            //
            m_Menu = this.GetComponent<Menu>();

            //
            if( m_Menu == null )
            {
                Debug.LogError( "This GameObject has not assigned Component:'Menu'.", this );
                return;
            }

            //
            m_Menu.OnOpen += this.OnMenuOpen;
            m_Menu.OnOpened += this.OnMenuOpened;

            //
            if( m_OrbitCamera == null )
                m_OrbitCamera = Camera.main.GetComponent<OrbitCamera>();

            //
            if( m_OrbitCamera == null )
            {
                Debug.LogError( "The OrbitCamera has not assigned.", this );
                return;
            }

            //
            StartCoroutine( DelayInit() );
        }