Beispiel #1
0
        /// <summary>
        /// 合并
        /// </summary>
        public void Combine()
        {
            if (_selectedObjs.Count > 1)
            {
                //需要排序,否则绘图的先后顺序会发生改变
                int[] indexA = new int[_selectedObjs.Count];
                for (int i = 0; i < indexA.Length; i++)
                {
                    indexA[i] = Objs.IndexOf(_selectedObjs[i]);
                }
                Array.Sort(indexA);

                DrawCombine draw = new DrawCombine(_selectedObjs)
                {
                    Parant = Container
                };
                _nameManager.CreateName(draw);
                draw.Layer = DefaultLayer;
                draw.LoadInitializationEvent();

                foreach (IDrawObj obj in _selectedObjs)
                {
                    Objs.Remove(obj);
                }
                Objs.Insert(indexA[0], draw);
                _selectedObjs.Clear();
                if (draw.CanSelect())
                {
                    _selectedObjs.Add(draw);
                }

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }
Beispiel #2
0
        public void Group(object sender, EventArgs e)
        {
            if (_selectedObjs.Count > 1)
            {
                //需要排序,否则绘图的先后顺序会发生改变
                int[] indexA = new int[_selectedObjs.Count];
                for (int i = 0; i < indexA.Length; i++)
                {
                    indexA[i] = Objs.IndexOf(_selectedObjs[i]);
                }
                Array.Sort(indexA);
                List <IDrawObj> groupL = indexA.Select(t => Objs[t]).ToList();
                DrawGroup       group  = new DrawGroup(groupL);
                _nameManager.CreateName(group);
                group.Layer = DefaultLayer;
                group.LoadInitializationEvent();

                foreach (IDrawObj obj in _selectedObjs)
                {
                    Objs.Remove(obj);
                }
                Objs.Insert(indexA[0], group);
                _selectedObjs.Clear();
                if (group.CanSelect())
                {
                    _selectedObjs.Add(group);
                }

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }
        /// <summary>
        /// Saves the data into the given <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
        public void Save(Stream stream)
        {
            // Before saving all the instances, allow references to be resolved.
            Areas?.ForEach(x => x.SerializeReferences(this));

            EnemyPaths?.ForEach(x => x.SerializeReferences(this));
            GCameraPaths?.ForEach(x => x.SerializeReferences(this));
            GlidePaths?.ForEach(x => x.SerializeReferences(this));
            GravityPaths?.ForEach(x => x.SerializeReferences(this));
            ItemPaths?.ForEach(x => x.SerializeReferences(this));
            JugemPaths?.ForEach(x => x.SerializeReferences(this));
            LapPaths?.ForEach(x => x.SerializeReferences(this));
            PullPaths?.ForEach(x => x.SerializeReferences(this));

            Objs.ForEach(x => x.SerializeReferences(this));

            ReplayCameras?.ForEach(x => x.SerializeReferences(this));

            // Save the serialized values.
            ByamlSerializer serializer = new ByamlSerializer(new ByamlSerializerSettings()
            {
                SupportPaths = true,
                Version = ByamlVersion.Version1
            });
            serializer.Serialize(stream, this);
        }
        // ---- METHODS(PUBLIC) ---------------------------------------------------------------------------------------

        /// <summary>
        /// Loads the data from the given <paramref name="stream"/>.
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
        public void Load(Stream stream)
        {
            // Load all the values from the stream.
            ByamlSerializer serializer = new ByamlSerializer(new ByamlSerializerSettings()
            {
                SupportPaths = true,
                Version = ByamlVersion.Version1
            });
            serializer.Deserialize(stream, this);

            // After loading all the instances, allow references to be resolved.
            Areas?.ForEach(x => x.DeserializeReferences(this));

            EnemyPaths?.ForEach(x => x.DeserializeReferences(this));
            GCameraPaths?.ForEach(x => x.DeserializeReferences(this));
            GlidePaths?.ForEach(x => x.DeserializeReferences(this));
            GravityPaths?.ForEach(x => x.DeserializeReferences(this));
            ItemPaths?.ForEach(x => x.DeserializeReferences(this));
            JugemPaths?.ForEach(x => x.DeserializeReferences(this));
            LapPaths?.ForEach(x => x.DeserializeReferences(this));
            ObjPaths?.ForEach(x => x.DeserializeReferences(this));
            Paths?.ForEach(x => x.DeserializeReferences(this));
            PullPaths?.ForEach(x => x.DeserializeReferences(this));

            Objs.ForEach(x => x.DeserializeReferences(this));

            ReplayCameras?.ForEach(x => x.DeserializeReferences(this));
        }
Beispiel #5
0
        public virtual object Clone()
        {
            var b = (DoubleBag)MemberwiseClone();

            b.Objs = (double[])Objs.Clone();
            return(b);
        }
    static void Main(string[] args)
    {
        Door       sideDoor    = new Door("Side Door");
        Decoration photo       = new Decoration("Awkward Family Portrait");
        Decoration antiqueVase = new Decoration("Antique Vase", 5, true);

        Objs <Decoration> decorations = new Objs <Decoration>();

        decorations.Add(photo);
        decorations.Add(antiqueVase);

        foreach (Decoration deco in decorations)
        {
            Console.WriteLine(deco);
            while (deco.durability > 0)
            {
                deco.Break();
            }
        }

        Console.WriteLine("------------");

        Objs <IInteractive> interactables = new Objs <IInteractive>();

        interactables.Add(sideDoor);
        interactables.Add(photo);
        interactables.Add(antiqueVase);

        foreach (IInteractive obj in interactables)
        {
            Console.WriteLine(obj);
            obj.Interact();
        }
    }
Beispiel #7
0
        public void Top(object sender, EventArgs e)
        {
            IDrawObj obj = _selectedObjs[0];

            Objs.Remove(obj);
            Objs.Add(obj);
            obj.Invalidate();
        }
Beispiel #8
0
        public void Last(object sender, EventArgs e)
        {
            IDrawObj obj = _selectedObjs[0];

            Objs.Remove(obj);
            Objs.Insert(0, obj);
            obj.Invalidate();
        }
Beispiel #9
0
 public static void Write(string dirname, Objs objs)
 {
     if (!Directory.Exists(DATAPATH + "/" + dirname))
     {
         Directory.CreateDirectory(DATAPATH + "/" + dirname); //duplicated code
     }
     using (StreamWriter stream = new StreamWriter(DATAPATH + "/" + dirname + "/" + FN)) {
         stream.Write(JsonUtility.ToJson(objs, true));
     }
 }
Beispiel #10
0
        private IDrawObj CloneDrawObj(IDrawObj origObj)
        {
            IDrawObj newObj = (IDrawObj)origObj.Clone();

            newObj.Parant = Container;
            _nameManager.CreateName(newObj);
            newObj.LoadInitializationEvent();
            Objs.Add(newObj);
            newObj.Invalidate();
            return(newObj);
        }
Beispiel #11
0
 public void Delete()
 {
     foreach (IDrawObj obj in _selectedObjs)
     {
         Objs.Remove(obj);
         obj.Invalidate();
         _nameManager.RemoveName(obj);
     }
     _selectedObjs.Clear();
     _controlPoint.ChangeSelectObj(null);
 }
Beispiel #12
0
        public void Back(object sender, EventArgs e)
        {
            IDrawObj obj   = _selectedObjs[0];
            int      index = Objs.IndexOf(obj);

            if (index > 0)
            {
                Objs.Remove(obj);
                Objs.Insert(index - 1, obj);
                obj.Invalidate();
            }
        }
Beispiel #13
0
        public void Front(object sender, EventArgs e)
        {
            IDrawObj obj   = _selectedObjs[0];
            int      index = Objs.IndexOf(obj);

            if (index != Objs.Count - 1)
            {
                Objs.Remove(obj);
                Objs.Insert(index + 1, obj);
                obj.Invalidate();
            }
        }
Beispiel #14
0
        private void UpdateObjects()
        {
            foreach (IGameObj o in DeadObjs)
            {
                o.Die(this);
                Objs.Remove(o);
            }
            DeadObjs.Clear();

            foreach (IGameObj o in NewObjs)
            {
                Objs.Add(o);
            }
            NewObjs.Clear();
        }
Beispiel #15
0
 // Crap, when must this happen?
 // It can happen whenever Objs is the current state... which is thoretically always.
 // This will nuke the particles though.
 // This is actually pretty close to correct.
 public void SetLevel(int level)
 {
     UpdateObjects();
     Objs.Remove(Player);
     Levels[CurrentLevel].Objs = Objs;
     // This is PROBABLY right, but I'm not sure.
     CurrentLevel = level;
     Objs         = Levels[CurrentLevel].Objs;
     Objs.Add(Player);
     NewObjs.Clear();
     DeadObjs.Clear();
     Particles.Clear();
     NewParticles.Clear();
     DeadParticles.Clear();
     UpdateCollisionTree();
 }
Beispiel #16
0
        /// <summary>
        /// Remove objects from creation queue and
        /// add to object registry
        /// </summary>
        public void UnqueueObjects()
        {
            for (int i = CreationQueue.Count - 1; i > -1; i--)
            {
                Objs.Add(CreationQueue[i]);

                // Add to decayable registry and sort registry by time to live
                IDecay decay = CreationQueue[i] as IDecay;
                if (decay != null)
                {
                    Decayables.Add(decay);
                    Decayables = Decayables.OrderByDescending(d => d.TTL).ToList();
                }

                CreationQueue.RemoveAt(i);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Update all game objects
        /// </summary>
        public override void Update()
        {
            // Update GameObjects in world
            foreach (GameObject obj in Objs)
            {
                obj.Update();
            }

            // Add queued objects to world
            for (int i = CreationQueue.Count - 1; i > -1; i--)
            {
                Objs.Add(CreationQueue[i]);
                CreationQueue.RemoveAt(i);
            }

            _mouseObs.Update();
        }
Beispiel #18
0
        public static void LoadInstance_Boss_Creatures()
        {
            _InstanceBossSpawns = new Dictionary <uint, List <Instance_Boss_Spawn> >();

            IList <Instance_Boss_Spawn> InstanceSpawns = Database.SelectAllObjects <Instance_Boss_Spawn>();

            foreach (Instance_Boss_Spawn Obj in InstanceSpawns)
            {
                List <Instance_Boss_Spawn> Objs;
                if (!_InstanceBossSpawns.TryGetValue(Obj.InstanceID, out Objs))
                {
                    Objs = new List <Instance_Boss_Spawn>();
                    _InstanceBossSpawns.Add(Obj.InstanceID, Objs);
                }

                Objs.Add(Obj);
            }
            Log.Success("WorldMgr", "Loaded " + _InstanceBossSpawns.Count + "Instance_Boss_Spawn");
        }
Beispiel #19
0
        public static void LoadInstance_Encounter()
        {
            _InstanceEncounter = new Dictionary <uint, List <Instance_Encounter> >();

            IList <Instance_Encounter> InstanceEncounter = Database.SelectAllObjects <Instance_Encounter>();

            foreach (Instance_Encounter Obj in InstanceEncounter)
            {
                List <Instance_Encounter> Objs;
                if (!_InstanceEncounter.TryGetValue(Obj.InstanceID, out Objs))
                {
                    Objs = new List <Instance_Encounter>();
                    _InstanceEncounter.Add(Obj.InstanceID, Objs);
                }

                Objs.Add(Obj);
            }
            Log.Success("WorldMgr", "Loaded " + _InstanceEncounter.Count + "Instance_Encounters");
        }
Beispiel #20
0
    public static Objs GenerateDumb()
    {
        List <Obj> list = new List <Obj>();

        list.Add(new Obj()
        {
            name = "aaa?"
        });
        list.Add(new Obj()
        {
            name = "bbb?"
        });

        Objs objs2 = new Objs()
        {
            list = list
        };

        return(objs2);
    }
Beispiel #21
0
        public static void LoadPQuest_Creatures()
        {
            _PQuest_Spawns = new Dictionary <uint, List <PQuest_Spawn> >();

            IList <PQuest_Spawn> PQSpawns = Database.SelectAllObjects <PQuest_Spawn>();

            foreach (PQuest_Spawn Obj in PQSpawns)
            {
                List <PQuest_Spawn> Objs;
                if (!_PQuest_Spawns.TryGetValue(Obj.Objective, out Objs))
                {
                    Objs = new List <PQuest_Spawn>();
                    _PQuest_Spawns.Add(Obj.Objective, Objs);
                }

                Objs.Add(Obj);
            }

            Log.Success("WorldMgr", "Loaded " + PQSpawns.Count + " Public Quest Spawns");
        }
Beispiel #22
0
        public static void LoadPQuest_Objective()
        {
            _PQuest_Objectives = new Dictionary <uint, List <PQuest_Objective> >();

            IList <PQuest_Objective> PObjectives = Database.SelectObjects <PQuest_Objective>("Type != 0");

            foreach (PQuest_Objective Obj in PObjectives)
            {
                List <PQuest_Objective> Objs;
                if (!_PQuest_Objectives.TryGetValue(Obj.Entry, out Objs))
                {
                    Objs = new List <PQuest_Objective>();
                    _PQuest_Objectives.Add(Obj.Entry, Objs);
                }

                Objs.Add(Obj);
            }

            Log.Success("WorldMgr", "Loaded " + PObjectives.Count + " Public Quest Objectives");
        }
Beispiel #23
0
        /// <summary>初始化</summary>
        /// <param name="addlib"></param>
        /// <returns></returns>
        public virtual Boolean Init(Boolean addlib = true)
        {
            var tp = ToolPath;

            if (tp.IsNullOrEmpty() || !Directory.Exists(tp))
            {
                XTrace.WriteLine("未找到编译器!");
                return(false);
            }

            XTrace.WriteLine("发现 {0} {1} {2}", Name, Version, tp);

            Libs.Clear();
            Objs.Clear();

            // 扫描当前所有目录,作为头文件引用目录
            //var ss = new String[] { ".", "..\\SmartOS" };
            var ss = new String[] { ".", "inc", "include", "lib" };

            foreach (var src in ss)
            {
                var p = src.GetFullPath();
                if (!Directory.Exists(p))
                {
                    p = ("..\\" + src).GetFullPath();
                }
                if (!Directory.Exists(p))
                {
                    continue;
                }

                AddIncludes(p, false);
                if (addlib)
                {
                    AddLibs(p);
                }
            }

            return(true);
        }
Beispiel #24
0
        private void LoadMouseEvent(MouseButtons button, PointF location, MouseType type)
        {
            IDrawObj draw = Objs.LastOrDefault(obj => obj.CanSelect(location));

            if (_mouseMovingObj != draw)
            {
                if (_mouseMovingObj != null)
                {
                    _mouseMovingObj.LoadMouseLeaveEvent();
                }
                _mouseMovingObj = draw;
                if (_mouseMovingObj != null)
                {
                    _mouseMovingObj.LoadMouseEnterEvent();
                }
            }

            if (_mouseMovingObj != null)
            {
                _mouseMovingObj.LoadMouseEvent(button, location, type);
            }
        }
Beispiel #25
0
        public void UnGroup(object sender, EventArgs e)
        {
            DrawGroup group = null;

            foreach (IDrawObj obj in _selectedObjs)
            {
                if (obj.Type != DrawType.Group)
                {
                    continue;
                }

                group = (DrawGroup)obj;
                group.Ungroup();
                int index = Objs.IndexOf(group);
                Objs.Remove(group);
                Objs.InsertRange(index, group.ObjList);
            }

            if (group != null)
            {
                //去除锁定的控件
                int count = group.ObjList.Count;
                for (int i = count - 1; i >= 0; i--)
                {
                    IDrawObj obj = group.ObjList[i];
                    if (!group.ObjList[i].CanSelect())
                    {
                        group.ObjList.Remove(obj);
                    }
                }

                _selectedObjs.Clear();
                _selectedObjs.AddRange(group.ObjList);

                _controlPoint.ChangeSelectObj(_selectedObjs);
                Container.Invalidate();
            }
        }
Beispiel #26
0
    private void Load()
    {
        Objs objs = ObjLoader.Read(dirname);

        foreach (Obj obj in objs.list)
        {
            switch (obj.type)
            {
            case Obj.TYPE_WALL:
            case "Plane":
                GameObject go = Instantiate(wallToSpawn, obj.position, obj.rotation);
                go.name = obj.name;
                spawnedWalls.Add(go);
                break;

            case Obj.TYPE_PHOTO:     //photo without UI
                GameObject go2 = new GameObject(obj.name);
                go2.transform.SetPositionAndRotation(obj.position, obj.rotation);
                spawnedPhotos.Add(go2);
                //go2.SetActive(false);
                break;
            }
        }
    }
Beispiel #27
0
        /// <summary>添加对象文件</summary>
        /// <param name="path"></param>
        /// <param name="filter"></param>
        /// <param name="allSub"></param>
        public void AddObjs(String path, String filter = null, Boolean allSub = false)
        {
            path = path.GetFullPath();
            if (!Directory.Exists(path))
            {
                return;
            }

            if (filter.IsNullOrEmpty())
            {
                filter = "*.o";
            }
            //var opt = allSub ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
            foreach (var item in path.AsDirectory().GetAllFiles(filter, allSub))
            {
                // 不包含,直接增加
                if (!Objs.Contains(item.FullName))
                {
                    var lib = new LibFile(item.FullName);
                    WriteLog("发现对象文件:{0, -12} {1}".F(lib.Name, item.FullName));
                    Objs.Add(item.FullName);
                }
            }
        }
Beispiel #28
0
    public Objs GetObjects()
    {
        // 使用中でないものを探して返す
        for (int i = 0; i < poolObjList.Count; i++)
        {
            if (poolObjList[i].activeSelf == false)
            {
                Objs objs = new Objs();
                poolObjList[i].SetActive(true);
                objs.gameObject = poolObjList[i];
                objs.component  = componentList[i];
                return(objs);
            }
        }
        //全て使用中だったら新しく作る
        GameObject newObj = CreateNewObject();
        Objs       o      = new Objs();

        o.gameObject = newObj;
        newObj.SetActive(true);
        poolObjList.Add(newObj);
        componentList.Add(newObj.GetComponent <T>());
        return(o);
    }
Beispiel #29
0
    public static Objs GameObjectsToObjs(List <GameObject> walls, List <GameObject> photos)
    {
        Objs objs = new Objs();

        foreach (GameObject o in walls)
        {
            Obj obj = new Obj()
            {
                name = o.name, position = o.transform.position, rotation = o.transform.rotation, eulerAngles = o.transform.rotation.eulerAngles, type = Obj.TYPE_WALL
            };                                                                                                                                                                         //todo add ro
            objs.list.Add(obj);
        }

        foreach (GameObject o in photos)
        {
            Obj obj = new Obj()
            {
                name = o.name, position = o.transform.position, rotation = o.transform.rotation, eulerAngles = o.transform.rotation.eulerAngles, type = Obj.TYPE_PHOTO
            };
            objs.list.Add(obj);
        }

        return(objs);
    }
Beispiel #30
0
 public void KillGameObj(IGameObj g)
 {
     Objs.Remove(g);
     DeadObjs.Add(g);
 }