コード例 #1
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
//	public void FireMulti(Character target){
//		curTarget = target;
//		Transform house = transform.GetChild (0);
//		house.gameObject.GetComponent<Renderer>().sortingOrder = 4;
//		foreach(Character chara in EnemySpawnManager._instance.enemyList){
//			if(Vector3.Distance(chara.GetPos(),curTarget.GetPos()) <= explosionRange){
//				curTargetList.Add(chara);
//			}
//		}
//		distanceToTarget = Vector3.Distance (this.transform.position, target.GetPos());
//		StartCoroutine (Shoot (target));
//	}

    IEnumerator Shoot(Character target)
    {
        while (move)
        {
            if (target != null)
            {
                Vector3 targetPos = target.GetPos();
                this.transform.LookAt(targetPos);
                float currentDist = Vector3.Distance(this.transform.position, target.GetPos());
                if (currentDist < minDistance)
                {
                    move = false;
                    if (node.GetPosion && isAntennaFire == false)
                    {
                        OnDOTEffect();
                    }
                    OnHited();
                }
                this.transform.Translate(Vector3.forward * Mathf.Min(speed * Time.deltaTime, currentDist));
                yield return(null);
            }
            else
            {
                move = false;
                if (parent1 != null)
                {
                    parent1 = null;
                    BulletPool.instance.Push(this.gameObject);
                }
                else if (antennaParent != null)
                {
                    antennaParent = null;
                    AtennaEffectPool.instance.Push(this.gameObject);
                }
                else
                {
                    Destroy(this.gameObject);
                }
            }
        }
    }
コード例 #2
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
    public void Update()
    {
        Timer += Time.deltaTime;

        if (Timer >= maxTime)
        {
            if (parent1 != null)
            {
                this.parent1 = null;
                BulletPool.instance.Push(this.gameObject);
            }
            else if (antennaParent != null)
            {
                this.antennaParent = null;
                AtennaEffectPool.instance.Push(this.gameObject);
            }
            else
            {
                //	Destroy(this.gameObject);
            }
            Timer = 0;
            return;
        }
    }
コード例 #3
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
//	public void FireMulti(Character target){
//		curTarget = target;
//		Transform house = transform.GetChild (0);
//		house.gameObject.GetComponent<Renderer>().sortingOrder = 4;
//		foreach(Character chara in EnemySpawnManager._instance.enemyList){
//			if(Vector3.Distance(chara.GetPos(),curTarget.GetPos()) <= explosionRange){
//				curTargetList.Add(chara);
//			}
//		}
//		distanceToTarget = Vector3.Distance (this.transform.position, target.GetPos());
//		StartCoroutine (Shoot (target));
//	}

	IEnumerator Shoot(Character target){
		while (move) {
			if(target != null){
				Vector3 targetPos = target.GetPos();
				this.transform.LookAt(targetPos);
				float currentDist = Vector3.Distance(this.transform.position, target.GetPos());
				if(currentDist < minDistance){
					move = false;
					if(node.GetPosion && isAntennaFire == false){
						OnDOTEffect();
					}
					OnHited();
				}
				this.transform.Translate(Vector3.forward*Mathf.Min(speed * Time.deltaTime,currentDist));
				yield return null;
			}
			else{
				move = false;
				if(parent1 != null){
					parent1 = null;
					BulletPool.instance.Push(this.gameObject);
				}
				else if(antennaParent != null){
					antennaParent = null;
					AtennaEffectPool.instance.Push(this.gameObject);
				}
				else 
					Destroy(this.gameObject);
			}
		}
	}
コード例 #4
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
	public void Update(){
		Timer += Time.deltaTime;

		if (Timer >= maxTime) {
			if(parent1 != null){
				this.parent1 = null;
				BulletPool.instance.Push(this.gameObject);
			} else if(antennaParent != null){
				this.antennaParent = null;
				AtennaEffectPool.instance.Push(this.gameObject);
			} else {
			//	Destroy(this.gameObject);
			}
			Timer = 0;
			return;
		}
	}
コード例 #5
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
	public void OnHited(){
		if (parent != null) {
			BulletManager.Instance.CalcuBulletDamage (curTarget, this.parent);
			if (curTarget.Life <= 0) {
				parent.curEnemy = null;
			} 
		}
		if (parent1 != null) {
			BulletManager.Instance.CalcuBulletDamage (curTarget, this.parent1);
			if (curTarget.Life <= 0) {
				parent1.curEnemy = null;
			} 
		}
		if (parent2 != null) {
			BulletManager.Instance.CalcuBulletDamage (curTarget, this.parent2);
			if (curTarget.Life <= 0) {
				parent2.curEnemy = null;
			} 
		}
		if (parent7 != null) {
//			foreach(Character chara in EnemySpawnManager._instance.enemyList){
//				Distance = Vector3.Distance(chara.GetPos(),curTarget.GetPos());
//				if(Distance <= explosionRange){
//					BulletManager.Instance.CalcuBulletDamage (chara, this.parent7);
//				}
//			}

			for(int i = 0 ; i< EnemySpawnManager._instance.enemyList.Count ; i++){
				Distance = Vector3.Distance(EnemySpawnManager._instance.enemyList[i].GetPos(),curTarget.GetPos());
				if(Distance <= explosionRange){
					if((EnemySpawnManager._instance.enemyList[i].Life - this.parent7.GetAttackPower()) <= 0){
						//thie enemy die, remove from the enemy list
						BulletManager.Instance.CalcuBulletDamage (EnemySpawnManager._instance.enemyList[i], this.parent7);
						i--;
					} else {
						BulletManager.Instance.CalcuBulletDamage (EnemySpawnManager._instance.enemyList[i], this.parent7);
					}
				}
			}
			OnExplosionEffect();
			if (curTarget.Life <= 0) {
				parent7.curEnemy = null;
				Destroy(gameObject);
			} 
		}

		if(parent1 != null){
			parent1 = null;
			BulletPool.instance.Push(this.gameObject);
		}
		else if(antennaParent != null){
			antennaParent = null;
			AtennaEffectPool.instance.Push(this.gameObject);
		}
		else 
			Destroy(this.gameObject);
	}
コード例 #6
0
ファイル: CannonBullet.cs プロジェクト: ziyihu/Tower-Defence
    public void OnHited()
    {
        if (parent != null)
        {
            BulletManager.Instance.CalcuBulletDamage(curTarget, this.parent);
            if (curTarget.Life <= 0)
            {
                parent.curEnemy = null;
            }
        }
        if (parent1 != null)
        {
            BulletManager.Instance.CalcuBulletDamage(curTarget, this.parent1);
            if (curTarget.Life <= 0)
            {
                parent1.curEnemy = null;
            }
        }
        if (parent2 != null)
        {
            BulletManager.Instance.CalcuBulletDamage(curTarget, this.parent2);
            if (curTarget.Life <= 0)
            {
                parent2.curEnemy = null;
            }
        }
        if (parent7 != null)
        {
//			foreach(Character chara in EnemySpawnManager._instance.enemyList){
//				Distance = Vector3.Distance(chara.GetPos(),curTarget.GetPos());
//				if(Distance <= explosionRange){
//					BulletManager.Instance.CalcuBulletDamage (chara, this.parent7);
//				}
//			}

            for (int i = 0; i < EnemySpawnManager._instance.enemyList.Count; i++)
            {
                Distance = Vector3.Distance(EnemySpawnManager._instance.enemyList[i].GetPos(), curTarget.GetPos());
                if (Distance <= explosionRange)
                {
                    if ((EnemySpawnManager._instance.enemyList[i].Life - this.parent7.GetAttackPower()) <= 0)
                    {
                        //thie enemy die, remove from the enemy list
                        BulletManager.Instance.CalcuBulletDamage(EnemySpawnManager._instance.enemyList[i], this.parent7);
                        i--;
                    }
                    else
                    {
                        BulletManager.Instance.CalcuBulletDamage(EnemySpawnManager._instance.enemyList[i], this.parent7);
                    }
                }
            }
            OnExplosionEffect();
            if (curTarget.Life <= 0)
            {
                parent7.curEnemy = null;
                Destroy(gameObject);
            }
        }

        if (parent1 != null)
        {
            parent1 = null;
            BulletPool.instance.Push(this.gameObject);
        }
        else if (antennaParent != null)
        {
            antennaParent = null;
            AtennaEffectPool.instance.Push(this.gameObject);
        }
        else
        {
            Destroy(this.gameObject);
        }
    }