protected virtual void OnTriggerEnter2D(Collider2D collider) { // if the object that collides with the teleporter is on its ignore list, we do nothing and exit. if (_ignoreList.Contains(collider.transform)) { return; } if (collider.GetComponent <Character>() != null) { _player = collider.GetComponent <Character>(); playerAnimator = collider.GetComponent <Animator>(); _characterPause = collider.GetComponent <CharacterPause>(); _controller = collider.GetComponent <CorgiController>(); _lucyHealth = collider.GetComponent <LucyHealth>(); } if (_player != null) { if (_player.CharacterType == Character.CharacterTypes.Player) { if (_controller.State.IsGrounded) { StartCoroutine(SaveGameEffect()); _lucyHealth.ResetHealthToMaxHealth(); } } AddToIgnoreList(collider.transform); } }
/// <summary> /// Describes what happens when colliding with a damageable object /// </summary> /// <param name="health">Health.</param> protected virtual void OnCollideWithDamageable(LucyHealth health) { if (health._ultraSuitAcquired == true) { return; } else { // if what we're colliding with is a CorgiController, we apply a knockback force _colliderCorgiController = health.gameObject.GetComponentNoAlloc <CorgiController>(); if ((_colliderCorgiController != null) && (DamageCausedKnockbackForce != Vector2.zero) && (!_lucyHealth.Invulnerable)) { Vector2 totalVelocity = _colliderCorgiController.Speed + _velocity; _knockbackForce.x = -1 * Mathf.Sign(totalVelocity.x) * DamageCausedKnockbackForce.x; _knockbackForce.y = DamageCausedKnockbackForce.y; if (DamageCausedKnockbackType == KnockbackStyles.SetForce) { _colliderCorgiController.SetForce(_knockbackForce); } if (DamageCausedKnockbackType == KnockbackStyles.AddForce) { _colliderCorgiController.AddForce(_knockbackForce); } } // we apply the damage to the thing we've collided with _lucyHealth.Damage(DamageCaused, gameObject, InvincibilityDuration, InvincibilityDuration); SelfDamage(DamageTakenEveryTime + DamageTakenDamageable); } }
private void OnTriggerExit2D(Collider2D collision) { lucyHealth = collision.gameObject.GetComponent <LucyHealth>(); if (lucyHealth != null) { controller = collision.gameObject.GetComponent <CorgiController>(); controller.Parameters.MaxVelocity = new Vector2(50, 50); controller.Parameters.FallMultiplier = 1f; controller.Parameters.Gravity = -30f; } }
/// Override this to describe what happens when the object gets picked /// </summary> protected override void Pick() { _health = _collider.GetComponent <LucyHealth>(); _inventory = _collider.GetComponent <LucyInventory>(); _sprite = gameObject.GetComponent <SpriteRenderer>(); //Starts the process of increasing heath count and size of health bar _health.BatteryObtained(); _sprite.enabled = false; //Tell the inventory to update the GUI on power nodes collected _inventory.PowerNodesCollected++; _inventory.UpdateGUIPowerNodes(); CheckPowerNodeNumber(PowerNodeNumber); }
protected void OnTriggerEnter2D(Collider2D _collider) { _lucyHealth = _collider.gameObject.GetComponent <LucyHealth>(); if (_lucyHealth != null) { if (FullHealthPickup) { _lucyHealth.ResetHealthToMaxHealth(); } else { _lucyHealth.HealthRecoveryPickedUp(pickupHealthAmount); } PlayPickupSfx(); Destroy(gameObject); } }
/// Override this to describe what happens when the object gets picked /// </summary> protected override void Pick() { base.Pick(); _sprite = gameObject.GetComponent <SpriteRenderer>(); characterInventory = _collider.GetComponent <LucyInventory>(); _lucyHealth = _collider.GetComponent <LucyHealth>(); _lucyHealth.KnockbackReducerAcquired(); _sprite.enabled = false; //if we haven't already obtained it if (!GameManager.Instance.KnockbackReducerObtained) { if (!GameManager.Instance.DebugMode) { RunSplashScreen(); } GameManager.Instance.KnockbackReducerObtained = true; RetroAdventureProgressManager.Instance.SaveProgress(); } }
/// Override this to describe what happens when the object gets picked /// </summary> protected override void Pick() { base.Pick(); _animator = _collider.GetComponent <Animator>(); _health = _collider.GetComponent <LucyHealth>(); _sprite = gameObject.GetComponent <SpriteRenderer>(); _characterInventory = _collider.GetComponent <CharacterInventory>(); _health.UltraSuitAquired(); _animator.runtimeAnimatorController = Resources.Load("UltraSuitAnimator") as RuntimeAnimatorController; _sprite.enabled = false; //if we haven't already obtained it if (!GameManager.Instance.UltraSuitObtained) { if (!GameManager.Instance.DebugMode) { RunSplashScreen(); } GameManager.Instance.UltraSuitObtained = true; RetroAdventureProgressManager.Instance.SaveProgress(); } }
protected override void Setup() { base.Setup(); _animator = GetComponent <Animator>(); _characterHandleEMP = GetComponent <CharacterHandleEMP>(); _lucyHealth = GetComponent <LucyHealth>(); _magnetEffect = GetComponent <LucyMagnet>(); _characterHandleMelee = GetComponent <CharacterHandleMelee>(); _walljump = GetComponent <LucyWallJump>(); _wallcling = GetComponent <LucyWallClinging>(); _lucyFlamethrower = GetComponent <LucyFlamethrower>(); _characterRun = GetComponent <CharacterRun>(); _plasmaRainbow = GetComponent <_2dxFX_PlasmaRainbow>(); PowerNodesCollected = 0; StartCoroutine(AddItemsToInventory()); StartCoroutine(GetTheRightSuitOn()); }