示例#1
0
    private static PropSdo ConvertPropForSaving(Prop prop)
    {
        if (prop == null)
        {
            return(null);
        }

        var propType = prop.GetType();

        PropSdo sdo = null;

        if (propType == typeof(CheeseTree))
        {
            sdo = new CheeseTreeSdo();
        }
        else if (propType == typeof(Chest))
        {
            sdo = new ChestSdo((Chest)prop);
        }
        else if (propType == typeof(Field))
        {
            sdo = new FieldSdo((Field)prop);
        }
        else if (propType == typeof(Grave))
        {
            sdo = new GraveSdo((Grave)prop);
        }
        else if (propType == typeof(Furniture))
        {
            sdo = new FurnitureSdo((Furniture)prop);
        }

        return(sdo);
    }
示例#2
0
    public Field(FieldSdo sdo)
    {
        Type = sdo.Type;

        GameObject[] tiles;

        if (Type == FieldType.Wheat)
        {
            tiles = WorldData.Instance.WheatFieldTiles;
        }
        else
        {
            Debug.Log($@"Invalid Field Type! {Type}");
            throw new ArgumentException($@"Invalid Field Type! {Type}");
        }

        PrefabKey   = sdo.PrefabKey;
        Prefab      = tiles[Random.Range(0, tiles.Length)];
        IsContainer = false;
    }