Пример #1
0
    public void RefreshLineColor(GameObject c)
    {
        Color cr = Color.white;

        for (int i = 0; i < c.transform.childCount; i++)
        {
            SkillConnection sc = c.transform.GetChild(i).GetComponent <SkillConnection>();

            if (sc.skills[0].unlocked == true && sc.skills[1].unlocked == true)
            {
                cr = Color.green;
            }
            else if (sc.skills[0].unlocked == true && sc.skills[1].canUnlock == true)
            {
                cr = Color.grey;
            }
            else
            {
                cr = Color.red;
            }

            sc.GetComponent <LineRenderer>().startColor = cr;
            sc.GetComponent <LineRenderer>().endColor   = cr;
        }
    }
Пример #2
0
 static void ParseConnectedSkills()
 {
     SkillConnections = new List <SkillConnection>();
     foreach (var sk in ConnectedSkillsDoc.Descendants().Where(x => x.Name == "Skill"))
     {
         var id = Convert.ToInt32(sk.Attribute("id").Value);
         Enum.TryParse(sk.Attribute("class").Value, out Class c);
         var skc = new SkillConnection(id, c);
         foreach (var conn in sk.Descendants())
         {
             skc.AddConnectedSkill(Convert.ToInt32(conn.Attribute("id").Value));
         }
         SkillConnections.Add(skc);
     }
 }
Пример #3
0
        public static void Load()
        {
            var f = File.OpenText(Environment.CurrentDirectory + "/resources/data/skills.tsv");

            SkillConnections = new List <SkillConnection>();
            Skills           = new Dictionary <Class, Dictionary <uint, Skill> >();
            for (int i = 0; i <= 12; i++)
            {
                Skills.Add((Class)i, new Dictionary <uint, Skill>());
            }
            Skills.Add(Class.Common, new Dictionary <uint, Skill>());


            while (true)
            {
                var line = f.ReadLine();
                if (line == null)
                {
                    break;
                }
                var s  = line.Split('\t');
                var id = Convert.ToUInt32(s[0]);
                Enum.TryParse(s[1], out Class c);
                var name     = s[2];
                var tooltip  = s[3];
                var iconName = s[4];

                var sk = new Skill(id, c, name, tooltip);
                sk.SetSkillIcon(iconName);
                Skills[c].Add(id, sk);


                var skc = new SkillConnection((int)id, c);
                for (int i = 5; i < s.Count(); i++)
                {
                    skc.AddConnectedSkill(Convert.ToInt32(s[i]));
                }
                if (skc.ConnectedSkills.Count > 0)
                {
                    SkillConnections.Add(skc);
                }
            }
        }
Пример #4
0
    void RenderLines()
    {
        Camera cam = Camera.main;

        foreach (Int2 sc in skillConnections)
        {
            GameObject con = Instantiate(element, connections.transform);

            LineRenderer line = con.GetComponent <LineRenderer>();

            Vector3 f = cam.ScreenToWorldPoint(GetSkill(sc.first, defence.transform).GetComponent <RectTransform>().position); f.z = 1;
            Vector3 s = cam.ScreenToWorldPoint(GetSkill(sc.second, defence.transform).GetComponent <RectTransform>().position); s.z = 1;

            line.SetPosition(0, f);
            line.SetPosition(1, s);

            skillConn           = con.GetComponent <SkillConnection>();
            skillConn.skills[0] = GetSkill(sc.first, defence.transform);
            skillConn.skills[1] = GetSkill(sc.second, defence.transform);
        }
    }