Exemplo n.º 1
0
    // private Shield _shield;
    // private HashSet<Buff> _buffs = new HashSet<Buff>();

    /// <summary>
    /// 设置坦克数据
    /// </summary>
    // public void SetData(DataSetTank dataSet, string fsmName, TankSide side = TankSide.Enemy)
    // {
    //     Rigidbody = StateMachine.GetComponent<Rigidbody2D>();
    //     Renderer = StateMachine.GetComponent<SpriteRenderer>();
    //     Collider2D = StateMachine.GetComponent<BoxCollider2D>();
    //
    //     _dataSet = dataSet;
    //     if (_dataSet.Shield && _dataSet.Shield.ShieldValue > 0)
    //     {
    //         _shield = StateMachine.GetComponentByChild<Shield>("护盾");
    //         _shield.Generate(_dataSet.Shield);
    //     }
    //     else
    //     {
    //         _shield = null;
    //     }
    //     Side = side;
    //     MaxHP = HP = _dataSet.HP;
    //     Speed = _dataSet.Speed;
    //     StateMachine.Name = fsmName;
    //
    //     Renderer.sprite = _dataSet.Picture;
    //     Collider2D.size = _dataSet.Picture.rect.size * 0.01f;
    // }

    /// <summary>
    /// 生成行为控制器
    /// </summary>
    public void GenerateController()
    {
        if (Controller == null)
        {
            if (Side == TankSide.Enemy)
            {
                Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(_dataSet.AIController);
                Controller = Activator.CreateInstance(type) as TankController;
            }
            else
            {
                Controller = new PlayerController();
            }
            Controller.InitControll(this);
        }
    }
Exemplo n.º 2
0
        private void Awake()
        {
            DontDestroyOnLoad(gameObject);

            Current = this;

            Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(XHotfixLoaderType);

            if (type != null)
            {
                if (type.IsSubclassOf(typeof(XHotfixLoaderBase)))
                {
                    _loader = Activator.CreateInstance(type) as XHotfixLoaderBase;
                }
                else
                {
                    Log.Error("创建XLua加载器失败:XLua加载器类 " + XHotfixLoaderType + " 必须继承至加载器基类:XHotfixLoaderBase!");
                }
            }
            else
            {
                Log.Error("创建XLua加载器失败:丢失XLua加载器类 " + XHotfixLoaderType + "!");
            }

            _luaEnv = new LuaEnv();
            _luaEnv.AddLoader(_loader.OnLoadRequire);
            _luaTable = _luaEnv.NewTable();

            LuaTable meta = _luaEnv.NewTable();

            meta.Set("__index", _luaEnv.Global);
            _luaTable.SetMetaTable(meta);
            meta.Dispose();

            if (Main.m_Resource.LoadMode == ResourceLoadMode.Resource)
            {
                Log.Error("热更新初始化失败:热更新代码不支持使用Resource加载模式!");
                return;
            }
        }
Exemplo n.º 3
0
        private void Awake()
        {
            Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(EvaluationType);

            if (type != null)
            {
                _evaluation = Activator.CreateInstance(type) as AStarEvaluation;
                if (_evaluation == null)
                {
                    Log.Error("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                    return;
                }
            }
            else
            {
                Log.Error("A*:初始化网格失败,丢失了估价算法 " + EvaluationType);
                return;
            }

            if (IsAutoGenerate)
            {
                GenerateGrid();
            }
        }