void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }
        DontDestroyOnLoad(this.gameObject);

        BinaryFormatter bf = new BinaryFormatter();

        if (!File.Exists(Application.persistentDataPath + "/progress.dat"))
        {
            FileStream file = File.Create(Application.persistentDataPath + "/progress.dat");

            ProgressPaths newPaths = new ProgressPaths();
            newPaths.progressPaths = new List <ProgressPath>();
            newPaths.progressPaths.Add(new ProgressPath(1, 1));
            newPaths.progressPaths.Add(new ProgressPath(1, 2));
            bf.Serialize(file, newPaths);
            file.Close();
        }

        FileStream openFile = File.Open(Application.persistentDataPath + "/progress.dat", FileMode.Open);

        this.ProgressPaths = (ProgressPaths)bf.Deserialize(openFile);
        openFile.Close();
    }
示例#2
0
        public int RemoveZIndex(LevelItem obj)
        {
            int idx = -1;

            if (obj is NSMBObject)
            {
                idx = Objects.IndexOf(obj as NSMBObject);
                Objects.Remove(obj as NSMBObject);
            }
            if (obj is NSMBSprite)
            {
                idx = Sprites.IndexOf(obj as NSMBSprite);
                Sprites.Remove(obj as NSMBSprite);
            }
            if (obj is NSMBEntrance)
            {
                idx = Entrances.IndexOf(obj as NSMBEntrance);
                Entrances.Remove(obj as NSMBEntrance);
            }
            if (obj is NSMBView)
            {
                NSMBView v = obj as NSMBView;
                if (v.isZone)
                {
                    idx = Zones.IndexOf(v);
                    Zones.Remove(v);
                }
                else
                {
                    idx = Views.IndexOf(v);
                    Views.Remove(v);
                }
            }
            if (obj is NSMBPathPoint)
            {
                NSMBPathPoint pp = obj as NSMBPathPoint;
                idx = pp.parent.points.IndexOf(pp);
                pp.parent.points.Remove(pp);
                if (pp.parent.points.Count == 0)
                {
                    if (pp.parent.isProgressPath)
                    {
                        ProgressPaths.Remove(pp.parent);
                    }
                    else
                    {
                        Paths.Remove(pp.parent);
                    }
                }
            }
            return(idx == -1 ? 0 : idx);
        }
示例#3
0
 public void Add(LevelItem obj, int zIndex)
 {
     if (obj is NSMBObject)
     {
         Objects.Insert(zIndex, obj as NSMBObject);
     }
     if (obj is NSMBSprite)
     {
         Sprites.Insert(zIndex, obj as NSMBSprite);
     }
     if (obj is NSMBEntrance)
     {
         Entrances.Insert(zIndex, obj as NSMBEntrance);
     }
     if (obj is NSMBView)
     {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
         {
             Zones.Insert(zIndex, v);
         }
         else
         {
             Views.Insert(zIndex, v);
         }
     }
     if (obj is NSMBPathPoint)
     {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Insert(zIndex, pp);
         if (pp.parent.isProgressPath)
         {
             if (!ProgressPaths.Contains(pp.parent))
             {
                 ProgressPaths.Add(pp.parent);
             }
         }
         else
         {
             if (!Paths.Contains(pp.parent))
             {
                 Paths.Add(pp.parent);
             }
         }
     }
 }
示例#4
0
 public void Remove(LevelItem obj)
 {
     if (obj is NSMBObject)
     {
         Objects.Remove(obj as NSMBObject);
     }
     if (obj is NSMBSprite)
     {
         Sprites.Remove(obj as NSMBSprite);
     }
     if (obj is NSMBEntrance)
     {
         Entrances.Remove(obj as NSMBEntrance);
     }
     if (obj is NSMBView)
     {
         NSMBView v = obj as NSMBView;
         if (v.isZone)
         {
             Zones.Remove(v);
         }
         else
         {
             Views.Remove(v);
         }
     }
     if (obj is NSMBPathPoint)
     {
         NSMBPathPoint pp = obj as NSMBPathPoint;
         pp.parent.points.Remove(pp);
         if (pp.parent.points.Count == 0)
         {
             if (pp.parent.isProgressPath)
             {
                 ProgressPaths.Remove(pp.parent);
             }
             else
             {
                 Paths.Remove(pp.parent);
             }
         }
     }
 }