public override void DealDamage(LivingCreature target) { if (target != null) { target.TakeDamage(damage); } }
void DamageHittableTarget(RaycastHit hit) { LivingCreature hitObj = hit.transform.GetComponent <LivingCreature>(); //checks if the object hit is part of the LivingCreature Class if (hitObj != null) // if it is part of the class, take damage { hitObj.TakeDamage(damage); hitObj.KnockBackWhenShot(impactForce); } }
public override int Heal(LivingCreature target) { if (target != null) { target.Heal(20); return(20); } return(0); }
protected virtual void Awake() { if (transform.root.GetComponent <LivingCreature>() != null) { creature = transform.root.GetComponent <LivingCreature>(); } else if (transform.parent.GetComponent <LivingCreature>() != null) { creature = transform.parent.GetComponent <LivingCreature>(); } }
void Explode(Collision collision) { KillObject(); LivingCreature hitObj = collision.collider.transform.GetComponent <LivingCreature>(); //checks if the object hit is part of the LivingCreature Class if (hitObj != null) // if it is part of the class, take damage { hitObj.TakeDamage(explosionDamage); hitObj.KnockBackWhenShot(explosionForce); } }
//******************************************************************************** public void OnNewborn(LivingCreature iNewborn) { for (int i = 0; i < humans.Count; i++) { if (humans[i] == null) { humans[i] = iNewborn; return; } } humans.Add(iNewborn); }
public override bool Damage(int damageTaken, LivingCreature dmgSource, int knockbackPower) { base.Damage(damageTaken, dmgSource, knockbackPower); if (stats.invincible) { return(false); } #region Restore Health if (RestoreHeatlhOn) { healthToRestore += damageTaken; timeToRH = timeForRH; if (timeToRH <= 0) { timeToRH = timeForRH; } } #endregion #region Stun if (!stats.stunned) { if (anim != null) { anim.SetTrigger("Stunned"); } stats.stunned = true; } #endregion #region Knockback if (knockbackPower != 0 && dmgSource != null) { float direction = Mathf.Sign(dmgSource.transform.position.x - transform.position.x); float velocityX = (direction > 0 ? -1 : 1) * knockbackPower; controller.velocity.x += velocityX; } #endregion return(true); }
/// <summary> /// 逻辑层创建未添加的角色 /// </summary> /// <param name="name"></param> public static void LogicCreatPlayer(string name, int id) { var tempobject = new LivingCreature(); tempobject.name = name; tempobject.id = id; //Debug.Log("player name " + name); tempobject.tag = "player" + id; tempobject.pos = new Vector3(0, 0, 0); tempobject.rot = new Vector3(0, 0, 0); tempobject.InitLivinngCreature(); //PlayerMp[name] = Instantiate(MyResources[PlayerResourcesName[i]],tempobject.pos,tempobject.rot); obinfmp[name] = tempobject; }
public override bool Damage(int damageTaken, LivingCreature dmgSource, int knockbackPower) { base.Damage(damageTaken, dmgSource, knockbackPower); if (dmgSource is SummonCreature) { if (dmgSource.transform != null) { controller.enemyTarget = dmgSource.transform; } } if (stats.invincible) { return(false); } if (!stats.stunned) { if (anim != null) { anim.SetTrigger("Stunned"); } if (controller != null) { controller.attacked = false; } stats.stunned = true; } if (hitParticles != null) { GameObject clone = Instantiate(hitParticles, transform.position, transform.localRotation, transform); Destroy(clone, 3f); } // Knockback if (knockbackPower != 0 && dmgSource != null && controller != null && !stats.immovable && !controller.freeze) { float direction = Mathf.Sign(dmgSource.transform.position.x - transform.position.x); float velocityX = (direction > 0 ? -1 : 1) * knockbackPower; controller.velocity.x += velocityX; } return(true); }
protected virtual void Start() { if (playerTarget == null) { playerTarget = GameManager.player.transform; target = playerTarget; } attackTimer = attackCooldown; controller = GetComponent <Controller2D>(); creature = GetComponent <LivingCreature>(); anim = GetComponent <Animator>(); if (pathfinding && GetComponent <Seeker>() != null) { seeker = GetComponent <Seeker>(); StartCoroutine(UpdatePath()); } }
protected virtual void OnTriggerStay2D(Collider2D other) { if (ignoreFlying && other.gameObject.layer == 13) { return; } if (other.GetComponent <LivingCreature>() == null) { return; } LivingCreature _target = other.GetComponent <LivingCreature>(); if (!_target.stats.alive) { return; } if (_target == creature) { return; } if ((_target is PlayerCreature || _target is SummonCreature) && target == Target.enemy) { return; } if (_target is EnemyCreature && target == Target.player) { return; } bool hit = _target.Damage(damage, creature, creature == null ? 0 : creature.stats.knockbackPower); if (hit) { AfterHit(other.gameObject); } }
public void OnTriggerEnter2D(Collider2D col) { //for some reason this reads col as player so i need to go down and find the weapon through this //child thing target = col.gameObject.GetComponent <LivingCreature>(); if (target) { Vector3 enemyPos = target.transform.position; if (target.GetComponent <Enemy>()) { print(target.ToString() + " taking damage"); target.RecieveDamage(player.GetLastAttack().GetDamage()); //prevent enemy from stopping when no knockback if (player.GetLastAttack().GetKnockBack() > 0) { KnockBack(target); } } } }
private void KnockBack(LivingCreature lc) { if (lc.GetComponent <Enemy>()) { enemyTarget = lc.GetComponent <Enemy>(); } Vector3 enemyPos = lc.transform.position; Vector2 weaponPos = transform.position; float xDifference = weaponPos.x - enemyPos.x; Rigidbody2D targetRB = lc.GetComponent <Rigidbody2D>(); //player is on the left of enemy if (xDifference < 0) { targetRB.AddForce(Vector2.right * player.GetLastAttack().GetKnockBack(), ForceMode2D.Impulse); } //player is on the right of enemy else if (xDifference > 0) { targetRB.AddForce(Vector2.left * player.GetLastAttack().GetKnockBack(), ForceMode2D.Impulse); } }
//******************************************************************************** static void UpdateLivingCreate(List <LivingCreature> iLivingCreature, float[,] iFertilityGrid, List <LivingCreature> iEnemies) { var creatures = new List <LivingCreature>(iLivingCreature); foreach (var creature in creatures) { if (creature != null) { var closestFood = FindClosestResource(iFertilityGrid, creature.transform.position); if (creature.IsAdult && iEnemies.Count > 0) { var closestEnemy = LivingCreature.FindClosest(iEnemies, creature.transform.position); if (closestEnemy != null && Vector3.Distance(closestEnemy.transform.position, creature.transform.position) < 5.0f) { closestFood = new Vector2(closestEnemy.transform.position.x, closestEnemy.transform.position.y); } } creature.UpdateLogic(iLivingCreature, closestFood, GetAreaFertility(iFertilityGrid, creature.transform.position)); } } }
public virtual bool Damage(int damageTaken, LivingCreature dmgSource, int knockbackPower) { if (stats.invincible) { return(false); } else { if (damageTaken > stats.curHealth) { damageTaken = stats.curHealth; } if (damageDisplay != null) { GameObject clone = Instantiate(damageDisplay, transform.position, Quaternion.identity); Text txt = clone.transform.GetChild(0).GetComponent <Text>(); if (dmgSource is PlayerCreature) { txt.text = (WeaponController.wc.eqWeaponCurAttack.crit ? "<color=yellow>CRIT " : "") + damageTaken.ToString() + (WeaponController.wc.eqWeaponCurAttack.crit ? "!</color>" : ""); } else { txt.text = damageTaken.ToString(); } clone.GetComponent <Animator>().SetTrigger("Display"); clone.transform.SetParent(GameObject.Find("DamageNumbers").transform); Destroy(clone, 1f); } stats.curHealth -= damageTaken; stats.Invincibility(); return(true); } }
public void DealDamage(LivingCreature target) { target.TakeDamage(damage); }
public override int Damage(LivingCreature Target) { throw new NotImplementedException(); }
public LivingCreatureActionController(LivingCreature livingCreature) { _livingCreature = livingCreature; _livingCreature.ServiceManager.DestroyHandler += OnDestroy; _livingCreature.ServiceManager.UpdateHandler += OnUpdate; }
public void changeMonsterLabelHealth(LivingCreature livingCreature) { this.form.setMonsterLabelText(getLabel("monsterHpLabel"), livingCreature.currentHp.ToString() + " / " + livingCreature.maxHp.ToString()); }
public async Task <IActionResult> Update(LivingCreature creature) { await _livingCreatureRepository.Update(creature); return(Ok()); }
public virtual void DealDamage(LivingCreature target) { Debug.Log($"DealDamage() on {gameObject} not implemented!"); }
public override void Use(LivingCreature Target) { }
public async Task AddCreature(LivingCreature creature) { await _livingCreatreCollction.InsertOneAsync(creature); }
public async Task Update(LivingCreature creature) { await _livingCreatreCollction.ReplaceOneAsync(_ => _.Id == creature.Id, creature); }
void Awake() { line = GetComponent <LineRenderer>(); player = transform.root.GetComponent <Player>(); playerStats = transform.root.GetComponent <PlayerCreature>(); }