コード例 #1
0
ファイル: Utils.cs プロジェクト: yanhan-dev/BNSAtomix
 public static void SpawnNPC(Map.Map map, ushort npcID, int appearEffect, short x, short y, short z, ushort dir, ushort motion)
 {
     NPC.SpawnData spawn = new NPC.SpawnData()
     {
         MapID        = map.ID,
         IsMapObject  = false,
         NpcID        = npcID,
         Range        = 0,
         Count        = 1,
         X            = x,
         Y            = y,
         Z            = z,
         Dir          = dir,
         Delay        = 0,
         Motion       = motion,
         AppearEffect = appearEffect
     };
     spawn.DoSpawn(map);
 }
コード例 #2
0
        protected override void ParseXML(System.Xml.XmlElement root, System.Xml.XmlElement current, QuestDetail item)
        {
            switch (root.Name.ToLower())
            {
            case "quest":
            {
                switch (current.Name.ToLower())
                {
                case "id":
                    item.QuestID = uint.Parse(current.InnerText);
                    break;

                case "step":
                {
                    QuestStep s = new QuestStep()
                    {
                        StepID = byte.Parse(current.Attributes["id"].Value),
                        Finish = current.HasAttribute("finish") && bool.Parse(current.Attributes["finish"].Value)
                    };
                    item.Steps.Add(s.StepID, s);
                }
                break;

                case "nextquest":
                {
                    Job job = Job.None;
                    if (current.HasAttribute("job"))
                    {
                        job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value);
                    }

                    item.NextQuest[job] = uint.Parse(current.InnerText);
                }
                break;
                }
            }
            break;

            case "step":
            {
                QuestStep step = item.Steps[byte.Parse(root.Attributes["id"].Value)];
                switch (current.Name.ToLower())
                {
                case "target":
                {
                    QuestTarget target = new QuestTarget();
                    string      type   = current.Attributes["type"].Value;
                    switch (type.ToLower())
                    {
                    case "npc":
                        target.TargetType = StepTargetType.NPC;
                        break;

                    case "mapobject":
                        target.TargetType = StepTargetType.MapObject;
                        break;

                    case "map":
                        target.TargetType = StepTargetType.Map;
                        break;

                    case "loot":
                        target.TargetType = StepTargetType.Loot;
                        break;

                    default:
                        target.TargetType = StepTargetType.None;
                        break;
                    }
                    if (current.HasAttribute("flagidx"))
                    {
                        target.TargetFlagIndex = int.Parse(current.Attributes["flagidx"].Value);
                    }

                    if (current.HasAttribute("increment"))
                    {
                        target.TargetFlagIncrement = short.Parse(current.Attributes["increment"].Value);
                    }

                    if (current.HasAttribute("index"))
                    {
                        target.SpecifyIndex = int.Parse(current.Attributes["index"].Value);
                    }

                    if (current.HasAttribute("finishflagidx"))
                    {
                        target.TargetFinishFlagIndex = int.Parse(current.Attributes["finishflagidx"].Value);
                    }

                    if (current.HasAttribute("finishincrement"))
                    {
                        target.TargetFinishFlagIncrement = short.Parse(current.Attributes["finishincrement"].Value);
                    }

                    if (current.HasAttribute("count"))
                    {
                        target.TargetCount = short.Parse(current.Attributes["count"].Value);
                    }

                    if (current.HasAttribute("x"))
                    {
                        target.HasCoordinate = true;
                        target.TargetX       = short.Parse(current.Attributes["x"].Value);
                    }
                    if (current.HasAttribute("y"))
                    {
                        target.HasCoordinate = true;
                        target.TargetY       = short.Parse(current.Attributes["y"].Value);
                    }
                    if (current.HasAttribute("z"))
                    {
                        target.HasCoordinate = true;
                        target.TargetZ       = short.Parse(current.Attributes["z"].Value);
                    }
                    if (target.TargetType != StepTargetType.None)
                    {
                        foreach (string s in current.InnerText.Split(','))
                        {
                            target.TargetIDs.Add(uint.Parse(s));
                        }
                    }

                    if (target.TargetType == StepTargetType.MapObject)
                    {
                        target.TargetMapID = uint.Parse(current.Attributes["map"].Value);
                        foreach (uint id in target.TargetIDs)
                        {
                            ulong objID = (ulong)target.TargetMapID << 32 | id;
                            Dictionary <uint, byte> tbl;
                            if (mapObjectMapping.ContainsKey(objID))
                            {
                                tbl = mapObjectMapping[objID];
                            }
                            else
                            {
                                tbl = new Dictionary <uint, byte>();
                                mapObjectMapping.Add(objID, tbl);
                            }
                            tbl.Add(item.QuestID, step.StepID);
                        }
                    }
                    if (target.TargetType == StepTargetType.Map && target.HasCoordinate)
                    {
                        foreach (uint i in target.TargetIDs)
                        {
                            NPC.SpawnData spawn = new NPC.SpawnData()
                            {
                                IsQuest = true,
                                MapID   = i,
                                X       = target.TargetX,
                                Y       = target.TargetY,
                                Z       = target.TargetZ
                            };
                            NPC.NPCSpawnManager.Instance[i].Add(spawn);
                        }
                    }
                    step.Targets.Add(target);
                }
                break;

                case "nextstep":
                    step.NextStep = byte.Parse(current.InnerText);
                    break;

                case "stepstatus":
                    step.StepStatus = byte.Parse(current.InnerText);
                    break;

                case "giveitem":
                {
                    ushort count = 1;
                    Job    job   = Job.None;
                    if (current.HasAttribute("count"))
                    {
                        count = ushort.Parse(current.Attributes["count"].Value);
                    }

                    if (current.HasAttribute("job"))
                    {
                        job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value);
                    }

                    step.GiveItems[job].Add(uint.Parse(current.InnerText), count);
                }
                break;

                case "rewarditemoption":
                {
                    int count = 1;
                    Job job   = Job.None;
                    if (current.HasAttribute("count"))
                    {
                        count = int.Parse(current.Attributes["count"].Value);
                    }

                    if (current.HasAttribute("job"))
                    {
                        job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value);
                    }

                    step.RewardOptions[job][uint.Parse(current.InnerText)] = count;
                }
                break;

                case "teleport":
                    step.TeleportMapID = uint.Parse(current.InnerText);
                    if (current.HasAttribute("x"))
                    {
                        step.X = short.Parse(current.Attributes["x"].Value);
                    }

                    if (current.HasAttribute("y"))
                    {
                        step.Y = short.Parse(current.Attributes["y"].Value);
                    }

                    if (current.HasAttribute("z"))
                    {
                        step.Z = short.Parse(current.Attributes["z"].Value);
                    }

                    if (current.HasAttribute("u1"))
                    {
                        step.TeleportU1 = short.Parse(current.Attributes["u1"].Value);
                    }

                    if (current.HasAttribute("u2"))
                    {
                        step.TeleportU2 = short.Parse(current.Attributes["u2"].Value);
                    }

                    if (current.HasAttribute("cutscene"))
                    {
                        step.TeleportCutscene = uint.Parse(current.Attributes["cutscene"].Value);
                    }

                    break;

                case "cutscene":
                    step.CutScene = uint.Parse(current.InnerText);
                    break;

                case "takeitem":
                {
                    ushort count = 1;
                    Job    job   = Job.None;
                    if (current.HasAttribute("count"))
                    {
                        count = ushort.Parse(current.Attributes["count"].Value);
                    }

                    if (current.HasAttribute("job"))
                    {
                        job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value);
                    }

                    step.TakeItems[job].Add(uint.Parse(current.InnerText), count);
                }
                break;

                case "exp":
                {
                    step.Exp = uint.Parse(current.InnerText);
                }
                break;

                case "learnskill":
                {
                    Job job = Job.None;
                    if (current.HasAttribute("job"))
                    {
                        job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value);
                    }

                    step.LearnSkills[job].Add(uint.Parse(current.InnerText));
                }
                break;

                case "gold":
                {
                    step.Gold = int.Parse(current.InnerText);
                }
                break;

                case "spawn":
                {
                    NPC.SpawnData spawn = new NPC.SpawnData()
                    {
                        NpcID = ushort.Parse(current.Attributes["npcID"].Value),
                        X     = short.Parse(current.Attributes["x"].Value),
                        Y     = short.Parse(current.Attributes["y"].Value),
                        Z     = short.Parse(current.Attributes["z"].Value),
                        Dir   = ushort.Parse(current.Attributes["dir"].Value)
                    };
                    if (current.HasAttribute("motion"))
                    {
                        spawn.Motion = ushort.Parse(current.Attributes["motion"].Value);
                    }

                    if (current.HasAttribute("appeareffect"))
                    {
                        spawn.AppearEffect = ushort.Parse(current.Attributes["appeareffect"].Value);
                    }

                    step.Spawns.Add(spawn);
                }
                break;

                case "flag1":
                    step.Flag1 = short.Parse(current.InnerText);
                    break;

                case "flag2":
                    step.Flag2 = short.Parse(current.InnerText);
                    break;

                case "flag3":
                    step.Flag3 = short.Parse(current.InnerText);
                    break;

                case "holditem":
                    step.HoldItem = uint.Parse(current.InnerText);
                    break;

                case "dropitem":
                    step.DropItem = uint.Parse(current.InnerText);
                    break;
                }
            }
            break;
            }
        }