Esempio n. 1
0
    public LevelData DeepCopy(int level)
    {
        LoadTargetObject();
        var other = (LevelData)MemberwiseClone();

        other.hashCode = other.GetHashCode();
        other.levelNum = level;
        other.Name     = "Level " + other.levelNum;
        other.fields   = new List <FieldData>();
        for (var i = 0; i < fields.Count; i++)
        {
            other.fields.Add(fields[i].DeepCopy());
        }
        if (targetEditorArray.Count > 0)
        {
            other.target = targetEditorArray.First(x => x.name == target.name);//target.DeepCopy();
        }
        else
        {
            other.target = target.DeepCopy();
        }
        if (targetObject != null)
        {
            other.targetObject = targetObject.DeepCopy();
        }
        other.subTargetsContainers = new List <SubTargetContainer>();
        for (var i = 0; i < subTargetsContainers.Count; i++)
        {
            other.subTargetsContainers.Add(subTargetsContainers[i].DeepCopy());
        }

        other.targetObject = (Target)Activator.CreateInstance(Type.GetType(target.name));

        return(other);
    }