//コンポーネントの取得 void LoadComponents() { //タイトル画面じゃないなら取得 if (SceneManager.GetActiveScene().name != "StartScene") { playmotion = GameObject.Find("Player").GetComponent <PlayMotion>(); cannonforward = GameObject.Find("CannonRotation").GetComponent <CannnonForward>(); cannonbullet = GameObject.Find("CannonBulletFire").GetComponent <CannonBullet>(); Maincamera = GameObject.FindWithTag("MainCamera").GetComponent <PlayerFollowCamera>(); target_image = GameObject.FindWithTag("MainCamera").GetComponent <Target>(); //enemy = GameObject.Find("CannonBulletFire_Enemy").GetComponent<AttackEnemyMove>(); playerRigidbody = GameObject.Find("Player").GetComponent <Rigidbody>(); game_stop_flg = false; pause_flg = false; target_image.enabled = true; } }
// Update is called once per frame void Update() { time += Time.deltaTime; foreach (Antenna ant in TowerBuildManager._instance.GetAntennaList()) { //if the antenna is providing power to the towers nearby, set the animation work if (ant.GetProvidePowerTowerList().Count > 0) { ant.SetAniActive(); } //if the antenna is not working, set the animation not active else { ant.SetAniNotActive(); } } //set the effect to show the power is providing to the towers if (time >= timer) { foreach (Antenna ant in TowerBuildManager._instance.GetAntennaList()) { if (ant.GetProvidePowerTowerList().Count > 0 && Time.deltaTime != 0) { foreach (Character chara in ant.GetProvidePowerTowerList()) { //show the effect //start position : ant.GetPos(); //end position : chara.GetPos(); //effect name : powerprovide GameObject bulletgo = AtennaEffectPool.instance.Pop(); CannonBullet bullet = bulletgo.GetComponent <CannonBullet>(); bullet.move = true; bullet.antennaParent = this; bulletgo.transform.position = new Vector3(ant.GetPos().x, 0.4f, ant.GetPos().z); bullet.minDistance = 0.2f; bullet.AntennaFire(chara); } } } time = 0; } }
void HitAnimation() { Debug.Log("33"); if (endAttack || canAttack == false) { return; } mHitDelta += RealTime.deltaTime; float rate = 0.5f; if (rate < mHitDelta) { mHitDelta = (rate > 0f) ? mHitDelta - rate : 0f; if (curFps > 0) { Debug.Log("11"); curFps = 0; GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = 0.5f; endAttack = true; canAttack = false; } else { Debug.Log("22"); GameObject bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet")); CannonBullet bullet = bulletgo.GetComponent <CannonBullet>(); bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f; bullet.parent = this; curEnemy = EnemySpawnManager._instance.enemyList[0]; bullet.Fire(curEnemy); Vector3 dir = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = scalefactor; curFps++; } } }
void HitAni() { if (endAttack || canAttack == false) { return; } mHitDelta += RealTime.deltaTime; float rate = 1f / mFPS; if (rate < mHitDelta) { mHitDelta = (rate > 0f) ? mHitDelta - rate : 0f; if (curFps > 0) { curFps = 0; GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f); QuadTexture4Ngui gui = GetTransform().GetChild(0).GetComponent <QuadTexture4Ngui>(); gui.ScaleFactor = 0.5f; endAttack = true; canAttack = false; } else { GameObject bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet")); CannonBullet bullet = bulletgo.GetComponent <CannonBullet>(); Transform gun = GetTransform().GetChild(0); bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f; bullet.parent = this; bullet.Fire(curEnemy.GetTransform().gameObject); Vector3 dir = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z); QuadTexture4Ngui gui = GetTransform().GetChild(0).GetComponent <QuadTexture4Ngui>(); gui.ScaleFactor = scaleFactor; ++curFps; } } }
void HitAnimation() { if (endAttack || canAttack == false) { return; } mHitDelta += RealTime.deltaTime; if (data.attackRate < mHitDelta) { mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f; if (curFps > 0) { curFps = 0; GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = 0.5f; endAttack = true; canAttack = false; } else { if (curEnemy != null) { GameObject bulletgo = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet1")); CannonBullet bullet = bulletgo.GetComponent <CannonBullet>(); bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f; bullet.parent2 = this; if (curEnemy != null) { AudioSource.PlayClipAtPoint(AudioManager._instance.tower2FireMusic, this.GetPos()); bullet.Fire(curEnemy); } Vector3 dir = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = scalefactor; curFps++; } if (secondEnemy != null) { GameObject bulletgo1 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet2")); CannonBullet bullet1 = bulletgo1.GetComponent <CannonBullet>(); bulletgo1.transform.position = GetTransform().position + GetTransform().forward * 0.6f; //bulletgo.transform.position = gun.position ; bullet1.parent2 = this; if (secondEnemy != null) { bullet1.Fire(secondEnemy); } Vector3 dir1 = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z); QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui1.ScaleFactor = scalefactor; curFps++; } if (thirdEnemy != null) { GameObject bulletgo2 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet3")); CannonBullet bullet2 = bulletgo2.GetComponent <CannonBullet>(); bulletgo2.transform.position = GetTransform().position + GetTransform().forward * 0.6f; //bulletgo.transform.position = gun.position ; bullet2.parent2 = this; if (thirdEnemy != null) { bullet2.Fire(thirdEnemy); } Vector3 dir1 = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z); QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui1.ScaleFactor = scalefactor; curFps++; } if (forthEnemy != null) { GameObject bulletgo3 = (GameObject)GameObject.Instantiate(Resources.Load("cannonbullet4")); CannonBullet bullet3 = bulletgo3.GetComponent <CannonBullet>(); bulletgo3.transform.position = GetTransform().position + GetTransform().forward * 0.6f; //bulletgo.transform.position = gun.position ; bullet3.parent2 = this; if (forthEnemy != null) { bullet3.Fire(forthEnemy); } Vector3 dir1 = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir1.x, dir1.y + 0.3f, dir1.z); QuadTextureNgui gui1 = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui1.ScaleFactor = scalefactor; curFps++; } } } }
void HitAnimation() { if (endAttack || canAttack == false) { return; } mHitDelta += RealTime.deltaTime; if (data.attackRate < mHitDelta) { mHitDelta = (data.attackRate > 0f) ? mHitDelta - data.attackRate : 0f; if (curFps > 0) { curFps = 0; GetTransform().GetChild(0).localPosition = new Vector3(0.0f, 0.3f, 0.0f); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = 0.5f; endAttack = true; canAttack = false; } else { if (curEnemy != null) { GameObject bulletgo = BulletPool.instance.Pop(); CannonBullet bullet = bulletgo.GetComponent <CannonBullet>(); bullet.move = true; bulletgo.transform.position = GetTransform().position + GetTransform().forward * 0.6f; bullet.parent1 = this; if (enemyLists.Count > 0) { for (int i = 0; i < EnemySpawnManager._instance.enemyList.Count; i++) { for (int j = 0; j < enemyLists.Count; j++) { if (EnemySpawnManager._instance.enemyList[i].ID == enemyLists[j].ID) { curEnemy = enemyLists[j]; break; } } if (curEnemy != null) { break; } } if (curEnemy != null) { AudioSource.PlayClipAtPoint(AudioManager._instance.tower1FireMusic, this.GetPos()); bullet.Fire(curEnemy); } Vector3 dir = Vector3.back * moveDistance; GetTransform().GetChild(0).localPosition = new Vector3(dir.x, dir.y + 0.3f, dir.z); QuadTextureNgui gui = GetTransform().GetChild(0).GetComponent <QuadTextureNgui>(); gui.ScaleFactor = scalefactor; curFps++; } else if (enemyLists.Count == 0) { curEnemy = null; return; } } } } }