Esempio n. 1
0
    private bool CheckTypeChange(Node node, NodeType newType)
    {
        if (node.type != newType) {
          Node p = node.parent;
          if (p != null)
          {
        int index = -1 ;
        for (int i = 0; i < p.sequels.Length; i++)
              {

          if (p.sequels[i] == node) {
            index = i;
            break;
          }
              }
        if (index < 0) {
          Debug.Log("error: node not found!");
          return false;
        }
        p.sequels[index] = newType.ToNode();
        ObjectDictionaries.Sequences.SaveDictionary();
        return true;
          }
          else {
        string key = "";

        Dictionary<string, Node>.KeyCollection keys = ObjectDictionaries.Sequences.GetKeys();

        foreach (string k in keys)
        {
          if(ObjectDictionaries.Sequences.GetElement(k) == node){
          key = k;
            break;
          }
        }

        if (key =="")
        {
          Debug.Log("error: node not found!");
          return false;
        }
        ObjectDictionaries.Sequences.AddElement(key, newType.ToNode());
        ObjectDictionaries.Sequences.SaveDictionary();
        return true;
          }
        }

        return false;
    }