public bool doBehavior(bool condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (condition) { forceVector = home - this.transform.position; if (entity.flying != true) { forceVector.y = 0; } myBody.AddForce( forceVector * movementSpeed, ForceMode.Impulse); } return(condition); }
public void updateContact() { if (contact == AI_Contact.PLAYER) { contactRepresentation = GameObject.FindGameObjectWithTag("Player"); } if (contact == AI_Contact.TAG) { contactRepresentation = GameObject.FindGameObjectWithTag(contactTag); } if (contact == AI_Contact.RANDOM_FROM_TEAM) { contactRepresentation = nearest_team_contact(true); } if (contact == AI_Contact.NEAREST_FROM_TEAM) { contactRepresentation = nearest_team_contact(false); } if (deathController == null) { deathController = this.GetComponent <CanDie>(); } if (contactRepresentation != null) { contactAIController = contactRepresentation.GetComponent <AI_Entity>(); } }
public bool doBehavior(bool condition) { if (condition && !ended) { if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } foreach (GameObject target in entity.activateTargets) { target.SetActive(entity.activate); } foreach (Trigger_IncreaseTriggerValue increaseTriggerValue in entity.runIncreaseTrigger) { increaseTriggerValue.run(); } if (!entity.repeatActivation) { ended = true; } } return(condition); }
public bool doBehavior(bool condition) { if (condition) { contactBody = contact.GetComponent <Rigidbody>(); if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (entity.pushOneShotParticles != null) { entity.pushOneShotParticles.Emit(entity.pushOneShotAmount); } if (entity.playPushSound) { entity.playSound(); } contactBody.velocity = Vector3.zero; if (contact.GetComponent <IncreaseFallingSpeed>() != null) { contact.GetComponent <IncreaseFallingSpeed>().resetStrength(); } contactBody.AddForce( (contact.transform.position - this.transform.position) * movementSpeed, ForceMode.Impulse); } return(condition); }
public bool doBehavior(bool condition) { if (condition && !active) { if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (entity.pushOneShotParticles != null) { entity.pushOneShotParticles.Emit(entity.pushOneShotAmount); } if (!ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesPostProcessing.getInstance().hackingEntities.Add(this.gameObject); } if (ManagesPlayer.getInstance().playerValues.canUseAbilities) { if (entity.playRemoveAbilitiesSound) { entity.playSound(); } } ManagesPlayer.getInstance().canUseAbilities(false); ManagesGame.getInstance().utilityFunctions.particleEmission( ManagesPlayer.getInstance().noAbilityParticleSystem, true); active = true; } else if (condition && active) { if (entity.pushOneShotParticles != null) { entity.pushOneShotParticles.Emit(entity.pushOneShotAmount); } } else if (!condition && active) { ManagesPlayer.getInstance().canUseAbilities(true); if (ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesPostProcessing.getInstance().hackingEntities.Remove(this.gameObject); } ManagesGame.getInstance().utilityFunctions.particleEmission( ManagesPlayer.getInstance().noAbilityParticleSystem, false); active = false; } return(condition); }
public bool doBehavior(bool condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (condition) { forceVector = contact.transform.position - this.transform.position; if (entity.flying != true) { forceVector.y = 0; } if (entity.activationHint != null) { entity.activationHint.SetActive(true); } myBody.AddForce(-forceVector.normalized * movementSpeed, ForceMode.Impulse); startedBehavior = true; return(condition); } if (entity.activationHint != null) { entity.activationHint.SetActive(false); } startedBehavior = false; return(condition); }
public bool doBehavior(bool condition) { if (condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (entity.flying == true) { forceVector = new Vector3( Random.Range(-movementSpeed, movementSpeed), Random.Range(-movementSpeed, movementSpeed), Random.Range(-movementSpeed, movementSpeed) ); } else { forceVector = new Vector3( Random.Range(-movementSpeed, movementSpeed), 0, Random.Range(-movementSpeed, movementSpeed) ); } // this.transform.LookAt(forceVector); myBody.AddForce(forceVector, ForceMode.Impulse); } return(condition); }
public bool doBehavior(bool condition) { if (condition && !pulling) { contactBody = contact.GetComponent <Rigidbody>(); if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (entity.pushOneShotParticles != null) { entity.pushOneShotParticles.Emit(entity.pushOneShotAmount); } contactBody.velocity = Vector3.zero; if (contact.GetComponent <IncreaseFallingSpeed>() != null) { contact.GetComponent <IncreaseFallingSpeed>().resetStrength(); } if (entity.playPullSound) { entity.playSound(); } StartCoroutine("pull"); } else if (pulling) { return(false); } return(condition); }
public bool doBehavior(bool condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (jumped) { currentTime += entity.executionInterval; if (currentTime >= entity.timeBetweenJumps) { jumped = false; } } if (jumping) { myBody.AddForce(Vector3.up * entity.multiJumpStrength, ForceMode.Impulse); if (currentTime >= entity.jumpLength) { jumping = false; } } if (condition && currentJump < entity.multiJumps && !jumped) { jumping = true; jumped = true; currentJump++; currentTime = 0; if (!entity.groundCheck.checkGrounded()) { GameObject.Instantiate(entity.multiJumpCube, new Vector3( this.transform.position.x, this.transform.position.y - 1, this.transform.position.z), this.transform.rotation); } if (entity.fallSpeedAccelerator != null) { entity.fallSpeedAccelerator.resetStrength(); } myBody.velocity = Vector3.zero; myBody.AddForce(Vector3.up * entity.initialJumpStrength, ForceMode.Impulse); if (entity.transmitAnimation != null) { if (entity.transmitAnimation.GetInteger("JumpType") == 1 || entity.transmitAnimation.GetInteger("JumpType") == 3) { entity.transmitAnimation.SetInteger("JumpType", 2); } else if (entity.transmitAnimation.GetInteger("JumpType") == 2) { entity.transmitAnimation.SetInteger("JumpType", 3); } } return(condition); } if (entity.groundCheck.checkGrounded()) { currentJump = 0; jumped = false; jumping = false; currentTime = 0; } return(condition); }
void Start() { entity = this.gameObject.GetComponent <AI_Entity>(); myBody = this.gameObject.GetComponent <Rigidbody>(); }
void Start() { entity = this.gameObject.GetComponent <AI_Entity>(); }
public bool doBehavior(bool condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (condition) { if (entity.useHackingPostProcessings && !ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesPostProcessing.getInstance().hackingEntities.Add(this.gameObject); } if (!startedBehavior && entity.playActivationSound) { entity.playSound(); } if (entity.playCombatMusic && !ManagesSound.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesSound.getInstance().hackingEntities.Add(this.gameObject); } if (entity.activationHint != null) { entity.activationHint.SetActive(true); } forceVector = contact.transform.position - this.transform.position; if (entity.flying != true) { forceVector.y = 0; } myBody.AddForce(forceVector.normalized * movementSpeed, ForceMode.Impulse); startedBehavior = true; return(condition); } if (entity.useHackingPostProcessings && ManagesPostProcessing.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesPostProcessing.getInstance().hackingEntities.Remove(this.gameObject); } if (!entity.keepHintActive && entity.activationHint != null) { entity.activationHint.SetActive(false); } if (entity.playCombatMusic && ManagesSound.getInstance().hackingEntities.Contains(this.gameObject)) { ManagesSound.getInstance().hackingEntities.Remove(this.gameObject); } startedBehavior = false; return(condition); }
public GameObject nearest_team_contact(bool randomly) { contactTeamEntities.Clear(); GameObject[] team_entities = GameObject.FindGameObjectsWithTag("AI_Entity"); GameObject player = GameObject.FindGameObjectWithTag("Player"); foreach (GameObject entity in team_entities) { contactTeamEntities.Add(entity); } if (contactTeam == AI_Team.PLAYER) { contactTeamEntities.Add(GameObject.FindGameObjectWithTag("Player")); } float lastDistance = 0; float currentDistance; GameObject nearestEntity = null; if (contactTeamEntities.Count > 0) { if (randomly) { // currently not random, only first found, to add later foreach (GameObject entity in contactTeamEntities) { AI_Entity entityAI = entity.GetComponent <AI_Entity>(); if (entity != this.gameObject && entityAI.myTeam == contactTeam) { if (entityAI.deathController == null || !entityAI.deathController.hasDied()) { return(entity); } } } } else { foreach (GameObject entity in contactTeamEntities) { AI_Entity entityAI = entity.GetComponent <AI_Entity>(); if ((entityAI != null && entity != this.gameObject && entityAI.myTeam == contactTeam) || (contactTeam == AI_Team.PLAYER && entity == player)) { if (entityAI == null || entityAI.deathController == null || !entityAI.deathController.hasDied()) { currentDistance = (entity.transform.position - this.transform.position).magnitude; if (currentDistance < lastDistance || lastDistance == 0) { nearestEntity = entity; lastDistance = currentDistance; } } } } if (nearestEntity != null) { return(nearestEntity); } } } if (contactTeam == AI_Team.PLAYER) { return(GameObject.FindGameObjectWithTag("Player")); } return(null); }
public bool doBehavior(bool condition) { if (myBody == null) { myBody = this.gameObject.GetComponent <Rigidbody>(); } if (entity == null) { entity = this.gameObject.GetComponent <AI_Entity>(); } if (condition && !dashing && currentDashLength > entity.dashLength) { currentDashLength += entity.executionInterval; if (currentDashLength > entity.timeBetweenDashs) { currentDashLength = 0; } else { return(false); } } if (dashing) { if (entity.fallSpeedAccelerator != null) { entity.fallSpeedAccelerator.resetStrength(); } } if (condition && !dashing) { dashing = true; currentDashLength = 0; ManagesGame.getInstance().utilityFunctions.particleEmission(entity.dashEffect, true); originalMass = myBody.mass; originalDrag = myBody.drag; myBody.mass = entity.dashMass; myBody.drag = entity.dashDrag; if (entity.dashRenderer != null) { entity.dashRenderer.enabled = false; } return(condition); } if (condition && dashing) { currentDashLength += entity.executionInterval; if (currentDashLength > entity.dashLength) { condition = false; } } if (!condition && dashing) { dashing = false; myBody.mass = originalMass; myBody.drag = originalDrag; ManagesGame.getInstance().utilityFunctions.particleEmission(entity.dashEffect, false); if (entity.dashRenderer != null) { if (entity.deathController != null && !entity.deathController.hasDied()) { entity.dashRenderer.enabled = true; } } } return(condition); }