示例#1
0
    public void Load(NarratorState narratorState)
    {
        this.index              = narratorState.index;
        this.runestoneIndex     = narratorState.runestoneIndex;
        this.runestoneLetter    = narratorState.runestoneLetter;
        this.herbRoll           = narratorState.herbRoll;
        this.towerSkralCell     = narratorState.towerSkralCell;
        this.runestoneRoll      = narratorState.runestoneRoll;
        this.runestoneCells     = narratorState.runestoneCells;
        this.witchFound         = narratorState.witchFound;
        this.medicineDelivered  = narratorState.medicineDelivered;
        this.towerSkralDefeated = narratorState.towerSkralDefeated;
        MoveNarratorToIndex(this.index);
        SetRunestonePosition();

        tasks = new Dictionary <String, String>();
        if (!witchFound)
        {
            tasks.Add("Witch", "- Find the Witch hidden in the fog \n");
        }
        else if (!medicineDelivered)
        {
            tasks.Add("Herb", "- Bring the Herb (Cell " + herbCellId + ") to the Castle \n");
        }

        if (!towerSkralDefeated && index >= 2)
        {
            tasks.Add("Tower Skrall", "- Kill the Tower Skral \n");
        }

        UpdateTasks();
    }
示例#2
0
    void LoadGame(string directory)
    {
        // Load from json here
        // Heroes
        foreach (Hero hero in heroes)
        {
            hero.Load(directory);
        }

        // Cells
        CellStates Cells = FileManager.Load <CellStates>(directory + "/Cells.json");

        foreach (CellState cellstate in Cells.cellStates)
        {
            foreach (string token in cellstate.inventory)
            {
                Type type = Type.GetType(token);
                if (type == typeof(Farmer))
                {
                    farmers.Add(Farmer.Factory(cellstate.index));
                }
                else if (type == typeof(Gor))
                {
                    gors.Add(Gor.Factory(cellstate.index));
                }
                else if (type == typeof(Skral))
                {
                    skrals.Add(Skral.Factory(cellstate.index));
                }
                else if (type == typeof(Wardrak))
                {
                    wardraks.Add(Wardrak.Factory(cellstate.index));
                }
                else if (type == typeof(TowerSkral))
                {
                    towerskrals.Add(TowerSkral.Factory(cellstate.index, players.Count));
                }
                else if (type.IsSubclassOf(typeof(Fog)))
                {
                    string id = type.ToString().Replace("Fog", "");
                    Fog.Load(id, type, cellstate.index);
                }
                else if (type == typeof(Well))
                {
                    wells.Add(Well.Factory(cellstate.index));
                }
                // Items in cells
                if (PhotonNetwork.IsMasterClient)
                {
                    if (type == typeof(GoldCoin))
                    {
                        GoldCoin.Factory(cellstate.index);
                    }
                    else if (type.IsSubclassOf(typeof(SmallToken)))
                    {
                        type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index });
                    }
                    else if (type.IsSubclassOf(typeof(BigToken)))
                    {
                        type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index });
                    }
                }
            }
        }

        // Narrator
        NarratorState narratorState = FileManager.Load <NarratorState>(directory + "/Narrator.json");

        narrator.Load(narratorState);

        // Wells
        WellsState wellsState = FileManager.Load <WellsState>(directory + "/Wells.json");

        foreach (int cellId in wellsState.wellsCellId)
        {
            bool found = false;
            foreach (Well well in wells)
            {
                if (well.Cell.Index == cellId)
                {
                    found = true;
                    break;
                }
            }

            // If not found, the well is empty
            if (!found)
            {
                wells.Add(Well.Factory(cellId, false));
            }
        }
    }