public void CopyFrom(SmoothFollow2 sf2)
 {
     this.bControl           = sf2.bControl;
     this.bInUI              = sf2.bInUI;
     this.target             = sf2.target;
     this.targetRoot         = sf2.targetRoot;
     this.baseHeight         = sf2.baseHeight;
     this.height             = sf2.height;
     this.damping            = sf2.damping;
     this.rotationDamping    = sf2.rotationDamping;
     this.CenterOffset       = sf2.CenterOffset;
     this.CamDistance        = sf2.CamDistance;
     this.fieldOfView        = sf2.fieldOfView;
     this.CamPos             = sf2.CamPos;
     this.CamRot             = sf2.CamRot;
     this.FocalPos           = sf2.FocalPos;
     this.LastTargetPos      = sf2.LastTargetPos;
     this.LastWantedRotation = sf2.LastWantedRotation;
     this.charCtrl           = sf2.charCtrl;
     this.CanScroll          = sf2.CanScroll;
     this.shakeScript        = sf2.shakeScript;
     this.curShakeType       = sf2.curShakeType;
     this.HVByLoadArchive    = sf2.HVByLoadArchive;
     this.offsetScale        = sf2.offsetScale;
     this.TargetCamRot       = sf2.TargetCamRot;
     this.bJolt              = sf2.bJolt;
     this.lastAngleH         = sf2.lastAngleH;
     this.bNeedReturn        = sf2.bNeedReturn;
     this.ReturnSpeed        = sf2.ReturnSpeed;
     this.bUseLeftReturn     = sf2.bUseLeftReturn;
     this.CameraRadius       = sf2.CameraRadius;
     this.InsideFun          = sf2.InsideFun;
     this.horizontalRotSpeed = sf2.horizontalRotSpeed;
     this.verticalRotSpeed   = sf2.verticalRotSpeed;
     this.angleH             = sf2.angleH;
     this.angleV             = sf2.angleV;
     this.maxVerticalAngle   = sf2.maxVerticalAngle;
     this.minVerticalAngle   = sf2.minVerticalAngle;
     this.m_maxVerticalAngle = sf2.m_maxVerticalAngle;
     this.m_minVerticalAngle = sf2.m_minVerticalAngle;
     this.TargetCamDistance  = sf2.TargetCamDistance;
     this.MaxDistance        = sf2.MaxDistance;
     this.MinDistance        = sf2.MinDistance;
     this.currentDistance    = sf2.currentDistance;
     this.elasticSpeed       = sf2.elasticSpeed;
     this.ray        = sf2.ray;
     this.cullPlayer = sf2.cullPlayer;
     this.posOrig    = sf2.posOrig;
     this.posEnd     = sf2.posEnd;
     this.YSpeed     = sf2.YSpeed;
     this.UseYSpeed  = sf2.UseYSpeed;
     this.curY       = sf2.curY;
     this.BigMap_maxVerticalAngle  = sf2.BigMap_maxVerticalAngle;
     this.BigMap_verticalRotSpeed  = sf2.BigMap_verticalRotSpeed;
     this.BigMap_CamDistanceSpeed  = sf2.BigMap_CamDistanceSpeed;
     this.BigMap_maxVerticalAngleK = sf2.BigMap_maxVerticalAngleK;
     this.lastDistance             = sf2.lastDistance;
     this.lastVerticalAngle        = sf2.lastVerticalAngle;
     this.MiddleEvent = sf2.MiddleEvent;
 }
Exemple #2
0
    // Use this for initialization
    void OnTriggerEnter2D(Collider2D other)
    {
        print("bam");
        // create funny camera effect by removing lock and remembering in player prefs

        // freeze player
        characterMotor = GameObject.FindWithTag("Player").GetComponent <CharacterMotor>();
        StartCoroutine(FreezeMovement());

        // set position slightly above warper and in front of player
        Vector3 pos = new Vector3(transform.position.x, transform.position.y + 2, -5.0f);

        // check if effect already set, and if so set back to normal
        int nWarped = PlayerPrefs.GetInt("Warped");

        if (nWarped == 1)
        {
            // return to normal
            audio.Play();

            // create particle effect (and set it to self destruct)
            GameObject effect = Instantiate(Resources.Load("WarpBack"), pos, Quaternion.identity) as GameObject;
            Destroy(effect, effectDuration);


            SmoothFollow2 smoothFollow = GameObject.FindWithTag("MainCamera").GetComponent <SmoothFollow2>();
            if (smoothFollow != null)
            {
                smoothFollow.lockRotation = true;
                PlayerPrefs.SetInt("Warped", 0);
            }

            /*Light light = GetComponent <Light>();
             * light.enabled = true;*/
        }
        else
        {
            // warp effect
            audio.Play();

            // create particle effect (and set it to self destruct)
            GameObject effect = Instantiate(Resources.Load("WarpParticles"), pos, Quaternion.identity) as GameObject;
            Destroy(effect, effectDuration);

            SmoothFollow2 smoothFollow = GameObject.FindWithTag("MainCamera").GetComponent <SmoothFollow2>();
            if (smoothFollow != null)
            {
                smoothFollow.lockRotation = false;
                PlayerPrefs.SetInt("Warped", 1);
            }

            /*Light light = GetComponent <Light>();
             * light.enabled = true;*/
        }
    }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        networkHandlerObject = GameObject.FindGameObjectWithTag("NetworkHandler");
        MainCamera           = GameObject.FindGameObjectWithTag("MainCamera");

        menuControl = GameObject.FindGameObjectWithTag("Menu").GetComponent <MenuControl>();

        networkHandler   = networkHandlerObject.GetComponent <NetworkGameHandler>();
        MainCameraFollow = MainCamera.GetComponent <SmoothFollow2>();

        InitializeGame();
    }
Exemple #4
0
    private void CreateNewPlayer()
    {
        GameObject newPlayer = Instantiate(Resources.Load("Spaceman"), m_spawnPoint.position, Quaternion.identity) as GameObject;

        if (newPlayer == null)
        {
            // TODO: better error handling
            print("no new player object!");
            return;
        }

        SmoothFollow2 followScript = Camera.main.GetComponent <SmoothFollow2>();

        followScript.target = newPlayer.transform;
    }
Exemple #5
0
    // Use this for initialization
    void Awake()
    {
        mControl = GameObject.FindGameObjectWithTag("Menu");

        mControlScript = mControl.GetComponent<MenuControl>() as MenuControl;

        mCameraFollowScript = mCamera.GetComponent<SmoothFollow2>() as SmoothFollow2;

        rStartScript = rStart.GetComponent<RaceStart>() as RaceStart;

        lrPadScript = lrPad.GetComponent<InputLRPad>() as InputLRPad;

        //jumpScript = jButton.GetComponent<JumpButton>() as JumpButton;

        //fallScript = fButton.GetComponent<FallButton>() as FallButton;

        if(mControlScript.dinoIndex == 0)
        {
            dinos[0].SetActive(true);
            mCameraFollowScript.target = dinos[0].transform;
            lrPadScript.player = dinos[0];
            rStartScript.player = dinos[0];
            //jumpScript.player = dinos[0];
            //fallScript.player = dinos[0];
        }
        else if(mControlScript.dinoIndex == 1)
        {
            dinos[1].SetActive(true);
            mCameraFollowScript.target = dinos[1].transform;
            mCameraFollowScript.distance = -(mCameraFollowScript.distance);
            lrPadScript.player = dinos[1];
            rStartScript.player = dinos[1];
            //jumpScript.player = dinos[1];
            //fallScript.player = dinos[1];
        }
        else if(mControlScript.dinoIndex == 2)
        {
            dinos[2].SetActive(true);
            mCameraFollowScript.target = dinos[2].transform;
            lrPadScript.player = dinos[2];
            rStartScript.player = dinos[2];
            //jumpScript.player = dinos[2];
            //fallScript.player = dinos[2];

        }
    }
    // Use this for initialization
    void Awake()
    {
        main         = Camera.main;
        cameraScript = main.GetComponent <SmoothFollow2>();
        //dinosaurs = GameObject.FindGameObjectsWithTag("Dino");

//		foreach (GameObject dino in dinosaurs)
//		{
//			if (dino != dinosaurs[Index])
//			{
//				dino.SetActive (false);
//			}
//		}
        selectedDino        = Instantiate(dinosaurs[Index], transform.position, transform.rotation) as GameObject;
        anim                = selectedDino.GetComponentInChildren <Animator>();
        cameraScript.target = selectedDino.transform;
    }
Exemple #7
0
    private static void SetAgentProperty(Agent agent)
    {
        agent.curCtrlMode = ControlMode.ControlByPlayer;

        if (agent.charCtrller == null)
        {
            agent.charCtrller = agent.GetComponent <CharacterController>();
        }

        if (agent.charCtrller != null && !agent.charCtrller.enabled)
        {
            agent.charCtrller.enabled          = true;
            agent.charCtrller.detectCollisions = true;
        }
        //agent.gameObject.layer = 8;
        Animator animator = agent.animator;

        if (animator != null)
        {
            animator.Play("ZhanLi");
            animator.SetFloat("Speed", 0f);
            animator.SetBool("Move", false);
            animator.speed = 1f;
        }
        agent.IsJump = false;
        SmoothFollow2 orAddComponent = PalMain.MainCamera.GetOrAddComponent <SmoothFollow2>();

        orAddComponent.Init(agent.gameObject);
        orAddComponent.InNormal();
        //if (agent.name == "YueJinChao" && animator != null)
        //{
        //    float layerWeight = animator.GetLayerWeight(1);
        //    if (layerWeight < 0.5f && agent.palNPC != null)
        //    {
        //        List<GameObject> weapons = agent.palNPC.Weapons;
        //        foreach (GameObject current in weapons)
        //        {
        //            if (!(current == null))
        //            {
        //                UtilFun.YueJinChaoShenSuo(current.transform, Vector3.zero);
        //            }
        //        }
        //    }
        //}
    }
    // Use this for initialization
    void Awake()
    {
        main = Camera.main;
        cameraScript = main.GetComponent<SmoothFollow2>();
        //dinosaurs = GameObject.FindGameObjectsWithTag("Dino");

        //		foreach (GameObject dino in dinosaurs)
        //		{
        //			if (dino != dinosaurs[Index])
        //			{
        //				dino.SetActive (false);
        //			}
        //		}
        selectedDino = Instantiate(dinosaurs[Index], transform.position, transform.rotation) as GameObject;
        anim = selectedDino.GetComponentInChildren<Animator>();
        MotionControl dinoMotion = selectedDino.GetComponent<MotionControl>();
        dinoMotion.anim = anim;
        cameraScript.target = selectedDino.transform;
    }
    // Use this for initialization
    void Start()
    {
        networkHandlerObject = GameObject.FindGameObjectWithTag("NetworkHandler");
        MainCamera = GameObject.FindGameObjectWithTag("MainCamera");

        menuControl = GameObject.FindGameObjectWithTag("Menu").GetComponent<MenuControl>();

        networkHandler = networkHandlerObject.GetComponent<NetworkGameHandler>();
        MainCameraFollow = MainCamera.GetComponent<SmoothFollow2>();

        InitializeGame();
    }
    private void LateUpdate()
    {
        if (this.target == null)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0))
        {
            SmoothFollow2.LeftCameraMove = false;
            SmoothFollow2.lastMousePos   = Input.mousePosition;
        }
        else if (Input.GetMouseButton(0) && Vector3.SqrMagnitude(Input.mousePosition - SmoothFollow2.lastMousePos) > 4f)
        {
            SmoothFollow2.LeftCameraMove = true;
        }

        if (this.InsideFun != null)
        {
            this.InsideFun();
            return;
        }
        Vector3 position = Vector3.zero;

        if (this.curShakeType != ShakeType.None)
        {
            position = base.transform.position;
            base.transform.position = this.CamPos;
        }

        if (this.bControl && !this.bInUI)
        {
            if (this.CanScroll)
            {
                this.TargetCamDistance = this.GetTargetCamDistance();
                this.CamDistance       = this.TargetCamDistance;
            }

            this.AdjustFOV(this.CamDistance);

            if (InputManager.GetKey(KEY_ACTION.CAMERA_LEFT, false))
            {
                this.CamAngleH -= this.horizontalRotSpeed * Time.smoothDeltaTime;
            }
            else if (InputManager.GetKey(KEY_ACTION.CAMERA_RIGHT, false))
            {
                this.CamAngleH += this.horizontalRotSpeed * Time.smoothDeltaTime;
            }

            if (Input.GetMouseButton(1))
            {
                this.GetHV();
                this.bNeedReturn = false;
            }
            else if (Input.GetMouseButton(0))
            {
                this.GetHV();
            }

            if (this.bUseLeftReturn)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    if (!this.bNeedReturn)
                    {
                        this.lastAngleH = this.CamAngleH;
                    }
                    this.bNeedReturn = false;
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    this.bNeedReturn = true;
                }

                if (this.bNeedReturn)
                {
                    this.CamAngleH = Mathf.LerpAngle(this.CamAngleH, this.lastAngleH, Time.deltaTime * this.ReturnSpeed);
                    if (Mathf.Abs(this.CamAngleH - this.lastAngleH) < 0.5f)
                    {
                        this.bNeedReturn = false;
                    }
                }
            }

            if (this.bJolt)
            {
                this.MakeJolt();
            }
            this.TargetCamRot = Quaternion.Euler(this.angleV, this.CamAngleH, 0f);
            this.CamRot       = Quaternion.Lerp(this.CamRot, this.TargetCamRot, Time.deltaTime * this.rotationDamping);
        }
        this.FocalPos = this.GetLookAtPos(this.UseYSpeed);
        this.CamPos   = this.FocalPos + this.CamRot * this.CenterOffset * this.CamDistance;
        this.CheckForCollision(ref this.CamPos, this.FocalPos, 0f, this.CameraRadius);
        if (this.curShakeType != ShakeType.None)
        {
            if (this.shakeScript != null)
            {
                this.shakeScript.referPos = this.CamPos;
            }
            base.transform.position = position;
        }
        else
        {
            base.transform.position = this.CamPos;
        }
        base.transform.rotation = this.CamRot;
        SmoothFollow2.CastRay(base.GetComponent <Camera>());
    }