Example #1
0
    /// <summary>
    /// 初始化
    /// </summary>
    public override void spriteInit()
    {
        //调用父类初始化方法
        base.spriteInit();

        //实例化所需状态
        IdleState   = new GeneralIdleState(this);
        MoveState   = new GeneralMoveState(this);
        AttackState = new GeneralAttackState(this);
        HurtState   = new GeneralHurtState(this);
        DeadState   = new GeneralDeadState(this);
        WinState    = new GeneralWinState(this);

        //取得角色动作
        _animator = GetComponent <Animator>();
    }
Example #2
0
    /// <summary>
    /// 初始化
    /// </summary>
    public override void spriteInit()
    {
        //调用父类初始化方法
        base.spriteInit();

        //实例化所需状态
        IdleState = new GeneralIdleState(this);
        MoveState = new GeneralMoveState(this);
        AttackState = new GeneralAttackState(this);
        HurtState = new GeneralHurtState(this);
        DeadState = new GeneralDeadState(this);
        WinState = new GeneralWinState(this);

        //取得角色动作
        _animator = GetComponent<Animator>();
    }
Example #3
0
    /// <summary>
    /// 初始化
    /// </summary>
    public override void spriteInit()
    {
        //调用父类初始化方法
        base.spriteInit();

        _navmeshAgent = GetComponent <NavMeshAgent>();

        //实例化所需状态
        IdleState   = new GeneralIdleState(this);
        MoveState   = new GeneralMoveState(this);
        AttackState = new GeneralAttackState(this);
        HurtState   = new GeneralHurtState(this);
        DeadState   = new GeneralDeadState(this);
        WinState    = new GeneralWinState(this);

        _walkState = new GeneralWalkState(this);

        //取得角色动作
        _animator = GetComponent <Animator>();

#if true
        if (_lifeTestObj == null)//判断血条组件是否为空
        {
            //实例化血条组件
            _lifeTestObj = ResourceManager.getInstance().getGameObject(PanelConfig.BLOOD_BAR);

            //获取当前Canvas下第一个对象
            _lifeTestObj.transform.SetParent(GameObject.Find("Canvas").transform.GetChild(0));
            _lifeTestObj.transform.SetAsFirstSibling();
            //设置缩放比
            _lifeTestObj.transform.localScale    = Vector3.one;
            _lifeTestObj.transform.localPosition = Vector3.zero;
        }
        //获取血条脚本
        _lifeLine = _lifeTestObj.GetComponent <LifeTest>();
        //获取场景主摄像机
        _lifeLine._mainCamera = Game.GameEntry.Instance.Cameras.mainCamera;
        //设置士兵
        _lifeLine.soldier = this;
#endif
    }
Example #4
0
    /// <summary>
    /// 初始化
    /// </summary>
    public override void spriteInit()
    {
        //调用父类初始化方法
        base.spriteInit();

        _navmeshAgent = GetComponent<NavMeshAgent>();

        //实例化所需状态
        IdleState = new GeneralIdleState(this);
        MoveState = new GeneralMoveState(this);
        AttackState = new GeneralAttackState(this);
        HurtState = new GeneralHurtState(this);
        DeadState = new GeneralDeadState(this);
        WinState = new GeneralWinState(this);

        _walkState = new GeneralWalkState(this);

        //取得角色动作
        _animator = GetComponent<Animator>();

        #if true
        if (_lifeTestObj == null)//判断血条组件是否为空
        {
            //实例化血条组件
            _lifeTestObj = ResourceManager.getInstance().getGameObject(PanelConfig.BLOOD_BAR);

            //获取当前Canvas下第一个对象
            _lifeTestObj.transform.SetParent(GameObject.Find("Canvas").transform.GetChild(0));
            _lifeTestObj.transform.SetAsFirstSibling();
            //设置缩放比
            _lifeTestObj.transform.localScale = Vector3.one;
            _lifeTestObj.transform.localPosition = Vector3.zero;
        }
        //获取血条脚本
        _lifeLine = _lifeTestObj.GetComponent<LifeTest>();
        //获取场景主摄像机
        _lifeLine._mainCamera = Game.GameEntry.Instance.Cameras.mainCamera;
        //设置士兵
        _lifeLine.soldier = this;
        #endif
    }