//public ObjetoRecompensa.tipoRecompensa = // Use this for initialization void Start() { Time.timeScale = 1; gancho = transform.Find("Gadgets").Find("Gancho").gameObject; rigidBody = GetComponent <Rigidbody>(); anim = GetComponent <Animator>(); controller = GetComponent <CharacterController>(); shurikenPrefab = Resources.Load("Prefabs/Shuriken", typeof(GameObject)) as GameObject; canvas = transform.parent.GetComponentInParent <MainMenuController>(); mira = transform.Find("PuntoMira").gameObject; missionRewards = new List <ObjetoRecompensa.tipoRecompensa>(); levelFinished = false; points = 0; detected = false; detectedTime = -1; secDetected = 0; movimiento = estadosMovimiento.parado; if (transform.parent != null) { transform.parent.GetComponent <Edificio>().player = this.gameObject; Edificio = transform.parent.GetComponent <Edificio>(); canvas.addCondicionVictoria(Edificio.objetivosMision); pointsPerDetection = Edificio.dificultad * 0.5f; } canvas.setPlayer(this.gameObject.GetComponent <PlayerController>()); canvas.setEdificio(Edificio); trapCount = Edificio.cantTrampasHackeablesTotal; canvas.updateTrapCount(trapCount); hidden = false; enSitioOculto = false; tiempoVueloGancho = 0.5f; recoveringShuriken = false; usandoObjeto = false; lanzado = false; pulsado = false; rollingDistance = 10; rollingTime = 1f; rollingStep = 1; modoSigiloHeight = 2.95f; normalHeight = 3.61f; shurikenRecoveryTime = 10f; objetoEquipado = 0; distMaximaMira = 75; estado = 0; velocidad = 60; rolling = false; multiplicadorBase = 1; multiplicadorCorrer = 2; multiplicadorSigilo = 0.25f; tiempoAturdido = 0; maxVida = 100; vida = maxVida; facingRight = true; cambioProfundidad = false; gravity = 20.0f; jumpSpeed = 8.0f; moveDirection = Vector3.zero; modoSigilo = false; shurikenCount = 2; }
private void updateControl() { if (Input.GetButtonDown("Start")) { pausar(); } if (!pausado) { if (Input.GetAxis("ChangeObject") > 0 && !pulsado && !usandoObjeto) { pulsado = true; objetoEquipado++; if (objetoEquipado > 2) { objetoEquipado = 0; } canvas.changeObjetoEquipado(objetoEquipado); } if (Input.GetAxis("ChangeObject") < 0 && !pulsado && !usandoObjeto) { pulsado = true; objetoEquipado--; if (objetoEquipado < 0) { objetoEquipado = 2; } canvas.changeObjetoEquipado(objetoEquipado); } if (Input.GetAxis("ChangeObject") == 0) { pulsado = false; } controlMira(); usoObjeto(); float moveH = Input.GetAxis("Horizontal"); float moveV = Input.GetAxis("Vertical"); if (controller.isGrounded && !usandoObjeto) { if (cambioProfundidad) { moveDirection = new Vector3(moveH, 0, moveV); } else { moveDirection = new Vector3(moveH, 0, 0); } moveDirection *= velocidad * multiplicadorBase; if ((moveH > 0 && controller.velocity.x > 0) || (moveH < 0 && controller.velocity.x < 0)) { movimiento = estadosMovimiento.moviendose; } else if ((moveH > 0 && controller.velocity.x < 0) || (moveH < 0 && controller.velocity.x > 0)) { movimiento = estadosMovimiento.cambiandoDeDireccion; } else if (moveH == 0 && controller.velocity.x != 0) { movimiento = estadosMovimiento.frenando; } else if (moveH == 0 && controller.velocity.x == 0) { movimiento = estadosMovimiento.parado; } //print("Estoy "+movimiento); } if (enSitioOculto && modoSigilo) { hidden = true; //print("ERES INVISIBLE"); } else { hidden = false; } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); if (!rolling && !usandoObjeto) { if (moveH < 0 && facingRight) { swap(); } if (moveH > 0 && !facingRight) { swap(); } } if (Input.GetButtonDown("Run")) { if (!modoSigilo) { multiplicadorBase = multiplicadorCorrer; anim.speed = 1.5f; } else { if (!rolling) { rolling = true; rollingInitialPosition = transform.position.x; if (facingRight) { rollingFinalPosition = rollingInitialPosition + rollingDistance; } else { rollingFinalPosition = rollingInitialPosition - rollingDistance; } rollingActualTime = Time.time + rollingTime; anim.Play("Roll"); } } } else if (Input.GetButtonUp("Run")) { if (!modoSigilo) { multiplicadorBase = 1; anim.speed = 1; } } rollingController(); if (controller.isGrounded && Input.GetButtonDown("Jump")) { jump(); } ganchoUso(); if (Input.GetButtonDown("ModoSigilo") && !modoSigilo) { setModoSigilo(true); } else if (Input.GetButtonDown("ModoSigilo") && modoSigilo && !rolling) { setModoSigilo(false); } } }