public bool forceSet(string mapName, int eventId, string code, bool value)
    {
        string key = GameSelfSwitches.key(mapName, eventId, GameSelfSwitches.code(code));

        this[key] = value;
        return(value);
    }
示例#2
0
    /// <summary>
    /// 检查条件满足
    /// </summary>
    /// <param name="page">事件页序号</param>
    /// <returns></returns>
    public bool isConditionMet(int page)
    {
        EventPage pageInfo       = this.getPageInfo(page);
        bool      switchFlag     = true;
        bool      variableFlag   = true;
        bool      selfSwitchFlag = true;

        // 检查开关
        if (pageInfo.activeSwitches.Length > 0)
        {
            switchFlag = new List <GameInterpreter.ActiveSwitch>(pageInfo.activeSwitches).TrueForAll(
                _switch => GameTemp.gameSwitches[_switch.index]
                );
        }
        // 检查变量
        if (pageInfo.activeVariables.Length > 0)
        {
            variableFlag = new List <GameInterpreter.ActiveVariable>(pageInfo.activeVariables).TrueForAll(
                _variable => GameTemp.gameVariables[_variable.index] >= _variable.value
                );
        }
        // 检查独立开关
        if (pageInfo.activeSelfSwitches.Length > 0)
        {
            selfSwitchFlag = new List <GameInterpreter.ActiveSelfSwitch>(pageInfo.activeSelfSwitches).TrueForAll(
                _selfSwitch => GameTemp.gameSelfSwitches[GameSelfSwitches.key(this.mapName, this.eventId, _selfSwitch.index)]
                );
        }
        return(switchFlag && variableFlag && selfSwitchFlag);
    }
示例#3
0
    /// <summary>
    /// 123 独立开关操作
    /// A
    /// true
    /// </summary>
    /// <returns></returns>
    public bool command_setSelfSwitch()
    {
        Debug.Log(string.Format("command_setSelfSwitch"));
        string code  = this.currentParam[0].Trim().ToUpper();
        bool   value = bool.Parse(this.currentParam[1]);

        string key = GameSelfSwitches.key(this.mapName, this.eventId, GameSelfSwitches.code(code));

        GameTemp.gameSelfSwitches[key] = value;
        GameTemp.gameMap.needRefresh   = true;
        return(true);
    }
示例#4
0
    /// <summary>
    /// 读取存档数据,不处理异常
    /// </summary>
    /// <param name="fileName"></param>
    private static void loadGameData(string fileName)
    {
        //
        // header
        // HeaderData
        //
        // GameVariables
        // GameSwitches
        // GameSelfSwitches
        // GameScreen
        // GameMap
        FileStream fs = new FileStream(fileName, FileMode.Open);  // 读取文件

        // 反序列化内容
        byte[] lenBytes = new byte[4];
        int    len      = 0;
        int    offset   = 0;

        // header
        fs.Read(lenBytes, 0, 4);
        offset += lenBytes.Length;
        // HeaderData
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        Dictionary <string, string> headerData = (Dictionary <string, string>)loadObjData(fs, offset, len);

        offset += len;
        // GameVariables
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameVariables gameVariables = (GameVariables)loadObjData(fs, offset, len);

        offset += len;
        // GameSwitches
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameSwitches gameSwitches = (GameSwitches)loadObjData(fs, offset, len);

        offset += len;
        // GameSelfSwitches
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameSelfSwitches gameSelfSwitches = (GameSelfSwitches)loadObjData(fs, offset, len);

        offset += len;
        // GameScreen
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameScreen gameScreen = (GameScreen)loadObjData(fs, offset, len);

        offset += len;
        // GameMap
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameMap gameMap = (GameMap)loadObjData(fs, offset, len);

        offset += len;
        // GamePlayer
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GamePlayer gamePlayer = (GamePlayer)loadObjData(fs, offset, len);

        offset += len;
        // GameParty
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        GameParty gameParty = (GameParty)loadObjData(fs, offset, len);

        offset += len;
        // bgm
        fs.Read(lenBytes, 0, 4);
        offset += 4;
        len     = BitConverter.ToInt32(lenBytes, 0);
        string bgmName = (string)loadObjData(fs, offset, len);

        offset += len;
        fs.Close();

        // 绑定新数据
        GameTemp.gameVariables    = gameVariables;
        GameTemp.gameSwitches     = gameSwitches;
        GameTemp.gameSelfSwitches = gameSelfSwitches;
        GameTemp.gameScreen       = gameScreen;
        GameTemp.gameMessage      = new GameMessage();
        GameTemp.gameChoice       = new GameChoice();
        GameTemp.gameMap          = gameMap;
        GameTemp.gamePlayer       = gamePlayer;
        GameTemp.gameParty        = gameParty;
        GameTemp.bgmName          = bgmName;
    }