private void GetGrabbed(GameObject grabbedBy) { if (state != State.Null) { return; } if (!_characterState.CanBeGrabbed()) { return; } if (gameObject.tag == "Enemy") { EventHandler.SendEvent(EventHandler.Events.ENEMY_GRAB); } state = State.Grabbed; _animator.TransitionPlay("Grabbed"); _characterState.SetState(CharacterState.State.Grabbed); _movement.Move(Vector2.zero); _movement.SetDirection(grabbedBy.GetComponent <Movement>().direction, true); if (_movementAI) { _movementAI.enabled = false; } // AI stuff: Mark this enemy's position around the player as available if (_blackboard) { float attackPosition = _blackboard.GetFloatVar("attackPosition"); if (attackPosition != -1) { string positionVar = "pos" + attackPosition; if (GlobalBlackboard.Instance.GetBoolVar(positionVar) != null) { GlobalBlackboard.Instance.GetBoolVar(positionVar).Value = false; } _blackboard.GetFloatVar("attackPosition").Value = -1; } } grabbedBy.GetComponent <Grabber>().Hold(gameObject); _previousParent = transform.parent; transform.SetParent(grabbedBy.transform, true); _grabbedBy = grabbedBy; gameObject.layer = grabbedBy.layer; _collision.AddCollisionLayer("Enemy"); if (GetComponentInChildren <AttackArea>()) { GetComponentInChildren <AttackArea>().gameObject.SetActive(false); } }
private void Land() { EventHandler.SendEvent(EventHandler.Events.LAND); SetState(State.Land); _animator.TransitionPlay("Jump Land"); if (FindObjectOfType <LevelManager>().currentScene < 2) { SoundPlayer.Play("JumpLand Grass"); } else { SoundPlayer.Play("Jump Land"); } _characterState.SetState(CharacterState.State.Null); isGrounded = true; _collision.AddCollisionLayer("Environment"); _collision.AddCollisionLayer("Enemy"); Invoke("FinishLand", landDuration); }