Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- import System.IO;
- import System.IO.Directory;
- import System;
- //Config Mundo
- private var MenuInicialAux : MenuInicial;
- //HUD's
- static var HUD : boolean = true;
- var TexturaMenu : Texture;
- var TexturaVida : Texture;
- var TexturaEstamina : Texture;
- var TexturaFundo : Texture;
- private var ArmaAux: BancoDadosItens;
- private var SistemaInventario : Inventario;
- var Mouser : boolean;
- //Estatísticas
- static var frameCount : float = 0;
- static var deltaTimee : float = 0.0f;
- static var fps : float = 0.0f;
- static var updateRate : float = 4.0f;
- //Desligar Funçoes
- private var DesativarFuncoes : boolean;
- private var PlayerAndar = true;
- //Menu Pausa
- private var VerificarSaves : Salvamentos ;
- private var qualities = QualitySettings.names; //Qualidades
- private var DistanciaPlayer : float; //Otimizaçao
- var _OBJETOS : GameObject[]; //Otimizaçao
- private var Estatisticas : boolean;
- var Sons : AudioClip[]; //Som
- private var Render : float = 200;
- private var shadows: LightShadows;
- private var graficos = false;
- private var video = false;
- private var jogabilidadeconf = false;
- private var FOVConf : float = 50;
- private var AntiAliasingConf : float;
- static var volumeconf : float = 1.0;
- private var SombraON = false;
- private var SombraOFF= false;
- private var _fullscreen = true;
- private var RectWindow : Rect;
- private var MouseLookCamera : MouseLook;
- private var MouseLook : MouseLook;
- private var Sensibilidade : float = 10;
- //Config.
- var GUISkinPausa : GUISkin;
- var controlePause: boolean;
- //Controles do Player
- var Sangue : GameObject;
- static var Animacao : int;
- private var DanoArma : BancoDadosItens;
- private var DanoAux : FPSInputController;
- private var LarguraSede : float;
- private var LarguraFome : float;
- private var LarguraVida : float;
- private var LarguraEstamina : float;
- private var LarguraFundoVida : float;
- private var LarguraFundoFome : float;
- private var LarguraFundoSede : float;
- private var dano : float; //Dano
- private var FomeTaxa : float; //Taxa de Fome
- private var SedeTaxa : float; //Taxa de Sede
- static var Fome : float; //Fome
- static var Sede : float; //Sede
- static var Vida : float = 100; //Vida
- static var Estamina : float = 100; //Estamina
- private var PerderVida : boolean; //Vida
- private var RecarregarEstamina : boolean;
- private var Correr : boolean = true;
- var Cast : RaycastHit;
- var CastCalc : RaycastHit; //Calcular dano da queda
- public var Player : CharacterController;
- private var motor : CharacterMotor;
- public var Correndo : float;
- private var Andar : float;
- private var i : int;
- var OBJETOS : GameObject;
- function SedeFome(TaxaFome : float,TaxaSede: float){
- if(Fome<100){
- Fome+=TaxaFome;
- }
- if(Sede<100){
- Sede+=TaxaSede;
- }
- }
- function OnCollisionEnter(collision: Collision){
- DanoAux = collision.transform.GetComponent("FPSInputController");
- if (DanoAux.Animacao==1)
- {
- //Vida -= DanoArma.Dano;
- }
- }
- function Start(){
- VerificarSaves = transform.GetComponent("Salvamentos");
- VerificarSaves.Saves();
- RectWindow = Rect (Screen.width / 2- Screen.width / 2.2, Screen.height / 2-Screen.height / 2.2, Screen.width / 1.1, Screen.height / 1.1);
- //Pegar Inf sobre o player
- if (PlayerPrefs.HasKey ("Sensibilidade")) {
- Sensibilidade = PlayerPrefs.GetFloat ("Sensibilidade");
- } else {
- PlayerPrefs.SetFloat ("Sensibilidade", Sensibilidade);
- }
- if (PlayerPrefs.HasKey ("AntiAliasingConf")) {
- AntiAliasingConf = PlayerPrefs.GetFloat ("AntiAliasingConf");
- } else {
- PlayerPrefs.SetFloat ("AntiAliasingConf", AntiAliasingConf);
- }
- if (PlayerPrefs.HasKey ("Render")) {
- Render = PlayerPrefs.GetFloat ("Render");
- } else {
- PlayerPrefs.SetFloat ("Render", Render);
- }
- if (PlayerPrefs.HasKey ("FOVConf")) {
- FOVConf = PlayerPrefs.GetFloat ("FOVConf");
- } else {
- PlayerPrefs.SetFloat ("FOVConf", FOVConf);
- }
- if (PlayerPrefs.HasKey ("volumeconf")) {
- volumeconf = PlayerPrefs.GetFloat ("volumeconf");
- } else {
- PlayerPrefs.SetFloat ("volumeconf", volumeconf);
- }
- // OBJETOS = GameObject.FindGameObjectWithTag("Terrain");
- // var Objetos = OBJETOS.GetComponentsInChildren(GameObject)as GameObject[];
- // for(var Filhos : GameObject[] in Objetos){
- //_OBJETOS = Filhos;
- // }
- _OBJETOS = GameObject.FindGameObjectsWithTag("Arvore");
- SistemaInventario = transform.GetComponent("Inventario");
- MouseLookCamera = transform.FindChild("Main Camera").GetComponent("MouseLook");
- MouseLook = transform.GetComponent("MouseLook");
- controlePause = true;
- Time.timeScale = 1;
- }
- function Awake () {
- motor = GetComponent(CharacterMotor);
- Andar = motor.movement.maxForwardSpeed;
- }
- function Update (){
- //Inputs(Clicks)
- if(!GetComponent.<Animation>().isPlaying){
- if(Input.GetAxis("Vertical")==0){
- Animacao = 0;
- }else{
- Animacao = 1;
- }
- }
- if(Input.GetMouseButtonDown(0)){
- Animacao = 2;
- }
- if(Input.GetKeyDown(KeyCode.F1))
- HUD = !HUD;
- if(Input.GetKeyDown(KeyCode.F3)){ //Mostrar Estatisticas
- Estatisticas = !Estatisticas;
- }
- if(Input.GetKeyDown("j") && controlePause){ //Quando clicar J vai sumir o cursor do mouse
- Mouser = !Mouser;
- DesativarFuncoes = !DesativarFuncoes;
- MouseLook.ControleMouse = !MouseLook.ControleMouse;
- }
- if(Mouser){
- Cursor.visible = true;
- Screen.lockCursor = false;
- }else{
- Cursor.visible = false;
- Screen.lockCursor = true;
- }
- if(Mouser){
- Cursor.visible = true;
- }else{
- Cursor.visible = false;
- }
- if(Estatisticas){ //Estatisticas
- frameCount++;
- deltaTimee += Time.deltaTime;
- if (deltaTimee > 1.0f/updateRate){
- fps = frameCount / deltaTimee ;
- frameCount = 0;
- deltaTimee -= 1.0f/updateRate;
- }
- }
- if(DesativarFuncoes){
- PlayerAndar = false;
- }else{
- PlayerAndar = true;
- }
- if(Input.GetKeyDown(KeyCode.Escape) && !SistemaInventario.ExibeMenu) //Exibir menu
- {
- Mouser = !Mouser;
- if (controlePause)
- {
- MouseLookCamera.ControleMouse=false;
- HUD = false;
- Time.timeScale = 0;
- controlePause = false;
- }
- else
- {
- PlayerPrefs.SetFloat ("Sensibilidade", Sensibilidade);
- PlayerPrefs.SetFloat ("volumeconf", volumeconf);
- PlayerPrefs.SetFloat ("FOVConf", FOVConf);
- PlayerPrefs.SetFloat ("Render", Render);
- PlayerPrefs.SetFloat ("AntiAliasingConf", AntiAliasingConf);
- MouseLookCamera.ControleMouse=true;
- HUD = true;
- Time.timeScale = 1;
- controlePause = true;
- }
- }
- }
- function FixedUpdate () {
- for(var i = 0;i<_OBJETOS.Length;i++){ //Rendenizaçao
- if ( Vector3.Distance(transform.position, _OBJETOS[i].transform.position) >= Render) {
- _OBJETOS [i].active = false;
- }else{
- _OBJETOS[i].active = true;
- }
- }
- if(_fullscreen)
- Screen.fullScreen = true;
- else
- Screen.fullScreen = false;
- //Fome & Sede
- SedeTaxa = (0.01*Time.deltaTime/24/5)*100;
- FomeTaxa = (0.01*Time.deltaTime/24/10)*100;
- SedeFome(SedeTaxa,FomeTaxa);
- //Configuraçao para o menu
- MouseLookCamera.sensitivityY = Sensibilidade;
- MouseLook.sensitivityX = Sensibilidade;
- AudioListener.volume = volumeconf;
- Camera.main.fieldOfView = FOVConf;
- QualitySettings.antiAliasing = AntiAliasingConf;
- LarguraFome =Screen.width/4 - (Fome/100);
- LarguraFundoFome = Screen.width/4 * (Fome/100);
- LarguraSede =Screen.width/4 - (Sede/100);
- LarguraFundoSede = Screen.width/4 * (Sede/100);
- LarguraVida = Screen.width/4 * (Vida/100) ;
- LarguraFundoVida = Screen.width/4 - (Vida/100);
- LarguraEstamina = Screen.width/4 * (Estamina/100) ;
- //Dano de Queda
- if(Player.collisionFlags == CollisionFlags.None){
- if(!Physics.Raycast(transform.position , -transform.up,Cast, 5) && !PerderVida){
- //calculando dano de queda:
- if(Physics.Raycast(transform.position , -transform.up,CastCalc)){
- if(!PerderVida){
- var disCalc = Vector3.Distance(transform.position, CastCalc.point);
- dano = disCalc;
- PerderVida = true;
- }
- }
- //--
- }
- }
- if(PlayerAndar){
- Movimento();
- }
- if(Player.isGrounded){
- if(PerderVida){
- Vida = Vida - dano;dano = 0;
- Instantiate(Sangue,transform.position,transform.rotation);
- }
- PerderVida = false;
- }
- }
- function Movimento(){
- //Animaçoes
- if(Animacao == 0)
- //animation.CrossFade("Parado");
- if(Animacao == 1)
- //animation.CrossFade("Andando");
- if(Animacao == 2){
- //animation.Play("Ataque");
- Animacao =-1;
- }
- //Andar
- var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
- if (directionVector != Vector3.zero) {
- var directionLength = directionVector.magnitude;
- directionVector = directionVector / directionLength;
- directionLength = Mathf.Min(1, directionLength);
- directionLength = directionLength * directionLength;
- directionVector = directionVector * directionLength;
- }
- // Direçoes
- motor.inputMoveDirection = transform.rotation * directionVector;
- motor.inputJump = Input.GetButton("Jump");
- if(Estamina <= 0){
- Correr = false;
- }else{
- Correr = true;
- }
- if(Estamina >= 100){
- RecarregarEstamina = false;
- }else{
- RecarregarEstamina = true;
- }
- //Correr
- if(Input.GetKey(KeyCode.LeftShift)&& Correr){
- Estamina -= 10*Time.deltaTime;
- motor.movement.maxForwardSpeed = Correndo;
- motor.movement.maxBackwardsSpeed = Correndo;
- motor.movement.maxSidewaysSpeed = Correndo;
- }
- else {
- if(RecarregarEstamina){
- Estamina += Time.deltaTime * 1;
- }
- motor.movement.maxForwardSpeed = Andar;
- motor.movement.maxBackwardsSpeed = Andar;
- motor.movement.maxSidewaysSpeed = Andar;
- }
- }
- function OnGUI(){
- if(!controlePause){
- GUI.Box(Rect(0,0,Screen.width,Screen.height),"Last Survivor");
- GUI.skin = GUISkinPausa;
- RectWindow = GUI.Window (0, RectWindow, JanelaPausa, "");
- }
- if(Estatisticas){
- GUI.Label (new Rect (Screen.width/2-Screen.width/2.05f, Screen.height/2-Screen.height/5.05f, Screen.width/5, Screen.height/12), "Z : " +transform.position.z); //Posicao do Z
- GUI.Label (new Rect (Screen.width/2-Screen.width/2.05f, Screen.height/2-Screen.height/4.05f, Screen.width/5, Screen.height/12), "Y : " +transform.position.y); //Posicao do Y
- GUI.Label (new Rect (Screen.width/2-Screen.width/2.05f, Screen.height/2-Screen.height/3.3f, Screen.width/5, Screen.height/12), "X : " +transform.position.x);//Posicao do X
- GUI.Label (new Rect (Screen.width/2-Screen.width/2.05f, Screen.height/2-Screen.height/2.05f, Screen.width/6, Screen.height/12), "FPS: " +Mathf.RoundToInt(fps + 4));//FPS
- }
- if(HUD){ //HUD-IU
- GUI.DrawTexture(Rect(0,Screen.height - 45,LarguraFome,15),TexturaVida); //Textura Fome
- GUI.DrawTexture(Rect(0,Screen.height - 45,LarguraFundoFome,15),TexturaFundo); //Fundo Vida
- GUI.DrawTexture(Rect(0,Screen.height - 30,LarguraSede,15),TexturaVida); //Textura Sede
- GUI.DrawTexture(Rect(0,Screen.height - 30,LarguraFundoSede,15),TexturaFundo); //Fundo Sede
- GUI.DrawTexture(Rect(0,Screen.height - 15,LarguraVida,15),TexturaVida); //Textura Vida
- GUI.DrawTexture(Rect(0,Screen.height - 15,LarguraFundoVida,15),TexturaFundo); //Fundo Vida
- GUI.DrawTexture(Rect(0,Screen.height - 50,LarguraEstamina,5),TexturaEstamina); //Textura Estamina
- }
- }
- function JanelaPausa (windowID : int) {
- if(!video && !jogabilidadeconf){
- }
- //Inicio Menu Pausa
- if (GUI.Button(Rect(Screen.height/5,Screen.height/30,100,50),"Video"))
- {
- GetComponent.<AudioSource>().clip = Sons[0];
- GetComponent.<AudioSource>().Play();
- video = true;
- jogabilidadeconf = false;
- }
- if (GUI.Button(Rect(Screen.height-2,Screen.height/30,200,50),"Jogabilidade/Audio"))
- {
- GetComponent.<AudioSource>().clip = Sons[0];
- GetComponent.<AudioSource>().Play();
- jogabilidadeconf = true;
- video = false;
- }
- if (GUI.Button(Rect(Screen.height/1.5,Screen.height/30,100,50),"Sair"))
- {
- GetComponent.<AudioSource>().clip = Sons[0];
- GetComponent.<AudioSource>().Play();
- VerificarSaves.Salvar();
- MouseLookCamera.ControleMouse = true;
- Application.LoadLevel("Menu Inicial");
- }
- if(video){
- //if (GUI.Button(Rect(Screen.width/50+1000,Screen.height-500,100,50),"640x480"))
- //Screen.SetResolution(640,480,FullScreenAux != !FullScreenAux);
- //if (GUI.Button(Rect(Screen.width/50+1000,Screen.height-450,100,50),"800x600"))
- //Screen.SetResolution(800,600,FullScreenAux != !FullScreenAux);
- //if (GUI.Button(Rect(Screen.width/50+1000,Screen.height-400,110,50),"1024x640"))
- //Screen.SetResolution(1024,640,FullScreenAux != !FullScreenAux);
- //if (GUI.Button(Rect(Screen.width/50+1000,Screen.height-350,110,50),"1280x720"))
- //Screen.SetResolution(1280,720,FullScreenAux != !FullScreenAux);
- //if (GUI.Button(Rect(Screen.width/50+1000,Screen.height-300,110,50),"1280x800"))
- //Screen.SetResolution(1280,800,FullScreenAux != !FullScreenAux);
- GUILayout.BeginVertical ();
- for (var i = 0; i < qualities.Length; i++){
- if (GUI.Button(Rect(Screen.width/15 - 50, Screen.height-350 - 200 + i * 35, 120, 30), qualities[i]))
- QualitySettings.SetQualityLevel (i, true);
- }
- GUI.Label(Rect(Screen.width/31,Screen.height-125,100,20),"Anti Aliasing");
- AntiAliasingConf = GUI.HorizontalScrollbar(Rect(Screen.width/35,Screen.height-100,100,100), AntiAliasingConf, 0.8,0,8);
- GUI.Label(Rect(Screen.width/31,Screen.height-175,100,20),"Rendenizaçao");
- Render = GUI.HorizontalScrollbar(Rect(Screen.width/35,Screen.height-150,100,100), Render, 50,70,500);
- }
- if(jogabilidadeconf){
- GUI.Label(Rect(Screen.width/31,Screen.height-475,100,20),"Sensibilidade");
- Sensibilidade = GUI.HorizontalScrollbar(Rect(Screen.width/35,Screen.height-450,100,100), Sensibilidade, 5,5,55);
- _fullscreen = GUI.Toggle(Rect(Screen.width/35,Screen.height-400,100,20), _fullscreen, "FullScreen");
- GUI.Label(Rect(Screen.width/31,Screen.height-275,100,20),"Audio");
- GUI.Label(Rect(Screen.width/31,Screen.height-125,100,20),"FOV");
- FOVConf = GUI.HorizontalScrollbar(Rect(Screen.width/35,Screen.height-100,100,100), FOVConf, 3,50,80);
- volumeconf = GUI.HorizontalScrollbar(Rect(Screen.width/35,Screen.height-250,100,100), volumeconf, 0.1,0.0,1.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement