Beispiel #1
0
 public StaticObject(L2StaticObject obj)
 {
     this.obj = obj;
 }
Beispiel #2
0
 public StaticObject(L2StaticObject obj)
 {
     _obj = obj;
 }
Beispiel #3
0
        public void Initialize()
        {
            Objects = new SortedList <int, L2StaticObject>();
            using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine() ?? string.Empty;
                    if ((line.Length == 0) || line.StartsWithIgnoreCase("#"))
                    {
                        continue;
                    }

                    string[] pt = line.Split('\t');

                    L2StaticObject obj = null;

                    switch (pt[1])
                    {
                    case "map":
                        obj = new L2TownMap();
                        break;

                    case "chair":
                        obj = new L2Chair();
                        break;

                    case "pvp":
                        obj = new L2PvPSign();
                        break;

                    case "door":
                        obj = new L2Door();
                        break;
                    }

                    if (obj == null)
                    {
                        continue;
                    }

                    obj.StaticId = Convert.ToInt32(pt[0]);

                    for (byte ord = 2; ord < pt.Length; ord++)
                    {
                        string parameter = pt[ord];
                        string value     = parameter.Substring(parameter.IndexOf('{') + 1);
                        value = value.Remove(value.Length - 1);

                        switch (parameter.Split('{')[0].ToLower())
                        {
                        case "spawn":
                            obj.SetLoc(value.Split(' '));
                            break;

                        case "tex":
                            obj.SetTex(value.Split(' '));
                            break;

                        case "htm":
                            obj.Htm = value;
                            break;

                        case "hp":
                            obj.MaxHp = Convert.ToInt32(value);
                            break;

                        case "defence":
                            obj.Pdef = Convert.ToInt32(value.Split(' ')[0]);
                            obj.Mdef = Convert.ToInt32(value.Split(' ')[1]);
                            break;

                        case "unlock":
                        {
                            foreach (string str in value.Split(' '))
                            {
                                switch (str)
                                {
                                case "trigger":
                                    obj.UnlockTrigger = true;
                                    break;

                                case "skill":
                                    obj.UnlockSkill = true;
                                    break;

                                case "drop":
                                    obj.UnlockNpc = true;
                                    break;
                                }
                            }
                        }

                        break;
                        }
                    }

                    Objects.Add(obj.StaticId, obj);
                }
            }

            foreach (L2StaticObject o in Objects.Values)
            {
                L2World.Instance.AddObject(o);
                o.OnSpawn();
            }

            Log.Info($"StaticObjTable: Spanwed {Objects.Count} objects.");
        }
Beispiel #4
0
        public void read()
        {
            objects = new SortedList <int, L2StaticObject>();
            StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line.Length == 0 || line.StartsWith("#"))
                {
                    continue;
                }

                string[] pt = line.Split('\t');

                L2StaticObject obj = null;

                switch (pt[1])
                {
                case "map":
                    obj = new L2TownMap();
                    break;

                case "chair":
                    obj = new L2Chair();
                    break;

                case "pvp":
                    obj = new L2PvPSign();
                    break;

                case "door":
                    obj = new L2Door();
                    break;
                }

                obj.StaticID = Convert.ToInt32(pt[0]);

                for (byte ord = 2; ord < pt.Length; ord++)
                {
                    string parameter = pt[ord];
                    string value     = parameter.Substring(parameter.IndexOf('{') + 1); value = value.Remove(value.Length - 1);

                    switch (parameter.Split('{')[0].ToLower())
                    {
                    case "spawn":
                        obj.setLoc(value.Split(' '));
                        break;

                    case "tex":
                        obj.setTex(value.Split(' '));
                        break;

                    case "htm":
                        obj.htm = value;
                        break;

                    case "hp":
                        obj.MaxHP = Convert.ToInt32(value);
                        break;

                    case "defence":
                        obj.pdef = Convert.ToInt32(value.Split(' ')[0]);
                        obj.mdef = Convert.ToInt32(value.Split(' ')[1]);
                        break;

                    case "unlock":
                    {
                        foreach (string str in value.Split(' '))
                        {
                            switch (str)
                            {
                            case "trigger":
                                obj.UnlockTrigger = true;
                                break;

                            case "skill":
                                obj.UnlockSkill = true;
                                break;

                            case "drop":
                                obj.UnlockNpc = true;
                                break;
                            }
                        }
                    }
                    break;
                    }
                }

                objects.Add(obj.StaticID, obj);
            }
        }