Example #1
0
    SerializedTileObject FillSerializedTileData(TileObject tileObject)
    {
        SerializedTileObject serialiedTileObject = new SerializedTileObject();

        serialiedTileObject.CoordX             = (int)tileObject.transform.position.x;
        serialiedTileObject.CoordY             = (int)tileObject.transform.position.y;
        serialiedTileObject.DefenceModifier    = tileObject.DefenceModifier;
        serialiedTileObject.EvasionModifier    = tileObject.EvasionModifier;
        serialiedTileObject.FlipFlagX          = tileObject.FlipFlagX;
        serialiedTileObject.FlipFlagY          = tileObject.FlipFlagY;
        serialiedTileObject.InGameDescription  = tileObject.InGameDescription;
        serialiedTileObject.MovementDifficulty = tileObject.MovementDifficulty;
        serialiedTileObject.PrefabName         = tileObject.PrefabName;

        return(serialiedTileObject);
    }
Example #2
0
    void InstantiateTileObject(TileBase tb, SerializedTileObject sto, int layer)
    {
        string prefabName = sto.PrefabName;

        var res = PrefabsManager.Instance.FindPrefabByName(prefabName, layer);

        if (res.Value != null)
        {
            float      zDepth = (layer == 0) ? sto.CoordY : sto.CoordY - 1;
            Vector3    pos    = new Vector3(sto.CoordX, sto.CoordY, zDepth);
            var        go     = Instantiate(res.Value, pos, Quaternion.identity, tb.transform);
            TileObject to     = go.GetComponent <TileObject>();
            to.PrefabName         = prefabName;
            to.DefenceModifier    = sto.DefenceModifier;
            to.EvasionModifier    = sto.EvasionModifier;
            to.FlipFlagX          = sto.FlipFlagX;
            to.FlipFlagY          = sto.FlipFlagY;
            to.InGameDescription  = sto.InGameDescription;
            to.MovementDifficulty = sto.MovementDifficulty;

            if (sto.FlipFlagX)
            {
                to.FlipX();
            }

            if (sto.FlipFlagY)
            {
                to.FlipY();
            }

            if (layer == 0)
            {
                tb.TileObjectLayer1 = to;
            }
            else if (layer == 1)
            {
                tb.TileObjectLayer2 = to;
            }
        }
    }