private static bool ResolveSimple(List <AttackTarget> results, List <Entity> units, Dictionary <int, List <EntityTarget> > unitTargets)
        {
            foreach (Entity unit in units)
            {
                EntityTarget        bestTarget = null;
                List <EntityTarget> targets    = unitTargets[unit.Id];

                foreach (EntityTarget target in targets)
                {
                    Entity enemy = target.Entity;
                    if (bestTarget == null || (enemy.CanAttack && enemy.Health < bestTarget.Entity.Health))
                    {
                        bestTarget = target;
                    }
                }

                if (bestTarget != null)
                {
                    results.Add(new AttackTarget(unit, bestTarget.Entity));
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
 public HarmEffect(int damage, EDamageType damageType, int statID, EntityTarget useOn)
 {
     Damage     = damage;
     DamageType = damageType;
     StatID     = statID;
     UseOn      = useOn;
 }
Exemple #3
0
        public static void OreToIngot()
        {
            var player = PlayerMobile.GetPlayer();
            var ores   = Scanner.Find <Item>(Ore, 0xFFFF, Stealth.Client.GetBackpackID(), false);
            var forge  = Scanner.Find <Item>(Forge, 0xFFFF, Stealth.Client.GetBackpackID(), false);

            foreach (var ore in ores)
            {
                ore.DoubleClick();
                var target = new EntityTarget(1000);
                target.Action(forge[0]);
            }
        }
Exemple #4
0
 protected void BroadcastValueChange()
 {
     if (BaseEntityEx.IsValid(this))
     {
         EntityTarget target       = GetTarget();
         AppBroadcast appBroadcast = Facepunch.Pool.Get <AppBroadcast>();
         appBroadcast.entityChanged          = Facepunch.Pool.Get <AppEntityChanged>();
         appBroadcast.entityChanged.entityId = net.ID;
         appBroadcast.entityChanged.payload  = Facepunch.Pool.Get <AppEntityPayload>();
         FillEntityPayload(appBroadcast.entityChanged.payload);
         CompanionServer.Server.Broadcast(target, appBroadcast);
     }
 }
Exemple #5
0
 public BaseModifier(string modifierName)
 {
     eventActions   = new Dictionary <ModifierEventType, List <BaseAction> >();
     properties     = new Dictionary <Modifier_Property, AbilitySpecial>();
     modifierParams = ModifierManager.GetModifier(modifierName);
     isAura         = modifierParams.isAura;
     isOrb          = eventActions.ContainsKey(ModifierEventType.Orb);
     if (isAura)
     {
         auraRadius = modifierParams.auraRadius;
         auraTarget = new EntityTarget(modifierParams.auraTargetTeam, modifierParams.auraTargetType, modifierParams.auraTargetFlags);
     }
     //name = modifierName;
 }
Exemple #6
0
        public static void Rush(List <Entity> units, List <Entity> enemies)
        {
            foreach (Entity unit in units.ToList())
            {
                EntityTarget target = Helper.GetNearest(unit.Position, enemies);
                if (target == null)
                {
                    continue;
                }

                Entity enemy = target.Entity;
                MoveHelper.Move(unit, enemy.Position);
                units.Remove(unit);
            }
        }
        private static bool ResolveOneOnOne(List <AttackTarget> result, List <Entity> units, Dictionary <int, List <EntityTarget> > unitTargets)
        {
            var resolved = false;

            foreach (Entity unit in units)
            {
                List <EntityTarget> targets = unitTargets[unit.Id];
                if (targets.Count == 1) // only one target for unit
                {
                    EntityTarget target = targets[0];
                    result.Add(new AttackTarget(unit, target.Entity));
                    resolved = true;
                }
            }

            return(resolved);
        }
Exemple #8
0
        private static bool CheckSpawn(EntityType type, Point candidate, int size, ref int minDistance, ref Point spawn)
        {
            if (!CanBuildHere(candidate, size))
            {
                return(false);
            }

            if (type == EntityType.Turret)
            {
                if (candidate.X < 18 && candidate.Y < 18 ||
                    candidate.X < 8 || candidate.Y < 8)
                {
                    return(false);
                }

                List <Entity> turrets       = World.All(e => e.My && e.Type == EntityType.Turret);
                EntityTarget  nearestTurret = Helper.GetNearest(candidate, turrets);
                if (nearestTurret != null && nearestTurret.Distance < 5)
                {
                    return(false);
                }
            }

            if (type == EntityType.RangedBase)
            {
                if (candidate.X < 5 || candidate.Y < 5)
                {
                    return(false);
                }
            }

            var target   = new Point(0, 0);
            int distance = candidate.L1(target);

            if (distance < minDistance)
            {
                spawn       = candidate;
                minDistance = distance;
                return(true);
            }

            return(false);
        }
Exemple #9
0
	public ProjectileItem(BaseEntity source, BaseAbility ability, ProjectileItemParams infoParams, EntityTarget target)
	{
		this.source = source;
		this.ability = ability;
		this.infoParams = infoParams;
		this.target = target;
		this.projectileID = ProjectileManager.Instance.GernerateProjectileID();
		this.velocity = infoParams.velocity;
		this.position = infoParams.spawnOrigin;
		this.expireTime = infoParams.expireTime;
		this.particleItem = new ParticleItem(this.infoParams.effectName, this.source);

		var obj = new GameObject("projectile"+projectileID);
		obj.AddComponent<BoxCollider>();
		shellObj = obj.transform;
		CObjectsPool.Instance.Instantiate("", infoParams.effectName, (_obj,uid)=>{
			var tmp = _obj as Transform;
			if(tmp != null) tmp.parent = shellObj;
		} ,ObjectType.Effect);
	}
Exemple #10
0
        public static void Apply(List <Entity> units)
        {
            List <Entity> ranges = units.Where(u => u.Type == EntityType.RangedUnit).ToList();

            List <Entity> enemies = World.All(e => !e.My && e.Type == EntityType.MeleeUnit);

            foreach (Entity ranged in ranges)
            {
                EntityTarget target = Helper.GetNearest(ranged.Position, enemies);
                if (target == null)
                {
                    continue;
                }

                if (target.Distance == ranged.AttackDistance + target.Entity.AttackDistance)
                {
                    units.Remove(ranged);
                }
                else
                {
                    ;
                    if (target.Distance == 2)
                    {
                        var cowardPositions = Helper
                                              .GetNeighbors(ranged.Position)
                                              .AsTiles()
                                              .Where(t => t.CanMoveHere && !t.Attacked)
                                              .AsPoints()
                                              .ToList();

                        if (cowardPositions.Count > 0) // Не убегать если FATALITY!
                        {
                            var p = Dice.Roll(cowardPositions);
                            MoveHelper.Move(ranged, p);
                            units.Remove(ranged);
                        }
                    }
                }
            }
        }
 public TeleportEffect(EntityTarget useOn)
 {
     UseOn = useOn;
 }
Exemple #12
0
 public void SetTarget(EntityTarget target)
 {
     this.target = target;
 }
Exemple #13
0
 public HealEffect(int restore, int statID, EntityTarget useOn)
 {
     Restore = restore;
     StatID  = statID;
     UseOn   = useOn;
 }