Beispiel #1
0
    public HeroUnit CreateHeroUnit(string unit_name, int id, Vector3 pos)
    {
        GDSKit.unit unit_gds = GDSKit.unit.GetInstance(unit_name);

        GameObject hero_unit_gameobj = ObjectPoolManager.Instance().GetObject(unit_gds.resource_name);

        hero_unit_gameobj.transform.SetParent(cache_root_unit_node);

        HeroUnit hero_unit = hero_unit_gameobj.GetComponent <HeroUnit>();

        // 属性相关设置
        hero_unit.unit_name    = unit_name;
        hero_unit.unit_type    = UnitType.Hero;
        hero_unit.unit_id      = id;
        hero_unit.resource_key = unit_gds.resource_name;
        hero_unit.position     = pos;

        if (all_unit_list.ContainsKey(hero_unit.unit_id))
        {
            Debug.LogError("相同名字的unit已经在管理器里了 id : " + hero_unit.unit_id);
            return(null);
        }

        all_unit_list.Add(hero_unit.unit_id, hero_unit);
        hero_unit_list.Add(hero_unit.unit_id, hero_unit);

        hero_unit.PlayIdle();

        return(hero_unit);
    }
Beispiel #2
0
    public void OnEndMove(object[] all_params)
    {
        int      unit_id = (int)all_params[0];
        HeroUnit unit    = GetHeroUnit(unit_id);

        if (unit != null)
        {
            unit.is_move = false;
            unit.PlayIdle();
        }
    }