Example #1
0
        public override void Help(Player p, string message)
        {
            if (message.CaselessEq("options"))
            {
                p.Message("%HOptions: &f{0}", LevelOptions.Options.Join(o => o.Name));
                p.Message("%HUse %T/Help map [option] %Hto see description for that option");
                return;
            }

            LevelOption opt = LevelOptions.Find(message);

            if (opt == null)
            {
                p.Message("Unrecognised option \"{0}\".", message); return;
            }

            bool   isMotd = opt.Name == LevelOptions.MOTD;
            string suffix = isMotd ? " <value>" : (HasArgument(opt.Name) ? " [value]" : "");

            p.Message("%T/Map [level] {0}{1}", opt.Name, suffix);
            p.Message("%H" + opt.Help);
            if (isMotd)
            {
                ShowMotdRules(p);
            }
        }
Example #2
0
 public void SetValByLevelOption(LevelOption lo)
 {
     version     = GameCommon.GAME_DATA_VERSION;
     levelName   = lo.levelName;
     mapWidth    = lo.mapWidth;
     mapHeight   = lo.mapHeight;
     missionList = lo.missionList;
 }
Example #3
0
 public void SetLevelOption(LevelOption lo)
 {
     lo.version     = version;
     lo.levelName   = levelName;
     lo.mapWidth    = mapWidth;
     lo.mapHeight   = mapHeight;
     lo.missionList = missionList;
 }
    public bool isServer = false;   //If player is server or not



    /// <summary>
    /// Start is called before the first frame update
    /// </summary>
    void Start()
    {
        //Set the configuration for the network
        select          = GameObject.Find("player").GetComponent <Select>();
        level           = GameObject.Find("level").GetComponent <LevelOption>();
        chosenCharacter = select.elect;
        Destroy(select.gameObject);
        NetworkManager.singleton.onlineScene = level.elect;
    }
Example #5
0
    public static void SaveLevel()
    {
        Debug.Log("SaveLevel");
        msobjlist.Clear();
        // 场景路径

        /*
         * string scenePath = AssetDatabase.GetAssetPath(selectObject);
         *
         * Debug.Log("=====================================");
         * Debug.Log(sceneName + "   path : " + scenePath );
         * // 打开这个关卡
         * EditorApplication.OpenScene(scenePath);
         */

        MSLevelOptionDataModel od     = null;
        DataStream             stream = new DataStream(true);

        //获取场景中全部道具
        Object[] objects = Object.FindObjectsOfType(typeof(GameObject));

        foreach (GameObject sceneObject in objects)
        {
            if (sceneObject.name == "LevelOption")
            {
                LevelOption editor = sceneObject.GetComponent <LevelOption>();
                if (editor != null)
                {
                    od = new MSLevelOptionDataModel();
                    od.SetValByLevelOption(editor);

                    od.serialize(stream);

                    GameCommon.LOAD_DATA_VERSION = od.version;
                }

                ForeachObjAndSave(sceneObject);
            }
        }

        Debug.Log("save list count:" + msobjlist.Count);
        stream.WriteSInt32(msobjlist.Count);

        foreach (MSBaseObject msobj in msobjlist)
        {
            msobj.Serialize(stream);
        }

        if (od == null)
        {
            Debug.LogError("can't find the level option!");
            return;
        }

        WriteDataToFile(od, stream);
    }
Example #6
0
    static void WriteDataToFile(LevelOption od, DataStream data)
    {
        string filePath = GameConst.GetLevelDataFilePath(od.levelName + ".bytes");

        byte[] objData     = data.ToByteArray();
        byte[] objGzipData = GameCommon.CompressGZip(objData);
        GameCommon.WriteByteToFile(objGzipData, filePath);

        Debug.Log("save path : " + filePath);
        EditorUtility.DisplayDialog("导出关卡" + od.levelName + "成功!", filePath, "确定");
    }
 public void SetLevelOption(LevelOption levelOption, bool active)
 {
     if (active)
     {
         LevelOptions |= (int)levelOption;
     }
     else
     {
         LevelOptions &= ~((int)levelOption);
     }
     PerformAutosave();
 }
 protected LevelOption GetLevelOption()
 {
     LevelOption choice = new LevelOption();
     choice.Amount = Num;
     choice.CorpMatch = Input_Matching.Checked;
     if (choice.CorpMatch)
     {
         choice.CorpName = Input_CorpName.Text;
     }
     choice.TaxDeduct = Input_DeclineBenefits.Checked;
     choice.AnonDonation = Input_Anon.Checked;
     if (!choice.AnonDonation && Input_DoAcknowl.Checked)
     {
         choice.AckName = Input_AcknowlName.Text;
     }
     return choice;
 }
Example #9
0
        static bool IsMapOption(string[] args)
        {
            LevelOption opt = LevelOptions.Find(args[0]);

            if (opt == null)
            {
                return(false);
            }
            // In rare case someone uses /map motd motd My MOTD
            if (opt.Name == LevelOptions.MOTD && (args.Length == 1 || !args[1].CaselessStarts("motd ")))
            {
                return(true);
            }

            int argsCount = HasArgument(opt.Name) ? 2 : 1;

            return(args.Length == argsCount);
        }
Example #10
0
    public static void NewLevel()
    {
        MSLevelOptionDataModel od = new MSLevelOptionDataModel();

        od.version   = GameCommon.GAME_DATA_VERSION;
        od.levelName = "newlevel";
        od.mapWidth  = 100;
        od.mapHeight = 100;


        List <GameObject> delarr = new List <GameObject>();
        bool isfind = false;

        foreach (GameObject sceneObject in Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (sceneObject.name == "LevelOption")
            {
                LevelOption me = sceneObject.GetComponent <LevelOption>();
                od.SetLevelOption(me);
                GameCommon.LOAD_DATA_VERSION = od.version;

                isfind = true;
            }
            else if (sceneObject.name != "Main Camera")
            {
                delarr.Add(sceneObject);
            }
        }
        foreach (GameObject obj in delarr)
        {
            DestroyImmediate(obj);
        }
        if (!isfind)
        {
            GameObject  tGO = new GameObject("LevelOption");
            LevelOption lo  = tGO.AddComponent <LevelOption>();
            od.SetLevelOption(lo);
            GameCommon.LOAD_DATA_VERSION = od.version;
        }
    }
Example #11
0
    public static void NewLevel()
    {
        List <GameObject> delarr = new List <GameObject>();
        bool isfind = false;

        foreach (GameObject sceneObject in Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (sceneObject.name == "MapEditor")
            {
                LevelOption lo = sceneObject.GetComponent <LevelOption>();
                lo.levelName = "newlevel";
                lo.version   = GameCommon.GAME_DATA_VERSION;
                lo.mapWidth  = 100;
                lo.mapHeight = 100;

                isfind = true;
            }
            else if (sceneObject.name != "Main Camera" && sceneObject.name != "Directional Light")
            {
                delarr.Add(sceneObject);
            }
        }
        foreach (GameObject obj in delarr)
        {
            DestroyImmediate(obj);
        }
        if (!isfind)
        {
            GameObject  tGO = new GameObject("MapEditor");
            LevelOption lo  = tGO.AddComponent <LevelOption>();
            lo.levelName = "newlevel";
            lo.version   = GameCommon.GAME_DATA_VERSION;
            lo.mapWidth  = 100;
            lo.mapHeight = 100;
            MapEditor me = tGO.AddComponent <MapEditor>();
            me.lo = lo;
        }
    }
Example #12
0
    public void Initialize()
    {
        int i = 0;

        foreach (Level level in Client.LevelManagerInstance.levels)
        {
            LevelOption option = Instantiate(levelOptionPrefab) as LevelOption;
            option.transform.SetParent(Container, false);
            option.title.text  = level.name;
            option.levelToLoad = i;

            levelOptions.Add(option);
            i++;
        }

        for (int j = 0; j < levelOptions.Count; j++)
        {
            int index = levelOptions[j].levelToLoad;
            levelOptions[j].button.onClick.AddListener
            (
                delegate { SelectLevel(index); }
            );
        }
    }
Example #13
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (CheckSuper(p, message, "level name"))
            {
                return;
            }
            if (message.Length == 0)
            {
                message = p.level.name;
            }
            string[] args = message.SplitSpaces(3);
            Level    lvl = null;
            string   optName = null, value = null;

            if (IsMapOption(args))
            {
                if (p.IsSuper)
                {
                    SuperRequiresArgs(p, "level name"); return;
                }
                lvl = p.level;

                optName = args[0];
                args    = message.SplitSpaces(2);
                value   = args.Length > 1 ? args[1] : "";
            }
            else if (args.Length == 1)
            {
                string map = Matcher.FindMaps(p, args[0]);
                if (map == null)
                {
                    return;
                }

                PrintMapInfo(p, LevelInfo.GetConfig(map, out lvl));
                return;
            }
            else
            {
                lvl = Matcher.FindLevels(p, args[0]);
                if (lvl == null)
                {
                    return;
                }

                optName = args[1];
                value   = args.Length > 2 ? args[2] : "";
            }

            if (!CheckExtraPerm(p, data, 1))
            {
                return;
            }
            if (optName.CaselessEq(LevelOptions.RealmOwner) && !CheckExtraPerm(p, data, 2))
            {
                return;
            }
            if (!LevelInfo.Check(p, data.Rank, lvl, "change map settings of this level"))
            {
                return;
            }

            LevelOption opt = LevelOptions.Find(optName);

            if (opt == null)
            {
                p.Message("Could not find option entered.");
            }
            else
            {
                opt.SetFunc(p, lvl, value);
                lvl.SaveSettings();
            }
        }
Example #14
0
    public void ReloadScene(DataStream datastream)
    {
        Debug.Log("ReloadScene");

        MSLevelOptionDataModel od = new MSLevelOptionDataModel();

        od.deserialize(datastream);
        //od.version = (float)datastream.ReadSInt32() / 10000f;
        //od.levelName = datastream.ReadString16();
        //od.mapWidth = datastream.ReadSInt32();
        //od.mapHeight = datastream.ReadSInt32();


        List <GameObject> delarr = new List <GameObject>();
        LevelOption       me     = null;

        foreach (GameObject sceneObject in Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (sceneObject.name == "LevelOption")
            {
                me = sceneObject.GetComponent <LevelOption>();
                od.SetLevelOption(me);

                GameCommon.LOAD_DATA_VERSION = od.version;
            }
            else if (sceneObject.name != "Main Camera" && sceneObject.name != "Directional light")
            {
                delarr.Add(sceneObject);
            }
        }

        //创建关卡配置物体
        if (me == null)
        {
            GameObject tGO = new GameObject("LevelOption");
            me = tGO.AddComponent <LevelOption>();
            od.SetLevelOption(me);
            GameCommon.LOAD_DATA_VERSION = od.version;
        }

        foreach (GameObject obj in delarr)
        {
            DestroyImmediate(obj);
        }
        int objcount = datastream.ReadSInt32();

        Dictionary <int, MSBaseObject> dic = new Dictionary <int, MSBaseObject>();

        Debug.Log("objcount : " + objcount);
        for (int i = 0; i < objcount; i++)
        {
            //MSBaseObject.CreateObj(datastream);
            //从字节流中获取id
            int    type = datastream.ReadSInt32();
            string id   = datastream.ReadString16();

            GameObject go;

            if (type == -1)
            {
                //组物体
                go = new GameObject("LevelOption");
            }
            else
            {
                Object tempObj = Resources.Load("Prefabs/MapObj/" + id) as GameObject;
                if (tempObj == null)
                {
                    Debug.Log(type + "/" + id + " is null!");
                }
                go = (GameObject)Instantiate(tempObj);
            }

            MSBaseObject baseobj = go.GetComponent <MSBaseObject>();

            if (baseobj == null)
            {
                baseobj = go.AddComponent <MSBaseObject>();
            }
            //baseobj.itemtype = type;
            baseobj.itemid = id;

            baseobj.Deserialize(datastream);
            baseobj.init();


            if (dic.ContainsKey(baseobj.parent))
            {
                go.transform.parent = dic[baseobj.parent].transform;
            }
            else
            {
                go.transform.parent = me.transform;
            }

            dic.Add(baseobj.myData.instanceID, baseobj);
        }
    }
	void ToggleLevelOption(LevelOption levelOption)
	{
		GridManager.instance.SetLevelOption(levelOption, !GridManager.instance.IsLevelOptionActive(levelOption));
		UpdateText();
	}
Example #16
0
    protected void InsertGroup(Vector2 pos, int groupid)
    {
        Debug.Log(groupid);
        int          x = (int)pos.x, y = (int)pos.y;
        MapGroupConf conf = ConfigManager.mapGroupConfManager.dataMap[groupid];

        if (conf == null)
        {
            return;
        }
        TextAsset text = Resources.Load(conf.path) as TextAsset;

        byte[]     data       = GameCommon.UnGZip(text.bytes);
        DataStream datastream = new DataStream(data, true);

        //配置LevelOption
        GameObject logo = new GameObject(conf.path);

        //logo.transform.parent = this.mapObj.transform;
        logo.transform.position = GameCommon.GetWorldPos(pos);
        LevelOption me = logo.AddComponent <LevelOption>();

        me.deserialize(datastream);

        //生成物体
        int objcount = datastream.ReadSInt32();

        for (int i = 0; i < objcount; i++)
        {
            //MSBaseObject.CreateObj(datastream);
            //从字节流中获取id
            //int confid = datastream.ReadSInt32();
            //float objx = datastream.ReadSInt32() / 1000f;
            //float objy = datastream.ReadSInt32() / 1000f;
            int        confid = 0;
            float      objx = 0, objy = 0, objsx = 0, objsy = 0;
            MapObjConf objconf = null;
            GameObject column  = null;
            int        dataid  = datastream.ReadByte();
            string     goname  = "";
            while (dataid != 0)
            {
                switch (dataid)
                {
                case 1:
                    confid  = datastream.ReadSInt32();
                    objconf = ConfigManager.mapObjConfManager.map[confid];
                    break;

                case 2: objx = datastream.ReadSInt32() / 1000f; break;

                case 3: objy = datastream.ReadSInt32() / 1000f; break;

                case 4:
                    int parentid = datastream.ReadSInt32();
                    break;

                case 5:
                    int instanceid = datastream.ReadSInt32();
                    break;

                case 7: goname = datastream.ReadString16(); break;

                case 8:
                    objsx = datastream.ReadSInt32() / 1000f;
                    break;

                case 9:
                    objsy = datastream.ReadSInt32() / 1000f;
                    break;

                case 6:
                    if (objconf.isstatic == 1)
                    {
                        column = (GameObject)Resources.Load(objconf.path);
                        column = MonoBehaviour.Instantiate(column);
                        column.transform.parent   = mapObj.transform;
                        column.transform.position = GameCommon.GetWorldPos(pos) + new Vector2(objx, objy);
                        InGameBaseObj point = column.GetComponent <InGameBaseObj>();
                        point.Deserialize(datastream);
                        GameCommon.SetObjZIndex(column, objconf.depth);
                    }

                    break;
                }
                dataid = datastream.ReadByte();
            }

            if (confid == 4000002)
            {
                startPointList.Add(pos + GameCommon.GetMapPos(new Vector2(objx, objy)));
                continue;
            }
            if (objconf.isstatic == 1)
            {
                SetWayProperty(pos + GameCommon.GetMapPos(new Vector2(objx, objy)), objconf);
                column.transform.localScale = new Vector3(objsx, objsy, 1);
                continue;
            }

            SetGroupPoint(pos + GameCommon.GetMapPos(new Vector2(objx, objy)), objconf, new Vector3(objsx, objsy, 1));
        }
    }
 protected LevelOption GetLevelOption()
 {
     LevelOption choice = new LevelOption();
     choice.Amount = Decimal.Parse(Input_Amount.Text);
     if (Input_PublicTheater.Checked)
     {
         choice.Option = 'P';
         if (choice.Amount < 1000)
             choice.Level = "Supporter";
         else if (choice.Amount < 10000)
             choice.Level = "Friend";
         else if (choice.Amount < 25000)
             choice.Level = "Peer";
         else if (choice.Amount < 100000)
             choice.Level = "Contributor";
         else if (choice.Amount < 1000000)
             choice.Level = "Angel";
         else
             choice.Level = "Leader";
     }
     else if (Input_JoesPub.Checked)
     {
         choice.Option = 'J';
         if (choice.Amount < 1000)
             choice.Level = "Opening Act";
         else if (choice.Amount < 5000)
             choice.Level = "Rising Star";
         else if (choice.Amount < 10000)
             choice.Level = "Headliner";
         else if (choice.Amount < 15000)
             choice.Level = "Diva";
         else if (choice.Amount < 25000)
             choice.Level = "Rock Star";
         else
             choice.Level = "Icon";
     }
     return choice;
 }
 void ToggleLevelOption(LevelOption levelOption)
 {
     GridManager.instance.SetLevelOption(levelOption, !GridManager.instance.IsLevelOptionActive(levelOption));
     UpdateText();
 }
Example #19
0
    public static void SaveLevel()
    {
        Debug.Log("SaveLevel");
        msobjlist.Clear();
        // 场景路径

        /*
         * string scenePath = AssetDatabase.GetAssetPath(selectObject);
         *
         * Debug.Log("=====================================");
         * Debug.Log(sceneName + "   path : " + scenePath );
         * // 打开这个关卡
         * EditorApplication.OpenScene(scenePath);
         */

        DataStream stream = new DataStream(true);

        //获取场景中全部道具
        Object[]    objects = Object.FindObjectsOfType(typeof(GameObject));
        LevelOption lo      = null;

        foreach (GameObject sceneObject in objects)
        {
            if (sceneObject.name == "MapEditor")
            {
                lo = sceneObject.GetComponent <LevelOption>();
                if (lo != null)
                {
                    lo.serialize(stream);
                    GameCommon.GAME_DATA_VERSION = lo.version;
                }

                ForeachObjAndSave(sceneObject);
            }
        }
        if (lo == null)
        {
            Debug.LogError("Can't find LevelOption!!");
            return;
        }
        Debug.Log("save list count:" + msobjlist.Count);
        stream.WriteSInt32(msobjlist.Count);

        foreach (InGameBaseObj msobj in msobjlist)
        {
            stream.WriteByte(1);
            stream.WriteSInt32(msobj.confid);
            int x = (int)(msobj.transform.position.x * 1000f);
            int y = (int)(msobj.transform.position.y * 1000f);
            stream.WriteByte(2);
            stream.WriteSInt32(x);
            stream.WriteByte(3);
            stream.WriteSInt32(y);
            stream.WriteByte(4);
            stream.WriteSInt32(msobj.parentid);
            stream.WriteByte(5);
            stream.WriteSInt32(msobj.instanceId);

            stream.WriteByte(7);
            stream.WriteString16(msobj.gameObject.name);

            int sx = (int)(msobj.transform.localScale.x * 1000f);
            int sy = (int)(msobj.transform.localScale.y * 1000f);

            stream.WriteByte(8);
            stream.WriteSInt32(sx);
            stream.WriteByte(9);
            stream.WriteSInt32(sy);

            stream.WriteByte(6);
            msobj.Serialize(stream);
            stream.WriteByte(0);
        }

        WriteDataToFile(lo, stream);
    }
        static void HandleMap(Player p, string cmd, string value)
        {
            cmd = cmd.ToUpper();
            bool mapOnly = !(cmd.Length == 0 || IsCreateCommand(cmd));

            if (mapOnly && !LevelInfo.IsRealmOwner(p.level, p.name))
            {
                p.Message("You may only perform that action on your own map."); return;
            }

            if (IsCreateCommand(cmd))
            {
                AddMap(p, value);
            }
            else if (cmd == "PHYSICS")
            {
                if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5")
                {
                    CmdPhysics.SetPhysics(p.level, int.Parse(value));
                }
                else
                {
                    p.Message("Accepted numbers are: 0, 1, 2, 3, 4 or 5");
                }
            }
            else if (IsDeleteCommand(cmd))
            {
                DeleteMap(p, value);
            }
            else if (cmd == "SAVE")
            {
                UseCommand(p, "Save", "");
            }
            else if (cmd == "RESTORE")
            {
                UseCommand(p, "Restore", value);
            }
            else if (cmd == "RESIZE")
            {
                value = p.level.name + " " + value;
                string[] args = value.SplitSpaces();
                if (args.Length < 4)
                {
                    Command.Find("ResizeLvl").Help(p); return;
                }

                bool needConfirm;
                if (CmdResizeLvl.DoResize(p, args, p.DefaultCmdData, out needConfirm))
                {
                    return;
                }

                if (!needConfirm)
                {
                    return;
                }
                p.Message("Type &T/os map resize {0} {1} {2} confirm &Sif you're sure.",
                          args[1], args[2], args[3]);
            }
            else if (cmd == "PERVISIT")
            {
                // Older realm maps didn't put you on visit whitelist, so make sure we put the owner here
                AccessController access = p.level.VisitAccess;
                if (!access.Whitelisted.CaselessContains(p.name))
                {
                    access.Whitelist(Player.Console, LevelPermission.Console, p.level, p.name);
                }

                if (value.Length > 0)
                {
                    value = p.level.name + " " + value;
                }
                UseCommand(p, "PerVisit", value);
            }
            else if (cmd == "PERBUILD")
            {
                if (value.Length > 0)
                {
                    value = p.level.name + " " + value;
                }
                UseCommand(p, "PerBuild", value);
            }
            else if (cmd == "TEXTURE" || cmd == "TEXTUREZIP" || cmd == "TEXTUREPACK")
            {
                if (value.Length == 0)
                {
                    value = "normal";
                }
                UseCommand(p, "Texture", "levelzip " + value);
            }
            else
            {
                LevelOption opt = LevelOptions.Find(cmd);
                if (opt == null)
                {
                    p.MessageLines(mapHelp);
                }
                else if (DisallowedMapOption(opt.Name))
                {
                    p.Message("&WYou cannot change that map option via /os map."); return;
                }
                else
                {
                    opt.SetFunc(p, p.level, value);
                    p.level.SaveSettings();
                }
            }
        }
Example #21
0
    public void ReloadScene(DataStream datastream)
    {
        Debug.Log("ReloadScene");

        LevelOption me = null;

        List <GameObject> delarr = new List <GameObject>();

        foreach (GameObject sceneObject in Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (sceneObject.name == "MapEditor")
            {
                me = sceneObject.GetComponent <LevelOption>();
                me.deserialize(datastream);
                GameCommon.GAME_DATA_VERSION = me.version;
                continue;
            }
            else if (sceneObject.name != "Main Camera" && sceneObject.name != "Directional Light")
            {
                delarr.Add(sceneObject);
            }
        }

        //创建关卡配置物体
        if (me == null)
        {
            GameObject tGO = new GameObject("MapEditor");
            me = tGO.AddComponent <LevelOption>();
            me.deserialize(datastream);

            MapEditor me1 = tGO.AddComponent <MapEditor>();
            me1.lo = me;
        }

        Debug.Log(me.levelName + " / " + me.version);

        foreach (GameObject obj in delarr)
        {
            DestroyImmediate(obj);
        }
        int objcount = datastream.ReadSInt32();

        Debug.Log("objcount : " + objcount);
        Dictionary <int, InGameBaseObj> dic = new Dictionary <int, InGameBaseObj>();
        MapObjConfManager mapObjConfManager = ConfigManager.GetEditorMapObjConfManager();

        for (int i = 0; i < objcount; i++)
        {
            //MSBaseObject.CreateObj(datastream);
            //从字节流中获取id

            int   confid = 0;
            float x = 0, y = 0, sx = 1, sy = 1;

            MapObjConf    conf = null;
            GameObject    go = null, tempObj;
            InGameBaseObj baseObj = null;
            int           dataid  = datastream.ReadByte();
            while (dataid != 0)
            {
                switch (dataid)
                {
                case 1:
                    confid  = datastream.ReadSInt32();
                    conf    = mapObjConfManager.map[confid];
                    tempObj = Resources.Load(conf.path) as GameObject;
                    if (tempObj == null)
                    {
                        Debug.Log(confid + " is null!");
                    }
                    go      = (GameObject)Instantiate(tempObj);
                    baseObj = go.GetComponent <InGameBaseObj>();
                    break;

                case 2: x = datastream.ReadSInt32() / 1000f; break;

                case 3: y = datastream.ReadSInt32() / 1000f; break;

                case 4:
                    int parentid = datastream.ReadSInt32();
                    if (dic.ContainsKey(parentid))
                    {
                        go.transform.parent = dic[parentid].transform;
                    }
                    else
                    {
                        go.transform.parent = me.transform;
                    }
                    break;

                case 5:
                    int instanceid = datastream.ReadSInt32();
                    dic.Add(instanceid, baseObj);
                    break;

                case 7: go.name = datastream.ReadString16(); break;

                case 8: sx = datastream.ReadSInt32() / 1000f; break;

                case 9: sy = datastream.ReadSInt32() / 1000f; break;

                case 6: baseObj.Deserialize(datastream); break;
                }
                dataid = datastream.ReadByte();
            }

            go.transform.position   = new Vector3(x, y);
            go.transform.localScale = new Vector3(sx, sy, 1);
            GameCommon.SetObjZIndex(go, conf.depth);
        }
    }
 protected MessageEventArgs(string message, LevelOption level)
 {
     this.message = message;
     this.time    = DateTime.Now;
     this.level   = level;
 }
Example #23
0
    public virtual void Deserialize(DataStream datastream)
    {
        od.deserialize(datastream);

        GameObject  tGO = new GameObject("LevelOption");
        LevelOption me  = tGO.AddComponent <LevelOption>();

        od.SetLevelOption(me);

        GameCommon.LOAD_DATA_VERSION = od.version;

        int objcount = datastream.ReadSInt32();

        for (int i = 0; i < objcount; i++)
        {
            int    type = datastream.ReadSInt32();
            string id   = datastream.ReadString16();

            GameObject go;

            if (type == -1)
            {
                //组物体
                go = new GameObject("LevelOption");
            }
            else
            {
                Object tempObj = Resources.Load("Prefabs/MapObj/" + id) as GameObject;
                if (tempObj == null)
                {
                    Debug.Log(type + "/" + id + " is null!");
                    return;
                }
                go = (GameObject)MonoBehaviour.Instantiate(tempObj);
            }

            MSBaseObject baseobj = go.GetComponent <MSBaseObject>();

            if (baseobj == null)
            {
                baseobj = go.AddComponent <MSBaseObject>();
            }
            //baseobj.itemtype = type;
            baseobj.itemid = id;

            baseobj.Deserialize(datastream);
            baseobj.init();
            baseobj.Init();


            if (dic.ContainsKey(baseobj.parent))
            {
                go.transform.parent = dic[baseobj.parent].transform;
            }
            else
            {
                go.transform.parent = me.transform;
            }

            dic.Add(baseobj.myData.instanceID, baseobj);
        }
    }
Example #24
0
        public static void LoadMap(LevelOption Level_Map, GameBuild build)
        {
            string xboxName = AppSettings.Settings.IP_and_XDK_Name;

            if (xboxName != "")
            {
                XboxDebugCommunicator communicator = new XboxDebugCommunicator(xboxName);
                try
                {
                    communicator.Connect();
                }
                catch (Exception ex)
                {
                    throw new Exception("Not Connected");
                }
                EndianIO nio = new EndianIO(communicator.ReturnXboxMemoryStream(), EndianType.BigEndian);
                nio.Open();
                communicator.Freeze();
                if (build == GameBuild.PreBeta)
                {
                    nio.Out.BaseStream.Position = 0x83b8dea8L;
                }
                else
                {
                    nio.Out.BaseStream.Position = 0x8357d140L;
                }
                nio.Out.WriteAsciiString(beta_mapScenarioPaths[(int)Level_Map], 0x100);
                if (build == GameBuild.PreBeta)
                {
                    nio.Out.BaseStream.Position = 0x83b7fe78L;
                }
                else
                {
                    nio.Out.BaseStream.Position = 0x8356f110L;
                }
                if (Level_Map <= LevelOption.boneyard)
                {
                    nio.Out.Write((int)AppSettings.Settings.Force_Load_MapType);
                }
                else
                {
                    byte[] buffer = new byte[4];
                    buffer[3] = 2;
                    nio.Out.Write(buffer);
                }
                if (build == GameBuild.PreBeta)
                {
                    nio.Out.BaseStream.Position = 0x83b7fe6eL;
                }
                else
                {
                    nio.Out.BaseStream.Position = 0x8356f106L;
                }
                nio.Out.Write((byte)1);
                communicator.Unfreeze();
                nio.Close();
                communicator.Disconnect();
            }
            else
            {
                MessageBox.Show("XDK name not set. Please set it in settings before continuing.");
            }
        }
 protected LevelOption GetLevelOption()
 {
     LevelOption choice = new LevelOption();
     if (Input_L1.Checked)
     {
         choice.Level = "Summer Partner";
         choice.Amount = 1000;
     }
     else if (Input_L2A.Checked)
     {
         choice.Level = "Shiva Partner";
         choice.Amount = 2000;
         choice.Option = 'A';
     }
     else if (Input_L2B.Checked)
     {
         choice.Level = "Shiva Partner";
         choice.Amount = 2000;
         choice.Option = 'B';
     }
     else if (Input_L3A.Checked)
     {
         choice.Level = "Martinson Partner";
         choice.Amount = 4000;
         choice.Option = 'A';
     }
     else if (Input_L3B.Checked)
     {
         choice.Level = "Martinson Partner";
         choice.Amount = 4000;
         choice.Option = 'B';
     }
     else if (Input_L4A.Checked)
     {
         choice.Level = "Anspacher Partner";
         choice.Amount = 6000;
         choice.Option = 'A';
     }
     else if (Input_L4B.Checked)
     {
         choice.Level = "Anspacher Partner";
         choice.Amount = 6000;
         choice.Option = 'B';
     }
     else if (Input_L5A.Checked)
     {
         choice.Level = "Newman Partner";
         choice.Amount = 10000;
         choice.Option = 'A';
     }
     else if (Input_L5B.Checked)
     {
         choice.Level = "Newman Partner";
         choice.Amount = 10000;
         choice.Option = 'B';
     }
     else if (Input_L6A.Checked)
     {
         choice.Level = "LuEsther Partner";
         choice.Amount = 15000;
         choice.Option = 'A';
     }
     else if (Input_L6B.Checked)
     {
         choice.Level = "LuEsther Partner";
         choice.Amount = 15000;
         choice.Option = 'B';
     }
     else
     {
         throw new ApplicationException(
                 "The chosen level hasn't been accounted for in GetLevelOption().");
     }
     return choice;
 }
Example #26
0
 void OnEnable()
 {
     //获取当前编辑自定义Inspector的对象
     lo = (LevelOption)target;
 }
 public bool IsLevelOptionActive(LevelOption levelOption)
 {
     return((LevelOptions & (int)levelOption) != 0);
 }