Inheritance: MonoBehaviour
Beispiel #1
0
    public IEnumerator StartTemporaryCamera(PlayerCamera cam)
    {
        // target exists
        if (temporaryCameraTarget != null)
        {
            // temporarily disable hud
            cam.hud.Hide();
            cam.counter.Hide();

            // temporarily disable player input
            cam.player.inputEnabled = false;

            // temporarily disable ai
            Enemy[] enemies = GameObject.Find("Enemies").GetComponentsInChildren <Enemy> ();
            foreach (Enemy enemy in enemies)
            {
                enemy.aiEnabled = false;
            }

            yield return(new WaitForSeconds(delayIn + hudFadeDelay));

            // set temporary camera target
            cam.temporaryTarget = temporaryCameraTarget;

            // set current temporary camera
            currentTemporaryCamera = cam;

            StartCoroutine(EndTemporaryCamera());
        }
    }
Beispiel #2
0
 public void Initialize()
 {
     this.SubscribeAsSingleton();
     PlayerCamera     = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraController> ();
     CinemachineBrain = PlayerCamera.GetComponentInChildren <CinemachineBrain> ();
     SetCurrentCamera(PlayerCamera);
 }
Beispiel #3
0
    /**
     * set the player back to the last checkpoint
     * if the camera have the player as target, set the camera
     */
    private void setToCheckpoint()
    {
        // move player to the last check point
        this.transform.position = m_lastCheckPoint;

        PlayerCamera camera = m_playerCamera.GetComponent <PlayerCamera>();

        // player is the target object in the camera script?
        if (camera != null && camera.m_object.Equals(transform))
        {
            // set the camera to a new position
            camera.setTheCamera();
        }

        // remove impediments if available
        setImpedimentJumping(false);
        setImpedimentSlip(Vector2.zero);
        setImpedimentVelocity(1f);

        // haven't a check point action?
        if (m_checkPointAction == null)
        {
            return;
        }

        // process the checkpoint action
        m_checkPointAction();
    }
 private void Awake()
 {
     rig              = GetComponent <Rigidbody>();
     playerCamera     = GetComponent <PlayerCamera>();
     playerController = GetComponent <CharacterController>();
     anim             = GetComponent <Animator>();
 }
 void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible = false;
     player = GameObject.FindGameObjectWithTag("Player");
     playerCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<PlayerCamera>();
 }
Beispiel #6
0
 private void Start()
 {
     animator = GetComponent <Animator>();
     scopeOverlay.SetActive(false);
     playerCamera = mainCamera.GetComponent <PlayerCamera>();
     defaultFOV   = playerCamera.cameraFOV;
 }
Beispiel #7
0
    public bool CheckIfUserCameraInput()
    {
        bool keyboardMove = false;
        bool mouseMove    = false;
        bool zoomMove     = false;
        bool canMove      = false;

        if (PlayerCamera.AreCameraKeyboardButtonsPressed())
        {
            keyboardMove = true;
        }

        if (PlayerCamera.IsMousePositionWithinBounaries())
        {
            mouseMove = true;
        }

        if (PlayerCamera.IsMouseScrollerScrolled())
        {
            zoomMove = true;
        }

        if (keyboardMove || mouseMove || zoomMove)
        {
            canMove = true;
        }

        return(canMove);
    }
Beispiel #8
0
 void Awake()
 {
     GX.GameManager.PLAYER = gameObject;
     motor        = GetComponent <Motor>();
     playerCamera = Camera.main.GetComponent <PlayerCamera>();
     playerCamera.SetCamTarget(camTargetTransform);
 }
        public override void Draw(PlayerCamera camera)
        {
            player.PlayerHUD.DrawTray(camera);
            player.PlayerHUD.DrawShipHUD(camera);

            if (player.ObjectivesDrawActive)
            {
                if (player.CurrentTeam == Ship.Team.Esxolus)
                {
                    if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent() != null)
                    {
                        ((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent().Draw((PlayerCamera)camera);
                    }
                    else { }
                }
                else if (player.CurrentTeam == Ship.Team.Halk)
                {
                    if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent() != null)
                    {
                        ((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent().Draw((PlayerCamera)camera);
                    }
                }
                else { }
            }
            else { }
        }
Beispiel #10
0
    /// <summary>
    /// MonoBehaviour method called on GameObject by Unity during initialization phase.
    /// </summary>
    public void Start()
    {
        GameObject    cameraController = GameObject.Find("Camera Controller");
        Camera        playercam        = GameObject.Find("Camera Controller").GetComponent <Camera>();
        PlayerCamera  playerCamScript  = GameObject.Find("Camera Controller").GetComponent <PlayerCamera>();
        AudioListener playerAudio      = GameObject.Find("Camera Controller").GetComponent <AudioListener>();

        if (photonView.IsMine)
        {
            gameObject.GetComponent <CharacterController>().enabled = true;
            gameObject.GetComponent <PlayerMovement>().enabled      = true;

            playerCamScript.enabled = true;
            playerAudio.enabled     = true;
            playercam.enabled       = true;

            GameObject.Find("SelectionManager").GetComponent <SelectionManager>().enabled = true;
        }

        // Create the UI
        if (this.playerUiPrefab != null)
        {
            GameObject _uiGo = Instantiate(this.playerUiPrefab);
            _uiGo.SendMessage("SetTarget", this, SendMessageOptions.RequireReceiver);
        }

#if UNITY_5_4_OR_NEWER
        // Unity 5.4 has a new scene management. register a method to call CalledOnLevelWasLoaded.
        UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoaded;
#endif
    }
Beispiel #11
0
 private void Start()
 {
     if (!playerCamera)
     {
         playerCamera = GameObject.FindObjectOfType <PlayerCamera>();
     }
 }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.tag == "Food" && !IsStunned)      // if the player collides with a food object
        {
            // Check if there's room in the player inventory
            if (currentLoad < invSize)
            {
                PlayerCamera pcScript = PlayerUI.GetComponent <PlayerCamera>();
                pcScript.AddFood(collision.gameObject);
                currentLoad++;
            }
        }

        else if (collision.transform.tag == "Guard")    // if the player collides with a guard
        {
            //IsStunned = true;
            // Launch food in a directions
            PlayerCamera pcScript = PlayerUI.GetComponent <PlayerCamera>();
            for (int i = currentLoad; i > 0; i--)
            {
                // generate a random vector and speed to launch the food
                Vector2 randDir = new Vector2();
                randDir.x = Random.Range(-2.0f, 2f);
                randDir.y = Random.Range(-2.0f, 2f);
                float rSpeed = Random.Range(8f, 16f);

                LaunchFood(pcScript.RemoveFood(), randDir, rSpeed);
                currentLoad--;
            }
            // Stun the player momentarily
        }
    }
    public override IEnumerator PlayAnimation(GameObject boss, BossRoom room)
    {
        PlayerCamera camera = PlayerCamera.Instance;

        camera.enabled = false;

        DungeonCreator.Instance.AdjustMask(new Vector2(room.Border.xMin, room.Border.yMin), room.Border.size);

        yield return(EnumeratorUtil.GoToInSecondsSlerp(camera.transform, room.Middle, 2.0f));

        BossUIManager.Instance.Show(boss.GetComponent <Entity>(), 2.0f);
        yield return(new WaitForSeconds(2.0f));

        if (Player.LocalPlayer.isServer)
        {
            List <Player> activePlayers = PlayersDict.Instance.Players;
            for (int i = 0; i < activePlayers.Count; i++)
            {
                activePlayers[i].SmoothSync.teleportAnyObjectFromServer(room.PlayersStartPos, Quaternion.identity, new Vector3(1, 1, 1));
            }
        }

        yield return(EnumeratorUtil.GoToInSecondsSlerp(camera.transform, Player.LocalPlayer.transform.position, 2.0f));

        camera.enabled = true;
    }
    private void Start() {
        if (Instance == null)
            Instance = this;

        wantedHeight = transform.position.y;
        StartCoroutine(Wait(1));        
    }
Beispiel #15
0
        private void SetupCamera()
        {
            PlayerCamera playerCamera = FindObjectOfType <PlayerCamera>();

            playerCamera.target             = playersManager.controlledClientPlayer.gameObject;
            playerCamera.transform.position = Vector3.zero;
        }
Beispiel #16
0
    private void OnEnable()
    {
        sourceRef = serializedObject;
        source    = (PlayerCamera)target;

        GetProperties();
    }
        public override void Draw(PlayerCamera camera)
        {
            player.PlayerHUD.DrawTray(camera);

            if (player.ObjectivesDrawActive)
            {
                if (player.CurrentTeam == Ship.Team.Esxolus)
                {
                    if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent() != null)
                    {
                        ((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent().Draw((PlayerCamera)camera);
                    }
                    else { }
                }
                else if (player.CurrentTeam == Ship.Team.Halk)
                {
                    if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent() != null)
                    {
                        ((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent().Draw((PlayerCamera)camera);
                    }
                }
                else { }
            }
            else { }

            SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch;
            spriteBatch.Begin();
            victoryTexture.DrawAlreadyBegunMaintainRatio(camera);
            spriteBatch.End();
        }
Beispiel #18
0
    public void Throw(Vector3 direction, PlayerCamera camera, PlayerCamera otherCamera, float delay)
    {
        if (direction != new Vector3(0.0f, 1.0f, 0.0f) && direction != new Vector3(0.0f, -1.0f, 0.0f))
            throw new System.Exception();

        if (delay > 0.0f)
        {
            delayedDirection = direction;
            delayedCamera = camera;
            delayedOtherCamera = otherCamera;
            throwDelayCountdown = delay;
        }
        else
        {
            DisableActor();
            floatDirection = direction * blockThrowSpeed;

            if(camera != null)
                originCamera = camera.camera;

            if(otherCamera != null)
                destinationCamera = otherCamera.camera;

            if (throwAnimation.Length != 0)
                PlayAnimation(throwAnimation);

            collider.isTrigger = true;
            passedThroughSomething = false;
        }
    }
 void Start()
 {
     inst = this;
     SetCameraMode(CameraMode.Normal, null);
     startingPosition = transform.localPosition;
     startingRot      = transform.localRotation;
 }
Beispiel #20
0
    // Start is called before the first frame update
    void Start()
    {
        body = gameObject.GetComponent <Rigidbody2D>();

        // set target of main camera's follow script
        if (isLocalPlayer)
        {
            PlayerCamera playerCamera = Camera.main.gameObject.GetComponent <PlayerCamera>();
            playerCamera.player = this.gameObject;

            shipHealthBar   = GameObject.FindGameObjectWithTag("ShipHealthBar").GetComponent <Slider>();
            shieldHealthBar = GameObject.FindGameObjectWithTag("ShieldHealthBar").GetComponent <Slider>();

            playerHealth = playerHealthMax;
            shieldHealth = shieldHealthMax;

            shipHealthBar.value   = playerHealth;
            shieldHealthBar.value = shieldHealth;
        }

        // create shield object that will follow player around
        var shield = Instantiate(shieldPrefab,
                                 gameObject.transform.position,
                                 Quaternion.identity,
                                 this.transform);

        playerShield = shield.GetComponent <Shield>();
        // this needs to be fixed because only the server can assign client authority, maybe put into a command?
        playerShield.GetComponent <NetworkIdentity>().AssignClientAuthority(this.GetComponent <NetworkIdentity>().connectionToClient);
        shieldActive = true;
    }
Beispiel #21
0
    void SetupPlayerConnections()
    {
        playerRb        = player.GetComponent <Rigidbody>();
        playerTransform = player.transform;
        playerCollider  = player.GetComponent <Collider>();
        motor           = player.GetComponent <PlayerMovement>();
        attackSystem    = player.GetComponent <PlayerAttack>();
        playerHead      = GameObject.FindGameObjectWithTag("PlayerHead");
        playerAnimator  = player.GetComponent <Animator>();

        if (weaponSlot == null)
        {
            weaponSlot = GameObject.Find("Weapon_Slot").transform.GetChild(0).gameObject;
        }

        Transform pickupCamTransform = player.transform.Find("PickupCamera");

        if (pickupCamTransform != null)
        {
            TotallyNotZeldaPickupCam = player.transform.Find("PickupCamera").GetComponent <Camera>();
        }

        if (Camera.main != null)
        {
            PlayerCam    = Camera.main.gameObject;
            cameraScript = PlayerCam.GetComponent <PlayerCamera>();
        }
    }
Beispiel #22
0
 private void Start()
 {
     if (!playerCamera)
     {
         playerCamera = Camera.main.GetComponent <PlayerCamera>();
     }
 }
Beispiel #23
0
 private void Awake()
 {
     _playerController = FindObjectOfType <PlayerController>();
     _playerCamera     = FindObjectOfType <PlayerCamera>();
     _jsonDataManager  = FindObjectOfType <JsonDataManager>();
     _gameManager      = FindObjectOfType <GameManager>();
 }
	// Use this for initialization
	void Awake () {
		instance = this;
		thisCamera = GetComponent<Camera>();
		player = FindObjectOfType<PlayerControler>();
		offset = transform.forward * -10;
		transform.position = offset + player.transform.position;
	}
Beispiel #25
0
    public IEnumerator EndTemporaryCamera()
    {
        yield return(new WaitForSeconds(temporaryCameraDuration));

        // remove temporary camera target
        currentTemporaryCamera.temporaryTarget = null;

        yield return(new WaitForSeconds(delayOut));

        // re-enable player input
        currentTemporaryCamera.player.inputEnabled = true;

        // re-enable ai
        Enemy[] enemies = GameObject.Find("Enemies").GetComponentsInChildren <Enemy>();
        foreach (Enemy enemy in enemies)
        {
            enemy.aiEnabled = true;
        }

        // re-enable hud
        currentTemporaryCamera.hud.Show();
        currentTemporaryCamera.counter.Show();

        // clear current temporary camera
        currentTemporaryCamera = null;
    }
Beispiel #26
0
    //重生
    void Respawn()
    {
        //判断人物是否死亡
        if (transform.position.y > -20)
        {
            return;
        }
        //减少生命值,若无生命则无法复活
        if (heart > 0)
        {
            heart--;
        }
        else
        {
            //死亡(未完成)
            return;
        }
        //确定相机移动的起始点和终止点
        Vector3 respawnPosition = respawnPlatform.transform.position + new Vector3(0, 2, 0);

        Vector3 startPos = PlayerCamera.instance.transform.position;
        Vector3 endPos   = respawnPosition + PlayerCamera.instance.transform.localPosition;

        //重置人物位置坐标及速度
        transform.position = respawnPosition;
        verticalVelocity   = 0;
        //开始相机移动
        PlayerCamera.Move(startPos, endPos, false);
    }
 public CameraState( CameraStateMachine stateMachine )
 {
     this.stateMachine = stateMachine;
     controller = (GameObject.FindObjectOfType( typeof( PlayerController ) ) as PlayerController);
     camera = (GameObject.FindObjectOfType( typeof( PlayerCamera ) ) as PlayerCamera);
     Actions = (GameObject.FindObjectOfType( typeof( PlayerCharacter ) ) as PlayerCharacter).Input.Actions;
 }
 public override void Draw(PlayerCamera camera)
 {
     player.PlayerHUD.DrawTray(camera);
     player.PlayerHUD.DrawShipHUD(camera);
     LogCat.updateValue("Alpha", ""+alpha);
     returningGraphic.Color = new Color(1.0f, 1.0f, 1.0f, alpha);
     returningGraphic.Draw(camera);
     if (player.ObjectivesDrawActive)
     {
         if (player.CurrentTeam == Ship.Team.Esxolus)
         {
             if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent() != null)
             {
                 ((GameScene)Space394Game.GameInstance.CurrentScene).getTopEsxolusEvent().Draw((PlayerCamera)camera);
             }
             else { }
         }
         else if (player.CurrentTeam == Ship.Team.Halk)
         {
             if (((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent() != null)
             {
                 ((GameScene)Space394Game.GameInstance.CurrentScene).getTopHalkEvent().Draw((PlayerCamera)camera);
             }
         }
         else { }
     }
     else { }
 }
 public void Awake()
 {
     Instance = this;
     offset   = OriginOffset;
     OverL    = OverL_Obj.transform.position;
     OverR    = OverR_Obj.transform.position;
 }
 private static void Postfix(PlayerCamera __instance)
 {
     if (!_isPatched)
     {
         _isPatched = true;
         var playerCameraTraverse = Traverse.Create(__instance);
         var minZoomTraverse      = playerCameraTraverse.Field("_configuration").Field("MinZoom");
         _minZoom = minZoomTraverse.GetValue <float>();
         Observable.EveryUpdate()
         .Where(_ => Input.GetKeyDown(ZoomInKey))
         .Subscribe(x =>
         {
             Debug.Log($"previous zoom: ${minZoomTraverse.GetValue<float>()}, mod zoom: {_minZoom}");
             _minZoom -= 100;
             minZoomTraverse.SetValue(_minZoom);
         });
         Observable.EveryUpdate()
         .Where(_ => Input.GetKeyDown(ZoomOutKey))
         .Subscribe(x =>
         {
             Debug.Log($"previous zoom: ${minZoomTraverse.GetValue<float>()}, mod zoom: {_minZoom}");
             _minZoom += 100;
             minZoomTraverse.SetValue(_minZoom);
         });
     }
 }
    public virtual void PlayGroundLandEffects()
    {
        float time = GameTime.time;

        if (time < nextGroundHitEffect)
        {
            return;
        }
        nextGroundHitEffect = time + 0.333f;

        if (footLandHardSound.Length > 0)
        {
            GetComponent <AudioSource>().PlayOneShot(UtilRandom.RandomFromArray(footLandHardSound) as AudioClip);
        }
        if (landGroundHardParticles)
        {
            landGroundHardParticles.Play();
        }

        // Send the camera info about the footstep for rolling effect.
        PlayerCamera pc = Camera.main.GetComponent <PlayerCamera>();

        if (pc)
        {
            pc.HitGround();
        }
    }
Beispiel #32
0
 private void Awake()
 {
     _Cam        = Camera.main.GetComponent <PlayerCamera>();
     _ChangeSize = _NewCameraPosition.GetComponent <Camera>().orthographicSize;
     _NewCameraPosition.gameObject.SetActive(false);
     _AS = GetComponent <AudioSource>();
 }
Beispiel #33
0
    // TODO: wacky shit ahead / unsure how the player will enter the level in a real game
    public void SpawnPlayerInitial()
    {
        // *
        // * Inventory
        // *
        inventory = GetComponent <PlayerInventory>();

        List <Item> toEquip = inventory.Init(); // items need to be initialized before they are equipped

        // *
        // * Create the ship and equip it
        // *
        ship = inventory.EquipShip(spawnPoint.position, spawnPoint.rotation).GetComponent <PlayerFighter>();

        for (int i = 0; i < toEquip.Count; i++)
        {
            Item itemToEquip = toEquip[i];
            inventory.EquipItem(itemToEquip);
        }

        // *
        // * Camera
        // *
        // playerCamera = GameObject.Instantiate(playerCameraPrefab, ship.transform.position, ship.transform.rotation, null);
        UIController.instance.GetComponent <Canvas>().worldCamera   = camera.GetComponentInChildren <Camera>();
        UIController.instance.GetComponent <Canvas>().planeDistance = 1;
        UIController.instance.playerUI.SetPlayer(this);
        cameraController.MainCamera      = camera.GetComponentInChildren <Camera>();
        cameraController.CameraTransform = camera.transform;
        camera        = camera.GetComponent <PlayerCamera>();
        camera.target = ship.transform; // Camera needs to be reset to new player fighter
    }
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         PlayerCamera.removeZone(zone);
     }
 }
Beispiel #35
0
    private void Move()
    {
        if (input == Vector2.zero)
        {
            currentSpeed = 0;
            return;
        }

        // Tune coefficients to control ramp up speed
        currentSpeed = ((1 * currentSpeed) + (chargingSlash ? walkSpeed : runSpeed)) / 2;
        //currentSpeed = Mathf.Clamp (currentSpeed + .3f, 0f, (chargingSlash ? walkSpeed : runSpeed));

        Vector3 newPosition = transform.position + (Vector3)input * currentSpeed * Time.deltaTime;

        // Smoothly rotate to face direction
        // TODO(samkern): Need to tune movement.
        if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0)
        {
            Rotate((Vector3)input, false);
        }
        else
        {
            transform.localScale = originalScale;
        }

        transform.position = MoveRaycast(PlayerCamera.WrapWithinCameraBounds(newPosition));
    }
 //When the player enters this trigger, add this CameraZone to the PlayerCamera's list of zones.
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         PlayerCamera.addZone(zone);
     }
 }
Beispiel #37
0
        private void Awake()
        {
            playerController = playerController ?? GetComponentInChildren <PlayerController>();
            playerCamera     = playerCamera ?? GetComponentInChildren <PlayerCamera>();

            trajectoryPredictor.raycastMask = ~pickupLayermask;
        }
 void Awake()
 {
     gameMode     = FindObjectOfType <GameMode>();
     playerCamera = FindObjectOfType <PlayerCamera>();
     hud          = FindObjectOfType <PlayerHUD>();
     character    = FindObjectOfType <PlayerCharacter>();
 }
 void Start()
 {
     playerCamera = GameObject.FindGameObjectWithTag(Tags.camera).GetComponent<PlayerCamera>();
     playerCollider = GetComponent<Collider>();
     playerParticleSystem = GetComponent<ParticleSystem>();
     //playerMesh = GetComponent<MeshRenderer>();            //disabled because player is now a particle system
     playerMovement = GetComponent<PlayerMovement>();
 }
 void Awake()
 {
     playerHUD = gameObject.GetComponent<PlayerHUD>();
     thisPlayerInfo = gameObject.GetComponent<BasePlayerInfo>();
     playerFaint = gameObject.GetComponent<PlayerFaint>();
     playerCamera = gameObject.GetComponent<PlayerCamera>();
     UpdateHealthText ();
 }
 // Use this for initialization
 void Start()
 {
     PMovement = GetComponent<PlayerMovement>();
     PCamera = GetComponent<PlayerCamera>();
     PInput = GetComponent<PlayerInput>();
     PWeapon = GetComponent<PlayerWeapon>();
     PData = GetComponent<PlayerData>();
 }
Beispiel #42
0
	void Start()
	{
		curAmmo = maxAmmo;
		gunAni = GetComponent<NetworkAnimator>();
		playCam = this.GetComponent<PlayerCamera>();
		if (gunAni == null)
			Debug.LogError ("Setup: Failed to find NetworkAnimator");
		curTeam = this.gameObject.GetComponent<PlayerController>().team;
	}
 void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible = false;
     player = GameObject.FindGameObjectWithTag(Tags.player);
     playerCamera = GameObject.FindGameObjectWithTag(Tags.camera).GetComponent<PlayerCamera>();
     playerMovement = player.GetComponent<PlayerMovement>();
     playerInteraction = player.GetComponent<Interaction>();
 }
Beispiel #44
0
    // Use this for initialization
    void Start()
    {
        _myTransform = this.GetComponent<Transform>();
        _pc = this.GetComponent<PlayerCharacter>();
        _camera = this.GetComponent<PlayerCamera>();

        _animator = _pc.Animator;
        _controller = _pc.Controller;
    }
    void Update()
    {
        // Find the players camera: need to do this in update because the camera may not be spawned for a frame or two
        if(masterCamera == null) {
            masterCamera = FindObjectOfType<PlayerCamera>();
        }
        if(masterCamera == null) {
            return;
        }

        /**
         * Update all background segments: move them to some fraction of the camera position for parallax.
         * When one segment reaches the end of the camera frustum, cycle it around for infini scrolling
         */
        float xOrigin = masterCamera.transform.position.x / parallaxFactor + leftEdgeIdx * segmentWidth;

        backgroundSegments[leftEdgeIdx].transform.position = new Vector3(xOrigin, yPosition, 0.0f);

        int idx = leftEdgeIdx + 1;
        for(int counter = 0; counter < backgroundSegments.Length; counter++) {
            if(idx >= backgroundSegments.Length) {
                idx = 0;
            }

            if(idx == leftEdgeIdx) {
                continue;
            }

            float xOffset = (counter + 1) * segmentWidth;

            backgroundSegments[idx].transform.position = new Vector3(xOrigin + xOffset, yPosition, 0.0f);

            idx += 1;
        }

        // Calculate if the right edge is showing
        Vector3 rightViewEdge = masterCamera.GetComponent<Camera>().ViewportToWorldPoint(VIEWPORT_RIGHT_EDGE);
        if(backgroundSegments[rightEdgeIdx].transform.position.x + segmentWidth / 2.0f <= rightViewEdge.x) {
            // Need to flip left edge to become rightmost, and move the left edge up one, wrapping back to 0 since that one could have been flipped around
            rightEdgeIdx = leftEdgeIdx;
            leftEdgeIdx = leftEdgeIdx + 1;
            if(leftEdgeIdx >= backgroundSegments.Length) {
                leftEdgeIdx = 0;
            }
        }

        // and the left edge
        Vector3 leftViewEdge = masterCamera.GetComponent<Camera>().ViewportToWorldPoint(VIEWPORT_LEFT_EDGE);
        if(backgroundSegments[leftEdgeIdx].transform.position.x - segmentWidth / 2.0f >= leftViewEdge.x) {
            leftEdgeIdx = rightEdgeIdx;
            rightEdgeIdx = rightEdgeIdx - 1;
            if(rightEdgeIdx < 0) {
                rightEdgeIdx = backgroundSegments.Length - 1;
            }
        }
    }
    //private Player
    void Awake()
    {
        this.cameraOne = GetComponentInChildren<PlayerOneCamera>();
        this.cameraTwo = GetComponentInChildren<PlayerTwoCamera>();

        this.playerOne = GameObject.Find("Player1");
        this.playerTwo = GameObject.Find("Player2");

        this.transitionCard = GameObject.Find("TransitionCard").gameObject.GetComponent<tk2dSprite>();
    }
	void Start()
	{
		playerAudio = GetComponent<PlayerAudioController>();
		if (isLocalPlayer)
		{
			playerCam = this.GetComponent<PlayerCamera>();
			HUD = GameObject.Find("HUD man").GetComponent<PlayerHUD>();
			HUD.Spawn(gameObject);
		}
	}
Beispiel #48
0
    // Use this for initialization
    protected override void CustomStart()
    {
        animator = GetComponent<Animator>();
        playerCamera = PlayerCamera.Get();
        player = this;

        cannon = new NormalCannon(this);
        blade = new NormalBlade(this);

        StartActions();
    }
Beispiel #49
0
    void Awake()
    {
        //		player = transform.root.GetComponent<Player>();

        playerCamera = transform.FindChild ("Main Camera").GetComponent<PlayerCamera> ();
        playCam = transform.FindChild ("Main Camera").GetComponent<Camera> ();
        miniCam = transform.FindChild ("Minimap Camera").GetComponent<Camera> ();

        // Initialize resources
        resources = InitResourceList();
    }
Beispiel #50
0
 /// <summary>
 /// Start
 /// </summary>
 private void Start()
 {
     //hud = GameObjectTools.GetComponentInChildren<menu_in_game_hud>(FindObjectOfType<menu_in_game>().gameObject);
     //hud = FindObjectOfType<menu_in_game>().gameObject.GetComponentInChildrenB<menu_in_game_hud>();
     //hud = GetComponentsInChildren<menu_in_game_hud>(true)[0];
     //menu_in_game m = FindObjectOfType<menu_in_game>();
     //hud = m.GetComponentsInChildren<menu_in_game_hud>(true)[0];
     pm = GetComponent<PlayerMotor>();
     cam = GetComponent<PlayerCamera>();
     cl = GetComponent<PlayerClimbing>();
     atk = GetComponent<PlayerAttack>();
 }
    // Use this for initialization
    void Start()
    {
        if( Instance == null ){
            Instance = this;
        }else if( Instance != null ){
            Destroy(this);
        }

        input = PlayerTarget.GetComponent<PlayerInputController>();
        machine = PlayerTarget.GetComponent<PlayerMachine>();
        controller = PlayerTarget.GetComponent<SuperCharacterController>();
        target = PlayerTarget.transform;
        onSpin = false;
        continueRotation = 1.0f;
    }
    // Use this for initialization
    void Start()
    {
        //Check what team the player is on
        if (gameWorldControl.teamOne)
        {
            //Get the first team spawn point
            GameObject spawnPointTeamOne = GameObject.FindWithTag("SpawnPointTeamOne");
            //Pull out the transform
            Transform spawnPointTeamOneTransform = spawnPointTeamOne.transform;
            //Set the spawn point
            spawnPoint = spawnPointTeamOneTransform;
            //Set the tag to assign on instantiate
            playerTag = "TeamOne";
        }
        else if (gameWorldControl.teamTwo)
        {
            //Get the second team spawn point
            GameObject spawnPointTeamTwo = GameObject.FindWithTag("SpawnPointTeamTwo");
            //Pull out the transform
            Transform spawnPointTeamTwoTransform = spawnPointTeamTwo.transform;
            //Set the spawn point
            spawnPoint = spawnPointTeamTwoTransform;
            //Set the tag to assign on instantiate
            playerTag = "TeamTwo";
        }
        else if (gameWorldControl.teamThree)
        {
            //Get the third team spawn point
            GameObject spawnPointTeamThree = GameObject.FindWithTag("SpawnPointTeamThree");
            //Pull out the transform
            Transform spawnPointTeamThreeTransform = spawnPointTeamThree.transform;
            //Set the spawn point
            spawnPoint = spawnPointTeamThreeTransform;
            //Set the tag to assign on instantiate
            playerTag = "TeamThree";
        }

        //Get the Main Camera
        mainCamera = GameObject.FindWithTag("MainCamera");
        playerCameraScript = mainCamera.GetComponent<PlayerCamera>();

        //Get the UI Elements
        //Not enough Sol object
        notEnoughSolObject = GameObject.FindWithTag("NotEnoughSolLabel");
        //Hide the not enough Sol warning
        NGUITools.SetActive(notEnoughSolObject, false);
    }
        public CameraCreatorHandler()
        {
            var pcam = new PlayerCamera("PlayerCamera");
            pcam.Register();
            pcam.MakeActiveCamera();

            var fcam = new FreeCamera("FreeCamera");
            fcam.Register();

            var kcam = new KnightyCamera("KnightyCamera");
            kcam.Register();

            var ccam = new ChaseCamera("ChaseCamera");
            ccam.Register();

            var acam = new AttachCamera("AttachCamera");
            acam.Register();

            var sfcam = new SmoothFreeCamera("SmoothFreeCamera");
            sfcam.Register();
        }
Beispiel #54
0
 void Start()
 {
     playerCam = PlayerCamera.instance;
     exploded = false;
     timer = 0.0f;
     thisTransform = transform;
 }
Beispiel #55
0
	/// <summary>
	/// Initialize player movement.
	/// </summary>
	void Awake() {
        //Time.timeScale = 0.33f;
        t = transform;
        a = GetComponent<Animator>();
        cl = GetComponent<PlayerClimbing>();
        cam = GetComponent<PlayerCamera>();
        atk = GetComponent<PlayerAttack>();
        j = GetComponent<PlayerJumping>();
        move_direction = transform.forward;
	}
Beispiel #56
0
    /// <summary>
    /// Initialize attack component.
    /// </summary>
    void Awake()
    {
        t = transform;
		pm = GetComponent<PlayerMotor>();
        cam = GetComponent<PlayerCamera>();
        a = GetComponent<Animator>();
	}
 public override void Draw(PlayerCamera camera)
 {
     player.PlayerHUD.DrawTray(camera);
     controls.DrawMaintainRatio(camera);
 }
Beispiel #58
0
 private void Awake()
 {
     current = this;
     distance = targetDistance;
     mode = CameraMode.Chase;
 }
 void Awake()
 {
     size = defaultSize = Camera.main.orthographicSize;
     Instance = this;
 }
 private void loadComponents()
 {
     if( camera == null )
         camera = GameObject.FindObjectOfType<PlayerCamera>() as PlayerCamera;
 }