Beispiel #1
0
 public void Clone(UnitKnowledge unitKnowledge)
 {
     path       = unitKnowledge.path;
     unitIDPool = unitKnowledge.unitIDPool;
     unitTypes.Clear();
     for (int i = 0; i < unitKnowledge.unitTypes.Count; ++i)
     {
         UnitType unitType = new UnitType();
         unitType.Clone(unitKnowledge.unitTypes [i]);
         unitTypes.Add(unitType);
     }
 }
    void CloneUnitType(UnitType unit)
    {
        if (unitType == null)
        {
            unitType = new UnitType();
        }

        unitType.Clone(unit);
        List <Object> sprites = null;

        if (unitType.spritePath.Length > 0)
        {
            sprites         = new List <Object> (AssetDatabase.LoadAllAssetsAtPath(unitType.spritePath));
            unitType.sprite = sprites.Find(m => m.name == unitType.spriteName) as Sprite;
        }
        else
        {
            unitType.sprite = null;
        }

        if (unitType.spritePath2.Length > 0)
        {
            sprites          = new List <Object> (AssetDatabase.LoadAllAssetsAtPath(unitType.spritePath2));
            unitType.sprite2 = sprites.Find(m => m.name == unitType.spriteName2) as Sprite;
        }
        else
        {
            unitType.sprite2 = null;
        }

        if (unitType.spritePath3.Length > 0)
        {
            sprites          = new List <Object> (AssetDatabase.LoadAllAssetsAtPath(unitType.spritePath3));
            unitType.sprite3 = sprites.Find(m => m.name == unitType.spriteName3) as Sprite;
        }
        else
        {
            unitType.sprite3 = null;
        }
    }