Esempio n. 1
0
    public ActionSkill(string Name, double _Q, double _B, double _v, EditorTwoVector position)
    {
        this.Name = Name;

        this.Q = _Q;
        this.B = _B;
        this.v = _v;

        Position = new EditorTwoVector(position);
    }
Esempio n. 2
0
    public ActionSkill AddSkill(string Name, double Q, double B, double v, EditorTwoVector position)
    {
        int index = 0;

        if (Get(Name) == null)
        {
            skills.Add(new ActionSkill(Name, Q, B, v, position));

            return(skills.Last());
        }
        else
        {
            while (Get(Name + index) != null)
            {
                ++index;
            }

            skills.Add(new ActionSkill(Name + index, Q, B, v));

            return(skills.Last());
        }
    }
Esempio n. 3
0
    public static void ImportActionLibrary()
    {
        string file = EditorUtility.OpenFilePanel("Select Action Library to import", "", "xml");

        if (file == null || file.Length == 0)
        {
            return;
        }

        XDocument doc = XDocument.Load(file);

        try
        {
            ActionLibrary importedLibrary = new ActionLibrary();

            foreach (var network in doc.Root.Elements("Network"))
            {
                ActionNetwork actN = new ActionNetwork(network.Attribute("Name").Value);

                importedLibrary.Add(actN);

                foreach (var skill in network.Elements("Skills").Elements("Skill"))
                {
                    string[] position = skill.Element("Position").Value.Replace("(", "").Replace(")", "").Split(',');

                    EditorTwoVector pos = new EditorTwoVector(float.Parse(position[0]), float.Parse(position[1]));

                    actN.AddSkill(skill.Attribute("Name").Value, double.Parse(skill.Element("Q").Value), double.Parse(skill.Element("B").Value),
                                  double.Parse(skill.Element("v").Value), pos);
                }

                foreach (var connection in network.Elements("Connections").Elements("Connection"))
                {
                    actN.AddConnection(actN.Get(connection.Element("ToSkill").Value), actN.Get(connection.Element("FromSkill").Value),
                                       double.Parse(connection.Element("ToValue").Value), double.Parse(connection.Element("FromValue").Value));
                }
            }

            string fileName = Path.GetFileNameWithoutExtension(file);

            string nameCopy = fileName.Clone().ToString();

            int index = 0;

            if (System.IO.File.Exists(Application.dataPath + "/coAdjoint/Action/Libraries/" + fileName + ".asset"))
            {
                ++index;

                while (System.IO.File.Exists(Application.dataPath + "/coAdjoint/Action/Libraries/" + fileName + index + ".asset"))
                {
                    ++index;
                }

                nameCopy += index.ToString();
            }

            var asset = ScriptableObject.CreateInstance <ActionAsset>();

            asset.libraryData = importedLibrary.GetData();

            AssetDatabase.CreateAsset(asset, "Assets/coAdjoint/Action/Libraries/" + nameCopy + ".asset");

            Selection.activeObject = asset;

            ActionMenu.EditLibraryAsset();
        }
        catch (Exception e)
        {
            Debug.LogError("Failed to deserialize. Reason: " + e.Message);
            throw;
        }
    }
Esempio n. 4
0
    public override bool Equals(object other)
    {
        EditorTwoVector point = other as EditorTwoVector;

        return(point != null && this.m_X == point.X && this.m_Y == point.Y);
    }
Esempio n. 5
0
 public EditorTwoVector(EditorTwoVector point)
 {
     this.m_X = point.X;
     this.m_Y = point.Y;
 }