private void Start() { winToggle = this.transform.GetChild(0).gameObject; gemAnimator = this.transform.GetChild(1).GetComponent <Animator>(); CharacterInputs = playerController.GetComponent <CharacterInputs>(); rigidBody = playerController.GetComponent <Rigidbody2D>(); playerAnimator = playerController.GetComponent <Animator>(); }
public override void Tick(Actor actor, float deltaTime) { if (_player.GetButtonDown(PlayerAction.LockOn)) { HandleLockOnInput(actor); } if (_player.GetButtonDown(PlayerAction.Attack)) { actor.InputBuffer.Add(PlayerAction.Attack, 0.5f); } var isRunning = _player.GetButtonLongPress(PlayerAction.Evade); CalculateMoveAndOrientation(actor, isRunning, out var move); if (_locomotion != null) { var inputs = new CharacterInputs() { Move = move, Look = _facingDirection, Run = isRunning, BeginRoll = _player.GetButtonShortPressUp(PlayerAction.Evade), BeginJump = _player.GetButtonDown(PlayerAction.Jump), IsInHitStun = actor.HitReaction.InProgress }; _locomotion.SetInputs(ref inputs); } else if (_legacyMotor != null) { _legacyMotor.Move = move; _legacyMotor.Run = isRunning; // Roll if (_player.GetButtonShortPressUp(PlayerAction.Evade)) { actor.InputBuffer.Add(PlayerAction.Evade, 0.25f); } // Jump if (_player.GetButtonDown(PlayerAction.Jump)) { actor.InputBuffer.Add(PlayerAction.Jump, 0.1f); } } }
private void Awake() { Time.timeScale = 1; Controller = gameObject.GetComponent <My2DCharacterController>(); this.TimeMachine = new TimeMachine();//Creates a timemachine with default values this.Score = gameObject.AddComponent <Score>(); this.Timer = gameObject.AddComponent <Timer>(); this.world = FindObjectOfType <World.World>(); inputController = new CharacterInputs(); this.Animator = gameObject.GetComponent <Animator>(); inputController.TimeMachine.DecreaseTime.performed += (obj) => StartIncreaseCR(obj); inputController.TimeMachine.IncreaseTime.performed += (obj) => StartDecreaseCR(obj); inputController.TimeMachine.DecreaseTime.canceled += (obj) => { decreaseCR_Switch = false; world.TimerStartStopState(true); }; inputController.TimeMachine.IncreaseTime.canceled += (obj) => { increaseCR_Switch = false; world.TimerStartStopState(true); }; this.isAttacking = false; }
private void trapped(GameObject obj) { if (!jugadorEntro) { jugadorEntro = true; ReproducirSonido(true); //obtiene los compoenentes del bot que vienen desde el delegado de detector players if (CambiarVelocidad == null) { CambiarVelocidad = obj.GetComponent <BotEngine>(); QuitarVida = obj.GetComponent <BotHealth>(); characterInputs = obj.GetComponent <CharacterInputs>(); } originalSpeed = CambiarVelocidad.Velocidad; //obtiene la velocidad el bot CambiarVelocidad.ChangeSpeed(originalSpeed / 2); //cambia la velocidad del bot Invoke("JugadorDentro", 0.5f); } }
public override void Release(Actor actor) { actor.InputBuffer.Clear(); TrackedTarget = null; _facingDirection = Vector3.zero; if (_meleeWeaponUser) { _meleeWeaponUser.UnregisterPlayerCallbacks(this); } if (_locomotion != null) { var inputs = new CharacterInputs(); _locomotion.SetInputs(ref inputs); } else if (_legacyMotor != null) { _legacyMotor.Move = Vector3.zero; _legacyMotor.Run = false; } }
public void ToggleSlingshotMap(OnSlingshotReady _) { CharacterInputs.Disable(); SlingshotInputs.Enable(); _playerInput.SwitchCurrentActionMap(_slingshotActionMapName); }
public override void Tick(ActorController controller, Actor actor) { if (actor == null || actor.Equals(null) || controller.TrackedTarget == null || controller.TrackedTarget.Equals(null)) { return; } var toTarget = (controller.TrackedTarget.GetEyesPosition() - actor.Trackable.GetEyesPosition()).WithY(0f); if (actor.GetComponent <ActorKinematicMotor>() is ActorKinematicMotor kinematicMotor) { var move = Vector3.zero; var look = kinematicMotor.transform.forward; var shouldRun = kinematicMotor.IsRunning; if (toTarget.magnitude > startDistance) { move = toTarget.normalized; look = move; if (!shouldRun && toTarget.magnitude > startRunDistance) { shouldRun = true; } if (shouldRun && toTarget.magnitude < stopRunDistance) { shouldRun = false; } } var inputs = new CharacterInputs() { Move = move, Look = look, Run = shouldRun }; kinematicMotor.SetInputs(ref inputs); } else if (actor.GetComponent <ActorPhysicalMotor>() is ActorPhysicalMotor physicalMotor) { if (physicalMotor.Move == Vector3.zero) { if (toTarget.magnitude > startDistance) { physicalMotor.Move = toTarget.normalized; } } else if (toTarget.magnitude > stopDistance) { if (!physicalMotor.Run && toTarget.magnitude > startRunDistance) { // Start running physicalMotor.Run = true; } else if (physicalMotor.Run && toTarget.magnitude < stopRunDistance) { // Stop running physicalMotor.Run = false; } physicalMotor.Move = toTarget.normalized; } else { physicalMotor.Move = Vector3.zero; } } }