示例#1
0
文件: Tutorial.cs 项目: semtle/MIM
        public static async Task AwakeningRescue(PlayerSetup.Player player, Room.Room room, string step, string calledBy)
        {
            //give player quest
            var findLance = new Quest()
            {
                Id          = 3,
                Name        = "Find and greet Lance",
                Description =
                    "Mortem has asked me to go find Lance the village elder who can be found in the main square, From the temple leave south and follow the hill path in to town." +
                    "<p class='RoomExits'>[Hint] Type greet lance to greet the Elder once you have found him</p>",
                QuestGiver   = "Mortem",
                QuestFindMob = Lance.VillageElderLance().Name,
                Type         = Quest.QuestType.FindMob,
                RewardXp     = 250,
                QuestHint    = "<h5>Hint:</h5><p>Lance is here, type greet Lance to interact with him.</p>",
                QuestTrigger = Lance.VillageElderLance().Name,
                RewardDialog = new DialogTree()
                {
                    Message       = "Yes I am Lance, well met $playerName",
                    ShowIfOnQuest = "Find and greet Lance"
                }
            };

            try
            {
                //to stop task firing twice
                if (player.QuestLog.FirstOrDefault(x => x.Name.Equals("Find and greet Lance")) != null)
                {
                    return;
                }

                var npc = room.mobs.FirstOrDefault(x => x.Name.Equals("Mortem"));

                if (npc == null)
                {
                    return;
                }

                if (step.Equals("wake", StringComparison.CurrentCultureIgnoreCase))
                {
                    //remove player from tutorial room
                    var oldRoom = Cache.ReturnRooms()
                                  .FirstOrDefault(
                        x => x.area.Equals("Tutorial") && x.areaId.Equals(1) && x.region.Equals("Tutorial"));

                    if (oldRoom != null && oldRoom.players.Contains(player))
                    {
                        PlayerManager.RemovePlayerFromRoom(oldRoom, player);
                    }


                    HubContext.SendToClient(npc.Name + " says \"Ah you are awake!\"", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(
                        npc.Name + " says \"You were in a bad way when we found you, I didn't think you would wake.\"",
                        player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(npc.Name + " Gets a pair of trousers and a shirt and hands them to you",
                                            player.HubGuid);

                    player.Inventory.Add(ClothingBody.PlainTop());
                    player.Inventory.Add(ClothingLegs.PlainTrousers());

                    Score.UpdateUiInventory(player);

                    await Task.Delay(2000);

                    HubContext.SendToClient(npc.Name + " says \"Wear them, you can't walk around naked I am afraid.\"",
                                            player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(
                        "<p class='RoomExits'>[Hint] To view items you are carrying type Inventory or i for short</p>",
                        player.HubGuid);

                    HubContext.SendToClient(npc.Name + " smiles at you.", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient(
                        "<p class='RoomExits'>[Hint] Type wear trousers and wear shirt or alternatively wear all</p>",
                        player.HubGuid);
                }

                if (step != null && step.Contains("plain"))
                {
                    if (player.QuestLog.FirstOrDefault(x => x.Name.Equals("Find and greet Lance")) != null)
                    {
                        return;
                    }



                    if (player.Equipment.Body.Equals(ClothingBody.PlainTop().name) &&
                        !player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name))
                    {
                        HubContext.SendToClient(
                            npc.Name + " says \"It fits well, don't forget to wear the trousers too.\"",
                            player.HubGuid);

                        await Task.Delay(2000);

                        return;
                    }

                    if (player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name) &&
                        !player.Equipment.Body.Equals(ClothingBody.PlainTop().name))
                    {
                        HubContext.SendToClient(npc.Name + " says \"It fits well, don't forget to wear the top too.\"",
                                                player.HubGuid);

                        await Task.Delay(2000);

                        return;
                    }

                    if (player.Equipment.Legs.Equals(ClothingLegs.PlainTrousers().name) &&
                        player.Equipment.Body.Equals(ClothingBody.PlainTop().name))
                    {
                        HubContext.SendToClient(
                            npc.Name +
                            " says \"Excellent, I have one request for you and that is to speak to Lance the Elder of the village.\"",
                            player.HubGuid);

                        HubContext.SendToClient(
                            npc.Name +
                            " says \"He wants to know if you remember anything about the attack that may help him? We have been raided a few times of late.\"",
                            player.HubGuid);

                        HubContext.SendToClient(
                            npc.Name +
                            " says \"You will found him in the Square of Anker just leave south and follow the hill path in to town you can't miss the Square.\"",
                            player.HubGuid);



                        player.QuestLog.Add(findLance);



                        HubContext.SendToClient(
                            "New Quest added: Find and greet Lance. Type qlog to be reminded about quest information.",
                            player.HubGuid);


                        HubContext.SendToClient(
                            npc.Name +
                            " waves to you, may Tyr bless you.",
                            player.HubGuid);
                    }
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "mortem"
                };

                Save.LogError(log);
            }
        }
        public static void SpawnAmbush(Vector3 ambushOrigin)
        {
            if (!Mod.Config.InfantryAmbush.Enabled)
            {
                return;
            }

            int infantrySpawns = Mod.Random.Next(ModState.InfantryAmbushDefForContract.MinSpawns, ModState.InfantryAmbushDefForContract.MaxSpawns);

            Mod.Log.Debug?.Write($"Spawning up to {infantrySpawns} infantry spawns as part of this ambush.");

            // Create a new lance in the target team
            Lance ambushLance = TeamHelper.CreateAmbushLance(ModState.AmbushTeam);

            // Build list of candidate trap buildings
            List <BattleTech.Building> candidates = CandidateBuildingsHelper.ClosestCandidatesToPosition(ambushOrigin, Mod.Config.Ambush.SearchRadius);

            if (candidates.Count < ModState.InfantryAmbushDefForContract.MinSpawns)
            {
                Mod.Log.Debug?.Write($"Insufficient candidate buildings to spawn an infantry ambush. Skipping.");
                return;
            }

            // Make sure we don't spawn more turrets than buildings
            if (infantrySpawns > candidates.Count)
            {
                infantrySpawns = candidates.Count;
            }

            List <AbstractActor>       spawnedActors  = new List <AbstractActor>();
            List <BattleTech.Building> spawnBuildings = new List <BattleTech.Building>();

            for (int i = 0; i < infantrySpawns; i++)
            {
                BattleTech.Building spawnBuildingShell = candidates.ElementAt(i);

                // Spawn a turret trap
                AbstractActor ambushTurret = SpawnAmbushTurret(ModState.AmbushTeam, ambushLance, spawnBuildingShell, ambushOrigin);
                spawnedActors.Add(ambushTurret);
                spawnBuildings.Add(spawnBuildingShell);
                Mod.Log.Info?.Write($"Spawned turret: {ambushTurret.DisplayName} in building: {spawnBuildingShell.DisplayName}");
            }

            // Remove any buildings that are part of this ambush from candidates
            ModState.CandidateBuildings.RemoveAll(x => spawnBuildings.Contains(x));

            // Determine the targets that should be prioritized by the enemies
            List <ICombatant> targets = new List <ICombatant>();

            foreach (ICombatant combatant in ModState.Combat.GetAllCombatants())
            {
                if (!combatant.IsDead && !combatant.IsFlaggedForDeath &&
                    combatant.team != null &&
                    ModState.Combat.HostilityMatrix.IsLocalPlayerFriendly(combatant.team))
                {
                    if (Vector3.Distance(ambushOrigin, combatant.CurrentPosition) <= Mod.Config.Ambush.SearchRadius)
                    {
                        targets.Add(combatant);
                    }
                }
            }

            Mod.Log.Info?.Write($"Adding InfantryAmbushSequence for {spawnedActors.Count} actors.");
            try
            {
                InfantryAmbushSequence ambushSequence =
                    new InfantryAmbushSequence(ModState.Combat, ambushOrigin, spawnedActors, spawnBuildings, targets, Mod.Config.InfantryAmbush.FreeAttackEnabled);
                ModState.Combat.MessageCenter.PublishMessage(new AddSequenceToStackMessage(ambushSequence));
            }
            catch (Exception e)
            {
                Mod.Log.Error?.Write(e, "Failed to create AES sequence due to error!");
            }
        }
示例#3
0
        public static AbstractActor GetClosestDetectedEnemy(AbstractActor focusedUnit, Lance allyLance)
        {
            List <AbstractActor> detectedEnemyUnits = new List <AbstractActor>();

            detectedEnemyUnits.AddRange(focusedUnit.lance.team.GetDetectedEnemyUnits());
            detectedEnemyUnits.AddRange(allyLance.team.GetDetectedEnemyUnits());

            float         num          = -1f;
            AbstractActor closestActor = null;

            for (int i = 0; i < detectedEnemyUnits.Count; i++)
            {
                AbstractActor actor     = detectedEnemyUnits[i] as AbstractActor;
                float         magnitude = (actor.CurrentPosition - focusedUnit.CurrentPosition).magnitude;
                if (num < 0f || magnitude < num)
                {
                    num          = magnitude;
                    closestActor = actor;
                }
            }

            return(closestActor);
        }
示例#4
0
 //ProporLance
 public void Propoe(Lance lance)
 {
     Lance.Add(lance);
 }
示例#5
0
 public void LanceMenorZero()
 {
     Lance lance = new Lance(joao, -100);
 }
示例#6
0
        public override void OnResponse(NetState state, RelayInfo info)           //Function for GumpButtonType.Reply Buttons
        {
            Mobile       from   = state.Mobile;
            PlayerMobile pm     = from as PlayerMobile;
            PlayerModule module = pm.PlayerModule;

            m_cost = 50;            //MOD COST OF WEAPON HERE!!
            Item      wep  = from.FindItemOnLayer(Layer.FirstValid);
            Item      weps = from.FindItemOnLayer(Layer.TwoHanded);
            Container pack = from.Backpack;

            if (wep != null)
            {
                pack.TryDropItem(from, wep, false);
            }

            if (weps != null)
            {
                pack.TryDropItem(from, weps, false);
            }

            switch (info.ButtonID)
            {
            case 0:                     //Cancel
            {
                from.SendMessage("You decide against spending your skill points.");
                //from.SendGump( new LevelGump( from ) );
                break;
            }

            case 1:                     //Katana
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Katana kat = new Katana();
                    (( Item )kat).Name = "Katana [Level Item]";
                    kat.Identified     = true;                                //Prevents others from being used in the upgrading!
                    kat.LootType       = LootType.Blessed;
                    from.EquipItem(kat);
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 2:                     //Broad Sword
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Broadsword bs = new Broadsword();
                    bs.Identified = true;
                    bs.Name       = "Broadsword";
                    bs.LootType   = LootType.Blessed;
                    from.EquipItem(bs);
                    from.SendMessage(102, "You chose a Broadsword");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 3:                     //Scimitar
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Scimitar sc = new Scimitar();
                    sc.Identified = true;
                    sc.Name       = "Scimitar";
                    sc.LootType   = LootType.Blessed;
                    from.EquipItem(sc);
                    from.SendMessage(102, "You chose a Scimitar");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 4:                     //Viking sword
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    VikingSword vs = new VikingSword();
                    vs.Identified = true;
                    vs.Name       = "Vikingsword";
                    vs.LootType   = LootType.Blessed;
                    from.EquipItem(vs);
                    from.SendMessage(102, "You chose a Viking Sword");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 5:                     //Halberd
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Halberd hb = new Halberd();
                    hb.Identified = true;
                    hb.Name       = "Halberd";
                    hb.LootType   = LootType.Blessed;
                    from.EquipItem(hb);
                    from.SendMessage(102, "You chose a Halberd");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 6:                     //Bardiche
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Bardiche bd = new Bardiche();
                    bd.Identified = true;
                    bd.Name       = "Bardiche";
                    bd.LootType   = LootType.Blessed;
                    from.EquipItem(bd);
                    from.SendMessage(102, "You chose a Bardiche");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 7:                     //Double Axe
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    DoubleAxe da = new DoubleAxe();
                    da.Identified = true;
                    da.Name       = "Double Axe";
                    da.LootType   = LootType.Blessed;
                    from.EquipItem(da);
                    from.SendMessage(102, "You chose a Double Axe");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 8:                     //Large Battle Axe
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    LargeBattleAxe lba = new LargeBattleAxe();
                    lba.Identified = true;
                    lba.Name       = "Large Battle Axe";
                    lba.LootType   = LootType.Blessed;
                    from.EquipItem(lba);
                    from.SendMessage(102, "You chose a Large Battle Axe");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 9:                     //Axe
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Axe a = new Axe();
                    a.Identified = true;
                    a.Name       = "Axe";
                    a.LootType   = LootType.Blessed;
                    from.EquipItem(a);
                    from.SendMessage(102, "You chose an Axe");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 10:                     //Kryss
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Kryss k = new Kryss();
                    k.Identified = true;
                    k.Name       = "Kryss";
                    k.LootType   = LootType.Blessed;
                    from.EquipItem(k);
                    from.SendMessage(102, "You chose a Kryss");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 11:                     //War Fork
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    WarFork wf = new WarFork();
                    wf.Identified = true;
                    wf.Name       = "War Fork";
                    wf.LootType   = LootType.Blessed;
                    from.EquipItem(wf);
                    from.SendMessage(102, "You chose a War Fork");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 12:                     //Dagger
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Dagger d = new Dagger();
                    d.Identified = true;
                    d.Name       = "Dagger";
                    d.LootType   = LootType.Blessed;
                    from.EquipItem(d);
                    from.SendMessage(102, "You chose a Dagger");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 13:                     //Pike
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Pike p = new Pike();
                    p.Identified = true;
                    p.Name       = "Pike";
                    p.LootType   = LootType.Blessed;
                    from.EquipItem(p);
                    from.SendMessage(102, "You chose a Pike");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 14:                     //Short Spear
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    ShortSpear ss = new ShortSpear();
                    ss.Identified = true;
                    ss.Name       = "Short Spear";
                    ss.LootType   = LootType.Blessed;
                    from.EquipItem(ss);
                    from.SendMessage(102, "You chose a Short Spear");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 15:                     //Long Spear
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Spear ls = new Spear();
                    ls.Identified = true;
                    ls.Name       = "Long Spear";
                    ls.LootType   = LootType.Blessed;
                    from.EquipItem(ls);
                    from.SendMessage(102, "You chose a Long Spear");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 16:                     //Pitchfork
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Pitchfork p = new Pitchfork();
                    p.Identified = true;
                    p.Name       = "Pitchfork";
                    p.LootType   = LootType.Blessed;
                    from.EquipItem(p);
                    from.SendMessage(102, "You chose a Pitchfork");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 17:                     //lance
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Lance l = new Lance();
                    l.Identified = true;
                    l.Name       = "Lance";
                    l.LootType   = LootType.Blessed;
                    from.EquipItem(l);
                    from.SendMessage(102, "You chose a Lance");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 18:                     //Sai's
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Sai s = new Sai();
                    s.Identified = true;
                    s.Name       = "Sai";
                    s.LootType   = LootType.Blessed;
                    from.EquipItem(s);
                    from.SendMessage(102, "You chose Sai's");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 19:                     //War Mace
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    WarMace wm = new WarMace();
                    wm.Identified = true;
                    wm.Name       = "War Mace";
                    wm.LootType   = LootType.Blessed;
                    from.EquipItem(wm);
                    from.SendMessage(102, "You chose a War Mace");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 20:                     //War Hammer
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    WarHammer wh = new WarHammer();
                    wh.Identified = true;
                    wh.Name       = "War Hammer";
                    wh.LootType   = LootType.Blessed;
                    from.EquipItem(wh);
                    from.SendMessage(102, "You chose a War Hammer");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 21:                     //Maul
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Maul w = new Maul();
                    w.Identified = true;
                    w.Name       = "Maul";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Maul");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 22:                     //Club
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Club w = new Club();
                    w.Identified = true;
                    w.Name       = "Club";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Club");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 23:                     //Q Staff
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    QuarterStaff w = new QuarterStaff();
                    w.Identified = true;
                    w.Name       = "Quarter Staff";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Quarter Staff");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 24:                     //G Staff
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    GnarledStaff w = new GnarledStaff();
                    w.Identified = true;
                    w.Name       = "Gnarled Staff";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Gnarled Staff");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 25:                     //B Staff
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    BlackStaff w = new BlackStaff();
                    w.Identified = true;
                    w.Name       = "BlackStaff";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Black Staff");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 26:                     //Hammer Pick
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    HammerPick w = new HammerPick();
                    w.Identified = true;
                    w.Name       = "Hammer Pick";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Hammer Pick");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 27:                     //War Axe
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    WarAxe w = new WarAxe();
                    w.Identified = true;
                    w.Name       = "War Axe";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a War Axe");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 28:                     //Bow
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Bow w = new Bow();
                    w.Identified = true;
                    w.Name       = "Bow";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Bow");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 29:                     //Composite Bow
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    CompositeBow w = new CompositeBow();
                    w.Identified = true;
                    w.Name       = "Composite Bow";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Composite Bow");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 30:                     //Crossbow
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Crossbow w = new Crossbow();
                    w.Identified = true;
                    w.Name       = "Crossbow";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Crossbow");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 31:                     //Heavy Crossbow
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    HeavyCrossbow w = new HeavyCrossbow();
                    w.Identified = true;
                    w.Name       = "Heavy Crossbow";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Heavy Crossbow");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 32:                     //Repeating Crossbow
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    RepeatingCrossbow w = new RepeatingCrossbow();
                    w.Identified = true;
                    w.Name       = "Repeating Crossbow";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Repeating Crossbow");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }

            case 33:                     //Yumi
            {
                if (module.SkillPts < m_cost)
                {
                    from.SendMessage(37, "Not enough skill points!");
                }
                else
                {
                    module.SkillPts -= m_cost;
                    Yumi w = new Yumi();
                    w.Identified = true;
                    w.Name       = "Yumi";
                    w.LootType   = LootType.Blessed;
                    from.EquipItem(w);
                    from.SendMessage(102, "You chose a Yumi");
                }

                from.SendGump(new WepUpgradeGump(from));
                break;
            }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public static Item CreateMetalWeapon()
        {
            Item item = null;

            int nType = Utility.RandomMinMax(0, 41);

            switch (nType)
            {
            case 1:         item = new Cutlass();                   item.Name = "cutlass";                  break;

            case 2:         item = new Katana();                    item.Name = "katana";                   break;

            case 3:         item = new Kryss();                             item.Name = "kryss";                    break;

            case 4:         item = new Broadsword();                item.Name = "broadsword";               break;

            case 5:         item = new Longsword();                 item.Name = "longsword";                break;

            case 6:         item = new ThinLongsword();             item.Name = "longsword";                break;

            case 7:         item = new VikingSword();               item.Name = "barbarian sword";  break;

            case 8:         item = new Scimitar();                  item.Name = "scimitar";                 break;

            case 9:         item = new BoneHarvester();             item.Name = "sickle";                   break;

            case 10:        item = new CrescentBlade();             item.Name = "crescent blade";   break;

            case 11:        item = new DoubleBladedStaff(); item.Name = "bladed staff";             break;

            case 12:        item = new Lance();                             item.Name = "lance";                    break;

            case 13:        item = new Pike();                              item.Name = "pike";                             break;

            case 14:        item = new Scythe();                    item.Name = "scythe";                   break;

            case 15:        item = new Dagger();                    item.Name = "dagger";                   break;

            case 16:        item = new HammerPick();                item.Name = "hammer pick";              break;

            case 17:        item = new Mace();                              item.Name = "mace";                             break;

            case 18:        item = new Maul();                              item.Name = "maul";                             break;

            case 19:        item = new WarHammer();                 item.Name = "war hammer";               break;

            case 20:        item = new WarMace();                   item.Name = "war mace";                 break;

            case 21:        item = new ExecutionersAxe();   item.Name = "great axe";                break;

            case 22:        item = new BattleAxe();                 item.Name = "battle axe";               break;

            case 23:        item = new TwoHandedAxe();              item.Name = "two-handed axe";   break;

            case 24:        item = new Axe();                               item.Name = "axe";                              break;

            case 25:        item = new DoubleAxe();                 item.Name = "double axe";               break;

            case 26:        item = new RoyalSword();                item.Name = "royal sword";              break;

            case 27:        item = new LargeBattleAxe();    item.Name = "large battle axe"; break;

            case 28:        item = new WarAxe();                    item.Name = "war axe";                  break;

            case 29:        item = new Bardiche();                  item.Name = "bardiche";                 break;

            case 30:        item = new Halberd();                   item.Name = "halberd";                  break;

            case 31:        item = new Pitchfork();                 item.Name = "trident";                  break;

            case 32:        item = new ShortSpear();                item.Name = "short spear";              break;

            case 33:        item = new Spear();                             item.Name = "spear";                    break;

            case 34:        item = new NoDachi();                   item.Name = "no dachi";                 break;

            case 35:        item = new Wakizashi();                 item.Name = "wakizashi";                break;

            case 36:        item = new Tetsubo();                   item.Name = "tetsubo";                  break;

            case 37:        item = new Lajatang();                  item.Name = "lajatang";                 break;

            case 38:        item = new Daisho();                    item.Name = "daisho";                   break;

            case 39:        item = new Tekagi();                    item.Name = "tekagi";                   break;

            case 40:        item = new Kama();                              item.Name = "kama";                             break;

            case 41:        item = new Sai();                               item.Name = "sai";                              break;
            }

            return(item);
        }
示例#8
0
        public JsonResult Create(Lance lance)
        {
            ResultProcessing result = LanceServico.Adicionar(lance);

            return(Json(new { success = result.Success, message = result.Message }, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        public void TestPlayCardsInQuest()
        {
            //not testing bids for now
            QuestMatch game = ScenarioCreator.GameNoDeal(2);

            game.AttachLogger(new Quest.Core.Logger("TestPlayCardsInTest"));
            Player aiPlayer      = game.Players[0];
            Player sponsorPlayer = game.Players[1];

            aiPlayer.Behaviour = new Strategy1();

            // Setup quest
            RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 stages.

            game.CurrentStory = quest;
            quest.Sponsor     = sponsorPlayer;
            //quest.AddParticipant(aiPlayer); // FIXME

            Thieves      questThieves      = new Thieves(game);
            Saxons       questSaxons       = new Saxons(game);
            RobberKnight questRobberKnight = new RobberKnight(game);

            sponsorPlayer.Hand.Add(new List <Card>()
            {
                questThieves, questSaxons, questRobberKnight
            });

            quest.AddFoeStage(questThieves);      //5
            quest.AddFoeStage(questSaxons);       //10
            quest.AddFoeStage(questRobberKnight); //15
            // Make player knight, 10 BP.
            aiPlayer.Rank.AddShields(5);

            //cards, no foes
            Lance         lance         = new Lance(game);         //20
            Lance         lance2        = new Lance(game);         //20
            BattleAx      battleAx      = new BattleAx(game);      //15
            SirGalahad    sirGalahad    = new SirGalahad(game);    //15
            Amour         amour         = new Amour(game);         //10
            Sword         sword         = new Sword(game);         //10
            KingPellinore kingPellinore = new KingPellinore(game); //10

            aiPlayer.Hand.Add(lance);
            aiPlayer.Hand.Add(lance2);
            aiPlayer.Hand.Add(battleAx);
            aiPlayer.Hand.Add(sirGalahad);       //play stage 2
            aiPlayer.Hand.Add(amour);            //play stage 1
            aiPlayer.Hand.Add(sword);
            aiPlayer.Hand.Add(kingPellinore);

            //first stage: amour
            List <BattleCard> played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand);

            Assert.AreEqual(1, played.Count);
            Assert.IsTrue(played.Contains(amour));
            aiPlayer.Play(played);
            //quest.ResolveStage(); FIXME
            //2nd stage: galahad
            played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand);
            Assert.AreEqual(1, played.Count);
            Assert.IsTrue(played.Contains(sirGalahad));
            aiPlayer.Play(played);
            //quest.ResolveStage(); FIXME
            //3rd stage: a lance, battleAx, sword, kingPellinore
            //is the quest not advancing stage?not sure
            played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand);
            Assert.AreEqual(4, played.Count);
            Assert.IsTrue((played.Contains(lance) || played.Contains(lance2)));
            Assert.IsTrue(played.Contains(battleAx));
            Assert.IsTrue(played.Contains(sword));
            Assert.IsTrue(played.Contains(kingPellinore));
        }
        public void LoadFusionFromFile(string fileName)
        {
            try
            {
                BinaryFormatter bf = new BinaryFormatter();
                FileInfo file = new FileInfo(fileName);
                FileStream fs = file.OpenRead();

                string heatNumber = file.Name.Replace(".dat", "");
                var deserializedObject = new object();
                try
                {
                    deserializedObject = bf.Deserialize(fs);
                }
                catch
                {
                }
                finally
                {
                    fs.Close();
                    fs.Dispose();
                }

                _heat = new Heat {Number = int.Parse(heatNumber)};
                if (deserializedObject is Heat)
                {
                    _heat = deserializedObject as Heat;
                }
                if (deserializedObject is Dictionary<DateTime, BaseEvent>)
                {
                    _heat.LanceHistory.Clear();
                    _heat.OffGasAnalysisHistory.Clear();
                    _heat.OffGasHistory.Clear();
                    _heat.BoilerWaterCoolingHistory.Clear();
                    _heat.IgnitionHistory.Clear();
                    _heat.SlagOutburstHistory.Clear();
                    Dictionary<DateTime, BaseEvent> events = deserializedObject as Dictionary<DateTime, BaseEvent>;
                    foreach (DateTime key in events.Keys)
                    {

                        switch (events[key].GetType().ToString())
                        {
                            case "Converter.LanceEvent":
                                _heat.LanceHistory.Add((LanceEvent)events[key]);
                                break;
                            case "Converter.OffGasAnalysisEvent":
                                _heat.OffGasAnalysisHistory.Add((OffGasAnalysisEvent)events[key]);
                                break;
                            case "Converter.OffGasEvent":
                                _heat.OffGasHistory.Add((OffGasEvent)events[key]);
                                break;
                            case "Converter.BoilerWaterCoolingEvent":
                                _heat.BoilerWaterCoolingHistory.Add((BoilerWaterCoolingEvent)events[key]);
                                break;
                            case "Converter.IgnitionEvent":
                                _heat.IgnitionHistory.Add((IgnitionEvent)events[key]);
                                break;
                            case "Converter.SlagOutburstEvent":
                                _heat.SlagOutburstHistory.Add((SlagOutburstEvent)events[key]);
                                break;
                        }
                    }
                }
                else if ((deserializedObject is List<BaseEvent>))
                {
                    _heat.LanceHistory.Clear();
                    _heat.OffGasAnalysisHistory.Clear();
                    _heat.OffGasHistory.Clear();
                    _heat.BoilerWaterCoolingHistory.Clear();
                    _heat.IgnitionHistory.Clear();
                    _heat.SlagOutburstHistory.Clear();
                    List<BaseEvent> events = deserializedObject as List<BaseEvent>;
                    foreach (BaseEvent e in events)
                    {

                        switch (e.GetType().ToString())
                        {
                            case "Converter.LanceEvent":
                                _heat.LanceHistory.Add((LanceEvent)e);
                                break;
                            case "Converter.OffGasAnalysisEvent":
                                _heat.OffGasAnalysisHistory.Add((OffGasAnalysisEvent)e);
                                break;
                            case "Converter.OffGasEvent":
                                _heat.OffGasHistory.Add((OffGasEvent)e);
                                break;
                            case "Converter.BoilerWaterCoolingEvent":
                                _heat.BoilerWaterCoolingHistory.Add((BoilerWaterCoolingEvent)e);
                                break;
                            case "Converter.IgnitionEvent":
                                _heat.IgnitionHistory.Add((IgnitionEvent)e);
                                break;
                            case "Converter.SlagOutburstEvent":
                                _heat.SlagOutburstHistory.Add((SlagOutburstEvent)e);
                                break;
                        }
                    }

                }

                CurrentFussion = m_Db.GetFusion(_heat.Number.ToString().Insert(2, "0"));
                CurrentListOfGas.Clear();

                //if (false)
                //{
                //    CurrentListOfGas.Clear();
                //    DateTime? lastEventTime = null;
                //    double ArSum = 0;
                //    double COSum = 0;
                //    double CO2Sum = 0;
                //    double N2Sum = 0;
                //    double H2Sum = 0;
                //    double O2Sum = 0;
                //    int counter = 0;
                //    foreach (OffGasAnalysisEvent ogaEvent in _heat.OffGasAnalysisHistory)
                //    {
                //        ArSum += ogaEvent.Ar;
                //        COSum += ogaEvent.CO;
                //        CO2Sum += ogaEvent.CO2;
                //        H2Sum += ogaEvent.H2;
                //        N2Sum += ogaEvent.N2;
                //        O2Sum += ogaEvent.O2;
                //        counter++;
                //        if (lastEventTime == null || lastEventTime.Value.AddSeconds(1) < key)
                //        {
                //            OffGas og = new OffGas();
                //            og.Ar = ArSum / counter;
                //            og.CO = COSum / counter;
                //            og.CO2 = CO2Sum / counter;
                //            og.H2 = H2Sum / counter;
                //            og.N2 = N2Sum / counter;
                //            og.O2 = O2Sum / counter;
                //            og.Date = key;
                //            foreach (DateTime offGasHistoryKey in _heat.OffGasHistory.Keys)
                //            {
                //                if (offGasHistoryKey.Hour == key.Hour &&
                //                   offGasHistoryKey.Minute == key.Minute &&
                //                   offGasHistoryKey.Second == key.Second)
                //                {
                //                    og.Temp = _heat.OffGasHistory[offGasHistoryKey].OffGasTemp;
                //                    og.Flow = (int)_heat.OffGasHistory[offGasHistoryKey].OffGasFlow;
                //                    break;
                //                }
                //            }
                //            if (og.Flow != 0)
                //            {
                //                CurrentListOfGas.Add(og);
                //            }
                //            lastEventTime = key;
                //            ArSum = 0;
                //            COSum = 0;
                //            CO2Sum = 0;
                //            N2Sum = 0;
                //            H2Sum = 0;
                //            O2Sum = 0;
                //            counter = 0;
                //        }
                //    }

                //    lastEventTime = null;
                //    CurrentListLance.Clear();
                //    # region Объявление переменных
                //    int HeightSum = 0;
                //    double O2FlowSum = 0;
                //    double O2PressureSum = 0;
                //    double O2VolSum = 0;
                //    double O2LeftLanceGewBaerSum = 0;
                //    double O2LeftLanceGewWeightSum = 0;
                //    int O2LeftLanceLeckSum = 0;
                //    double O2LeftLanceWaterInputSum = 0;
                //    double O2LeftLanceWaterOutputSum = 0;
                //    double O2LeftLanceWaterPressureSum = 0;
                //    double O2LeftLanceWaterTempInputSum = 0;
                //    double O2LeftLanceWaterTempOutputSum = 0;
                //    double O2RightLanceGewBaerSum = 0;
                //    double O2RightLanceGewWeightSum = 0;
                //    int O2RightLanceLeckSum = 0;
                //    double O2RightLanceWaterInputSum = 0;
                //    double O2RightLanceWaterOutputSum = 0;
                //    double O2RightLanceWaterPressureSum = 0;
                //    double O2RightLanceWaterTempInputSum = 0;
                //    double O2RightLanceWaterTempOutputSum = 0;
                //    #endregion

                //    counter = 0;
                //    foreach (LanceEvent lEvent in  _heat.LanceHistory)
                //    {
                //        # region Суммирование
                //        HeightSum += lEvent.LanceHeight;
                //        O2FlowSum += lEvent.O2Flow;
                //        O2PressureSum += lEvent.O2Pressure;
                //        O2VolSum += lEvent.O2TotalVol;
                //        O2LeftLanceGewBaerSum += lEvent.O2LeftLanceGewBaer;
                //        O2LeftLanceGewWeightSum += lEvent.O2LeftLanceGewWeight;
                //        O2LeftLanceLeckSum += lEvent.O2LeftLanceLeck;
                //        O2LeftLanceWaterInputSum += lEvent.O2LeftLanceWaterInput;
                //        O2LeftLanceWaterOutputSum += lEvent.O2LeftLanceWaterOutput;
                //        O2LeftLanceWaterPressureSum += lEvent.O2LeftLanceWaterPressure;
                //        O2LeftLanceWaterTempInputSum += lEvent.O2LeftLanceWaterTempInput;
                //        O2LeftLanceWaterTempOutputSum += lEvent.O2LeftLanceWaterTempOutput;
                //        O2RightLanceGewBaerSum += lEvent.O2RightLanceGewBaer;
                //        O2RightLanceGewWeightSum += lEvent.O2RightLanceGewWeight;
                //        O2RightLanceLeckSum += lEvent.O2RightLanceLeck;
                //        O2RightLanceWaterInputSum += lEvent.O2RightLanceWaterInput;
                //        O2RightLanceWaterOutputSum += lEvent.O2RightLanceWaterOutput;
                //        O2RightLanceWaterPressureSum += lEvent.O2RightLanceWaterPressure;
                //        O2RightLanceWaterTempInputSum += lEvent.O2RightLanceWaterTempInput;
                //        O2RightLanceWaterTempOutputSum += lEvent.O2RightLanceWaterTempOutput;
                //        # endregion

                //        counter++;
                //        if (lastEventTime == null || lastEventTime.Value.AddSeconds(1) < key)
                //        {
                //            #region Создание объекта lance
                //            Lance lance = new Lance();
                //            lance.Date = key;
                //            lance.Height = HeightSum / counter;
                //            lance.O2Flow = O2FlowSum / counter;
                //            lance.O2Pressure = O2PressureSum / counter;
                //            lance.O2Vol = O2VolSum / counter;
                //            //lance.O2FlowMode = _heat.LanceHistory[key].O2FlowMode;
                //            lance.O2LeftLanceGewBaer = O2LeftLanceGewBaerSum / counter;
                //            lance.O2LeftLanceGewWeight = O2LeftLanceGewWeightSum / counter;
                //            lance.O2LeftLanceLeck = O2LeftLanceLeckSum / counter;
                //            lance.O2LeftLanceWaterInput = O2LeftLanceWaterInputSum / counter;
                //            lance.O2LeftLanceWaterOutput = O2LeftLanceWaterOutputSum / counter;
                //            lance.O2LeftLanceWaterPressure = O2LeftLanceWaterPressureSum / counter;
                //            lance.O2LeftLanceWaterTempInput = O2LeftLanceWaterTempInputSum / counter;
                //            lance.O2LeftLanceWaterTempOutput = O2LeftLanceWaterTempOutputSum / counter;
                //            lance.O2RightLanceGewBaer = O2RightLanceGewBaerSum / counter;
                //            lance.O2RightLanceGewWeight = O2RightLanceGewWeightSum / counter;
                //            lance.O2RightLanceLeck = O2RightLanceLeckSum / counter;
                //            lance.O2RightLanceWaterInput = O2RightLanceWaterInputSum / counter;
                //            lance.O2RightLanceWaterOutput = O2RightLanceWaterOutputSum / counter;
                //            lance.O2RightLanceWaterPressure = O2RightLanceWaterPressureSum / counter;
                //            lance.O2RightLanceWaterTempInput = O2RightLanceWaterTempInputSum / counter;
                //            lance.O2RightLanceWaterTempOutput = O2RightLanceWaterTempOutputSum / counter;
                //            #endregion
                //            //_heat.LanceHistory[key].O2LeftLanceWaterInput
                //            CurrentListLance.Add(lance);
                //            BathLevel bathLevel = new BathLevel();
                //            bathLevel.Date = key;
                //            bathLevel.Value = _heat.LanceHistory[key].BathLevel;
                //            CurrentListBathLevel.Add(bathLevel);
                //            lastEventTime = key;

                //            #region Обнуление суммарных значений и счетчика
                //            HeightSum = 0;
                //            O2FlowSum = 0;
                //            O2PressureSum = 0;
                //            O2VolSum = 0;
                //            O2LeftLanceGewBaerSum = 0;
                //            O2LeftLanceGewWeightSum = 0;
                //            O2LeftLanceLeckSum = 0;
                //            O2LeftLanceWaterInputSum = 0;
                //            O2LeftLanceWaterOutputSum = 0;
                //            O2LeftLanceWaterPressureSum = 0;
                //            O2LeftLanceWaterTempInputSum = 0;
                //            O2LeftLanceWaterTempOutputSum = 0;
                //            O2RightLanceGewBaerSum = 0;
                //            O2RightLanceGewWeightSum = 0;
                //            O2RightLanceLeckSum = 0;
                //            O2RightLanceWaterInputSum = 0;
                //            O2RightLanceWaterOutputSum = 0;
                //            O2RightLanceWaterPressureSum = 0;
                //            O2RightLanceWaterTempInputSum = 0;
                //            O2RightLanceWaterTempOutputSum = 0;
                //            counter = 0;
                //            #endregion
                //        }
                //    }
                //}
                //else
                {
                    DateTime first = _heat.OffGasAnalysisHistory.First().Time;
                    DateTime last = _heat.OffGasAnalysisHistory.Last().Time;

                    DateTime current = first.AddMilliseconds(-first.Millisecond).AddSeconds(-first.Second);
                    OffGas og = new OffGas();

                    SummaryIgnition = _heat.IgnitionHistory;
                    SummarySlagOutburst = _heat.SlagOutburstHistory;

                    foreach (OffGasAnalysisEvent ogaEvent in _heat.OffGasAnalysisHistory)
                    {
                        og = new OffGas();
                        og.Ar = ogaEvent.Ar;
                        og.CO = ogaEvent.CO;
                        og.CO2 = ogaEvent.CO2;
                        og.H2 = ogaEvent.H2;
                        og.N2 = ogaEvent.N2;
                        og.O2 = ogaEvent.O2;
                        og.Date = ogaEvent.Time;
                        ListOfAllGas.Add(og);
                    }

                    for (int i = 1; i < (last - first).TotalMinutes * 4; i++)
                    {
                        og.Date = current.AddSeconds(7);
                        var gasArray = _heat.OffGasAnalysisHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                        if (gasArray.Length > 0)
                        {
                            og = new OffGas();
                            og.Ar = gasArray.Average(x => x.Ar);
                            og.CO = gasArray.Average(x => x.CO);
                            og.CO2 = gasArray.Average(x => x.CO2);
                            og.H2 = gasArray.Average(x => x.H2);
                            og.N2 = gasArray.Average(x => x.N2);
                            og.O2 = gasArray.Average(x => x.O2);
                            var gasFlowAndTempArray = _heat.OffGasHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                            if (gasFlowAndTempArray.Length > 0)
                            {
                                og.Temperature = (int)gasFlowAndTempArray.Average(x => x.OffGasTemp);
                                og.Flow = (int)gasFlowAndTempArray.Average(x => x.OffGasFlow);
                            }
                            var gasTempsArray = _heat.BoilerWaterCoolingHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                            if (gasTempsArray.Length > 0)
                            {
                                og.TemperatureOnExit = gasTempsArray.Average(x => x.GasTemperatureOnExit);
                                og.PrecollingTemperature = gasTempsArray.Average(x => x.PrecollingGasTemperature);
                                og.TemperatureAfter1Step = gasTempsArray.Average(x => x.GasTemperatureAfter1Step);
                                og.TemperatureAfter2Step = gasTempsArray.Average(x => x.GasTemperatureAfter2Step);
                            }
                        }
                        if (og.Flow != 0)
                        {
                            CurrentListOfGas.Add(og);
                        }
                        current = current.AddSeconds(15);
                    }

                    CurrentListLance.Clear();
                    CurrentListOfGas.Remove(CurrentListOfGas.Last());
                    current = CurrentListOfGas.First().Date.AddMilliseconds(-CurrentListOfGas.First().Date.Millisecond).AddSeconds(-CurrentListOfGas.First().Date.Second);
                    Lance lance = new Lance();
                    for (int i = 1; i < (CurrentListOfGas.Last().Date - CurrentListOfGas.First().Date).TotalMinutes * 4; i++)
                    {
                        current = current.AddSeconds(15);
                        var LanceEventArray = _heat.LanceHistory.Where(x => x.Time >= current && x.Time < current.AddSeconds(15)).Select(x => x).ToArray();
                        if (LanceEventArray.Length > 0)
                        {
                            lance = new Lance();
                            lance.Date = current.AddSeconds(7);
                            lance.Height = (int)LanceEventArray.Average(x => x.LanceHeight);
                            lance.O2Flow = LanceEventArray.Average(x => x.O2Flow);
                            lance.O2Pressure = LanceEventArray.Average(x => x.O2Pressure);
                            lance.O2Vol = LanceEventArray.Average(x => x.O2TotalVol);
                            lance.O2LeftLanceGewBaer = LanceEventArray.Average(x => x.O2LeftLanceGewBaer);
                            lance.O2LeftLanceGewWeight = LanceEventArray.Average(x => x.O2LeftLanceGewWeight);
                            lance.O2LeftLanceLeck = LanceEventArray.Average(x => x.O2LeftLanceLeck);
                            lance.O2LeftLanceWaterInput = LanceEventArray.Average(x => x.O2LeftLanceWaterInput);
                            lance.O2LeftLanceWaterOutput = LanceEventArray.Average(x => x.O2LeftLanceWaterOutput);
                            lance.O2LeftLanceWaterPressure = LanceEventArray.Average(x => x.O2LeftLanceWaterPressure);
                            lance.O2LeftLanceWaterTempInput = LanceEventArray.Average(x => x.O2LeftLanceWaterTempInput);
                            lance.O2LeftLanceWaterTempOutput = LanceEventArray.Average(x => x.O2LeftLanceWaterTempOutput);
                            lance.O2RightLanceGewBaer = LanceEventArray.Average(x => x.O2RightLanceGewBaer);
                            lance.O2RightLanceGewWeight = LanceEventArray.Average(x => x.O2RightLanceGewWeight);
                            lance.O2RightLanceLeck = LanceEventArray.Average(x => x.O2RightLanceLeck);
                            lance.O2RightLanceWaterInput = LanceEventArray.Average(x => x.O2RightLanceWaterInput);
                            lance.O2RightLanceWaterOutput = LanceEventArray.Average(x => x.O2RightLanceWaterOutput);
                            lance.O2RightLanceWaterPressure = LanceEventArray.Average(x => x.O2RightLanceWaterPressure);
                            lance.O2RightLanceWaterTempInput = LanceEventArray.Average(x => x.O2RightLanceWaterTempInput);
                            lance.O2RightLanceWaterTempOutput = LanceEventArray.Average(x => x.O2RightLanceWaterTempOutput);
                            if (CurrentListBathLevel.Count == 0)
                            {
                                BathLevel level = new BathLevel();
                                level.Value = (int)LanceEventArray.Average(x => x.BathLevel);
                                CurrentListBathLevel.Add(level);
                            }
                        }
                        if (lance.O2Flow > 0)
                        {
                            CurrentListLance.Add(lance);
                        }
                    }
                }
            }
            catch (Exception) { }
            CurrentListAddition.Clear();
            UpdateFusion();
        }
示例#11
0
 public async Task AdicionarLance(string id, Lance lance) => await _business.InserirLanceEmProduto(id, lance);
示例#12
0
        public static AbstractActor FilterEnemyUnitsToDesignatedTarget(AITeam aiteam, Lance attackerLance, List <ICombatant> enemyUnits)
        {
            AbstractActor designatedTarget = null;

            if (aiteam != null && aiteam.DesignatedTargetForLance.ContainsKey(attackerLance))
            {
                designatedTarget = aiteam.DesignatedTargetForLance[attackerLance];
                if (designatedTarget != null && !designatedTarget.IsDead)
                {
                    for (int i = 0; i < enemyUnits.Count; i++)
                    {
                        if (enemyUnits[i] == designatedTarget)
                        {
                            designatedTarget = enemyUnits[i] as AbstractActor;
                            break;
                        }
                    }
                }
            }
            return(designatedTarget);
        }
        private void btn_pilum_Click(object sender, EventArgs e)
        {
            Lance RLance = RomeBladeFactory.CreateLance();

            txtb_desc.Text = RLance.Description();
        }
        private void btn_naginata_Click(object sender, EventArgs e)
        {
            Lance JLance = JapanBladeFactory.CreateLance();

            txtb_desc.Text = JLance.Description();
        }
示例#15
0
 public async Task CreateLance(Lance NovoLance) => await LanceDAO.Create(NovoLance);
示例#16
0
        public static async Task AwakeningRescue(PlayerSetup.Player player, Room.Room room, string step, string calledBy)
        {
            //give player quest
            var findLance = new Quest()
            {
                Id          = 3,
                Name        = "Find and greet Lance",
                Description =
                    "Mortem has asked me to go find Lance the village elder who can be found in the main square, From the temple leave south and follow the hill path in to town." +
                    "<p class='RoomExits'>[Hint] Type greet lance to greet the Elder once you have found him</p>",
                QuestGiver   = "Mortem",
                QuestFindMob = Lance.VillageElderLance().Name,
                Type         = Quest.QuestType.FindMob,
                RewardXp     = 250,
                QuestHint    = "<h5>Hint:</h5><p>Lance is here, type greet Lance to interact with him.</p>",
                QuestTrigger = Lance.VillageElderLance().Name,
                RewardDialog = new DialogTree()
                {
                    Message       = "Yes I am Lance, well met $playerName",
                    ShowIfOnQuest = "Find and greet Lance"
                }
            };

            try
            {
                //to stop task firing twice
                if (player.QuestLog.FirstOrDefault(x => x.Name.Equals("Find and greet Lance")) != null)
                {
                    return;
                }

                var npc = room.mobs.FirstOrDefault(x => x.Name.Equals("Mortem"));

                if (npc == null)
                {
                    return;
                }

                if (step.Equals("wake", StringComparison.CurrentCultureIgnoreCase))
                {
                    //remove player from tutorial room
                    var oldRoom = Cache.ReturnRooms()
                                  .FirstOrDefault(
                        x => x.area.Equals("Tutorial") && x.areaId.Equals(player.AreaId) && x.region.Equals("Tutorial"));

                    if (oldRoom != null && oldRoom.players.Contains(player))
                    {
                        PlayerManager.RemovePlayerFromRoom(oldRoom, player);
                    }


                    HubContext.SendToClient("<span class='sayColor'>" + npc.Name + " says \"Ah you are awake!\"</span>", player.HubGuid);

                    await Task.Delay(2000);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name + " says \"You were in a bad way when we found you, I didn't think you would wake.\"</span>",
                                            player.HubGuid);

                    HubContext.SendToClient(npc.Name + " smiles at you.", player.HubGuid);

                    await Task.Delay(2000);



                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name +
                                            " says \"Lance has been asking about you, he's the Elder of the village.\"</span>",
                                            player.HubGuid);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name +
                                            " says \"He wants to know if you remember anything about the attack that may help him? We have been raided a few times of late.\"</span>",
                                            player.HubGuid);

                    HubContext.SendToClient("<span class='sayColor'>" +
                                            npc.Name +
                                            " says \"You will found him in the Square of Anker just leave south and follow the hill path into town, you can't miss the Square.\"</span>",
                                            player.HubGuid);



                    player.QuestLog.Add(findLance);



                    HubContext.SendToClient(
                        "<span class='questColor'>New Quest added: <br />Find and greet Lance. <br />Type qlog to be reminded about quest information.</span>",
                        player.HubGuid);


                    HubContext.SendToClient(
                        npc.Name +
                        " waves to you, may Tyr bless you.",
                        player.HubGuid);
                }
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "mortem"
                };

                Save.LogError(log);
            }
        }
示例#17
0
 public async Task UpdateLance(Lance lance) => await LanceDAO.UpdateLance(lance);
示例#18
0
        public void LanceOK()
        {
            Lance lance = new Lance(joao, 100);

            Assert.AreEqual(100.0, lance.Valor, 0.0001);
        }
示例#19
0
        static void Postfix(UnitSpawnPointGameLogic __instance, AbstractActor actor, Team team, Lance lance)
        {
            if (actor == null || actor.GetPilot() == null)
            {
                Mod.Log.Info?.Write("Actor or pilot is null, cannot check for multi-targeting, skipping.");
                return;
            }

            Statistic multiTargetStat = actor.StatCollection.GetStatistic(ModStats.EnableMultiTarget);

            if (multiTargetStat != null && multiTargetStat.Value <bool>())
            {
                bool hasMultiTargetAbility = false;
                foreach (Ability ability in actor.GetPilot().Abilities)
                {
                    if (ability.Def.Targeting == AbilityDef.TargetingType.MultiFire)
                    {
                        Mod.Log.Debug?.Write(" -- unit already has MultiFire ability, skipping.");
                        hasMultiTargetAbility = true;
                        break;
                    }
                }

                if (!hasMultiTargetAbility)
                {
                    Mod.Log.Debug?.Write("  -- adding multi-target ability to pilot.");
                    AbilityDef abilityDef = SharedState.Combat.DataManager.AbilityDefs.Get(Mod.Config.Abilities.MultiTargetId);
                    Ability    ability    = new Ability(abilityDef);
                    ability.Init(SharedState.Combat);

                    Pilot pilot = actor.GetPilot();
                    pilot.Abilities.Add(ability);
                    pilot.ActiveAbilities.Add(ability);
                    pilot.StatCollection.ModifyStat("", -1, ModStats.HBS_MaxTargets, StatCollection.StatOperation.Set, 3);
                    Mod.Log.Debug?.Write("  -- done.");
                }
            }
        }
示例#20
0
 public static void Prefix(UnitSpawnPointGameLogic __instance, AbstractActor actor, Team team, Lance lance)
 {
     CustomActivatableEquipment.Log.LogWrite("UnitSpawnPointGameLogic.initializeActor " + new Text(actor.DisplayName).ToString() + ":" + new Text(__instance.DisplayName).ToString() + "\n");
     actor.AddToActiveDefaultQueue();
 }
示例#21
0
        protected override BehaviorTreeResults Tick()
        {
            if (unit.HasMovedThisRound)
            {
                return(new BehaviorTreeResults(BehaviorNodeState.Failure));
            }

            BehaviorVariableValue targetLanceGuidValue = this.tree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_TARGET_GUID_KEY);

            if (targetLanceGuidValue == null)
            {
                return(new BehaviorTreeResults(BehaviorNodeState.Failure));
            }

            string targetLanceGuid = targetLanceGuidValue.StringVal;
            Lance  targetLance     = DestinationUtil.FindLanceByGUID(this.tree, targetLanceGuid);

            if (targetLance == null)
            {
                return(new BehaviorTreeResults(BehaviorNodeState.Failure));
            }

            AbstractActor closestEnemy = null;

            if (Main.Settings.AiSettings.FollowAiSettings.StopWhen == "OnEnemyVisible")
            {
                Main.LogDebug($"[MoveToFollowLanceNode] Looking for closest visible enemy.");
                closestEnemy = AiUtils.GetClosestVisibleEnemy(this.unit, targetLance);
            }
            else // OnEnemyDetected
            {
                Main.LogDebug($"[MoveToFollowLanceNode] Looking for closest detected enemy.");
                closestEnemy = AiUtils.GetClosestDetectedEnemy(this.unit, targetLance);
            }

            if (closestEnemy != null)
            {
                if (Main.Settings.AiSettings.FollowAiSettings.StopWhen != "WhenNotNeeded")
                {
                    Main.LogDebug($"[MoveToFollowLanceNode] Detected enemy. No longer following player mech.");
                    return(new BehaviorTreeResults(BehaviorNodeState.Failure));
                }
                else
                {
                    Main.LogDebug($"[MoveToFollowLanceNode] Enemies detected but keeping tight formation still. Following player mech.");
                }
            }
            else
            {
                Main.LogDebug($"[MoveToFollowLanceNode] No enemies detected. Following player mech.");
            }


            List <AbstractActor> lanceMembers = AIUtil.GetLanceUnits(this.unit.Combat, this.unit.LanceId);
            float travelDistance = Mathf.Max(this.unit.MaxSprintDistance, this.unit.MaxWalkDistance);

            if (this.waitForLance)
            {
                for (int i = 0; i < lanceMembers.Count; i++)
                {
                    AbstractActor abstractActor = lanceMembers[i] as AbstractActor;

                    if (abstractActor != null)
                    {
                        float lanceMemberTravelDistance = Mathf.Max(abstractActor.MaxWalkDistance, abstractActor.MaxSprintDistance);
                        travelDistance = Mathf.Min(travelDistance, lanceMemberTravelDistance);
                    }
                }
            }

            AbstractActor targetActor = GetMechToFollow(targetLance);

            if (targetActor == null)
            {
                Main.Logger.LogError("[MoveToFollowLanceNode] Target Actor is null");
                return(new BehaviorTreeResults(BehaviorNodeState.Failure));
            }

            Main.LogDebug($"[MoveToFollowLanceNode] Target to follow is '{targetActor.DisplayName} {targetActor.VariantName}'");

            bool shouldSprint = this.tree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_SHOULD_SPRINT_KEY).BoolVal;

            Main.LogDebug($"[MoveToFollowLanceNode] Should sprint by behaviour value being set? '{shouldSprint}'");

            shouldSprint = (!this.unit.HasAnyContactWithEnemy);

            Main.LogDebug($"[MoveToFollowLanceNode] Should sprint by contact with enemy? '{shouldSprint}'");

            shouldSprint = (this.unit.CurrentPosition - targetActor.CurrentPosition).magnitude > Main.Settings.AiSettings.FollowAiSettings.MaxDistanceFromTargetBeforeSprinting; // sprint if the unit is over 200 metres away
            Main.LogDebug($"[MoveToFollowLanceNode] Is the follow target further than 200m? Should sprint? '{shouldSprint}'");

            Vector3  lookDirection = (closestEnemy == null) ? targetActor.CurrentPosition : closestEnemy.CurrentPosition;
            MoveType moveType      = (shouldSprint) ? MoveType.Sprinting : MoveType.Walking;

            this.unit.Pathing.UpdateAIPath(targetActor.CurrentPosition, lookDirection, moveType);

            Vector3 vectorToTarget   = this.unit.Pathing.ResultDestination - this.unit.CurrentPosition;
            float   distanceToTarget = vectorToTarget.magnitude;

            if (distanceToTarget > travelDistance)
            {
                Main.LogDebug($"[MoveToFollowLanceNode] Can't reach follow target in one go so will go as far as I can");
                // If the target is out of range, head in the direction of that unit to the maximum possible travel distance for this turn
                vectorToTarget = vectorToTarget.normalized * travelDistance;
            }

            // Ensure the units aren't crowded
            Vector3 targetDestination = RoutingUtil.Decrowd(this.unit.CurrentPosition + vectorToTarget, this.unit);

            targetDestination = RegionUtil.MaybeClipMovementDestinationToStayInsideRegion(this.unit, targetDestination);

            float followLanceZoneRadius = this.unit.BehaviorTree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_ZONE_RADIUS_KEY).FloatVal;

            Main.LogDebug($"[MoveToFollowLanceNode] My follow zone radius is '{followLanceZoneRadius}'");
            if (RoutingUtils.IsUnitInsideRadiusOfPoint(this.unit, targetActor.CurrentPosition, followLanceZoneRadius))
            {
                Main.LogDebug($"[MoveToFollowLanceNode] ...and I am inside that zone.");
                return(new BehaviorTreeResults(BehaviorNodeState.Failure));
            }
            else
            {
                Main.LogDebug($"[MoveToFollowLanceNode] ...and I am NOT inside that zone.");
            }

            this.unit.Pathing.UpdateAIPath(targetDestination, lookDirection, moveType);
            targetDestination = this.unit.Pathing.ResultDestination;
            float        maxCost             = this.unit.Pathing.MaxCost;
            PathNodeGrid currentGrid         = this.unit.Pathing.CurrentGrid;
            Vector3      targetActorPosition = targetActor.CurrentPosition;

            // This method seems to get called all the time - this is meant to be a last resort method I think. I wonder why the other AI pathfinding methods don't work?
            if ((currentGrid.GetValidPathNodeAt(targetDestination, maxCost) == null || (targetDestination - targetActor.CurrentPosition).magnitude > 1f) && this.unit.Combat.EncounterLayerData.inclineMeshData != null)
            {
                float maxSlope = Mathf.Tan(0.0174532924f * AIUtil.GetMaxSteepnessForAllLance(this.unit));
                List <AbstractActor> lanceUnits = AIUtil.GetLanceUnits(this.unit.Combat, this.unit.LanceId);
                targetDestination = this.unit.Combat.EncounterLayerData.inclineMeshData.GetDestination(this.unit.CurrentPosition, targetDestination, maxCost, maxSlope, this.unit, shouldSprint, lanceUnits, this.unit.Pathing.CurrentGrid, out targetActorPosition);
            }

            Vector3 currentPosition = this.unit.CurrentPosition;

            AIUtil.LogAI(string.Format("issuing order from [{0} {1} {2}] to [{3} {4} {5}] looking at [{6} {7} {8}]", new object[] {
                currentPosition.x,
                currentPosition.y,
                currentPosition.z,
                targetDestination.x,
                targetDestination.y,
                targetDestination.z,
                targetActorPosition.x,
                targetActorPosition.y,
                targetActorPosition.z
            }), "AI.DecisionMaking");

            // TODO: Factor in jump mechs
            return(new BehaviorTreeResults(BehaviorNodeState.Success)
            {
                orderInfo = new MovementOrderInfo(targetDestination, targetActorPosition)
                {
                    IsSprinting = shouldSprint
                },
                debugOrderString = string.Format("{0} moving toward destination: {1} dest: {2}", this.name, targetDestination, targetActor.CurrentPosition)
            });
        }
示例#22
0
 public bool CriarLance(Lance lance)
 {
     return(gerenciadorLance.CriarLance(lance));
 }
        public HumanPaladin() : base(AIType.AI_Melee, FightMode.Agressor, 10, 1, 0.2, 0.4)
        {
            Title     = "the Righteous";
            SpeechHue = Utility.RandomDyedHue();
            Hue       = Utility.RandomSkinHue();
            Body      = 0x190;
            Level     = 10;

            if (this.Female = Utility.RandomBool())
            {
                Body = 0x191;
                Name = NameList.RandomName("female");
                FemalePlateChest fchest = new FemalePlateChest();
                fchest.Hue     = 2122;
                fchest.Movable = false;
                AddItem(fchest);
                Kilt kilt = new Kilt();
                kilt.Movable = false;
                kilt.Hue     = 2971;
                AddItem(kilt);
            }
            else
            {
                Body = 0x190;
                Name = NameList.RandomName("male");
                PlateChest chest = new PlateChest();
                chest.Hue     = 2122;
                chest.Movable = false;
                AddItem(chest);
                Surcoat coat = new Surcoat();
                coat.Hue     = 2971;
                coat.Movable = false;
                AddItem(coat);
                CloseHelm helm = new CloseHelm();
                helm.Hue     = 2122;
                helm.Movable = false;
                AddItem(helm);
            }

            Fame  = 2000;
            Karma = 8000;

            new Nightmare().Rider = this;

            PlateArms arms = new PlateArms();

            arms.Hue     = 2122;
            arms.Movable = false;
            AddItem(arms);
            PlateLegs legs = new PlateLegs();

            legs.Hue     = 2122;
            legs.Movable = false;
            AddItem(legs);
            PlateGorget gorget = new PlateGorget();

            gorget.Hue     = 2122;
            gorget.Movable = false;
            AddItem(gorget);
            PlateGloves gloves = new PlateGloves();

            gloves.Hue     = 2122;
            gloves.Movable = false;
            AddItem(gloves);

            Cloak cloak = new Cloak();

            cloak.Hue     = 2971;
            cloak.Movable = false;
            AddItem(cloak);

            PackGold(10, 17);

            SetSkill(SkillName.MagicResist, 80.0, 90.5);
            SetSkill(SkillName.Swords, 85.0, 101.5);
            SetSkill(SkillName.Tactics, 85.0, 93.5);
            SetSkill(SkillName.Wrestling, 65.0, 72.5);
            SetSkill(SkillName.Fencing, 85.0, 100.5);
            SetSkill(SkillName.Macing, 70.3, 95.5);

            SetStr(316, 440);
            SetDex(161, 223);
            SetInt(141, 165);
            SetHits(380, 433);
            SetDamage(12, 20);

            switch (Utility.Random(8))
            {
            case 0: WarMace wmace = new WarMace();
                wmace.Movable = false;
                wmace.Hue     = 2122;
                AddItem(wmace);

                OrderShield ashield = new OrderShield();
                ashield.Movable = false;
                ashield.Hue     = 2122;
                AddItem(ashield);
                break;

            case 1: Bardiche bd = new Bardiche();
                bd.Movable = false;
                bd.Hue     = 2122;
                AddItem(bd);
                break;

            case 2: Broadsword bsword = new Broadsword();
                bsword.Movable = false;
                bsword.Hue     = 2122;
                AddItem(bsword);

                OrderShield bshield = new OrderShield();
                bshield.Movable = false;
                bshield.Hue     = 2122;
                AddItem(bshield);
                break;

            case 3: Pike pike = new Pike();
                pike.Movable = false;
                pike.Hue     = 2122;
                AddItem(pike);
                break;

            case 4: Halberd hbrd = new Halberd();
                hbrd.Movable = false;
                hbrd.Hue     = 2122;
                AddItem(hbrd);
                break;

            case 5: Maul maul = new Maul();
                maul.Movable = false;
                maul.Hue     = 2122;
                AddItem(maul);

                OrderShield cshield = new OrderShield();
                cshield.Movable = false;
                cshield.Hue     = 2122;
                AddItem(cshield);
                break;

            case 6: VikingSword vsword = new VikingSword();
                vsword.Movable = false;
                vsword.Hue     = 2122;
                AddItem(vsword);

                OrderShield dshield = new OrderShield();
                dshield.Movable = false;
                dshield.Hue     = 2122;
                AddItem(dshield);
                break;

            case 7: Lance lance = new Lance();
                lance.Movable = false;
                lance.Hue     = 2122;
                AddItem(lance);
                break;
            }

            AddItem(Server.Items.Hair.GetRandomHair(Female));
        }
示例#24
0
        private void CreateClassic()
        {
            m_MoveSound    = 588;
            m_CaptureSound = 168;
            m_DeathSound   = 170;

            m_Piece.Female    = false;
            m_Piece.BodyValue = 0x190;

            if (m_BChessboard.OverrideMinorHue)
            {
                m_Piece.Hue = Hue;
            }
            else
            {
                m_Piece.Hue = m_BChessboard.SkinHue;
            }
            m_Piece.AddItem(new PonyTail(m_BChessboard.OverrideMinorHue ? Hue : m_BChessboard.HairHue));

            Item item = null;

            if (m_Color == ChessColor.White)
            {
                item = new OrderShield();
                m_Piece.AddItem(item);
            }
            else
            {
                item = new ChaosShield();
                m_Piece.AddItem(item);
            }

            item = new Doublet(MinorHue);
            m_Piece.AddItem(item);

            item     = new PlateLegs();
            item.Hue = Hue;
            m_Piece.AddItem(item);

            item     = new PlateChest();
            item.Hue = Hue;
            m_Piece.AddItem(item);

            item     = new PlateArms();
            item.Hue = Hue;
            m_Piece.AddItem(item);

            item     = new PlateGorget();
            item.Hue = Hue;
            m_Piece.AddItem(item);

            item     = new PlateGloves();
            item.Hue = Hue;
            m_Piece.AddItem(item);

            item = new Lance();
            m_Piece.AddItem(item);

            Server.Mobiles.Horse horse = new Server.Mobiles.Horse();
            if (m_Color == ChessColor.White)
            {
                horse.BodyValue = 226;
                horse.Hue       = 1150;
            }
            else
            {
                horse.BodyValue = 179;
                horse.ItemID    = 16055;
                horse.Hue       = 1109;
            }

            horse.Rider = m_Piece;

            m_Piece.Direction = Facing;
        }
示例#25
0
        public static AbstractActor GetClosestVisibleEnemy(AbstractActor focusedUnit, Lance allyLance)
        {
            string teamGuid = focusedUnit.lance.team.GUID;

            List <AbstractActor> visibleEnemyUnits = new List <AbstractActor>();

            visibleEnemyUnits.AddRange(focusedUnit.lance.team.GetVisibleEnemyUnits());
            visibleEnemyUnits.AddRange(allyLance.team.GetVisibleEnemyUnits());

            visibleEnemyUnits.RemoveAll(potentialEnemy => {
                if (!UnityGameInstance.BattleTechGame.Combat.HostilityMatrix.IsEnemy(teamGuid, potentialEnemy.team.GUID))
                {
                    Main.Logger.Log($"[GetClosestVisibleEnemy] Removing potential enemy Unit '{potentialEnemy.DisplayName}' because it's not an enemy.");
                    return(true);
                }

                return(false);
            });

            float         num          = -1f;
            AbstractActor closestActor = null;

            for (int i = 0; i < visibleEnemyUnits.Count; i++)
            {
                AbstractActor actor     = visibleEnemyUnits[i] as AbstractActor;
                float         magnitude = (actor.CurrentPosition - focusedUnit.CurrentPosition).magnitude;
                if (num < 0f || magnitude < num)
                {
                    num          = magnitude;
                    closestActor = actor;
                }
            }

            return(closestActor);
        }
示例#26
0
        public void Have_L_AsShortName()
        {
            var lance = new Lance(Player.Black, "5i");

            Assert.Equal('L', lance.ShortName);
        }
示例#27
0
 public async Task Create(Lance NovoLance)
 {
     _context.Add(NovoLance);
     await _context.SaveChangesAsync();
 }
        public override void GenerateLoot()
        {
            AddLoot(LootPack.FilthyRich, 3);
            AddLoot(LootPack.MedScrolls, 1);
            AddLoot(LootPack.LowScrolls, 5);
            AddLoot(LootPack.Gems, 3);

            if (Utility.RandomDouble() < 0.10)
            {
                BaseWeapon weapon = Loot.RandomWeapon(true);
                switch (Utility.Random(33))
                {
                case 0: weapon = new BattleAxe(); break;

                case 1: weapon = new ExecutionersAxe(); break;

                case 2: weapon = new LargeBattleAxe(); break;

                case 3: weapon = new WarAxe(); break;

                case 4: weapon = new Bow(); break;

                case 5: weapon = new Crossbow(); break;

                case 6: weapon = new HeavyCrossbow(); break;

                case 7: weapon = new WarHammer(); break;

                case 8: weapon = new WarMace(); break;

                case 9: weapon = new Bardiche(); break;

                case 10: weapon = new Halberd(); break;

                case 11: weapon = new Spear(); break;

                case 12: weapon = new QuarterStaff(); break;

                case 13: weapon = new Katana(); break;

                case 14: weapon = new Longsword(); break;

                case 15: weapon = new VikingSword(); break;

                case 16: weapon = new CompositeBow(); break;

                case 17: weapon = new CrescentBlade(); break;

                case 18: weapon = new DoubleBladedStaff(); break;

                case 19: weapon = new Lance(); break;

                case 20: weapon = new PaladinSword(); break;

                case 21: weapon = new Scythe(); break;

                case 22: weapon = new Daisho(); break;

                case 23: weapon = new Lajatang(); break;

                case 24: weapon = new NoDachi(); break;

                case 25: weapon = new Tetsubo(); break;

                case 26: weapon = new Yumi(); break;

                case 27: weapon = new ElvenCompositeLongbow(); break;

                case 28: weapon = new OrnateAxe(); break;

                case 29: weapon = new RadiantScimitar(); break;

                case 30: weapon = new WarCleaver(); break;

                case 31: weapon = new WildStaff(); break;

                default: weapon = new DiamondMace(); break;
                }

                BaseRunicTool.ApplyAttributesTo(weapon, 5, 35, 50);
                weapon.Hue = 1461;

                PackItem(weapon);
            }

            if (Utility.RandomDouble() < 0.10)
            {
                BaseArmor armor = Loot.RandomArmor(true);
                switch (Utility.Random(5))
                {
                case 0: armor = new CrusaderGauntlets(); break;

                case 1: armor = new CrusaderGorget(); break;

                case 2: armor = new CrusaderLeggings(); break;

                case 3: armor = new CrusaderSleeves(); break;

                default: armor = new CrusaderBreastplate(); break;
                }

                BaseRunicTool.ApplyAttributesTo(armor, 5, 35, 50);
                armor.Hue = 1461;

                PackItem(armor);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseClothing clothing = Loot.RandomClothing(true);
                BaseRunicTool.ApplyAttributesTo(clothing, 5, 35, 50);
                clothing.Hue = 1461;

                PackItem(clothing);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseShield shield = new MetalKiteShield();
                if (Core.AOS)
                {
                    BaseRunicTool.ApplyAttributesTo(shield, 5, 35, 50);
                }
                shield.Hue = 1461;

                PackItem(shield);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseJewel bracelet = new GoldBracelet();
                if (Core.AOS)
                {
                    BaseRunicTool.ApplyAttributesTo(bracelet, 5, 35, 50);
                }
                bracelet.Hue = 1461;

                PackItem(bracelet);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseJewel earrings = new GoldEarrings();
                if (Core.AOS)
                {
                    BaseRunicTool.ApplyAttributesTo(earrings, 5, 35, 50);
                }
                earrings.Hue = 1461;

                PackItem(earrings);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseJewel necklace = new GoldNecklace();
                if (Core.AOS)
                {
                    BaseRunicTool.ApplyAttributesTo(necklace, 5, 35, 50);
                }
                necklace.Hue = 1461;

                PackItem(necklace);
            }

            if (Utility.RandomDouble() < 0.05)
            {
                BaseJewel ring = new GoldRing();
                if (Core.AOS)
                {
                    BaseRunicTool.ApplyAttributesTo(ring, 5, 35, 50);
                }
                ring.Hue = 1461;

                PackItem(ring);
            }
        }
示例#29
0
 public async Task UpdateLance(Lance lance)
 {
     _context.Update(lance);
     await _context.SaveChangesAsync();
 }
        public static AbstractActor SpawnAmbushTurret(Team team, Lance ambushLance, BattleTech.Building building, Vector3 ambushOrigin)
        {
            // Randomly determine one of the spawnpairs from the current ambushdef
            List <TurretAndPilotDef> shuffledSpawns = new List <TurretAndPilotDef>();

            shuffledSpawns.AddRange(ModState.InfantryAmbushDefForContract.SpawnPool);
            shuffledSpawns.Shuffle();
            TurretAndPilotDef ambushDef = shuffledSpawns[0];

            PilotDef  pilotDef  = ModState.Combat.DataManager.PilotDefs.Get(ambushDef.PilotDefId);
            TurretDef turretDef = ModState.Combat.DataManager.TurretDefs.GetOrCreate(ambushDef.TurretDefId);

            turretDef.Refresh();

            // determine a position somewhere up the building's axis
            EncounterLayerData encounterLayerData = ModState.Combat.EncounterLayerData;
            Point cellPoint = new Point(
                ModState.Combat.MapMetaData.GetXIndex(building.CurrentPosition.x),
                ModState.Combat.MapMetaData.GetZIndex(building.CurrentPosition.z));
            MapEncounterLayerDataCell melDataCell =
                encounterLayerData.mapEncounterLayerDataCells[cellPoint.Z, cellPoint.X];
            float buildingHeight = melDataCell.GetBuildingHeight();

            float terrainHeight = ModState.Combat.MapMetaData.GetLerpedHeightAt(building.CurrentPosition, true);
            float heightDelta   = (buildingHeight - terrainHeight) * 0.7f;
            float adjustedY     = terrainHeight + heightDelta;

            Mod.Log.Debug?.Write($"At building position, terrain height is: {terrainHeight} while buildingHeight is: {buildingHeight}. " +
                                 $" Calculated 70% of building height + terrain as {adjustedY}.");

            Vector3 newPosition = building.GameRep.transform.position;

            newPosition.y = adjustedY;
            Mod.Log.Debug?.Write($"Changing transform position from: {building.GameRep.transform.position} to {newPosition}");

            /// Rotate to face the ambush origin
            Vector3    spawnDirection = Vector3.RotateTowards(building.CurrentRotation.eulerAngles, ambushOrigin, 1f, 0f);
            Quaternion spawnRotation  = Quaternion.LookRotation(spawnDirection);

            // Create the turret
            Turret turret = ActorFactory.CreateTurret(turretDef, pilotDef, team.EncounterTags, ModState.Combat, team.GetNextSupportUnitGuid(), "", null);

            turret.Init(newPosition, spawnRotation.eulerAngles.y, true);
            turret.InitGameRep(null);

            if (turret == null)
            {
                Mod.Log.Error?.Write($"Failed to spawn turretDefId: {ambushDef.TurretDefId} + pilotDefId: {ambushDef.PilotDefId} !");
            }

            Mod.Log.Debug?.Write($" Spawned trap turret, adding to team.");
            team.AddUnit(turret);
            turret.AddToTeam(team);
            turret.AddToLance(ambushLance);

            turret.BehaviorTree = BehaviorTreeFactory.MakeBehaviorTree(ModState.Combat.BattleTechGame, turret, BehaviorTreeIDEnum.CoreAITree);
            Mod.Log.Debug?.Write("Updated turret behaviorTree");

            ModState.AmbushBuildingGUIDToTurrets.Add(building.GUID, turret);
            ModState.AmbushTurretGUIDtoBuilding.Add(turret.GUID, building);

            // Associate the building withe the team
            building.AddToTeam(team);
            building.BuildingRep.IsTargetable = true;
            building.BuildingRep.SetHighlightColor(ModState.Combat, team);
            building.BuildingRep.RefreshEdgeCache();

            // Increase the building's health to the current value + turret structure
            float combinedStructure = (float)Math.Ceiling(building.CurrentStructure + turret.GetCurrentStructure(BuildingLocation.Structure));

            Mod.Log.Debug?.Write($"Setting ambush structure to: {combinedStructure} = building.currentStructure: {building.CurrentStructure} + " +
                                 $"turret.currentStructure: {turret.GetCurrentStructure(BuildingLocation.Structure)}");
            building.StatCollection.Set <float>("Structure", combinedStructure);

            // Finally notify others
            UnitSpawnedMessage message = new UnitSpawnedMessage("CJ_TRAP", turret.GUID);

            ModState.Combat.MessageCenter.PublishMessage(message);

            // Finally force the turret to be fully visible
            turret.OnPlayerVisibilityChanged(VisibilityLevel.LOSFull);

            return(turret);
        }
 bool isPathNodeInsideTetherDistanceFromGuardLance(PathNode pathNode, float guardTetherDistance, Lance guardLance)
 {
     return(findDistanceFromGuardLance(pathNode.Position, guardLance) <= guardTetherDistance);
 }