private GameObject GetClosestEnemy() { Collider[] enemies = Physics.OverlapSphere(transform.position, stateVariables.eatRadius, LayerMask.GetMask(Strings.Tags.ENEMY)); if (enemies != null) { Collider closestEnemy = null; float closestDistance = Mathf.Infinity; foreach (Collider enemy in enemies) { IEatable eatable = enemy.GetComponent <IEatable>(); if (!eatable.IsNull() && eatable.IsEatable()) { float distance = Vector3.Distance(enemy.ClosestPoint(transform.position), transform.position); if (closestDistance > distance) { closestDistance = distance; closestEnemy = enemy; } } } if (closestEnemy != null) { return(closestEnemy.gameObject); } } return(null); }
private void DoEating() { //Check if enemy is still alive if (stateVariables.eatTargetEnemy.activeSelf) { IEatable eatable = stateVariables.eatTargetEnemy.GetComponent <IEatable>(); if (!eatable.IsNull()) { int health; eatable.Eat(out health); stateVariables.statsManager.TakeHealth(health); Stats stats = GetComponent <Stats>(); EventSystem.Instance.TriggerEvent(Strings.Events.UPDATE_HEALTH, stats.GetHealthFraction()); EventSystem.Instance.TriggerEvent(Strings.Events.ENEMY_DEATH_BY_EATING); GameObject skinningEffect = ObjectPool.Instance.GetObject(PoolObjectType.VFXMallCopExplosion); playerFaceController.SetTemporaryEmotion(Turing.VFX.PlayerFaceController.Emotion.Happy, happyTimeAfterEating); if (skinningEffect && clawTransform) { skinningEffect.transform.position = clawTransform.position; } GameObject healthJuice = ObjectPool.Instance.GetObject(PoolObjectType.VFXHealthGain); if (healthJuice) { healthJuice.FollowAndDeActivate(3f, transform, Vector3.up * 3.2f, CoroutineName); } SFXManager.Instance.Play(stateVariables.EatSFX, transform.position); } } }
private void DoArmExtension(params object[] parameters) { if (isAnimating) { if (stateVariables.eatTargetEnemy) { // stateVariables.statsManager.MakeHappy(); IEatable eatable = stateVariables.eatTargetEnemy.GetComponent <IEatable>(); if (!eatable.IsNull()) { Assert.IsNotNull(eatable); grabSpot = eatable.GetGrabObject().transform.position; clawArmController.StartExtension(eatable.GetGrabObject(), stateVariables.clawExtensionTime, stateVariables.clawRetractionTime); SFXManager.Instance.Play(stateVariables.ArmExtensionSFX, transform.position); } } else { stateVariables.eatTargetEnemy = dummyObject; dummyObject.transform.position = stateVariables.modelHead.transform.position + stateVariables.modelHead.transform.forward * 5.0f; grabSpot = dummyObject.transform.position; clawArmController.StartExtension(dummyObject, stateVariables.clawExtensionTime, stateVariables.clawRetractionTime); SFXManager.Instance.Play(stateVariables.ArmExtensionSFX, transform.position); } } }
private bool CheckForEatableEnemy() { GameObject potentialEatableEnemy = GetClosestEnemy(); if (potentialEatableEnemy) { IEatable skinnable = potentialEatableEnemy.GetComponent <IEatable>(); if (!skinnable.IsNull() && skinnable.IsEatable()) { stateVariables.eatTargetEnemy = potentialEatableEnemy; stateVariables.eatTargetEnemy.GetComponent <EnemyBase>().TemporaryTerminalIndestructable(); return(true); } } return(false); }
private void CaptureEnemy(params object[] parameters) { if (stateVariables.eatTargetEnemy.activeSelf) { clawTransform = parameters[0] as Transform; IEatable eatable = stateVariables.eatTargetEnemy.GetComponent <IEatable>(); if (!eatable.IsNull()) { eatable.ToggleColliders(false); eatable.EnableRagdoll(); eatable.GrabObject(transform); stateVariables.eatTargetEnemy.transform.position = clawTransform.position; grabSpot = clawTransform.position; } } SFXManager.Instance.Play(stateVariables.ArmEnemyCaptureSFX, transform.position); //clawArmController.StartRetraction(stateVariables.clawRetractionTime); }
private void SetEnemyCloseToEat(Collider other, bool state) { if (other.tag.Equals(Strings.Tags.ENEMY) && !isInDashTutorial && isSpeedUpFinished) { IEatable skinnable = other.GetComponent <IEatable>(); if (!skinnable.IsNull() && skinnable.IsEatable()) { EnemyBase enemyBase = other.GetComponent <EnemyBase>(); if (enemyBase) { enemyBase.CloserToEat(state); if (state) { StartEatTutorial(); } } } } }