Inheritance: MonoBehaviour
        public Player()
        {
            Camera = new GameCamera();

            Mysz = new MOIS.MouseState_NativePtr();
            InventoryItem = null;
        }
    protected override void onInit(SceneProcedure lastProcedure, string intent)
    {
        // 从待机流程和选择赛道流程跳转过来,正常显示布局
        if (!lastProcedure.isThisOrParent(PROCEDURE_TYPE.PT_START_SETTING))
        {
            // 设置摄像机的变换
            RoleDisplay roleDisplay = mSceneSystem.getScene <RoleDisplay>(GameDefine.ROLE_DISPLAY);
            GameCamera  mainCamera  = mCameraManager.getMainCamera();
            if (!lastProcedure.isThisOrParent(PROCEDURE_TYPE.PT_START_SELECT_TRACK))
            {
                mainCamera.copyCamera(roleDisplay.mCameraPositionObject0);
                LayoutTools.LOAD_NGUI_SHOW(LAYOUT_TYPE.LT_BUTTOM_PROMPT, 9);
            }
            else
            {
                Transform cameraPos0 = roleDisplay.mCameraTransform0;
                ObjectTools.MOVE_OBJECT(mainCamera, mainCamera.getPosition(), cameraPos0.localPosition, 0.5f);
                ObjectTools.ROTATE_OBJECT(mainCamera, mainCamera.getRotation(), cameraPos0.localEulerAngles, 0.5f);
            }
            LayoutTools.LOAD_NGUI_SHOW(LAYOUT_TYPE.LT_SELECT_ROLE, 9);
        }
        // 从设置流程跳转过来,立即显示布局
        else
        {
            LayoutTools.LOAD_NGUI_SHOW(LAYOUT_TYPE.LT_BUTTOM_PROMPT, 9);
        }
        LayoutTools.LOAD_NGUI_SHOW(LAYOUT_TYPE.LT_RETURN, 0);
        // 设置当前选中角色
        CommandStartSceneSelectRole cmd = newCmd(out cmd);

        cmd.mIndex     = mRoleSystem.getSelectedIndex();
        cmd.mPlayAudio = false;
        pushCommand(cmd, mGameScene);
    }
Beispiel #3
0
    public void destroyCamera(string name)
    {
        GameCamera camera = getCamera(name);

        if (camera == null)
        {
            return;
        }
        camera.destroy();
        mCameraList.Remove(name);
        if (camera == mMainCamera)
        {
            mMainCamera = null;
        }
        else if (camera == mUICamera)
        {
            mUICamera = null;
        }
        else if (camera == mUIForeEffectCamera)
        {
            mUIForeEffectCamera = null;
        }
        else if (camera == mUIBackEffectCamera)
        {
            mUIBackEffectCamera = null;
        }
        else if (camera == mUIBlurCamera)
        {
            mUIBlurCamera = null;
        }
    }
Beispiel #4
0
    void Start()
    {
        Screen.SetResolution(1920, 1080, true);
        mapGenerator = GameObject.Find("MapGenerator").GetComponent <MapGenerator> ();
        tutContrl    = GetComponent <TutorialController>();
        maxDepth     = mapGenerator.mapHeight;

        loadMap();

        _player = Instantiate(player, new Vector3(mapGenerator.mapWidth / 2, mapGenerator.mapHeight + 2, 0), Quaternion.identity) as GameObject;

        _controller = Instantiate(controller, new Vector3(_player.transform.position.x, _player.transform.position.y, _player.transform.position.z - 0.5f), Quaternion.Euler(90, 0, 0)) as Controller;
        _controller.transform.parent = _player.transform;
        _controller.setPlayer(_player.GetComponent <PlayerController>());

        cam = cameraObj.GetComponent <GameCamera>();
        cam.SetTarget(_player.transform);

        _hud = Instantiate(hud, transform.position, Quaternion.identity) as HUD;
        _hud.setInfo(_player.GetComponent <PlayerController>(), maxDepth);


        lastLayer   = Mathf.Ceil((mapGenerator.mapHeight - _player.transform.position.y) / (mapGenerator.mapHeight / maxLayers));
        PlayerContl = _player.GetComponent <PlayerController>();

        fuelStyle.normal.background = FuelNormal;

        buttonStateUpdate();
    }
Beispiel #5
0
    // Use this for initialization
    void Start()
    {
        rigidBody = gameObject.GetComponent <Rigidbody2D> ();

        GameObject panel = GameObject.FindGameObjectWithTag("Panel");

        if (panel)
        {
            os = panel.GetComponent <Options>();
        }
        GameObject hudinstance = GameObject.FindGameObjectWithTag("HUD");

        if (hudinstance)
        {
            hud = hudinstance.GetComponent <HUD>();
        }

        audioSources  = gameObject.GetComponents <AudioSource>();
        currentVolume = globalVolume;
        changeVolume(currentVolume);

        thePrincess     = GameObject.FindGameObjectWithTag("Player").GetComponent <Princess> ();
        theCamera       = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <GameCamera> ();
        collisionDamage = 0;
        position        = transform.position;
        maxHspeed       = .5f;
        maxVspeed       = 0.2f;
        runAcceleration = 0.1625f;
    }
 public virtual void Draw(GameCamera camera)
 {
     foreach (Particle particle in particles)
     {
         particle.Draw(camera);
     }
 }
Beispiel #7
0
    // Token: 0x060004F2 RID: 1266 RVA: 0x00028E98 File Offset: 0x00027098
    private void Update()
    {
        Player localPlayer = Player.m_localPlayer;

        if (localPlayer && !InventoryGui.IsVisible() && !Menu.IsVisible() && !GameCamera.InFreeFly())
        {
            if (ZInput.GetButtonDown("JoyDPadLeft"))
            {
                this.m_selected = Mathf.Max(0, this.m_selected - 1);
            }
            if (ZInput.GetButtonDown("JoyDPadRight"))
            {
                this.m_selected = Mathf.Min(this.m_elements.Count - 1, this.m_selected + 1);
            }
            if (ZInput.GetButtonDown("JoyDPadUp"))
            {
                localPlayer.UseHotbarItem(this.m_selected + 1);
            }
        }
        if (this.m_selected > this.m_elements.Count - 1)
        {
            this.m_selected = Mathf.Max(0, this.m_elements.Count - 1);
        }
        this.UpdateIcons(localPlayer);
    }
Beispiel #8
0
 void Awake()
 {
     main = this;
     cam  = GetComponent <Camera>();
     UIAssistant.onScreenResize += OnScreenResize;
     OnScreenResize();
 }
    // Token: 0x06000428 RID: 1064 RVA: 0x00021AA0 File Offset: 0x0001FCA0
    private void LateUpdate()
    {
        Camera mainCamera = Utils.GetMainCamera();

        if (Player.m_localPlayer == null || mainCamera == null)
        {
            return;
        }
        Vector3 vector = Vector3.zero;

        if (this.m_follow == FollowPlayer.Type.Camera || GameCamera.InFreeFly())
        {
            vector = mainCamera.transform.position;
        }
        else
        {
            vector = Player.m_localPlayer.transform.position;
        }
        if (this.m_lockYPos)
        {
            vector.y = base.transform.position.y;
        }
        if (vector.y > this.m_maxYPos)
        {
            vector.y = this.m_maxYPos;
        }
        base.transform.position = vector;
    }
    public Camera OverrideCamera(Transform parent, bool applyEffects)
    {
        Camera component = parent.GetComponent <Camera>();

        if (component == null)
        {
            component         = UnityEngine.Object.Instantiate(Game.instance.cameraPrefab.gameObject, parent, worldPositionStays: false).GetComponent <Camera>();
            destroyTempOnExit = true;
        }
        else
        {
            destroyTempOnExit = false;
        }
        tempCamera = WrapCamera(component);
        for (int i = 0; i < gameCameras.Count; i++)
        {
            gameCameras[i].camera.gameObject.SetActive(value: false);
        }
        activeCameras.Clear();
        if (applyEffects)
        {
            activeCameras.Add(tempCamera);
            ApplyEffects();
        }
        Listener.instance.OverrideTransform(component.transform);
        return(component);
    }
Beispiel #11
0
        public void DrawReflectionMap(GameCamera.FreeCamera camera, float time, LightsAndShadows.Shadow shadow, LightsAndShadows.Light light, QuadTree tree)
        {
            Plane reflectionPlane = CreatePlane(waterHeight - 0.5f, new Vector3(0, -1, 0), camera.reflectionViewMatrix, true);
            //device.ClipPlanes[0].Plane = reflectionPlane;
            //device.ClipPlanes[0].IsEnabled = true;
            //device.SetRenderTarget(0, reflectionRenderTarget);

            effect.Parameters["ClipPlane0"].SetValue(new Vector4(reflectionPlane.Normal, reflectionPlane.D));
            //effect.Parameters["ClipPlane0"].SetValue(new Vector4(-reflectionPlane.Normal, -reflectionPlane.D));

            effect.Parameters["Clipping"].SetValue(true);    // Allows the geometry to be clipped for the purpose of creating a refraction map
            device.SetRenderTarget(reflectionRenderTarget);

            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
            sky.DrawSkyDome(camera);
               // tree.Draw(camera, time, shadow, light);

            //device.ClipPlanes[0].IsEnabled = false;
            effect.Parameters["Clipping"].SetValue(false);

            //device.SetRenderTarget(0, null);
            device.SetRenderTarget(null);

            reflectionMap = reflectionRenderTarget;
            //System.IO.Stream ss = System.IO.File.OpenWrite("C:\Test\Reflection.jpg");
            //reflectionRenderTarget.SaveAsJpeg(ss, 500, 500);
            //ss.Close();
        }
Beispiel #12
0
 public PoolManager([Inject] GameCamera cam, List <PoolData> poolData)
 {
     objectPoolData = new Dictionary <int, PoolableData>();
     poolableMap    = new Dictionary <int, Stack <Poolable> >();
     gameCamera     = cam;
     ProcessPoolData(poolData);
 }
 public override void Draw(GameCamera camera)
 {
     if (Active)
     {
         base.Draw(camera);
     }
 }
Beispiel #14
0
    /// <summary>
    /// Check if Touch t is inside right finger - tap zone
    /// </summary>
    /// <param name="t"></param>
    /// <returns></returns>
    private bool IsOnRightFingerZone(Touch t, out Touch normalizedT)
    {
        Vector2 tWorldPosition;

        //RaycastHit2D[] raycastHitResults = null;
        //if (Physics.Raycast(t.position, Vector2.right, .1f, raycastHitResults))
        normalizedT    = t;
        tWorldPosition = GameCamera.ScreenToWorldPoint(t.position);
        if (tWorldPosition.x > (_minRightFingerRef.position.x - _marginSaverDist) && tWorldPosition.x < (_maxRightFingerRef.position.x + _marginSaverDist) &&
            !UIHelper.Instance.ContainsPauseBtn(/*tWorldPosition*/ t.position))
        {
            //left margin saver
            if (tWorldPosition.x < _minRightFingerRef.position.x)
            {
                normalizedT.position = new Vector2(_minLeftFingerRef.position.x, t.position.y);
            }
            //right margin saver
            else if (tWorldPosition.x > _maxRightFingerRef.position.x)
            {
                normalizedT.position = new Vector2(_minLeftFingerRef.position.x, t.position.y);
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public void Init(GameCamera _gameCamera)
    {
        if (Data.Instance.userData.mode == UserData.modes.MULTIPLAYER)
        {
            isMultiplayer = true;
        }

        wind_stops            = Data.Instance.gameSettings.wind_stops;
        PU_BOOST_Acceleration = Data.Instance.gameSettings.PU_BOOST_Acceleration;
        PU_BOOST_duration     = Data.Instance.gameSettings.PU_BOOST_duration;
        PU_PAUSED_duration    = Data.Instance.gameSettings.PU_PAUSED_duration;

        GameSettings gameSettigns = Data.Instance.gameSettings;

        initialAacceleration = gameSettigns.player.initialAacceleration;
        initialDeceleration  = gameSettigns.player.initialDeceleration;
        decelerationJump     = gameSettigns.player.jumpDeceleration;
        speedJump            = gameSettigns.player.speedJump;

        gameCamera   = _gameCamera;
        acceleration = initialAacceleration;
        deceleration = initialDeceleration;

        if (isMultiplayer)
        {
            Events.OnPowerUpActive += OnPowerUpActive;
        }

        Events.OnAvatarJump    += OnAvatarJump;
        Events.OnAvatarRun     += OnAvatarRun;
        Events.OnLevelComplete += OnLevelComplete;
        Events.GameOver        += GameOver;
    }
Beispiel #16
0
 private void Update()
 {
     MouseDelta   = Input.mousePosition - prevMousePos;
     prevMousePos = Input.mousePosition;
     if (IsPaused && pauseScreen.activeSelf && Input.GetKeyDown(KeyCode.Escape))
     {
         UnpauseGame();
         return;
     }
     if (!IsIdle)
     {
         return;
     }
     if (Input.GetKeyDown(KeyCode.Escape) && (!SelectableObject.selected || SelectableObject.selected == main))
     {
         PauseGame();
         return;
     }
     if (frankCount == 0)
     {
         Win();
         return;
     }
     time  += Time.deltaTime;
     money += moneyGain * Time.deltaTime;
     MoneyText.SetNumber((int)money);
     GameCamera.HandleUpdate();
 }
 /// <summary>
 /// Rotate the camera with gyro.
 /// </summary>
 /// <param name="camera"></param>
 private void RotateCamera_Mobile(GameCamera camera)
 {
     camera.transform.Rotate(
         -Input.gyro.rotationRateUnbiased.x * GyroRotationSpeedX,
         -Input.gyro.rotationRateUnbiased.y * GyroRotationSpeedY,
         0);// -Input.gyro.rotationRateUnbiased.z * GyroRotationSpeedY);
 }
    private void Start()
    {
        instance = GameManager.Instance;
        cam      = GameCamera.Instance;

        Initialize(_fogImmediately: true);
    }
Beispiel #19
0
    private IEnumerator AnimateGameOver(Frank frank)
    {
        var t           = 0.0f;
        var frankStart  = frank.transform.position;
        var cameraStart = GameCamera.transform.position;

        while (t < cameraTime)
        {
            t += Time.deltaTime;
            frank.transform.position = Vector3.Lerp(frankStart, endTarget.position, t / cameraTime);
            var camPos = Vector3.Lerp(cameraStart, endTarget.position, t / cameraTime);
            camPos.z = cameraStart.z;
            GameCamera.transform.position = camPos;
            GameCamera.CheckBounds();
            yield return(null);
        }
        frank.transform.SetParent(endTarget);
        frank.finalSkip = false;
        t = 0.0f;
        var startBoat = endTarget.position;

        SFXManager.Instance.PlaySFX("Rowing");
        while (t < endTime)
        {
            t += Time.deltaTime;
            endTarget.transform.position = Vector3.Lerp(
                startBoat, endTarget2.position, t / endTime);
            yield return(null);
        }
        SFXManager.Instance.PlaySFX("GameOver");
        gameOverScreen.SetActive(true);
    }
Beispiel #20
0
    /// <summary>
    /// Despawns an enemy from the mob that is invisible to the camera. Used to control game difficulty.
    /// </summary>
    public void DespawnEnemy()
    {
        // Stores the camera which displays the world.
        GameCamera camera = GameManager.Instance.GameCamera;

        // Cycle through the list of enemies and find one that is invisible to the camera
        for (int i = enemies.Count - 1; i >= 0; i--)
        {
            Character enemy = enemies[i];

            // If the enemy is invisible to the camera
            if (!camera.IsViewable(enemy.Transform.position))
            {
                Debug.Log("Kill the enemy " + enemy);
                // Tell the EnemyMob that the enemy has died so that it is removed from the enemy mob.
                OnEnemyDeath(enemy);

                // Kill the enemy.
                enemy.Die();
                enemy.gameObject.SetActive(false);
            }
            else
            {
                Debug.Log("CANNOT kill the enemy " + enemy);
            }
        }
    }
Beispiel #21
0
 public void init()
 {
     // 默认获取主摄像机
     mMainCamera     = getCamera("Main Camera");
     mUIEffectCamera = getCamera("EffectCamera");
     mUICamera       = getCamera("UICamera");
 }
Beispiel #22
0
    /// <summary>
    /// Positions the player at the current spawn point
    /// Forces the camera to snap to the player
    /// Displays all menus
    /// </summary>
    /// <returns></returns>
    IEnumerator LevelStartRoutine()
    {
        DisableMenus();
        // Player should always start facing to the right
        PlayerScript.transform.rotation = Quaternion.LookRotation(Vector3.right);

        // Ensure the player is inside the level
        PlayerScript.transform.position = new Vector3(
            PlayerScript.transform.position.x,
            PlayerScript.transform.position.y,
            0f
            );

        PlayerScript.ControlsEnabled    = false;
        PlayerScript.transform.position = PlayerSpawnPoint;

        GameCamera.Target = PlayerScript.transform;

        // Player has respawned
        if (PlayerScript.IsDead)
        {
            PlayerScript.Respanwed();
        }

        // This could be a player respawn from being dead
        // So make sure we they are no logner dead
        PlayerScript.IsDead = false;

        GameCamera.Track(false);
        PlayerScript.ControlsEnabled = true;

        yield return(null);
    }
        public override void Draw(GameCamera camera)
        {
            generator.Draw(camera);

            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.Alpha = transparency;
                }
            }

            base.Draw(camera);

            Scale = Scale + OUTER_EXTRA_SIZE;
            foreach (ModelMesh mesh in explosion.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.Alpha = MathHelper.Max(outerAlpha - transparency, 0);
                }
            }
            drawExtraModel(camera, explosion);
            //foreach (ModelMesh mesh in explosion.Meshes)
            //{
            //    foreach (BasicEffect effect in mesh.Effects)
            //    {
            //        effect.Alpha = 1f;
            //    }
            //}
            Scale = Scale - OUTER_EXTRA_SIZE;
        }
Beispiel #24
0
    private void OnTriggerStay2D(Collider2D collider)
    {
        if (collider.gameObject.name.Equals("Player"))
        {
            if (GameObject.FindWithTag("InputManager").GetComponent <InputManager>().controlableCharacter.Equals(collider.GetComponent <Move>()))
            {
                if (activated < 0)
                {
                    if (Input.GetButtonDown("Fire1"))
                    {
                        activated = 1f;

                        collider.gameObject.GetComponent <Move>().SetActive(false);


                        GameCamera.SetFocus(GameObject.Find("Ship"));
                        GameObject.FindWithTag("InputManager").GetComponent <InputManager>().controller = GameObject.Find("Ship").GetComponent <Move>();

                        GameObject.FindGameObjectWithTag("Prompt").GetComponent <Prompt>().Show("Press <sprite=8> to Dock");
                    }
                }
                else
                {
                    activated -= Time.deltaTime;
                }
            }
        }
    }
Beispiel #25
0
    // Use this for initialization
    void Start()
    {
        rigidBody = gameObject.GetComponent <Rigidbody2D> ();
        GameObject panel = GameObject.FindGameObjectWithTag("Panel");

        if (panel)
        {
            os = panel.GetComponent <Options>();
        }
        GameObject hudinstance = GameObject.FindGameObjectWithTag("HUD");

        if (hudinstance)
        {
            hud = hudinstance.GetComponent <HUD>();
        }
        theCamera    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <GameCamera> ();
        thePrincess  = GameObject.FindGameObjectWithTag("Player").GetComponent <Princess> ();
        counterCycle = startCycle;

        audioSources  = gameObject.GetComponents <AudioSource>();
        currentVolume = globalVolume;
        changeVolume(currentVolume);
        adjacentPlatformCheck(gameObject.GetComponent <BoxCollider2D>(), LayerMask.NameToLayer("Platforms"));

        counterLife = 0;
        gravity     = 0.0125f;
        position    = transform.position;
        maxVspeed   = .2f;
    }
Beispiel #26
0
        public override void LoadContent()
        {
            ContentManager content = this.ScreenManager.Game.Content;

            this.player = new Player();

            this.graphicsDevice = this.ScreenManager.GraphicsDevice;
            this.spriteBatch    = this.ScreenManager.SpriteBatch;

            viewport = graphicsDevice.Viewport;

            bg1           = content.Load <Texture2D>("bg1");
            bg2           = content.Load <Texture2D>("bg2");
            asteroid      = content.Load <Texture2D>("asteroid");
            playerTexture = content.Load <Texture2D>("player");
            bulletTexture = content.Load <Texture2D>("bullet");
            ufoTexture    = content.Load <Texture2D>("UFO");

            font   = content.Load <SpriteFont>("Orbitron");
            font_S = content.Load <SpriteFont>("Orbitron_S");

            player.Initialize(playerTexture);

            cam     = new GameCamera(player.Position, viewport, worldWidth, worldHeight);
            cam.Pos = this.player.Position;
        }
Beispiel #27
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime, GameCamera camera)
 {
     foreach (var layer in Layers.Select(iLayer => iLayer))
     {
         layer.Draw(spriteBatch, gameTime, camera);
     }
 }
        private static void Prefix(GameCamera __instance)
        {
            if (AEM.isActive)
            {
                __instance.m_maxDistance = __instance.m_distance;
                __instance.m_minDistance = __instance.m_distance;
            }
            else
            {
                if (Configuration.Current.Camera.IsEnabled)
                {
                    if (Configuration.Current.Camera.cameraMaximumZoomDistance >= 1 && Configuration.Current.Camera.cameraMaximumZoomDistance <= 100)
                    {
                        __instance.m_maxDistance = Configuration.Current.Camera.cameraMaximumZoomDistance;
                    }
                    if (Configuration.Current.Camera.cameraBoatMaximumZoomDistance >= 1 && Configuration.Current.Camera.cameraBoatMaximumZoomDistance <= 100)
                    {
                        __instance.m_maxDistanceBoat = Configuration.Current.Camera.cameraBoatMaximumZoomDistance;
                    }
                    if (Configuration.Current.Camera.cameraFOV >= 1 && Configuration.Current.Camera.cameraFOV <= 140)
                    {
                        __instance.m_fov = Configuration.Current.Camera.cameraFOV;
                    }

                    __instance.m_minDistance = 1;
                }
                else
                {
                    __instance.m_maxDistance = 6;
                    __instance.m_minDistance = 1;
                }
            }
        }
Beispiel #29
0
 protected Scene()
 {
     camera = new GameCamera(this, new Vector3(0.0f, 50.0f, 0.0f), new Quaternion(), Space394Game.GameInstance.AspectRatio);
     sceneObjects = new Dictionary<int, SceneObject>();
     queuedForAdd = new List<SceneObject>();
     queuedForRemoval = new List<SceneObject>();
 }
Beispiel #30
0
 public void SetReferences(int entityID, EntityManager manager, GameCamera cam, Pathfinder pathfinder)
 {
     this.manager    = manager;
     this.entityID   = entityID;
     this.cam        = cam;
     this.pathfinder = pathfinder;
 }
Beispiel #31
0
		//ncrunch: no coverage end

		private void InitializeCamera()
		{
			Camera = new GameCamera(1 / 25.0f, 1 / 10.0f, 0.01f);
			Camera.AllowedMovementRect = Rectangle.FromCenter(Vector2D.Half,
				new Size(Size.Width, Size.Height) * 1.5f);
			Camera.ResetToMinZoom();
		}
        private static void UpdateStandingStillAnimationState(Player p, GameCamera c, ref Quaternion rot)
        {
            switch (_configForceBodyRotationModeWhileStandingStill.Value)
            {
            case ForceBodyRotationMode.AlwaysForward:
                p.FaceLookDirection();
                break;

            case ForceBodyRotationMode.LockNearShoulders:
                LockToShoulders(p, c, ref rot);
                break;

            case ForceBodyRotationMode.ForceRotateAtShoulders:
                ForceRotateAtShoulders(p, c);
                break;

            case ForceBodyRotationMode.SnapRotateAtShoulders:
                SnapRotateAtShoulders(p, c);
                break;

            case ForceBodyRotationMode.RotateFreely:     // do nothing!
                break;

            default:
                break;
            }
        }
Beispiel #33
0
    public override void execute()
    {
        GameCamera camera = (mReceiver) as GameCamera;

        camera.linkTarget(mLinkerName, mTarget);
        if (mTarget != null)
        {
            CameraLinker linker = camera.getComponent(mLinkerName) as CameraLinker;
            if (linker != null)
            {
                linker.setLookAtTarget(mLookAtTarget);
                linker.setLookAtOffset(mLookatOffset);
                // 不使用原来的相对位置,则设置新的相对位置
                if (!mUseOriginRelative)
                {
                    linker.setRelativePosition(mRelativePosition, mSwitchType, mUseLastSwitchSpeed, mSwitchSpeed);
                }
                if (mImmediately)
                {
                    linker.applyRelativePosition(linker.getNormalRelativePosition());
                }
            }
            else if (mLinkerName != "")
            {
                UnityUtility.logError("linker name is not empty, but can not find linker, name : " + mLinkerName);
            }
        }
    }
        private static void UpdateRotation(Player p, GameCamera c, ref Quaternion rot)
        {
            var state = CurrentAnimationState(p);

            switch (state)
            {
            case AnimationState.FrozenAction:     // Do nothing!
                break;

            case AnimationState.FrozenIdle:
                UpdateFrozenAnimationState(p, c, ref rot);
                break;

            case AnimationState.StandingStill:
                UpdateStandingStillAnimationState(p, c, ref rot);
                break;

            case AnimationState.Action:
                p.FaceLookDirection();
                break;

            default:
                break;
            }
        }
 void Awake()
 {
     main = this;
     cam = GetComponent<Camera>();
     UIAssistant.onScreenResize += OnScreenResize;
     OnScreenResize();
 }
Beispiel #36
0
        public GameMap(GameModelDTO data)
            : base(data)
        {
            Camera = new GameCamera();

            worldMatrix = new WorldMatrix(this);
        }
Beispiel #37
0
        //ncrunch: no coverage end

        private void InitializeCamera()
        {
            Camera = new GameCamera(1 / 25.0f, 1 / 10.0f, 0.01f);
            Camera.AllowedMovementRect = Rectangle.FromCenter(Vector2D.Half,
                                                              new Size(Size.Width, Size.Height) * 1.5f);
            Camera.ResetToMinZoom();
        }
        public Pause_Menu(Screen_Manager screen_manager, GameCamera _camera)
        {
            camera = _camera;

            rect = Assets.It.Get <Texture2D>("gui-rect");
            font = Assets.It.Get <SpriteFont>("gfont");

            actions = new Named_Action_List(new Dictionary <string, Action> {
                { "Resume", () => {
                      LostIslandRanal.Request_Resume();
                      showing = false;
                  } },
                { "Settings", () => {
                  } },
                { "Level Select", () =>
                  {
                      showing = false;
                      screen_manager.Goto_Screen("Level Select", false);
                  } },
                { "Exit", () => {
                      //LostIslandRanal.Request_Resume();
                      showing = false;
                      screen_manager.Goto_Screen("Menu", true);
                  } }
            });
        }
    public override void OnRestart(Vector3 position)
    {
        getBigger   = true;
        position.y += 3;

        transform.localScale = Vector3.one;

        GameCamera camera = Game.Instance.gameCamera;

        float distance = transform.position.z - Game.Instance.level.charactersManager.distance;

        distance /= 2;

        float explotionPower = 5 - distance;

        if (explotionPower < 1.5f)
        {
            explotionPower = 1.5f;
        }
        else if (explotionPower > 3.5f)
        {
            explotionPower = 3.5f;
        }

        camera.explote(explotionPower);

        base.OnRestart(position);

        setScore();

        position.z += 0;
        position.y += 2;
        timer       = 0f;
    }
Beispiel #40
0
 // Use this for initialization
 void Start()
 {
     camera = GetComponent<GameCamera>();
     Object clone = Instantiate(player, new Vector3(0, 5, 0), Quaternion.identity);
     Object Enemy1 = Instantiate(enemy, new Vector3(50, 7, 0), Quaternion.identity);
     Object Enemy2 = Instantiate(enemy, new Vector3(118, 3, 0), Quaternion.identity);
     camera.SetTarget((clone as GameObject).transform);
 }
    // Use this for initialization
    void Start()
    {
        cam = GetComponent<GameCamera>();
        timer = GetComponentInChildren<Timer>();

        PlayerPrefs.SetInt ("playerScore", 0);
        SpawnPlayer ();
    }
Beispiel #42
0
    void Awake()
    {
        Instance 				= this;

        this.tr 				= this.GetComponent<Transform>();

        this.initialPosition 	= this.tr.position;
    }
Beispiel #43
0
		public override void Initialize()
		{
			base.Initialize();
			camera = new GameCamera(1 / 15.0f);
			var grid = new Grid3D(new Size(10, 10));
			grid.RenderLayer = -10;
			new Player();
		}
Beispiel #44
0
 // Use this for initialization
 void Start()
 {
     cam = GetComponent<GameCamera> ();
     if (GameObject.FindGameObjectWithTag("Spawn")) {
         checkpoint = GameObject.FindGameObjectWithTag("Spawn").transform.position;
     }
     spawnPlayer (checkpoint);
 }
Beispiel #45
0
        /// <summary>
        /// Create terrain at <paramref name="position"/>
        /// </summary>
        /// <param name="position"></param>
        /// <param name="textures"></param>
        /// <param name="device"></param>
        /// <param name="scale"></param>
        /// <param name="Content"></param>
        /// <param name="camera"></param>
        public QuadTree(Vector3 position, List<Texture2D> textures, GraphicsDevice device, int scale, ContentManager Content, GameCamera.FreeCamera camera)
        {
            shadow = new LightsAndShadows.Shadow();
            light = new LightsAndShadows.Light(0.7f, 0.4f, new Vector3(513, 100, 513));

            ViewFrustrum = new BoundingFrustum(camera.View * camera.Projection);
             //  Model model = Content.Load<Model>("Models/stone2");
              //  this.model = new LoadModel(model, Vector3.One, Vector3.Up, new Vector3(1), device);
            this.textures = textures;
            effect = Content.Load<Effect>("Effects/MultiTextured");
            effect2 = Content.Load<Effect>("Effects/Shadows");
            Device = device;

            _position = position;
            _topNodeSize = textures[4].Width - 1;

            _vertices = new MapRender(textures[4],scale);
            _buffers = new BufferManager(_vertices.Vertices, device);
            _rootNode = new QuadNode(NodeType.FullNode, _topNodeSize, 1, null, this, 0);

            //Construct an array large enough to hold all of the indices we'll need.
            Indices = _vertices.indices;

            envBilbList.Add(new EnvBilb(textures[6], textures[5], device, Content, scale));
             foreach (EnvBilb pass in envBilbList)
            {
                pass.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData);
                pass.CreateBillboardVerticesFromList();
            }

            /*
            envModelList.Add(new EnvModel(textures[6], model, device, Content, scale));

               foreach (EnvModel pass1 in envModelList)
            {
                pass1.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData);
                pass1.CreateModelFromList();
            }
             * */

               effect.Parameters["xTexture0"].SetValue(textures[1]);
               effect.Parameters["xTexture1"].SetValue(textures[0]);
               effect.Parameters["xTexture2"].SetValue(textures[2]);
               effect.Parameters["xTexture3"].SetValue(textures[3]);
               effect.Parameters["xTexture5"].SetValue(textures[7]);
               Matrix worldMatrix = Matrix.Identity;
               effect.Parameters["xWorld"].SetValue(worldMatrix);
               effect.Parameters["xEnableLighting"].SetValue(true);
               effect.Parameters["xAmbient"].SetValue(light.Ambient);
               effect.Parameters["xLightPower"].SetValue(light.LightPower);

               effect.Parameters["Ground"].SetValue(textures[7]);
               effect.Parameters["GroundText0"].SetValue(textures[8]);
               effect.Parameters["GroundText1"].SetValue(textures[9]);
               effect.Parameters["GroundText2"].SetValue(textures[10]);

               _rootNode.EnforceMinimumDepth();
        }
Beispiel #46
0
		public void Initialize()
		{
			Command.Register("ViewPanning", new Trigger[] { new MouseDragTrigger(MouseButton.Middle) });
			Command.Register("ViewZooming", new Trigger[] { new MouseZoomTrigger() });
			Command.Register("TurnViewRight", new Trigger[] { new KeyTrigger(Key.E) });
			Command.Register("TurnViewLeft", new Trigger[] { new KeyTrigger(Key.Q) });
			camera = new GameCamera(1 / 15.0f);
			new Player();
		}
Beispiel #47
0
 // Singleton mode for camera. If a camera object exists on a subsequent scene, delete it and use the current one.
 void Awake()
 {
     if (gameCamera == null) {
         DontDestroyOnLoad (gameObject);
         gameCamera = this;
     } else if (gameCamera != this) {
         Destroy(gameObject);
     }
 }
 public override void Draw(GameCamera camera)
 {
     #if DEBUG
     detectionSphere.debugDraw(camera);
     firstTrailingSphere.debugDraw(camera);
     secondTrailingSphere.debugDraw(camera);
     #endif
     trailGenerator.Draw(camera);
     base.Draw(camera);
 }
Beispiel #49
0
		public void CreateGameCamera()
		{
			Command.Register("ViewPanning", new Trigger[] { new MouseDragTrigger(MouseButton.Middle) });
			Command.Register("ViewZooming", new Trigger[] { new MouseZoomTrigger() });
			Command.Register("TurnViewRight", new Trigger[]{new KeyTrigger(Key.E, State.Pressed)});
			Command.Register("TurnViewLeft", new Trigger[]{new KeyTrigger(Key.Q, State.Pressed)});
			gameCamera = new GameCamera(0.1f, 2.0f);
			new Grid3D(new Size(10.0f, 10.0f));
			gameCamera.AllowedMovementRect = new Rectangle(-4.0f, -4.0f, 8.0f, 8.0f);
		}
    void Start()
    {
        var currLevel = int.Parse(Application.loadedLevelName.Split(' ')[Application.loadedLevelName.Split(' ').Length-1]);
        if (currLevel >= levelCount) currentLevel = currLevel;

        cam = GetComponent<GameCamera>();
        if (GameObject.FindGameObjectWithTag("Spawn")) {
            checkpoint = GameObject.FindGameObjectWithTag("Spawn").transform.position;
        }

        SpawnPlayer(checkpoint);
    }
        public override void Draw(GameCamera.FreeCamera camera)
        {
            if (house != null)
            {
                house.Model.Draw(camera);
            }
            else
            {
                model.Draw(camera);

            }
        }
 public override void Draw(GameCamera camera)
 {
     if (Active)
     {
         for (int i = 0; i < particles.Count(); i++)
         {
             particles[i].Draw(camera);
         }
         Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
     }
     else { }
 }
Beispiel #53
0
 void Start()
 {
     stateManager = GetComponent<StateManager> ();
     adMnan = GetComponent<AdMan> ();
     gameStats = GetComponent<GameStats> ();
     menuManager = GetComponent<MenuManager> ();
     lanePlacer = GameObject.Find ("PROCEDURAL").GetComponent<LanePlacer> ();
     gameCamera = Camera.main.GetComponent<GameCamera> ();
     //		if(isFirstGame){
     //			menuManager.SwitchMenu(MenuManager.MenuTypes.PreGame);
     //		}
 }
        public override void Draw(GameCamera camera)
        {
            #if DEBUG
            Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort;

            CollisionBase.graphics.basicEffect.World = Matrix.Identity;
            CollisionBase.graphics.basicEffect.View = camera.ViewMatrix;
            CollisionBase.graphics.basicEffect.Projection = camera.ProjectionMatrix;

            foreach (EffectPass pass in CollisionBase.graphics.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                int count = LocalNodes.Count;
                for (int i = 0; i < count; i++)
                {
                    Vector3 nodeNormal = localNodes[i]; // -Position; //  +Vector3.Transform(Vector3.Forward, shipRotation);

                    Space394Game.GameInstance.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                        PrimitiveType.LineStrip,
                        new VertexPositionColor[] { new VertexPositionColor(nodeNormal, Color.Azure), // Pretransformed
                                                new VertexPositionColor(((nodeNormal + Vector3.Transform(Vector3.Forward, Rotation) * DRAW_LENGTH)), Color.Aquamarine) },
                        0,  // vertex buffer offset to add to each element of the index buffer
                        2,  // number of vertices in pointList
                        new short[] { 0, 1 },  // the index buffer
                        0,  // first index element to read
                        1   // number of primitives to draw
                        );
                }

                break;
            }

            if (CollisionBase != null)
            {
                CollisionBase.debugDraw(camera);
            }
            else { }

            Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort;

            Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            #endif
            if (Health > 0)
            {
                base.Draw(camera);
            }
            else
            {
                drawExtraModel(camera, destroyedModel);
            }
        }
Beispiel #55
0
        public void UpdateLightData(float ambientPower, float lightPower, Vector3 lightPos, GameCamera.FreeCamera camera)
        {
            //ambientPower = 0.2f;

            //lightPos = new Vector3(-18, 5, -2);
            //lightPower = 1.0f;

            Matrix lightsView = Matrix.CreateLookAt(lightPos, camera.Target, new Vector3(0, 1, 0));
            Matrix lightsProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, 1.333333f, 100f, 1000f);

            lightsViewProjectionMatrix = Matrix.Identity * lightsView * lightsProjection;
            woldsViewProjection = Matrix.Identity * camera.View * camera.Projection;
        }
   /// Inicia a camera e ponto de inicio do jogo
   /// </summary>
   public void Start()
   {
      StartCoroutine(Timer());
      cam = GetComponent<GameCamera>();

      if (GameObject.FindGameObjectWithTag("Spawn"))
      {
         checkpoint = GameObject.FindGameObjectWithTag("Spawn").transform.position;
      }

      SpawnPlayer(checkpoint);

   }
 public override void Draw(GameCamera camera)
 {
     if (Active)
     {
         using (new ReadLock(particleLock))
         {
             int count = particles.Count();
             for (int i = 0; i < count; i++)
             {
                 particles[i].Draw(camera);
             }
             Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
         }
     }
     else { }
 }
Beispiel #58
0
		public void Draw(SpriteBatch spriteBatch, GameTime gameTime, GameCamera camera) {
			if (Gid == 0) {
				return;
			}

			var tileset = ParentLayer.ParentMap.GetTilesetByGid(Gid);
			var relativeGid = tileset.GetRelativeGid(this);
			var rectSrc = tileset.GetSourceRectangleByGid(relativeGid);
			var rectDest = new Rectangle(X * tileset.TileWidth, Y * tileset.TileHeight, tileset.TileWidth, tileset.TileHeight);
			// Apply camera position
			rectDest.X += camera.X * tileset.TileWidth;
			rectDest.Y += camera.Y * tileset.TileHeight;
			if (camera.IsInViewport(rectDest) == false) {
				return;
			}

			var opacityColor = Color.White * (float)ParentLayer.Opacity;
			spriteBatch.Draw(tileset.Image.Texture, rectDest, rectSrc, opacityColor);
		}
Beispiel #59
0
    // Use this for initialization
    void Start()
    {
        //Platform
        if(numbPlatforms != 0){
            for (int i = 0; i < numbPlatforms; i++){
                SpawnPlatform(spawnPoint);
                spawnPoint.x += 5;
            }
        }

        cam = GetComponent<GameCamera>();

        if (GameObject.FindGameObjectWithTag("Spawn")){
            checkpoint = GameObject.FindGameObjectWithTag("Spawn").transform.position;

        }

        SpawnPlayer(checkpoint);
    }
Beispiel #60
0
 public void Init(GameCamera gameCam)
 {
     if (edgeOverlay == true)
     {
         transform.SetParent(gameCam.overlayParent);
         transform.localPosition = Vector3.zero;
         transform.localEulerAngles = new Vector3(90, 0, 0);
         edgeOverlays = GetComponent<EdgeOverlays>();
         edgeOverlays.updatePivotPosition = true;
         edgeOverlays.updatePivotRotation = true;
         edgeOverlays.myScreen = GameData.instance.allScreens[gameCam.target.GetComponent<Living>().myGameInstance.instanceIndex];
     }
     else
     {
         transform.SetParent(gameCam.overlayParent);
         transform.localPosition = Vector3.zero;
         transform.rotation = Quaternion.Euler(Vector3.zero);
     }
     SetFadeAmount(0);
 }