示例#1
0
    public PuzzleBoard(PuzzleBoardHandler handler, StageDefinition stageDefinition, PoemInstance poemInstance)
    {
        this.handler          = handler;
        this.stageDefinition  = stageDefinition;
        this.poemDefinition   = stageDefinition.PoemDefinition;
        this.puzzleDefinition = stageDefinition.PuzzleDefinition;
        this.poemInstance     = poemInstance;

        Vector2 size = TranslateBoardSize(this.puzzleDefinition.BoardSize);

        this.Width  = (int)size.x;
        this.Height = (int)size.y;

        List <string> targetCharacterIds    = ComposeTargetCharIds();
        List <string> appearingCharacterIds = GenerateAppearingCharIds(targetCharacterIds);

        this.PuzzleCharacters = new List <PuzzleCharacter>();
        currentCharacterIndex = 0;
        foreach (string appearingCharId in appearingCharacterIds)
        {
            this.PushCharacter(appearingCharId);
        }

        Debug.Log("Pushed all appearing characters.");

        try
        {
            GenerateAndEnsureMatrix(this.PuzzleCharacters);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
示例#2
0
    public static PoemDefinition LoadFromJsonText(string jsonText)
    {
        PoemDefinition def = new PoemDefinition();

        def = JsonConvert.DeserializeObject <PoemDefinition>(jsonText);

        return(def);
    }
示例#3
0
    public PoemInstance(PoemDefinition def, List <int> selectedLines, HashSet <int> uncoveredIndexes = null)
    {
        //this.definition = def;
        if (def == null || selectedLines == null)
        {
            throw new ArgumentNullException();
        }

        this.Width        = def.SentenceLength;
        this.Height       = selectedLines.Count;
        this.characterIds = new string[Width, Height];
        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                this.characterIds[i, j] = def.Content[selectedLines[j]][i];
            }
        }

        this.uncoveredCharIndexes = (uncoveredIndexes == null) ? new HashSet <int>() : uncoveredIndexes;
    }