public IEnemy GetNearestEnemyFromTheEntity(IFieldEntity entity) { IEnemy nearestEnemy = null; float nearestDistance = Mathf.Infinity; foreach(IEnemy enemy in enemies) { float distanceToTheEntity = Vector2.Distance(entity.GetPosition(), enemy.GetPosition()); if (nearestDistance > distanceToTheEntity) { nearestDistance = distanceToTheEntity; nearestEnemy = enemy; } } return nearestEnemy; }
public IEnemy GetNearestEnemyFromTheEntity(IFieldEntity entity) { IEnemy nearestEnemy = null; float nearestDistance = Mathf.Infinity; foreach (IEnemy enemy in enemies) { float distanceToTheEntity = Vector2.Distance(entity.GetPosition(), enemy.GetPosition()); if (nearestDistance > distanceToTheEntity) { nearestDistance = distanceToTheEntity; nearestEnemy = enemy; } } return(nearestEnemy); }
private int GetStrengthForPlayerAtPositionRecursive(Vector2Int pos, Vector2Int dir, PlayerKey requestingPlayer) { pos += dir; if (!fieldEntities.ContainsKey(pos)) { return(0); } IFieldEntity fieldEntity = fieldEntities[pos]; if (fieldEntity.TryGetEntity <CardInstance <Monster> >(out CardInstance <Monster> monster)) { if (cardInstances[monster] == requestingPlayer) { return(GetStrengthForPlayerAtPositionRecursive(pos, dir, requestingPlayer) + monster.data.combatValue); } else { return(0); } } return(0); }
public void Init(FieldEntity <CardInstance <Monster> > cardInstance) { data = cardInstance; }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> bool IEquatable <IFieldEntity <Guid> > .Equals(IFieldEntity <Guid> other) { return(Equals(other)); }
/// <summary> /// Indicates whether the current <see cref="object"/> is equal to another <see /// cref="object"/> of the same type. /// </summary> /// <param name="other">An <see cref="object"/> to compare with this <see cref="object"/>.</param> /// <returns> /// <c>true</c> if the current <see cref="object"/> is equal to the <paramref /// name="other"/> parameter; otherwise, false. /// </returns> /// <seealso cref="M:System.IEquatable{Jaytas.Omilos.Common.Domain.Interfaces.IBaseEntity{Guid}}.Equals(IBaseEntity{Guid})"/> public virtual bool Equals(IFieldEntity <Guid> other) { return(null != other && other.ExposedId.Equals(ExposedId)); }