Exemple #1
0
    public Unit(string _type, TeamColor _color, int _road) : this(_color, _road - 1)
    {
        type = _type;

        size = new Vector2(1.5f, 1.5f) * Settings.FhdToHD;

        if (UnitsSettings.Buffs(type).Contains("Boss"))
        {
            size = new Vector2(3f, 3f) * Settings.FhdToHD;
        }
        healthBarDeltaPosition = UnitsSettings.HealthBarPosition(_type) / 4f * Settings.FhdToHD;    //new Vector2 (0, 0.7f);
        shadowDeltaPosition    = UnitsSettings.ShadowPosition(_type) / 4f * Settings.FhdToHD;       //new Vector2 (0.1f, -0.575f);;

        try {
            healthMax  = BalanceSettings.health [_type];
            speed      = BalanceSettings.speed [_type];
            damage     = BalanceSettings.damage [_type];
            goldReward = BalanceSettings.price [_type];
            defence    = BalanceSettings.defence [_type];
        } catch (System.Exception e) {
            Debug.LogError("Wrong" + type);
        }

        objectAnimation.Load(_type + "Walk", -0.6f);
        objectAnimation.Play(-2);
    }
    public UnitsSettings()
    {
        instance = this;

        shadowPosition    = new Dictionary <string, Vector2> ();
        healthBarPosition = new Dictionary <string, Vector2> ();
        buffs             = new Dictionary <string, List <string> > ();

        var text  = (ResourcesController.LoadOnce("Units") as TextAsset).text;
        var units = text.Split('\n');

        foreach (var s in units)
        {
            if (s == "")
            {
                continue;
            }

            var res = s.Split('|');

            var name = res [0];

            var bfs = res [1].Split('☺');

            if (!buffs.ContainsKey(name))
            {
                buffs.Add(name, new List <string> ());
            }

            for (int i = 1; i < bfs.Length; i++)
            {
                buffs [name].Add(bfs [i]);
            }
            if (!shadowPosition.ContainsKey(name))
            {
                shadowPosition.Add(name, new Vector2(float.Parse(res [2].Split('☺') [0]), float.Parse(res [2].Split('☺') [1])));
            }

            if (!healthBarPosition.ContainsKey(name))
            {
                healthBarPosition.Add(name, new Vector2(float.Parse(res [3].Split('☺') [0]), float.Parse(res [3].Split('☺') [1])));
            }
        }
    }