public virtual void OnTriggerStay(Collider c) { if (!isServer) { return; } if (c.tag == "LiveEntity") { Vector3 direction = (c.transform.position - transform.position).normalized; if (c.name.StartsWith("MainPlayer")) { PlayerMain player = c.GetComponent <PlayerMain>(); if (CanTakeDamage(player)) { player.RpcApplyDamage(damage, dazeMovementTime, dazeActionTime, force, direction); alreadyHit.Add(player); HitSomething(); } } else { //TODO for sustained hurtboxes, use something else for already hit LiveEntity h = c.GetComponent <LiveEntity>(); if (CanTakeDamage(h)) { h.ApplyDamage(damage, dazeMovementTime, dazeActionTime, force, direction); alreadyHit.Add(h); HitSomething(); } } } }
public override void Update(LiveEntity entity) { Grunt grunt = (Grunt)entity; base.Update(grunt); GameObject ao = grunt.attachedObject; if (Director.playerIsAlive) { LiveEntity target = Director.player; Vector2 vectorToTarget = (target.attachedObject.transform.position - ao.transform.position); decisionTimer -= Time.deltaTime * Mathf.Max(1, grunt.aggroRadius / (vectorToTarget.magnitude)); if ((ao.transform.position - target.attachedObject.transform.position).magnitude < grunt.attackRadius) { grunt.Attack(target); } else { if (decisionTimer <= 0) { grunt.StandardSeek(target); decisionTimer = entity.decisionTimerMax; } } } }
public override void Enter(LiveEntity entity) { timer = 1; successfulHit = false; entity.velocity = Vector2.zero; hitBox = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/ConeHitBox"), entity.attachedObject.transform); }
public override void Enter(LiveEntity entity) { successfulHit = false; frame = 30; entity.velocity = Vector2.zero; hitBox = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/ChaserAttackHitbox"), entity.attachedObject.transform); }
public override void Update(LiveEntity entity) { base.Update(entity); Player player = (Player)entity; //INPUTS PlayerInput input = new PlayerInput(); input.GetInput(); float speedMod = (input.move.x != 0 && input.move.y != 0) ? 1 / Mathf.Sqrt(2) : 1; float appliedSpeed = speedMod * player.Stats["moveSpeed"]; //MOVEMENT Vector2 v = entity.velocity; v.x = (input.move.x != 0) ? v.x + input.move.x * 1.5f : Mathf.Sign(v.x) * Mathf.Max(0, Mathf.Abs(v.x) - 60 * Time.deltaTime); v.x = Mathf.Clamp(v.x, -appliedSpeed, appliedSpeed); v.y = (input.move.y != 0) ? v.y + input.move.y * 1.5f : Mathf.Sign(v.y) * Mathf.Max(0, Mathf.Abs(v.y) - 60 * Time.deltaTime); v.y = Mathf.Clamp(v.y, -appliedSpeed, appliedSpeed); player.velocity = v; player.hookStatesList.Last().Update(player, input); //TRACKING player.movingLastFrame = (input.move.x != 0 || input.move.y != 0); player.hookBackLastFrame = input.directHookBack; player.lastMoveAngle = player.moveAngle; }
void SetNewTarget(LiveEntity newLiveEntity) { target = newLiveEntity; if (target != null) { ParticleSystem.MainModule mainTargetingParticles = targetingParticlesReal.main; mainTargetingParticles.startSizeMultiplier = target.targetSize; int numCurrent = targetingParticlesReal.GetParticles(targetingParticlesRealParts); for (int index = 0; index < numCurrent; index++) { targetingParticlesRealParts[index].startSize = target.targetSize; } targetingParticlesReal.SetParticles(targetingParticlesRealParts, numCurrent); if (targetingParticlesGO.activeSelf == false) { targetingParticlesGO.SetActive(true); } } else { if (targetingParticlesGO.activeSelf == true) { targetingParticlesGO.SetActive(false); } } }
public override void Update(LiveEntity entity) { base.Update(entity); PlayerInput input = new PlayerInput(); input.GetInput(); ((Player)entity).hookStatesList.Last().Update((Player)entity, input); }
public bool CanTakeDamage(LiveEntity liveEntity) { foreach (LiveEntity live in alreadyHit) { if (live == liveEntity) { return(false); } } return(true); }
public override void ProcessNodeHit(Player player, LiveEntity target, RaycastHit2D collision) { if (!target.invincible) { target.TakeDamage(player.Stats["damage"] / 2); Transform t = target.attachedObject.transform; Vector2 knockback = (-collision.normal + player.hookVelocity).normalized / 2 * player.hookKnockback * Mathf.Clamp(player.hookVelocity.magnitude, 1, 2) * player.hookMass; //Vector2 knockback = collision.normal * -hookKnockback; target.ApplyKnockback(knockback, 0.15f, 0.03f, 0.1f); } }
public override void Update(LiveEntity entity) { base.Update(entity); if (timer <= 0) { Exit(entity); } else { timer -= Time.deltaTime; } }
private void Start() { playerEntity = FindObjectOfType <Player>(); playerT = playerEntity.transform; nextCampCheckTime = timeBetweenCampingChecks + Time.time; campPositionOld = playerT.position; playerEntity.OnDeath += OnPlayerDeath; map = FindObjectOfType <MapGeneration>(); NextWave(); }
void Start() { playerEntity = FindObjectOfType <Player>(); player = playerEntity.transform; mapGenerator = FindObjectOfType <MapGenerator>(); playerCampManager = new PlayerCampManager(player); playerEntity.OnDeath += OnPlayerDeath; // Load the first wave at index 0. LoadNewWave(0); }
private void Awake() { pathFinder = GetComponent <NavMeshAgent>(); if (GameObject.FindGameObjectWithTag("Player") != null) { hasTarget = true; target = GameObject.FindGameObjectWithTag("Player").transform; targetEntity = target.GetComponent <LiveEntity>(); myCollisionRadius = GetComponent <CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; } }
public float GetCamHeigth() { if (pParent) { // Get parent script LiveEntity pLiveEntity = (LiveEntity)pParent.GetComponent(typeof(LiveEntity)); if (pLiveEntity && pLiveEntity.IsCrouched()) { return(fCamHeigth * 0.5f); } } return(fCamHeigth); }
void Awake() { if (GameObject.FindGameObjectWithTag("Player") == null) { hasTarget = false; return; } target = GameObject.FindGameObjectWithTag("Player").transform; pathFinder = GetComponent <NavMeshAgent>(); targetEntity = target.GetComponent <LiveEntity>(); collisionRadius = GetComponent <CapsuleCollider>().radius; targetCollisionRadius = target.GetComponent <CapsuleCollider>().radius; hasTarget = true; nextAttackTime = Time.time; targetEntity.OnDeath += OnTargetDeath; }
public override void Update(LiveEntity entity) { base.Update(entity); Chaser chaser = (Chaser)entity; LiveEntity target = Director.player; if (Director.playerIsAlive) { if ((chaser.attachedObject.transform.position - target.attachedObject.transform.position).magnitude < chaser.attackRadius) { chaser.Attack(target); } else { entity.StandardSeek(target); } } }
public virtual void ParseHookCollisionData(Player player, RaycastHit2D[] col, List <Type> targets, HitProcessor action) { foreach (RaycastHit2D i in col) { if (null != i.transform.gameObject.GetComponent <Identifier>()) { LiveEntity target = i.transform.gameObject.GetComponent <Identifier>().linkedScript; //TODO: DO THIS BETTER LATER 2 (REPLACE GETTYPE with getsubclass or something) if (targets.Contains(target.GetType())) { action(player, target, i); //hookStatesList.Last().ProcessHookHit(this, target, i); } } ; } }
public override void Update(LiveEntity entity) { base.Update(entity); if (timer <= 0) { Exit(entity); entity.state = new GruntActiveState(); entity.state.Enter(entity); } else if (timer >= 0.25f && timer <= 0.5f) { if (!successfulHit && Director.playerIsAlive) { successfulHit = ((Grunt)entity).ProcessHit(target, hitBox); } } timer -= Time.deltaTime; }
void FixedUpdate() { //target = null; LiveEntity newLiveEntity = null; //Debug.Log (potentialTargets.Count); float bestDotProduct = 0; for (int index = 0; index < potentialTargets.Count; index++) { //Debug.Log(potentialTargets[index].name); if (potentialTargets[index] == null) { potentialTargets.RemoveAt(index); continue; //WE PROBABLY NEED TO BE MORE CAREFUL HERE, KEEP AN EYE OUT } else { Vector3 cameraHolderPos = playerMain.cameraControl.GetPivotPointPos(); float dotProduct = Vector3.Dot(playerMain.cameraControl.GetDirectionRaw().normalized, (potentialTargets[index].transform.position - cameraHolderPos).normalized); float distance = Vector3.Distance(cameraHolderPos, potentialTargets[index].transform.position); if (distance <= maxRange + potentialTargets[index].targetSize / 2.5f && dotProduct >= minimumDotProduct) { if (newLiveEntity == null) { newLiveEntity = potentialTargets[index]; bestDotProduct = dotProduct; } else if (dotProduct > bestDotProduct) { newLiveEntity = potentialTargets[index]; bestDotProduct = dotProduct; } } } } if (newLiveEntity != target) { SetNewTarget(newLiveEntity); } }
public override void Update(LiveEntity entity) { base.Update(entity); if (frame <= 0) { Exit(entity); entity.state = new ChaserActiveState(); entity.state.Enter(entity); } else if (frame >= 5 && frame <= 20) { if (!successfulHit && Director.playerIsAlive) { successfulHit = ((Chaser)entity).ProcessHit(target, hitBox); } } //timer -= Time.deltaTime; frame--; }
public abstract void Enter(LiveEntity entity);
public override void ProcessNodeHit(Player player, LiveEntity target, RaycastHit2D collision) { }
public abstract void ProcessNodeHit(Player player, LiveEntity target, RaycastHit2D collision);
public override void MakeDecision(LiveEntity entity) { }
public void AddAlreadyHit(LiveEntity liveEntity) { alreadyHit.Add(liveEntity); }
public override void Exit(LiveEntity entity) { }
public override void Exit(LiveEntity entity) { entity.state = new EnemyStunnedState(hitStunTimer); entity.state.Enter(entity); }
public abstract void Exit(LiveEntity entity);
public override void Enter(LiveEntity entity) { }
public override void Update(LiveEntity entity) { base.Update(entity); }