Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        enemyParent = GetComponent <EnemyParent>();

        enemyTalkTimer        += Random.Range(-2f, 2f);
        enemyTalkTimerDuration = enemyTalkTimer;
    }
Exemplo n.º 2
0
    void Callback(object param)
    {
        EachWaveConfig ewc = (EachWaveConfig)param;
        GameObject     go  = null;

        foreach (var item in ewc.enemyTypelist)
        {
            string resourceName = string.Empty;
            go = Instantiate(Resources.Load(item.model)) as GameObject;
            EnemyParent enemyParent = go.GetComponent <EnemyParent>();
            enemyParent.blood                  = item.blood;
            enemyParent.maxAttackDistance      = item.maxAttackDistance;
            enemyParent.walkSpeed              = item.walkSpeed;
            enemyParent.attackRepeatRateTime   = item.attackRepeatRateTime;
            enemyParent.attackValue            = item.attackValue;
            enemyParent.recoverBatteryDataBase = item.recoverBatteryDataBase;

            go.transform.position = ewc.point.position;

            HandleDic(ewc.point, go);

            hasSpawnEnemy.Add(go);
        }
        if (sPointWithdwarningDic.ContainsKey(ewc.point))
        {
            Transform        tt = sPointWithdwarningDic[ewc.point];
            DirectionWarning dw = tt.GetComponent <DirectionWarning>();
            if (dw != null)
            {
                dw.PlayAnim();
            }
        }
    }
Exemplo n.º 3
0
 void FixedUpdate()
 {
     if (target != null)
     {
         //if (transform.position.y < target.transform.position.y)
         if (Vector3.Distance(transform.position, target.transform.position) < 3)
         {
             //finish
             EnemyParent ep = target.GetComponent <EnemyParent>();
             if (ep != null)
             {
                 ep.blood -= damage;
                 ep.BeAttack();
                 if (ep.blood <= 0)
                 {
                     ep.Die();
                 }
                 DestoryOwn();
             }
             return;
         }
         if (gameObject)
         {
             time += Time.deltaTime;
             float test = verticalSpeed - g * time;
             transform.Translate(moveDirection.normalized * speed * Time.deltaTime, Space.World);
             transform.Translate(Vector3.up * test * Time.deltaTime, Space.World);
             float testAngle = -angle + angleSpeed * time;
             transform.eulerAngles = new Vector3(testAngle, transform.eulerAngles.y, transform.eulerAngles.z);
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        rb          = GetComponent <Rigidbody>();
        enemyParent = GetComponent <EnemyParent>();


        rb.AddForce(Vector3.forward * enemyMoveSpeed, ForceMode.Acceleration);
    }
Exemplo n.º 5
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.GetComponent <EnemyParent>() != null)
     {
         EnemyParent enemy = coll.gameObject.GetComponent <EnemyParent>();
         enemy.InflictDamage(int.MaxValue);
         Destroy(enemy.transform.gameObject);
     }
 }
Exemplo n.º 6
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject  hitInfo   = collision.gameObject;
        EnemyParent hitObject = hitInfo.GetComponent <EnemyParent>();

        if (hitObject != null)
        {
            Vector2 AB = (hitObject.getRB().position - rb.position);//vector from player to obj
            Vector2 KB = calcKB(AB, hitObject.getOnHit().x, hitObject.getOnHit().y);
            takeDamage(hitObject.getOnHit().z, KB);
        }
    }
Exemplo n.º 7
0
    public override void OnTriggerEnter2D(Collider2D hitInfo)
    {
        string tag = hitInfo.tag;

        if (tag == "Enemy" || tag == "Ground")//true if hit enemy or ground
        {
            EnemyParent hitObject = hitInfo.GetComponent <EnemyParent>();
            if (hitObject != null)
            {
                hitObject.Hit(10);
            }
            endEffect(tag);
        }
    }
Exemplo n.º 8
0
    void HandleEnemy()
    {
        EnemyParent ep = target.GetComponent <EnemyParent>();

        if (ep != null)
        {
            ep.blood -= damage;
            ep.BeAttack();
            if (ep.blood <= 0)
            {
                ep.Die();
            }
            DestoryOwn();
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        enemyParent         = GetComponent <EnemyParent>();
        enemyEffectsManager = GameObject.Find("EnemyEffectsManager").GetComponent <EnemyEffectsManager>();

        enemyMovement = GetComponent <EnemyMovement>();

        enemyAttackTimer = (1 / enemyBulletFireRate) + Random.Range(-.05f, .05f);

        enemyBulletFireRate += enemyEffectsManager.addEnemyFireRate;
        enemyBulletAccuracy += enemyEffectsManager.addEnemyAccuracy;
        if (enemyBulletAccuracy >= 1)
        {
            enemyBulletAccuracy = 1;
        }
    }
Exemplo n.º 10
0
 void Update()
 {
     if (spawnTaskList != null && spawnTaskList.Count > 0)
     {
         SpawnTask st = null;
         for (int i = 0; i < spawnTaskList.Count; i++)
         {
             st = spawnTaskList[i];
             if (st.isStop)
             {
                 spawnTaskList.Remove(st);
             }
             else
             {
                 st.Update(Time.deltaTime);
             }
         }
     }
     if (allEnemyCount != 0)
     {
         if (allEnemyCount == hasSpawnEnemy.Count)
         {
             bool isAllOver = true;
             foreach (var item in hasSpawnEnemy)
             {
                 if (item != null)
                 {
                     EnemyParent enemy = item.GetComponent <EnemyParent>();
                     if (enemy != null)
                     {
                         if (enemy.blood > 0)
                         {
                             isAllOver = false;
                             break;
                         }
                     }
                 }
             }
             if (isAllOver)
             {
                 result.SetActive(true);
             }
         }
     }
 }
Exemplo n.º 11
0
 //获取一个敌人
 GameObject GetEnemy()
 {
     if (enemySpawnPoint == null)
     {
         return(null);
     }
     canAttackEnemyList = EnemyManager.dic[enemySpawnPoint];
     if (canAttackEnemyList != null && canAttackEnemyList.Count > 0)
     {
         GameObject item = null;
         for (int i = canAttackEnemyList.Count - 1; i >= 0; i--)
         {
             item = canAttackEnemyList[i];
             if (item != null)
             {
                 EnemyParent ep = item.GetComponent <EnemyParent>();
                 if (ep != null && ep.blood > 0)
                 {
                     if (Vector3.Distance(transform.position, item.transform.position) < (maxAttackDistance + 5))
                     {
                         StartShoot();
                         return(item);
                     }
                 }
                 else
                 {
                     canAttackEnemyList.Remove(item);
                 }
             }
             else
             {
                 canAttackEnemyList.Remove(item);
             }
         }
     }
     return(null);
 }
Exemplo n.º 12
0
 void Start()
 {
     enemyParent = GetComponentInParent <EnemyParent>();
 }
Exemplo n.º 13
0
 public void RemoveEnemy(EnemyParent toRemoveEnemy)
 {
     ListEnemyParents.Remove(toRemoveEnemy);
 }//*/
Exemplo n.º 14
0
 public void AddEnemy(EnemyParent toAddEnemy)
 {
     ListEnemyParents.Add(toAddEnemy);
 }