コード例 #1
0
    /* Equips an item to an actor's arms, giving it max ammo if relevant. */
    public static void PrimaryEquip(string item, ref Actor actor)
    {
        Data dat = Item.GetItem(item);

        if (dat != null)
        {
            if (dat.itemType == Item.RANGED)
            {
                Ranged.MaxAmmo(ref dat);
            }
            actor.Equip(dat);
        }
        else
        {
            MonoBehaviour.print(item + " was null!");
        }
    }
コード例 #2
0
    public float judgeAbility(Unit user, Tile move, out Tile target)
    {
        HashSet <Tile> possibleTargets = GetAvailableTargets(move);

        target = null;
        if (possibleTargets.Count == 0)
        {
            return(0);
        }

        float value    = 0;
        float maxValue = 0;

        foreach (Tile q in possibleTargets)
        {
            value = 0;
            if (q.Unit.damageTaken < user.Character.Level + 10)
            {
                value = 0;
            }
            else
            {
                value  = q.Unit.damageTaken;
                value += 5;
                HashSet <Unit> enemyUnits = UnitManager.Instance.GetUnitsByHostility(user);
                foreach (Unit u in enemyUnits)
                {
                    if (Melee.StaticGetTiles(u.Tile).Contains(move))
                    {
                        value -= 1;
                    }
                    if (Ranged.staticGetTiles(u.Tile).Contains(move))
                    {
                        value -= 1;
                    }
                }
            }

            if (value > maxValue)
            {
                target   = q;
                maxValue = value;
            }
        }
        return(maxValue);
    }
コード例 #3
0
ファイル: WeaponSpawner.cs プロジェクト: justi1jc/FPS
    /* Spawns this weapon, giving it full ammo if applicable. */
    private void Spawn()
    {
        Data dat = Item.GetItem(weaponName);

        if (dat != null)
        {
            if (dat.itemType == Item.RANGED)
            {
                Ranged.MaxAmmo(ref dat);
            }
            Item item = Item.GetItem(dat);
            if (item != null)
            {
                weapon = item.gameObject;
                weapon.transform.position = transform.position;
            }
        }
    }
コード例 #4
0
ファイル: HostileAI.cs プロジェクト: justi1jc/FPS
    /* Returns true if this ranged weapon has ammo in it, or in the actor's
     * inventory. */
    public bool HasAmmo(Ranged r)
    {
        if (r.ammo > 0)
        {
            return(true);
        }
        Inventory inv = actor.inventory;

        for (int i = 0; i < inv.slots; i++)
        {
            Data dat = inv.Peek(i);
            if (dat != null && dat.displayName == r.ammunition)
            {
                return(true);
            }
        }
        return(false);
    }
コード例 #5
0
ファイル: RangedCombatAI.cs プロジェクト: justi1jc/FPS
    public override IEnumerator Begin()
    {
        yield return(new WaitForSeconds(0f));

        Item item = actor.arms.Peek(EquipSlot.RIGHT);

        if (item is Ranged)
        {
            weapon = (Ranged)item;
        }
        if (weapon == null)
        {
            manager.Change("HOSTILE");
            yield break;
        }
        if (manager.target != null)
        {
            combatant = manager.target.GetComponent <Actor>();
        }
        if (combatant != null && combatant.Alive())
        {
            actor.StartCoroutine(FireAt());
            actor.StartCoroutine(Positioning());
        }
        while (combatant != null && combatant.Alive())
        {
            yield return(new WaitForSeconds(1f));
        }
        firing = positioning = false;
        actor.StopCoroutine("Pursue");
        actor.StopCoroutine("AimAt");
        actor.StopCoroutine("MoveTo");
        if (actor.defaultAI != "")
        {
            manager.Change(actor.defaultAI);
        }
        else
        {
            manager.Change("IDLE");
        }
    }
コード例 #6
0
    public static Loot GetRandLoot(float value)
    {
        float r = Random.value;

        if (r < 0.1f)
        {
            return(Melee.GetRand(value));
        }
        if (r < 0.3f)
        {
            return(Ranged.GetRand(value));
        }
        if (r < 0.4f)
        {
            return(Shield.GetRand(value));
        }
        if (r < 1.0f)
        {
            return(Armor.GetRand(value));
        }
        return(null);
    }
コード例 #7
0
    public static void DualEquip(string item, ref Actor actor)
    {
        Data dat = Item.GetItem(item);

        if (dat != null)
        {
            if (dat.itemType == Item.RANGED)
            {
                Ranged.MaxAmmo(ref dat);
            }
            if (!actor.arms.DualEquipAvailable(dat))
            {
                MonoBehaviour.print("Could not dual equip " + item);
                return;
            }
            actor.DualEquip(dat);
        }
        else
        {
            MonoBehaviour.print(item + " was null!");
        }
    }
コード例 #8
0
        public static Single ModuloAddWithCarry(this Ranged <Single> ranged, Single value)
        {
            var    sum   = ranged.Value + value;
            Single carry = (Single)0;

            if (sum <= ranged.Max && sum >= ranged.Min)
            {
                ranged.Value = (Single)sum;
                return(carry);
            }

            Single positions = (Single)(ranged.Max - ranged.Min + 1);
            Single remainder = (Single)0;

            carry = Numbers.Divide((Single)(sum - ranged.Min), positions, out remainder);

            Single result;

            if (remainder >= 0)
            {
                result = (Single)(ranged.Min + remainder);
            }
            else
            {   // remainder is negative, back off from max & decrement carry
                result = (Single)(ranged.Max + 1 + remainder);
                carry--;
            }
            ranged.Value = result;
#if DEBUG
            if (Math.Abs(ranged.Value - result) > 1e-12)
            {
                throw new Exception($"Value={result} failed range [{ranged.Min},{ranged.Max}], {ranged.Value}+{value}, {carry}R{remainder}");
            }
#endif
            return(carry);
        }
コード例 #9
0
        public static Int64 ModuloAddWithCarry(this Ranged <Int64> ranged, Int64 value)
        {
            var   sum   = ranged.Value + value;
            Int64 carry = (Int64)0;

            if (sum <= ranged.Max && sum >= ranged.Min)
            {
                ranged.Value = (Int64)sum;
                return(carry);
            }

            Int64 positions = (Int64)(ranged.Max - ranged.Min + 1);
            Int64 remainder = (Int64)0;

            carry = Numbers.Divide((Int64)(sum - ranged.Min), positions, out remainder);

            Int64 result;

            if (remainder >= 0)
            {
                result = (Int64)(ranged.Min + remainder);
            }
            else
            {   // remainder is negative, back off from max & decrement carry
                result = (Int64)(ranged.Max + 1 + remainder);
                carry--;
            }
            ranged.Value = result;
#if DEBUG
            if (ranged.Value != result)
            {
                throw new Exception($"Value={result} failed range [{ranged.Min},{ranged.Max}], {ranged.Value}+{value}, {carry}R{remainder}");
            }
#endif
            return(carry);
        }
コード例 #10
0
 /// <summary>
 /// Initiates attack on unit
 /// </summary>
 /// <param name="defender">Unit thats being attacked</param>
 /// <param name="goal">Place on field attacking unit is going to</param>
 public void attackUnit(UnitGameObject defender, Point goal)
 {
     if (!isWalking && !finishedWalking && !attacking)
     {
         UnitGameObject activeUnit    = initative[whoseTurn];
         Unit           attackingUnit = activeUnit.UnitTree.GetUnits()[activeUnit.PosInUnitTree];
         //If unit does not need to move, call on method for attacking without moving
         if (activeUnit.LogicalPos.Equals(goal))
         {
             battleField.attackWithoutMoving(activeUnit.LogicalPos, defender.LogicalPos, false);
             beginAttacking(defender.LogicalPos.x);
         }
         else
         {
             //checks if unit is ranged, and if it has ammo. if not move and attack
             if (attackingUnit.IsRanged)
             {
                 Ranged r = (Ranged)attackingUnit;
                 if (r.Ammo > 0 && !r.Threatened)
                 {
                     battleField.attackWithoutMoving(activeUnit.LogicalPos, defender.LogicalPos, true);
                     beginAttacking(defender.LogicalPos.x);
                 }
                 else
                 {
                     path = battleField.UnitMoveAndAttack(activeUnit.LogicalPos, goal, defender.LogicalPos);
                     BeginWalking();
                     attacking = true;
                 }
             }
             else
             {
                 path = battleField.UnitMoveAndAttack(activeUnit.LogicalPos, goal, defender.LogicalPos);
                 BeginWalking();
                 attacking = true;
             }
         }
         //Updates living units counts
         if (defender.UnitTree.getUnitAmount(defender.PosInUnitTree) == 0)
         {
             if (defender.AttackingSide)
             {
                 livingAttackers--;
             }
             else
             {
                 livingDefenders--;
             }
         }
         if (activeUnit.UnitTree.getUnitAmount(activeUnit.PosInUnitTree) == 0)
         {
             if (activeUnit.AttackingSide)
             {
                 livingAttackers--;
             }
             else
             {
                 livingDefenders--;
             }
         }
         Debug.Log(livingAttackers + " " + livingDefenders);
         updateAmount(defender);
         updateAmount(getUnitWhoseTurnItIs());
     }
 }
コード例 #11
0
        private void GenerateGrid()
        {
            for (int x = 0; x < Battleground.Width; x++)
            {
                for (int y = 0; y < Battleground.Height; y++)
                {
                    var tile = Place(x, y);
                    _objects.Add(tile);

                    tile.name = $"Tile[{x}, {y}]";
                    tile.transform.position = new Vector2(x, y);
                }
            }

            GameObject Place(int x, int y)
            {
                IBehaviour behaviour;
                var        tile    = Battleground[x, y];
                GameObject @object = null;

                if (tile == null)
                {
                    return(Instantiate(EmptyTile, transform));
                }

                if (tile.Type == Unit.Type.Archer)
                {
                    @object = Instantiate(ArcherTile, transform);
                }
                if (tile.Type == Unit.Type.Wizard)
                {
                    @object = Instantiate(WizardTile, transform);
                }
                if (tile.Type == Unit.Type.Dragon)
                {
                    @object = Instantiate(DragonTile, transform);
                }
                if (tile.Type == Unit.Type.Infantry)
                {
                    @object = Instantiate(InfantryTile, transform);
                }
                if (tile.Type == Unit.Type.Knight)
                {
                    @object = Instantiate(KnightTile, transform);
                }

                if (tile.Type == Unit.Type.Archer || tile.Type == Unit.Type.Wizard)
                {
                    behaviour = new Ranged();
                }
                else
                {
                    behaviour = new Melee();
                }

                if (x == Battleground.Width - 1)
                {
                    var enemy = @object.AddComponent <EnemyComponent>();
                    enemy.Behaviour = behaviour;
                    enemy.Enemy     = Game.Heroes[0];
                    enemy.Behaviour.Control(Battleground, Battleground[x, y]);

                    var sprite = @object.GetComponent <SpriteRenderer>();
                    sprite.flipX = true;
                }
                else
                {
                    var player = @object.AddComponent <PlayerComponent>();
                    player.Behaviour = behaviour;
                    player.Behaviour.Control(Battleground, Battleground[x, y]);
                }

                return(@object);
            }
        }
コード例 #12
0
ファイル: Game1.cs プロジェクト: davemcal/SuperDeathRay
        Enemy createEnemy(int x, int y, int z)
        {
            Enemy e = new Enemy(player);
            e.tex = tex_dict["dog"];
            if (z < 3)
            {
                e = new Ranged(player);
                e.tex = tex_dict["police"];
                e.addPoint(new Vector2(0, 7));
                e.addPoint(new Vector2(64, 7));
                e.addPoint(new Vector2(64, 37));
                e.addPoint(new Vector2(0, 37));
                e.translate(new Vector2(x + 50, y + 50));
            }
            else
            {
                e.addPoint(new Vector2(16, 0));
                e.addPoint(new Vector2(45, 0));
                e.addPoint(new Vector2(45, 60));
                e.addPoint(new Vector2(0, 60));
                e.translate(new Vector2(x + 50, y + 50));

            }
            //e.offset = new Vector2(21, 0);
            /*e.addPoint(new Vector2(21, 0));
            e.addPoint(new Vector2(42, 0));
            e.addPoint(new Vector2(64, 21));
            e.addPoint(new Vector2(64, 42));
            e.addPoint(new Vector2(42, 64));
            e.addPoint(new Vector2(21, 64));
            e.addPoint(new Vector2(0, 42));
            e.addPoint(new Vector2(0, 21));
            e.translate(new Vector2(x+50, y+50));*/

            return e;
        }
コード例 #13
0
        /// <summary>
        /// Handles a circular skill.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="packet">The packet.</param>
        /// <param name="spellPacket">The spell packet.</param>
        /// <param name="spellInfo">The spell info.</param>
        /// <param name="isMagic">Boolean determining whether the circular skill is a magic skill or not.</param>
        /// <returns>True if the skill was handled correct.</returns>
        /// <remarks>This handles all types of circular skills (Physical, Magic, Ranged.) however ranged and physical is determined from either the skill id or whether isMagic is set.</remarks>
        public static bool Handle(AttackableEntityController attacker,
                                  Models.Packets.Entities.InteractionPacket packet,
                                  Models.Packets.Spells.SpellPacket spellPacket,
                                  Models.Spells.SpellInfo spellInfo,
                                  bool isMagic)
        {
            spellPacket.Process = true;

            if (!isMagic && spellInfo.Id < 8000 &&
                packet.TargetClientId == attacker.AttackableEntity.ClientId)
            {
                return(false);
            }

            var attackerPlayer = attacker as Models.Entities.Player;

            if (attackerPlayer != null)
            {
                if (DateTime.UtcNow < attackerPlayer.NextLongSkill)
                {
                    attackerPlayer.SendSystemMessage("REST");
                    return(false);
                }

                attackerPlayer.NextLongSkill = DateTime.UtcNow.AddMilliseconds(Data.Constants.Time.LongSkillTime);
            }

            foreach (var possibleTarget in attacker.GetAllInScreen())
            {
                if (spellPacket.Targets.Count > 8)
                {
                    return(true);
                }

                var target = possibleTarget as AttackableEntityController;

                if (target != null)
                {
                    if (!TargetValidation.Validate(attacker, target))
                    {
                        continue;
                    }

                    if (target.ContainsStatusFlag(Enums.StatusFlag.Fly))
                    {
                        continue;
                    }

                    if (Tools.RangeTools.GetDistanceU(attacker.MapObject.X, attacker.MapObject.Y, target.MapObject.X, target.MapObject.Y) >= 8)
                    {
                        continue;
                    }

                    bool isRanged = (spellInfo.Id == 8030 || spellInfo.Id == 10308 || spellInfo.Id == 7013 || spellInfo.Id > 10360);

                    uint damage = isRanged ?
                                  Calculations.RangedCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity) :
                                  isMagic?
                                  Calculations.MagicCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity, spellInfo) :
                                      Calculations.PhysicalCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity);

                    Damage.Process(attacker, target, ref damage, false);

                    if (isRanged && attackerPlayer != null)
                    {
                        Ranged.DecreaseArrows(attackerPlayer, 3);
                    }

                    if (damage > 0)
                    {
                        TargetFinalization.SkillFinalize(attacker, target, spellPacket, damage);
                    }
                }
            }

            return(true);
        }
コード例 #14
0
    private void parseAction(string s)
    {
        string[] pairs = s.Split('$');
        if (pairs.Length > 1)
        {
            string sig = pairs[1].Substring(0, 4);
            if (sig.Equals("unit"))
            {
                string id = pairs[1].Substring(5, pairs[1].Length - 5);
                for (int i = 2; i < pairs.Length; i++)
                {
                    switch (pairs[i].Substring(0, 4))
                    {
                    case "move":
                        try
                        {
                            string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                            Unit     u      = ((Unit)(GameData.LevelObjects.Find(id)));
                            u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1]));
                            u.TargetUnit     = null;
                        }
                        catch (NullReferenceException e)
                        {
                            string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                            Unit     u      = ((Unit)(GameData.LevelObjects.Find(id)));
                            if (u != null)
                            {
                                u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1]));
                                //u.TargetUnit = null;
                            }
                            Console.WriteLine("null");
                        }
                        break;

                    case "targ":
                        try
                        {
                            string targID  = pairs[i].Substring(5, pairs[i].Length - 5);
                            Unit   theUnit = ((Unit)(GameData.LevelObjects.Find(id)));
                            Unit   targetU = (Unit)GameData.LevelObjects.Find(targID);
                            theUnit.SetTargetUnit(targID);
                        }
                        catch (NullReferenceException e) { }
                        break;

                    case "tgbd":
                        string bdtgID = pairs[i].Substring(5, pairs[i].Length - 5);
                        ((Unit)(GameData.LevelObjects.Find(id))).targetBuilding = (Building)GameData.Buildings.Find(bdtgID);
                        break;

                    case "buil":
                        //build
                        break;

                    case "damg":
                        try
                        {
                            string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                            string   attackerID = parameters[1];
                            Unit     attacker   = (Unit)(GameData.LevelObjects.Find(attackerID));
                            ((Unit)(GameData.LevelObjects.Find(id))).DealDamage(int.Parse(parameters[0]), attacker);
                        }
                        catch (NullReferenceException e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                        break;

                    case "dead":
                        try
                        {
                            GameData.Units.Remove(((Unit)(GameData.LevelObjects.Find(id))));
                        }
                        catch (NullReferenceException e) {
                            Console.WriteLine(e.ToString());
                        }
                        break;
                    }
                }
            }
            else if (sig.Equals("bdng"))
            {
                Building b        = null;
                bool     polytile = false;
                string   id       = pairs[1].Substring(5, pairs[1].Length - 5);
                for (int i = 2; i < pairs.Length; i++)
                {
                    switch (pairs[i].Substring(0, 4))
                    {
                    case "type":
                        string type = pairs[i].Substring(5, pairs[i].Length - 5);
                        switch (type)
                        {
                        case "NatureBarracks":
                            b = new NatureBarracks();
                            break;

                        case "HumanityBarrack":
                            b        = new HumanityBarrack();
                            polytile = true;
                            break;

                        case "SunlightTree":
                            b = new SunlightTree();
                            break;

                        case "NatureBase":
                            b        = new NatureBase();
                            polytile = true;
                            break;

                        case "HumanityBase":
                            b        = new HumanityBase();
                            polytile = true;
                            break;

                        case "Mine":
                            b = new Mine();
                            break;

                        case "WaterTree":
                            b = new WaterTree();
                            break;
                        }
                        break;

                    case "posi":
                        string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                        b.gridPosition = new Point(int.Parse(coords[0]), int.Parse(coords[1]));
                        break;

                    case "fnsh":

                        GameData.LevelGrid.replaceTile((Tile)GameData.LevelGrid.Objects[b.gridPosition.X, b.gridPosition.Y], b, false);
                        if (polytile)
                        {
                            ((PolyTileBuilding)b).AddQuadCoTiles();
                        }
                        GameData.Buildings.Add(b);
                        break;

                    case "damg":
                        try
                        {
                            string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                            string   attackerID = parameters[1];
                            Unit     attacker   = (Unit)(GameData.LevelObjects.Find(attackerID));
                            ((Building)(GameData.Buildings.Find(id))).DealDamage(int.Parse(parameters[0]), attacker);
                        }
                        catch (NullReferenceException e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                        break;

                    case "dead":
                        try
                        {
                            GameData.Buildings.Remove(((Building)(GameData.LevelObjects.Find(id))));
                        }
                        catch (NullReferenceException e) {
                            Console.WriteLine(e.ToString());
                        }
                        break;
                    }
                }
            }
            else if (sig.Equals("spel"))
            {
                Spell  spell = null;
                string id    = pairs[1].Substring(5, pairs[1].Length - 5);
                for (int i = 2; i < pairs.Length; i++)
                {
                    switch (pairs[i].Substring(0, 4))
                    {
                    case "type":
                        switch (pairs[i].Substring(5, pairs[i].Length - 5))
                        {
                        case "MeteorStorm":
                            spell = new MeteorStorm();
                            break;

                        case "SnowStorm":
                            spell = new SnowStorm();
                            break;

                        case "Spell":
                            spell = new Spell();
                            break;
                        }
                        break;

                    case "posi":
                        string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                        spell.Position = new Vector2(float.Parse(coords[0]), float.Parse(coords[1]));
                        break;
                    }
                }
                spell.ID = id;
                GameData.LevelObjects.Add(spell);
            }
            else if (sig.Equals("addu"))
            {
                Unit u;//$addu:10$type:HumanityWorker$posi:1080,420
                u = null;
                string id = pairs[1].Substring(5, pairs[1].Length - 5);

                for (int i = 2; i < pairs.Length; i++)
                {
                    switch (pairs[i].Substring(0, 4))
                    {
                    case "type":

                        switch (pairs[i].Substring(5, pairs[i].Length - 5))
                        {
                        case "HumanityWorker":
                            u = new HumanityWorker();
                            break;

                        case "NatureWorker":
                            u = new NatureWorker();
                            break;

                        case "Melee1":
                            string asset = "";
                            asset = "natureWolf";
                            if (GameData.player.OppositeFaction == Player.Faction.humanity)
                            {
                                asset = "chainsaw";
                            }
                            u = new Melee1(GameData.player.OppositeFaction, asset, id);
                            break;

                        case "Ranged":
                            asset = "natureWolf";
                            if (GameData.player.OppositeFaction == Player.Faction.humanity)
                            {
                                asset = "flamethrower";
                            }
                            u = new Ranged(GameData.player.OppositeFaction, asset, id);
                            break;

                        case "Melee2":
                            asset = "treeUnit";
                            if (GameData.player.OppositeFaction == Player.Faction.humanity)
                            {
                                asset = "flamethrower";
                            }
                            u = new Melee2(GameData.player.OppositeFaction, asset, id);
                            break;

                        case "FlameThrower":
                            u = new FlameThrower();
                            break;

                        case "Unicorn":
                            asset = "unicorn";
                            if (GameData.player.OppositeFaction == Player.Faction.humanity)
                            {
                                asset = "quad";
                            }
                            u = new Unicorn(GameData.player.OppositeFaction, asset, id);
                            break;

                        case "WoodCutter":
                            u = new WoodCutter();
                            break;

                        case "Unit":
                            u = new Unit();
                            break;
                        }
                        break;

                    case "posi":
                        string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(',');
                        u.Position = new Vector2(int.Parse(coords[0]), int.Parse(coords[1]));
                        break;
                    }
                }
                u.ID = id;
                GameData.Units.Add(u);
                GameData.unitIdIndex++;
            }
        }
    }
コード例 #15
0
        /// <summary>
        /// Handles the single attack skills.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="target">The target.</param>
        /// <param name="interaction">The interaction packet.</param>
        /// <param name="usespell">The usespell packet.</param>
        /// <param name="spell">The spell.</param>
        /// <param name="damage">The damage.</param>
        /// <returns>Returns true if the skill was used successfully.</returns>
        public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage)
        {
            damage = 0;
            if (attacker is Entities.GameClient)
            {
                if (!Ranged.ProcessClient(attacker as Entities.GameClient, interaction, true))
                {
                    return(false);
                }
            }
            if (attacker.EntityUID == target.EntityUID)
            {
                return(false);
            }
            if (target is Entities.NPC)
            {
                return(false);
            }

            if (target is Entities.BossMonster)
            {
                if (!(target as Entities.BossMonster).CanBeAttacked)
                {
                    return(false);
                }
            }

            if (target is Entities.Monster)
            {
                if (((byte)(target as Entities.Monster).Behaviour) >= 3)
                {
                    return(false);
                }
            }

            if (target is Entities.GameClient)
            {
                if (!(target as Entities.GameClient).LoggedIn)
                {
                    return(false);
                }

                if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient))
                {
                    return(false);
                }

                if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10)))
                {
                    return(false);
                }

                if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5)))
                {
                    return(false);
                }

                if (!Combat.FixTarget(attacker, target))
                {
                    return(false);
                }
            }

            if (attacker is Entities.GameClient)
            {
                Ranged.DecreaseArrows(attacker as Entities.GameClient, 1);
            }
            damage = Calculations.Battle.GetRangedDamage(attacker, target);
            damage = (uint)(damage * 1.5);
            Combat.ProcessDamage(attacker, target, ref damage, false);
            if (damage > 0)
            {
                if (!(target is Entities.GameClient))
                {
                    uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage);
                    if (target.Level > (attacker.Level + 10))
                    {
                        exp *= 2;
                    }
                    if ((attacker is Entities.GameClient))
                    {
                        (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp);
                    }
                }
                usespell.AddTarget(target.EntityUID, damage);
            }
            return(true);
        }
コード例 #16
0
 public ArcherAdapter(Ranged ranger)
 {
     this.ranger = ranger;
 }
コード例 #17
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     base.OnStateEnter(animator, stateInfo, layerIndex);
     ranged = animator.gameObject.GetComponent <Ranged>();
     ranged.StartFiring();
 }
コード例 #18
0
ファイル: Projectile.cs プロジェクト: Drakon0168/Strength
 public void Init(Ranged ability, Vector2 direction)
 {
     this.ability = ability;
     velocity     = direction * flightSpeed;
 }
コード例 #19
0
        /// <summary>
        /// Handles the circle skills.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="targets">The targets. [not set yet]</param>
        /// <param name="interaction">The interaction packet.</param>
        /// <param name="usespell">The usespell packet.</param>
        /// <param name="spell">The spell.</param>
        /// <param name="damage">The damage.</param>
        /// <returns>Returns true if the skill was used successfully.</returns>
        public static bool HandleMag(Entities.IEntity attacker, ConcurrentBag <Entities.IEntity> targets, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage)
        {
            damage = 0;

            if (attacker is Entities.GameClient)
            {
                if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360)
                {
                    if (!Ranged.ProcessClient(attacker as Entities.GameClient, interaction, true, 3))
                    {
                        return(false);
                    }
                }
            }

            /*Calculations.InLineAlgorithm ila = new ProjectX_V3_Game.Calculations.InLineAlgorithm(
             *      attacker.X, interaction.X, attacker.Y, interaction.Y,
             *      (byte)spell.Range, Calculations.InLineAlgorithm.Algorithm.DDA);*/

            //	Calculations.Sector sector = new ProjectX_V3_Game.Calculations.Sector(attacker.X, attacker.Y, interaction.X, interaction.Y);
            //	sector.Arrange(spell.Sector, spell.Range);

            byte count    = 0;
            bool bluename = false;

            foreach (Maps.IMapObject obj in attacker.Screen.MapObjects.Values)
            {
                if (count > 28)
                {
                    return(true);
                }

                if (!(obj as Entities.IEntity).Alive)
                {
                    continue;
                }

                if (obj is Entities.NPC)
                {
                    continue;
                }

                if (obj.EntityUID == attacker.EntityUID)
                {
                    continue;
                }

                if (obj is Entities.BossMonster)
                {
                    if (!(obj as Entities.BossMonster).CanBeAttacked)
                    {
                        continue;
                    }
                }

                if (obj is Entities.Monster)
                {
                    if (((byte)(obj as Entities.Monster).Behaviour) >= 3)
                    {
                        continue;
                    }
                }

                if (!Core.Screen.ValidDistance(obj.X, obj.Y, attacker.X, attacker.Y))
                {
                    continue;
                }

                if (obj is Entities.GameClient)
                {
                    if (!(obj as Entities.GameClient).LoggedIn)
                    {
                        continue;
                    }

                    if (obj.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient))
                    {
                        continue;
                    }

                    if (attacker is Entities.GameClient)
                    {
                        if ((attacker as Entities.GameClient).PKMode != Enums.PKMode.PK)
                        {
                            continue;
                        }

                        if (!Combat.FixTarget(attacker, obj as Entities.IEntity))
                        {
                            continue;
                        }
                    }
                    if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly))
                    {
                        continue;
                    }

                    if (!(DateTime.Now >= (obj as Entities.GameClient).LoginProtection.AddSeconds(10)))
                    {
                        continue;
                    }

                    if (!(DateTime.Now >= (obj as Entities.GameClient).ReviveProtection.AddSeconds(5)))
                    {
                        continue;
                    }

                    if (!Combat.FixTarget(attacker, (obj as Entities.GameClient)))
                    {
                        continue;
                    }


                    if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.BlueName))
                    {
                        bluename = true;
                    }
                }

                //if (!ila.InLine(obj.X, obj.Y))
                //	continue;

                //if (!sector.Inside(obj.X, obj.Y))
                //	continue;

                Entities.IEntity targetentity = obj as Entities.IEntity;
                if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360)
                {
                    damage = Calculations.Battle.GetRangedDamage(attacker, targetentity);
                }
                else
                {
                    damage = Calculations.Battle.GetMagicDamage(attacker, targetentity, spell);
                }
                Combat.ProcessDamage(attacker, targetentity, ref damage, false);
                if (damage > 0)
                {
                    if (!(targetentity is Entities.GameClient))
                    {
                        uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage);
                        if (targetentity.Level > (attacker.Level + 10))
                        {
                            exp *= 2;
                        }
                        else if (attacker.Level > (targetentity.Level + 10))
                        {
                            exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(1, (int)targetentity.Level);
                        }
                        if ((attacker is Entities.GameClient))
                        {
                            (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp);
                        }
                    }
                    usespell.AddTarget(targetentity.EntityUID, damage);
                    targets.Add(targetentity);
                }
                count++;
            }
            if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360)
            {
                if (attacker is Entities.GameClient)
                {
                    Ranged.DecreaseArrows(attacker as Entities.GameClient, 3);
                }
            }
            if (attacker is Entities.GameClient && bluename)
            {
                (attacker as Entities.GameClient).AddStatusEffect1(Enums.Effect1.BlueName, 10000);
            }
            return(true);
        }
コード例 #20
0
        /// <summary>
        /// Handles single skills.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="target">The target.</param>
        /// <param name="packet">The packet.</param>
        /// <param name="spellPacket">The spell packet.</param>
        /// <param name="spellInfo">The spell info.</param>
        /// <param name="isMagic">Boolean determining whether the single attack is magic.</param>
        /// <param name="isRanged">Boolean determining whether the single attack is ranged.</param>
        /// <returns>True if the skill was handled correctly.</returns>
        /// <remarks>If both isMagic and isRanged is set to false then it's assumed as a physical skill.</remarks>
        public static bool Handle(AttackableEntityController attacker, AttackableEntityController target,
                                  Models.Packets.Entities.InteractionPacket packet,
                                  Models.Packets.Spells.SpellPacket spellPacket, Models.Spells.SpellInfo spellInfo,
                                  bool isMagic, bool isRanged = false)
        {
            if (target == null)
            {
                return(false);
            }

            if (attacker.AttackableEntity.ClientId == target.AttackableEntity.ClientId)
            {
                return(false);
            }

            if (!TargetValidation.Validate(attacker, target))
            {
                return(false);
            }

            var attackerPlayer = attacker as Models.Entities.Player;

            if (isRanged)
            {
                if (attackerPlayer != null)
                {
                    if (!Ranged.ProcessPlayer(attackerPlayer, packet, 1))
                    {
                        return(false);
                    }
                }

                Ranged.DecreaseArrows(attackerPlayer, 1);
            }

            uint damage = isRanged ?
                          Calculations.RangedCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity) :
                          isMagic?
                          Calculations.MagicCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity, spellInfo) :
                              Calculations.PhysicalCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity);

            if (!isMagic)
            {
                damage = (uint)Math.Max(1, (int)(((double)damage) * (1.1 + (0.1 * spellInfo.Level))));

                if (spellInfo.Id == 1290 && damage > 0 && !isRanged)
                {
                    double damagePercentage = (double)((damage / 100) * 26.6);
                    damage += (uint)(damagePercentage * spellInfo.Level);
                }

                if (spellInfo.Id == 6000 && damage > 0 && !isRanged)
                {
                    damage = (uint)((damage / 100) * (spellInfo.DbSpellInfo.Power - 30000));
                }
            }

            Damage.Process(attacker, target, ref damage, true);

            if (damage > 0)
            {
                TargetFinalization.SkillFinalize(attacker, target, spellPacket, damage);

                return(true);
            }

            return(false);
        }
コード例 #21
0
 // Start is called before the first frame update
 public override void Start()
 {
     base.Start();
     piece = this.GetComponent <Ranged>();
 }
コード例 #22
0
        /// <summary>
        /// Handles the scatter skill.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="packet">The packet.</param>
        /// <param name="spellPacket">The spell packet.</param>
        /// <param name="spellInfo">The spell info.</param>
        /// <returns>True if the skill was handled correctly.</returns>
        public static bool Handle(AttackableEntityController attacker,
                                  Models.Packets.Entities.InteractionPacket packet,
                                  Models.Packets.Spells.SpellPacket spellPacket,
                                  Models.Spells.SpellInfo spellInfo)
        {
            spellPacket.Process = true;

            var attackerPlayer = attacker as Models.Entities.Player;

            if (attackerPlayer != null)
            {
                if (!Ranged.ProcessPlayer(attackerPlayer, packet, 3))
                {
                    return(false);
                }
            }

            var sector = new Tools.Sector(attacker.MapObject.X, attacker.MapObject.Y,
                                          packet.X, packet.Y);

            sector.Arrange(spellInfo.Sector, spellInfo.DbSpellInfo.Range);

            foreach (var possibleTarget in attacker.GetAllInScreen())
            {
                if (spellPacket.Targets.Count > 8)
                {
                    return(true);
                }

                var target = possibleTarget as AttackableEntityController;

                if (target != null)
                {
                    if (!TargetValidation.Validate(attacker, target))
                    {
                        continue;
                    }

                    if (target.ContainsStatusFlag(Enums.StatusFlag.Fly))
                    {
                        continue;
                    }

                    if (!sector.Inside(target.MapObject.X, target.MapObject.Y))
                    {
                        continue;
                    }

                    uint damage = Calculations.RangedCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity);
                    Damage.Process(attacker, target, ref damage, false);

                    if (damage > 0)
                    {
                        TargetFinalization.SkillFinalize(attacker, target, spellPacket, damage);
                    }
                }
            }

            if (attackerPlayer != null && spellPacket.Targets.Count > 0)
            {
                Ranged.DecreaseArrows(attackerPlayer, 3);
            }

            return(true);
        }
コード例 #23
0
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        Unit unit = null;

        if (button1 != null && button1.Pressed && (tile as Building).level < (tile as Building).maxLevel)
        {
            if (GameData.player.MainResource - 200 >= 0 && GameData.player.SecondaryResource - 150 >= 0)
            {
                button1.Sprite.SheetIndex      = 1;
                (tile as Building).level      += 1;
                GameData.Cursor.HasClickedTile = false;
                GameData.LevelObjects.Remove(this);
            }
            else
            {
                Notification n = new Notification("Not enough resources, it costs:", " 200 and 150", "", 3);
                n.CreateNotification();
            }
        }
        //Create melee1 unit
        if (button2 != null && button2.Pressed)
        {
            button2.Sprite.SheetIndex      = 1;
            GameData.Cursor.HasClickedTile = false;

            if (tile is NatureBarracks)
            {
                unit = new Melee1(Player.Faction.nature, "natureWolf", "natureWolf");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Sunlight and " + unit.ResourceCosts.Y.ToString() + " Water", "", 3);
                    n.CreateNotification();
                    unit = null;
                }
            }
            else
            {
                unit = new Melee1(Player.Faction.humanity, "chainsaw", "chainsaw");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Coal and " + unit.ResourceCosts.Y.ToString() + " Wood", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
        }
        //Create ranged unit
        else if (button3 != null && button3.Pressed)
        {
            button3.Sprite.SheetIndex      = 1;
            GameData.Cursor.HasClickedTile = false;


            if (tile is NatureBarracks)
            {
                unit = new Ranged(Player.Faction.nature, "pelletGun", "rangedNature");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Sunlight and " + unit.ResourceCosts.Y.ToString() + " Water", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
            else
            {
                unit = new Ranged(Player.Faction.humanity, "hunter", "rangedHumanity");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Coal and " + unit.ResourceCosts.Y.ToString() + " Wood", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
        }
        //Create melee2 unit
        else if (button4 != null && button4.Pressed)
        {
            button4.Sprite.SheetIndex      = 1;
            GameData.Cursor.HasClickedTile = false;

            if (tile is NatureBarracks)
            {
                unit = new Melee2(Player.Faction.nature, "treeUnit", "melee2Nature");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Sunlight and " + unit.ResourceCosts.Y.ToString() + " Water", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
            else
            {
                unit = new Melee2(Player.Faction.humanity, "flamethrower", "melee2Human");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Coal and " + unit.ResourceCosts.Y.ToString() + " Wood", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
        }
        //Create fast_melee unit (renamed to Unicorn)
        else if (button5 != null && button5.Pressed)
        {
            button5.Sprite.SheetIndex      = 1;
            GameData.Cursor.HasClickedTile = false;

            if (tile is NatureBarracks)
            {
                unit = new Unicorn(Player.Faction.nature, "unicorn", "unicorn");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Sunlight and " + unit.ResourceCosts.Y.ToString() + " Water", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
            else
            {
                unit = new Unicorn(Player.Faction.humanity, "quad", "fastmeleeHuman");
                if (player.MainResource - unit.ResourceCosts.X >= 0 && player.SecondaryResource - unit.ResourceCosts.Y >= 0)
                {
                    player.MainResource      -= unit.ResourceCosts.X;
                    player.SecondaryResource -= unit.ResourceCosts.Y;
                }
                else
                {
                    Notification n = new Notification("Not enough resources, it costs:", unit.ResourceCosts.X.ToString() + " Coal and " + unit.ResourceCosts.Y.ToString() + " Wood", "", 3);
                    n.CreateNotification(); unit = null;
                }
            }
        }
        if (unit != null)
        {
            unit.Position = new Vector2(tile.Position.X + new Tile().Sprite.Width / 2 - unit.Sprite.Width / 2, tile.Position.Y + new Tile().Sprite.Height / 2);
            GameData.AddUnit(unit);
            this.actionString = "$addu:" + unit.ID + "$type:" + unit.GetType() + "$posi:" + unit.Position.X + "," + unit.Position.Y;//;
        }
    }
コード例 #24
0
ファイル: WeaponFactory.cs プロジェクト: McPalm/FEPonies
    /// <summary>
    /// Get the weapon you generated.
    /// </summary>
    /// <returns></returns>
    public Weapon GetWeapon()
    {
        Weapon w = new Weapon();

        w.Name = Name;
        w.buff = new Stats();

        float power         = level + 4;
        float advantages    = 0f;
        float disadvantages = 0f;

        // advantages
        if (reach == MELEEANDRANGE)
        {
            advantages += 0.25f;
        }
        if (reach == LONGRANGE)
        {
            advantages += 0.15f;
        }
        if (defences == APIERCE)
        {
            advantages += 0.5f;
        }
        if (hitMod > 0)
        {
            advantages += hitMod / 20f;
        }
        if (critMod > 0)
        {
            advantages += critMod / 20f;
        }

        // disadvantages
        if (hitMod < 0)
        {
            disadvantages += hitMod / 20f;
        }

        // modify base damage to work with modifiers
        power /= 1f + advantages;
        power *= 1f + disadvantages;

        // grant the weapon appropiate range
        IReach ir;

        if (reach == MELEE)
        {
            ir = new Melee();
        }
        else if (reach == MELEEANDRANGE)
        {
            ir = new RangeAndMelee();
        }
        else if (reach == LONGRANGE)
        {
            ir = new IncreasedRange();
        }
        else
        {
            ir = new Ranged();
        }

        // Weapon Damage Stuffs
        WeaponDamage wd = new WeaponDamage();

        wd.StrScale   = strenght * 0.25f;
        wd.DexScale   = dexterity * 0.25f;
        wd.IntScale   = intelligence * 0.25f;
        wd.BaseDamage = (int)power;

        w.attackInfo = new AttackInfo(ir, wd, null, anim);

        w.buff.hitBonus  += hitMod * 0.1f;
        w.buff.critBonus += critMod * 0.15f;

        level  += 4;
        w.value = level * level * 2;

        w.icon = SpriteLibrary.GetIcon("weapon");

        return(w);
    }
コード例 #25
0
    /// <summary>
    /// Checks in a growing circular fashion what you can reach and flips the appropriate bool
    /// </summary>
    /// <param name="startingPoint">Position of unit</param>
    /// <param name="speed">How many steps the unit can take</param>
    public void flipReachable(Point startingPoint, int speed)
    {
        // List for all nodes that are to be evaluvated
        List <Node> openSet = new List <Node>();

        UnitGameObject aktiveUnit = units[startingPoint.x, startingPoint.y].GetComponent <UnitGameObject>();
        Unit           u          = aktiveUnit.UnitTree.GetUnits()[aktiveUnit.PosInUnitTree];
        Ranged         r          = null;

        if (u.IsRanged)
        {
            r            = (Ranged)u;
            r.Threatened = false;
        }
        //Adds starting node to openSet
        Node s = field[startingPoint.x, startingPoint.y];

        s.WalkedSteps = 0;
        s.InOpenSet   = true;
        openSet.Add(s);

        //Loops as long as there are unevaluvated nodes
        while (openSet.Count > 0)
        {
            //Fetches current node from openset
            Node cur = openSet[0];
            //Removes cur from openset and marks as evaluvated
            openSet.Remove(cur);
            cur.InOpenSet  = false;
            cur.Evaluvated = true;

            //Flips bool for reachable or attackable if unit can reach cur
            if (cur.Ggo.IsOccupied && units[cur.Pos.x, cur.Pos.y] != null && cur.WalkedSteps <= speed + 1 &&
                aktiveUnit.AttackingSide != units[cur.Pos.x, cur.Pos.y].GetComponent <UnitGameObject>().AttackingSide)
            {
                units[cur.Pos.x, cur.Pos.y].GetComponent <UnitGameObject>().Attackable = true;
                if (u.IsRanged && cur.WalkedSteps == 1)
                {
                    r.Threatened = true;
                }
                cur.Ggo.MarkReachable(ATTACKABLE);
            }
            else if (cur.WalkedSteps <= speed)
            {
                cur.Ggo.Reachable = true;
                cur.Ggo.MarkReachable(!ATTACKABLE);
            }

            if (cur.Ggo.IsOccupied && !cur.Pos.Equals(startingPoint))
            {
                continue;
            }

            //Finds walkable neighbours
            Node[] neighbours = findNeighboursHex(cur.Pos);

            //Loops trou neighbours
            for (int i = 0; i < neighbours.Length && neighbours[i] != null; i++)
            {
                Node neighbour = neighbours[i];
                // If already evaluvated, skip node
                if (neighbour.Evaluvated)
                {
                    continue;
                }

                // If not in openSet, add to openSet and calculate WalkedSteps
                if (!neighbour.InOpenSet)
                {
                    neighbour.WalkedSteps = cur.WalkedSteps + 1;
                    neighbour.InOpenSet   = true;

                    //Inserts neighbour node into openset at sorted position
                    int index = Math.Abs(openSet.BinarySearch(neighbour));
                    if (index >= openSet.Count)
                    {
                        openSet.Add(neighbour);
                    }
                    else
                    {
                        openSet.Insert(index, neighbour);
                    }
                }
                // OpenSet contains node, then check if current path is better.
                else
                {
                    int newWalkedSteps = cur.WalkedSteps + 1;
                    if (neighbour.WalkedSteps > newWalkedSteps)
                    {
                        neighbour.WalkedSteps = newWalkedSteps;
                    }
                }
            }
            //Breaks loop if next node to be checked is unreachable
            if (cur.WalkedSteps == speed + 2)
            {
                break;
            }
        }
        //Readies for new run
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                field[x, y].Evaluvated = false;
                field[x, y].InOpenSet  = false;
            }
        }
    }