Ejemplo n.º 1
0
        void Start()
        {
            _MyProperty = this.gameObject.GetComponent <Ctrl_BaseEnemyProperty>();
            _Animator   = this.gameObject.GetComponent <Animator>();
            GameObject goHero = GameObject.FindGameObjectWithTag(Tag.Player);

            if (goHero)
            {
                _HeroProperty = goHero.GetComponent <Ctrl_HeroProperty>();
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
            _MyTransform = this.gameObject.transform;
            _GoHero      = GameObject.FindGameObjectWithTag(Tag.Player);
            _MyProperty  = this.gameObject.GetComponent <Ctrl_BaseEnemyProperty>();
            _cc          = this.gameObject.GetComponent <CharacterController>();

            /* 确定个体差异性参数  */
            FloMoveSpeed = UnityHelper.GetInstance().GetRandomNum(1, 2);
            //FloAttackDistance = UnityHelper.GetInstance().GetRandomNum(1, 3);
            FloCordonDistance = UnityHelper.GetInstance().GetRandomNum(4, 15);
            FloThinkInterval  = UnityHelper.GetInstance().GetRandomNum(1, 3);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///  get all enemy and put them in an array
 ///  and check is enemy is alive
 /// </summary>
 public void GetEnemiesToArray()
 {
     //empty enemy list
     _LisEnemies.Clear();
     GameObject[] GoEnemies = GameObject.FindGameObjectsWithTag(Tag.Tag_Enemy);
     foreach (GameObject goItem in GoEnemies)
     {
         //check the enemy is alive
         Ctrl_BaseEnemyProperty enemy = goItem.GetComponent <Ctrl_BaseEnemyProperty>();
         //if (enemy && enemy.IsAlive)
         if (enemy && enemy.CurrentState != EnemyState.Dead)
         {
             _LisEnemies.Add(goItem);
         }
     }
 }//function end
Ejemplo n.º 4
0
        //得到所有活着的敌人,放入敌人集合
        private void GetEnemyToArray()
        {
            //清空敌人
            _ListEnemys.Clear();

            GameObject[] goEnemy = GameObject.FindGameObjectsWithTag(Tag.Tag_Enemys);

            foreach (GameObject golItem in goEnemy)
            {
                //判断敌人是否还存活  存活就放进列表里面
                //Ctrl_Enemy enemy = golItem.GetComponent<Ctrl_Enemy>();
                Ctrl_BaseEnemyProperty enemy = golItem.GetComponent <Ctrl_BaseEnemyProperty>();
                if (enemy != null && enemy.CurrentState != EnemyState.Dead)
                {
                    _ListEnemys.Add(golItem);
                }
            }
        }
Ejemplo n.º 5
0
        private CharacterController _cc;            //charactercontroller component
        private void Start()
        {
            //get this enemy position
            _MyTransform = this.gameObject.transform;
            //get player
            goPlayer = GameObject.FindGameObjectWithTag(Tag.Player);

            //get Attributes instance
            _MyProperty = this.gameObject.GetComponent <Ctrl_BaseEnemyProperty>();

            //get character contronller
            _cc = this.gameObject.GetComponent <CharacterController>();

            /* get random property number for each enemy*/
            FloMoveSpeed = UnityHelper.GetInstance().GetRandomNum(1, 2);
            //FloAttackDistance = UnityHelper.GetInstance().GetRandomNum(1, 3);
            FloatCordonDistance = UnityHelper.GetInstance().GetRandomNum(4, 15);
            FloThinkInterval    = UnityHelper.GetInstance().GetRandomNum(1, 3);
        }
Ejemplo n.º 6
0
        // Use this for initialization
        void Start()
        {
            _MyTransform = this.gameObject.transform;

            /* 确定敌人的个体差异性的数值 */
            MoveSpeed           = UnityHelper.GetInstance().RandomNum(3, 4);
            EnemyAttackDistance = UnityHelper.GetInstance().RandomNum(10, 15);
            EnemyCordonDistance = UnityHelper.GetInstance().RandomNum(35, 40);
            EnemyThinkTime      = UnityHelper.GetInstance().RandomNum(1, 2);

            //得到当前主角
            _Hero = GameObject.FindGameObjectWithTag("Player");
            //得到主角属性
            _HeroProperty = _Hero.GetComponent <Ctrl_HeroProperty>();
            //得到当前属性实例
            _MyProperty = this.gameObject.GetComponent <Ctrl_BaseEnemyProperty>();
            //得到角色控制器
            _CharacterController = this.gameObject.GetComponent <CharacterController>();
        }