private void OnTriggerEnter(Collider collider) { if (collider.name == "Jumba") { ControllerLifePlayer _lifePlayer = collider.GetComponent <ControllerLifePlayer>(); _lifePlayer.RemoveLifePlayer(damage); } }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Player") { Director.sharedDirector().playEffect(restaurar); ControllerLifePlayer controler = collider.GetComponent <ControllerLifePlayer>(); controler.AddLifePlayer(amountLife); Destroy(gameObject); } }
private void toPush() { if (Vector3.Distance(player.transform.position, transform.position) <= distanceToPush) { GettingAttacks.checkGettingAttacks().setProperties(player.transform.position.x < transform.position.x ? true : false, time, speedX, speedY); PlayerStateControl.sharePlayer().setState(PlayerState.LeadingAttack); ControllerLifePlayer.sharedLife().RemoveLifePlayer(damageToPush); } }
public static bool leadAttack(float damagePercent, bool enemySide, float timeForcePush, float speedPush, float speedPushY) { if (PlayerStateControl.sharePlayer().getCurrentState() != PlayerState.Dead) { GettingAttacks.checkGettingAttacks().setProperties(enemySide, timeForcePush, speedPush, speedPushY); // Estado do player sendo atacado PlayerStateControl.sharePlayer().setState(PlayerState.LeadingAttack); // Remove a vida do jogador ControllerLifePlayer.sharedLife().RemoveLifePlayer(damagePercent); // Limpa a lista ControllerHitSequence.checkHitSequence().ClearList(); return(true); } return(false); }
void Start() { this.life = GameObject.Find("Jumba").GetComponent <ControllerLifePlayer>(); this.special = GameObject.Find("Jumba").GetComponent <ControllerSpecial>(); stateControl = GameObject.Find("Jumba").GetComponent <PlayerStateControl>(); }
void Update() { Vector3 _movement = Vector3.zero; // if the player is not dead if (stateControl.getCurrentState() != PlayerState.Dead && stateControl.getCurrentState() != PlayerState.DeadFloor) { // Apply movement from move joystick if (moveTouchPad.isMoveTouchPadRight()) { if (TutorialBehaviour.IndexTutorial == 0) { TutorialBehaviour.ActiveTutorial = true; } if (!stateControl.isBlowRunning()) { _movement += Vector3.right * this.forwardSpeed; if (raycastDistance.getHitFloor()) { transform.rotation = new Quaternion(transform.rotation.x, 0.0f, transform.rotation.z, transform.rotation.w); this.stateControl.setState(PlayerState.Running); } } } if (moveTouchPad.isMoveTouchPadLeft()) { if (TutorialBehaviour.IndexTutorial == 0) { TutorialBehaviour.ActiveTutorial = true; } if (!stateControl.isBlowRunning()) { _movement += Vector3.right * -this.backwardSpeed; if (raycastDistance.getHitFloor()) { transform.rotation = new Quaternion(transform.rotation.x, 180.0f, transform.rotation.z, transform.rotation.w); this.stateControl.setState(PlayerState.Running); } } } if (otherTouchPad.isAttackTouch()) { otherTouchPad.setAttackTouch(false); if (TutorialBehaviour.IndexTutorial == 3) { TutorialBehaviour.ActiveTutorial = true; } if (raycastDistance.getHitFloor()) { controllerHitSequence.addComboHit(); } else { this.jumpingAttackPending = true; } } if (jumpingAttackPending) { if (!stateControl.isJumpingRunning()) { SoundJumba _sound = GetComponent <SoundJumba>(); _sound.startSoundJump(golpePulo); this.stateControl.setState(PlayerState.JumpAttacking); this.jumpingAttackPending = false; } } if (character.isGrounded) { // Remove any persistent velocity after landing and back hitHead to false, stop jumping and jumpingQuantity this.velocity = Vector3.zero; this.hitHead = false; this.jumping = false; this.jumpQuantity = 0; if (_movement == Vector3.zero && !stateControl.isBlowRunning()) { this.stateControl.setState(PlayerState.Idle); } } else { // Apply gravity to our velocity to diminish it over time this.velocity.y += (Physics.gravity.y - this.mass) * Time.deltaTime; if (directionY > 0) { if (jumpQuantity > 1) { this.stateControl.setState(PlayerState.DobleJumping); } else { this.stateControl.setState(PlayerState.Jumping); } } else { if (jumping) { if (!stateControl.isBlowRunning()) { this.stateControl.setState(PlayerState.Falling); } } else { RaycastHit _ray; if (Physics.Raycast(transform.position, Vector3.down, out _ray, rayDistance)) { _movement.x += _movement.x * downVelocity; } else { this.stateControl.setState(PlayerState.Falling); } } } // Adjust additional movement while in-air _movement.x *= this.inAirMultiplier; } if (otherTouchPad.isJumpTouch() && ((jumpQuantity < jumpQuantityMaximum) && ((Time.time - lastJumpTime) > timeBetweenJumps)) && !stateControl.isBlowRunning()) { this.speedSlip = 4.0f; if (TutorialBehaviour.IndexTutorial == 2 || TutorialBehaviour.IndexTutorial == 1) { TutorialBehaviour.ActiveTutorial = true; } this.jumping = true; this.lastJumpTime = Time.time; // Apply the current movement to launch velocity this.velocity = this.character.velocity; this.velocity.y = this.jumpSpeed; SoundJumba _sound = GetComponent <SoundJumba>(); _sound.startSound(jumpQuantity); this.otherTouchPad.setJumpTouch(false); this.jumpQuantity++; } #region Moving To Slide if ((moveTouchPad.isMoveTouchPadLeft() && !this.isMoveSlipping && this.onIce) || (moveTouchPad.isMoveTouchPadRight() && !this.isMoveSlipping && this.onIce)) { this.isMoveSlipping = true; this.speedSlip = 4.0f; } if (speedSlip <= 0) { this.isMoveSlipping = false; this.onIce = false; this.speedSlip = 4.0f; } #endregion // Check for jump } //If a player is killed he had executed his move and call up the defeat else { if (ControllerLifePlayer.sharedLife().getLifePlayer() <= 0) { if (stateControl.isBlowRunning() && character.isGrounded) { velocity.y = 0; // Caso esteja pulando e morrer ele perde sua velocidade para cair _movement = transform.rotation.y == 0 ? _movement = new Vector3(1 * -10, 0, 0) : _movement = new Vector3(1 * 10, 0, 0); } else { if (stateControl.getCurrentState() == PlayerState.Dead && !stateControl.getAnimation().IsPlaying("morrendo")) { stateControl.setState(PlayerState.DeadFloor); } } } } if (!moveTouchPad.isMoveTouchPadLeft() && !moveTouchPad.isMoveTouchPadRight() && this.isMoveSlipping && this.onIce) { if (this.stateControl.getCurrentState() != PlayerState.Attacking && this.stateControl.getCurrentState() != PlayerState.Running && this.stateControl.getCurrentState() != PlayerState.Idle && this.stateControl.getCurrentState() != PlayerState.Jumping && this.stateControl.getCurrentState() != PlayerState.Falling) { this.stateControl.setState(PlayerState.Idle); } _movement += new Vector3((transform.rotation.y == 0 ? speedSlip * Time.deltaTime * 200 : -speedSlip * Time.deltaTime * 200), 0, 0); this.speedSlip -= Time.deltaTime; } _movement += new Vector3(this.velocity.x / 2, this.velocity.y, this.velocity.z); _movement += Physics.gravity; _movement *= Time.deltaTime; this.directionY = _movement.y; // Actually move the character CollisionFlags _collisionFlags = this.character.Move(_movement); transform.position = new Vector3(transform.position.x, transform.position.y, this.positionZ); if (_collisionFlags == CollisionFlags.CollidedAbove && !hitHead) { this.velocity.y = -Physics.gravity.y; this.hitHead = true; } }