public virtual void dealDamage(Entity guy) { if (guy.isTargeted(target) && active) { guy.takeDamage(power); } }
public override void hit(ref Entity other) { ArrayList temp = new ArrayList(); foreach (Minion a in player.oppBoard) { foreach (string s in a.abilityList) { if (s == "taunt") { temp.Add(a); } } } if (temp.Contains(other)) { if (this.attack != 0) { bool frozen = false; foreach (string e in abilityList) { if (e == "frozen") { frozen = true; } } if (!frozen) { other.takeDamage(this.attack); this.takeDamage(other.attack); } } canAttack--; } }
private IEnumerator damagePerSecond() { for (int i = 0; i < attacksPerIteration; i++) { kaiju.takeDamage(damageAmount); } yield return(null); }
private void dealDamage(GameObject collidedObject) { Entity kaiju = collidedObject.GetComponent <Entity>(); if (kaiju) { kaiju.takeDamage(damageValue); kaiju = null; } }
private void dealDamageTowardsBuildings(GameObject collidedObject) { Entity building = collidedObject.GetComponent <Entity>(); if (building) { building.takeDamage(attackDamage); GetComponent <TamPlayerScore>().increaseTheScore(GameTimer.scoreValue); building = null; } }
public override void dealDamage(Entity guy) { if (dead) { return; } if (guy.isTargeted(target) && active) { guy.takeDamage(power); dead = true; } }
public void play(Entity other, Player p) { bool temp = false; foreach (Minion a in p.board) { if (a.tribe == "beast") { temp = true; } } if (temp) { other.takeDamage(5); } else { other.takeDamage(3); } base.play(ref p); }
void Update () { RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up, Time.deltaTime * speed, layer.value); Debug.Log(transform.up); if (hit.transform == null) transform.Translate(Vector3.up * Time.deltaTime * speed); else { Entity e = hit.collider.GetComponent<Entity>(); if(e!=null) e.takeDamage(); GameObject.Destroy(gameObject); } Debug.DrawRay(transform.position, transform.up, Color.white); //Debug.Break(); }
public double dealDamage(double damage, DamageType type, Entity target) { double newDamage = damage; foreach (DealDamageListener listener in dealDamageListeners) { damage += listener.dealDamage(damage, type); } if (newDamage < 0) { newDamage = 0; } target.takeDamage(newDamage); return(newDamage); }
public Entity shoot() { Entity reciever = null; if (cooldown <= 0) { //Vector3 dir = new Vector3 (BulletSpawn.forward.x, BulletSpawn.forward.y, BulletSpawn.forward.z+(Random.Range(-accuracy, accuracy))); Vector3 dir = parent.forward; //Vector3 pos = BulletSpawn.position + (BulletSpawn.forward/10); Vector3 pos = BulletSpawn.position; RaycastHit hit; Ray ray = new Ray(pos, dir.normalized); Debug.DrawRay(pos, dir.normalized, Color.red); GetComponent <AudioSource>().Play(); if (Physics.Raycast(ray, out hit, range)) { if (Type <Entity> .isType(hit.transform, out reciever)) { if (parentEntity.team == reciever.team) { return(null); } EnemyController enemy; if (Type <EnemyController> .isType(reciever.transform, out enemy)) { enemy.entity.takeDamage(damage, parentUID); } else { reciever.takeDamage(damage); } } } cooldown = firerate; } return(reciever); }
/// <summary> /// Attempts to execute the specified move. If there is something in the way, will not change position, but will change facing. /// In FightingEntity, this handles fighting as well as movement. /// </summary> /// <returns><c>true</c>, if the move was successfully executed, <c>false</c> otherwise.</returns> /// <param name="move">The move to execute.</param> protected override bool AttemptMove(Move move) { if (move != Move.Fight) { return(base.AttemptMove(move)); } //Debug.Log (gameObject.name + " attempts to fight!"); //defaults to playing attack left, if the other animations are not triggered or not present animator.Play("AttackLeft"); //handles fighting //this function orders the tiles so that the entity will attack those in front of it before ones to the side Vector2[] fightOrder = facing.attackOrder(); for (int i = 0; i < 4; i++) { for (int j = 1; j <= range; j++) { Vector2 fightDir = fightOrder[i]; int destX = x + ((int)fightDir.x * j); int destY = y + ((int)fightDir.y * j); Entity target = GridManager.instance.getTarget(destX, destY); if (target != null) { if (target.gameObject.tag == foeTag) { //at this point, we have confirmed there is a fightable entity in this tile. //Attack animation code should go somewhere under this if. target.takeDamage(damageDealt); facing = moveExtensions.getMove(fightOrder[i]); if (facing == Move.Left || facing == Move.Right) { animator.Play("AttackLeft"); } else if (facing == Move.Down) { animator.Play("AttackDown"); } else if (facing == Move.Up) { animator.Play("AttackUp"); } return(true); } } //this code, if uncommented, would prevent ranged attacks through obstacles/other entities. //(however, if it reaches this point, the attack would be attempted but would fail; no other move would be substituted.) //at the moment, though, we don't care. /* * if(!GridManager.instance.isPassable(destX, destY)) * { * continue; * } * //*/ } } return(false); //no target was found. }
public void dealDamage(Entity entity, int damage) { entity.takeDamage(damage); }
public void attack(Entity e) { //Checking if e is in the attack range if (!isInAttackRange(e)) return; e.takeDamage (this.makeDamageForEntity (e)); }
public void attack(Entity entity) { entity.takeDamage(strength); }
protected override bool AttemptMove(Move move) { if (move == lastMove) { combo++; //Debug.Log(combo + "x COMBO!"); } else { lastMove = move; combo = fullCombo / 4; //Debug.Log("Combo reset to " + combo); } fullCombo++; if (move == Move.Heal) { health += healAmount + (combo * healIncrease); //1 and 2 are 5 less than before; 3 is the same; 4 and higher are more. if (health > maxHealth) { health = maxHealth; } Instantiate(healingEffect, transform.position + new Vector3(0, 0, .5f), Quaternion.identity); return(true); } else { bool success = false; if (move == Move.Fight && combo > 2) { //Debug.Log("AoE triggered!"); //play an obscenity //i.e. the fourth or later punch in a row List <Entity> closeEntities = GridManager.instance.getEntitiesInRect(x - 2, x + 2, y + 2, y - 2); foreach (Entity entity in closeEntities) { if (entity != null) { if (entity.gameObject.tag == foeTag) { entity.takeDamage(10); success = true; } } } animator.Play("AttackDown"); shakyCam = shakeTime; Instantiate(aoeEffect, transform.position, Quaternion.identity); audioSources[2].volume = PlayerPrefs.GetFloat(InGameMenu.effectVolKey); audioSources[2].Play(); if (Random.Range(0, 5) == 0) { SFXManager.PlayerVoice(); } return(success); } success = base.AttemptMove(move); if (success) { return(true); } //else if (move.isDirectional()) { facing = move; //find the destination tile Vector2 moveDir = move.getDirection(); int destX = x + (int)moveDir.x; int destY = y + (int)moveDir.y; Entity target = GridManager.instance.getTarget(destX, destY); if (target != null) { if (target.gameObject.tag == foeTag) { //a fightable enemy! //deal it some damage. target.takeDamage(blunderDamage); animator.Play("AttackLeft"); //Debug.Log("Player blunders into " + target.gameObject.name + ", dealing " + blunderDamage + " damage! " + target.health + " health remains."); target.currentRed = 100; return(true); } } return(false); } else if (move == Move.Fight && combo > 0) { //Debug.Log("Ranged attempt triggered"); //try again with range. //copy of the normal fight code, because we need to know our target. //this is bad practice Vector2[] fightOrder = facing.attackOrder(); for (int i = 0; i < 4; i++) { for (int j = 1; j <= 2; j++) { Vector2 fightDir = fightOrder[i]; int destX = x + ((int)fightDir.x * j); int destY = y + ((int)fightDir.y * j); Entity target = GridManager.instance.getTarget(destX, destY); if (target != null) { if (target.gameObject.tag == foeTag) { //play an obscenity IFF a bottle is actually thrown. target.takeDamage(damageDealt); facing = moveExtensions.getMove(fightOrder[i]); animator.Play("AttackLeft"); //changing this to an actual bottle throwing animation would be nice //but unlikely Bottle proj = (Bottle)Instantiate(bottlePrefab, gameObject.transform.position + bottleOffset, Quaternion.identity); proj.target_x = target.x; proj.target_y = target.y; if (Random.Range(0, 5) == 0) { SFXManager.PlayerVoice(); } return(true); } } } } } return(false); } }
public void attack(Entity entity) { entity.takeDamage (strength); }
public override void play(ref Entity other, ref Player p) { other.takeDamage(1); base.play(ref p); }
public void play(Entity other, Player p) { other.takeDamage(3); other.abilityList.Add("frozen"); base.play(ref p); }
public void play(Entity other, Player p) { other.takeDamage(6); base.play(ref p); }
private void damageIfEnemy(Entity other) { if (other != null && other.getIsPlayer() != GameManager.gameManager.getPlayerTurn()) { other.takeDamage(); } }