// Use this for initialization void Start() { enemyParent = GetComponent <EnemyParent>(); enemyTalkTimer += Random.Range(-2f, 2f); enemyTalkTimerDuration = enemyTalkTimer; }
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(); } } }
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); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.GetComponent <EnemyParent>() != null) { EnemyParent enemy = coll.gameObject.GetComponent <EnemyParent>(); enemy.InflictDamage(int.MaxValue); Destroy(enemy.transform.gameObject); } }
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); } }
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); } }
void HandleEnemy() { EnemyParent ep = target.GetComponent <EnemyParent>(); if (ep != null) { ep.blood -= damage; ep.BeAttack(); if (ep.blood <= 0) { ep.Die(); } DestoryOwn(); } }
// 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; } }
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); } } } }
//获取一个敌人 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); }
void Start() { enemyParent = GetComponentInParent <EnemyParent>(); }
public void RemoveEnemy(EnemyParent toRemoveEnemy) { ListEnemyParents.Remove(toRemoveEnemy); }//*/
public void AddEnemy(EnemyParent toAddEnemy) { ListEnemyParents.Add(toAddEnemy); }