コード例 #1
0
        public void LoadNPCs()
        {
            for (int i = 0; i < ConquestMap.NPCs.Count; i++)
            {
                if (ConquestMap.NPCs[i].Info.Conquest == Info.Index)
                {
                    ConquestMap.NPCs[i].Conq = this;
                    ConquestNPCs.Add(ConquestMap.NPCs[i]);
                }
            }


            PalaceMap = Envir.GetMap(Info.PalaceIndex);

            if (PalaceMap != null)
            {
                for (int i = 0; i < PalaceMap.NPCs.Count; i++)
                {
                    if (PalaceMap.NPCs[i].Info.Conquest == Info.Index)
                    {
                        PalaceMap.NPCs[i].Conq = this;
                        ConquestNPCs.Add(ConquestMap.NPCs[i]);
                    }
                }
            }

            Map temp;

            for (int i = 0; i < Info.ExtraMaps.Count; i++)
            {
                temp = Envir.GetMap(Info.ExtraMaps[i]);
                if (temp == null)
                {
                    continue;
                }
                for (int j = 0; j < temp.NPCs.Count; j++)
                {
                    if (temp.NPCs[j].Info.Conquest == Info.Index)
                    {
                        temp.NPCs[j].Conq = this;
                        ConquestNPCs.Add(temp.NPCs[j]);
                    }
                }
            }
        }
コード例 #2
0
ファイル: LMS_BR_Info.cs プロジェクト: coolzoom/mir2-master
        public void End_Match(bool foundWinner = false)
        {
            bool   failed      = false;
            string matchResult = "";

            if (foundWinner)
            {
                LMS_Rank     lmsRank       = null;
                PlayerObject winningPlayer = null;
                for (int i = 0; i < CurrentMap.Players.Count; i++)
                {
                    PlayerObject player = CurrentMap.Players[i];
                    if (player == null ||
                        player.Dead)
                    {
                        continue;
                    }
                    for (int x = 0; x < PlayerRanks.Count; x++)
                    {
                        if (player.Name == PlayerRanks[x].Player.Name &&
                            winningPlayer == null &&
                            lmsRank == null)
                        {
                            winningPlayer = player;
                            lmsRank       = PlayerRanks[x];
                        }
                    }
                }
                if (winningPlayer != null &&
                    lmsRank != null)
                {
                    //  TODO Reward players (send by mail)
                    matchResult = string.Format("{0} is the Victor of the match!", winningPlayer.Name);

                    winningPlayer.Teleport(Envir.GetMap(winningPlayer.BindMapIndex), winningPlayer.BindLocation, true, 0);
                    winningPlayer.InLMSBR = false;
                    List <LMS_RewardInfo> rewards = CreateRewards(1, winningPlayer);
                    if (rewards != null &&
                        rewards.Count > 0)
                    {
                        winningPlayer.ReceiveChat(string.Format("Victory is yours! Prize(s) will be sent via mail!"), ChatType.Hint);
                        List <UserItem> items = new List <UserItem>();
                        for (int i = 0; i < rewards.Count; i++)
                        {
                            if (rewards[i].ItemReward == null)
                            {
                                SMain.EnqueueDebugging(string.Format("Null reward"));
                                continue;
                            }
                            ItemInfo iInfo = Envir.GetItemInfo(rewards[i].ItemReward.Index);
                            if (iInfo == null)
                            {
                                SMain.EnqueueDebugging(string.Format("Null item info"));
                                continue;
                            }
                            UserItem item = Envir.CreateFreshItem(iInfo);
                            if (item != null)
                            {
                                items.Add(item);
                            }
                        }
                        MailInfo mail = new MailInfo(winningPlayer.Info.Index)
                        {
                            Items   = items,
                            Message = string.Format("Congratulations on winning the match! here is your prize(s)"),
                            Sender  = string.Format("LMS"),
                            MailID  = ++Envir.NextMailID
                        };
                        mail.Send();
                    }
                    SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} {1} wins the Match, made {2} kills.", CurrentMap.Info.Title, winningPlayer.Name, lmsRank.Kills));
                }
                else
                {
                    failed = true;
                }
            }
            if ((failed && foundWinner) || !foundWinner)
            {
                if (CurrentMap.Players.Count > 0)
                {
                    string[] finalPlayers = new string[CurrentMap.Players.Count];
                    if (finalPlayers.Length >= 1)
                    {
                        int index = 0;
                        for (int i = 0; i < CurrentMap.Players.Count; i++)
                        {
                            PlayerObject player = CurrentMap.Players[i];
                            if (player.Dead ||
                                player.IsGM)
                            {
                                continue;
                            }
                            finalPlayers[index] = player.Name;
                            player.Teleport(Envir.GetMap(player.BindMapIndex), player.BindLocation);
                            player.InLMSBR = failed;
                            index++;
                        }
                        Array.Resize(ref finalPlayers, index);
                    }
                    matchResult = "Stalemate, Players ";
                    for (int i = 0; i < finalPlayers.Length; i++)
                    {
                        matchResult += string.Format("{0}{1} ", finalPlayers[i], i - 1 <= finalPlayers.Length ? "," : " have drawn the match!");
                    }
                }
            }

            if (matchResult.Length > 0)
            {
                Envir.Broadcast(new ServerPackets.Chat {
                    Message = matchResult, Type = ChatType.Announcement
                });
            }
            StartTime        = 0;
            EndTime          = 0;
            SignedupPlayers  = new List <PlayerObject>();
            CircleLocations  = new List <Point>();
            PlayerRanks      = new List <LMS_Rank>();
            StartingLocation = Info.StartingLocation;
            Stage            = 0;
            Finished         = false;
            Started          = false;
        }
コード例 #3
0
        private void NPCVisibility(bool Show = true)
        {
            //Check if Players in Conquest Zone;
            for (int j = 0; j < ConquestMap.Players.Count; j++)
            {
                ConquestMap.Players[j].CheckConquest();
            }

            PalaceMap = Envir.GetMap(Info.PalaceIndex);
            if (PalaceMap != null)
            {
                if (Show)
                {
                    PalaceMap.tempConquest = this;
                }
                else
                {
                    PalaceMap.tempConquest = null;
                }

                for (int j = 0; j < PalaceMap.Players.Count; j++)
                {
                    PalaceMap.Players[j].CheckConquest();
                }
            }

            Map temp;

            for (int i = 0; i < Info.ExtraMaps.Count; i++)
            {
                temp = Envir.GetMap(Info.ExtraMaps[i]);
                if (temp == null)
                {
                    continue;
                }

                if (Show)
                {
                    temp.tempConquest = this;
                }
                else
                {
                    temp.tempConquest = null;
                }

                for (int k = 0; k < temp.Players.Count; k++)
                {
                    temp.Players[k].CheckConquest();
                }
            }


            //Set NPCs to invisible
            Map       npcMap;
            NPCObject npcTemp;

            for (int i = 0; i < ConquestNPCs.Count; i++)
            {
                npcMap  = ConquestNPCs[i].CurrentMap;
                npcTemp = ConquestNPCs[i];
                for (int j = 0; j < npcMap.Players.Count; j++)
                {
                    if (Functions.InRange(npcTemp.CurrentLocation, npcMap.Players[j].CurrentLocation, Globals.DataRange))
                    {
                        npcTemp.CheckVisible(npcMap.Players[j]);
                    }
                }
            }
        }