private void SelectedPosition() { for (int i = 0; i < Input.touchCount; ++i) { if (Input.GetTouch(i).phase == TouchPhase.Began) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(i).position); if (Physics.Raycast(ray, out hit, 5000f)) { if (hit.collider.CompareTag("Ground") && GameControls.euros >= price) { GameObject turret = Instantiate(selectedBuilding, hit.point, Quaternion.identity) as GameObject; turret.transform.SetParent(hit.transform); turret.transform.rotation = turret.transform.parent.transform.rotation; GameControls.euros -= price; selectedBuilding = null; if (turret.GetComponent <GunTurret>().turretType == 3) { GameControls.UnlockAchievement(GPGSIds.achievement_world_thanks_for_the_new_nuke); } if (turret.GetComponent <GunTurret>().turretType == 2) { GameControls.UnlockAchievement(GPGSIds.achievement_not_so_fast_anymore); hasSlowT = true; } if (turret.GetComponent <GunTurret>().turretType == 0) { GameControls.IncrementAchievement(GPGSIds.achievement_gunner, 1); hasGunT = true; } if (turret.GetComponent <GunTurret>().turretType == 1) { GameControls.IncrementAchievement(GPGSIds.achievement_missiles_op, 1); hasMissileT = true; } if (hasSlowT && hasGunT && hasMissileT) { GameControls.UnlockAchievement(GPGSIds.achievement_oh_theres_tactics_in_this_game); } } } } } }
public void GetXP(float xp) { currentXP += xp; if (xpToLevel <= currentXP) { level++; Destroy(Instantiate(levelUpEffect, transform.position, Quaternion.identity), 4f); GameControls.IncrementAchievement(GPGSIds.achievement_tower_upgrade, 1); shootCD *= 0.90f; damage *= 1.10f; rotationSpeed *= 1.10f; xpToLevel *= 1.2f; currentXP = startXp; } }
public void TakeDmg(float dmg, int dmgType) { int type = dmgType; dmgTypeEffect = dmgTypeEffects[type]; enemyHealth -= dmg; if (type == 4) { SkinnedMeshRenderer[] arr = gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int j = 0; j < arr.Length; j++) { arr[j].material.color = Color.green; } } else if (type == 2) { Collider[] cols = Physics.OverlapSphere(transform.position, 0.1f); for (int i = 0; i < cols.Length; i++) { if (cols[i].gameObject.CompareTag("Enemy")) { SkinnedMeshRenderer[] arr = cols[i].gameObject.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int j = 0; j < arr.Length; j++) { arr[j].material.color = Color.blue; } if (cols[i].gameObject.GetComponent <EnemyZombie>().move.z >= 0.00005f) { cols[i].gameObject.GetComponent <EnemyZombie>().move.z *= 0.95f; cols[i].gameObject.GetComponent <AudioSource>().clip = freezeSound; cols[i].gameObject.GetComponent <AudioSource>().spatialBlend = 1.0f; cols[i].gameObject.GetComponent <AudioSource>().maxDistance = 100f; cols[i].gameObject.GetComponent <AudioSource>().Play(); } } } } else { Destroy(Instantiate(bloodSpills[Random.Range(0, bloodSpills.Count)], transform.position, Quaternion.identity), 4f); Destroy(Instantiate(sounds[1], transform.position, Quaternion.identity), 1f); Destroy(Instantiate(sounds[Random.Range(5, 7)], transform.position, Quaternion.identity), 1f); Destroy(Instantiate(dmgTypeEffect, new Vector3(transform.position.x, transform.position.y + 0.1f, transform.position.z), Quaternion.identity), 2f); } if (enemyHealth <= 0 && !isDead) { isDead = true; GameControls.euros += 5; if (GameControls.euros == 500) { GameControls.UnlockAchievement(GPGSIds.achievement_new_mr_drumb); } eAnim.SetBool("Walk", false); Destroy(Instantiate(sounds[0], transform.position, Quaternion.identity), 2f); eAnim.SetTrigger("Die"); gameObject.GetComponent <EnemyZombie>().move.z = 0; GameControls.IncrementAchievement(GPGSIds.achievement_zombies_slain, 1); GameControls.IncrementAchievement(GPGSIds.achievement_50_zombies_slain, 1); GameControls.IncrementAchievement(GPGSIds.achievement_100_zombies_slain, 1); GameControls.IncrementAchievement(GPGSIds.achievement_200_zombies_slain, 1); GameControls.IncrementAchievement(GPGSIds.achievement_500_zombies_slain, 1); GameControls.IncrementAchievement(GPGSIds.achievement_over_9000, 1); GameControls.zombieCount++; Destroy(gameObject, 1f); } }