public void CallbackCannonballHit(Vector3 location) { SkillBase skillData = SkillBaseData.GetSkillBaseData(SkillNames.CANNON); float radius = skillData.radius; // TODO FIXME so do we want it to vary per cannonball, or per enemy hit? // my initiol reaction is it should be that the physical damage done to each // enemy is what varies, even within a single cannonball shot gameController.DoAOEGroundDamage(location, radius, skillData); // GENERATE PARTICLES :) (needs to me moved / reworked) // lots of optimization to happen here int numOfParticles = 40; for (int i = 0; i < numOfParticles; i++) { // create ground particles Vector2 particleCircle = Random.insideUnitCircle * radius; float particleX = location.x + particleCircle.x; float particleZ = location.z + particleCircle.y; GameObject particle = ObjectPoolHelper.Instantiate(pGroundParticle, new Vector3(particleX, 0, particleZ), Quaternion.identity); particle.GetComponent <Rigidbody> ().velocity = new Vector3(0, 3, 0); float spin = 100f; particle.GetComponent <Rigidbody> ().AddTorque(new Vector3(Random.Range(-spin, spin), Random.Range(-spin, spin), Random.Range(-spin, spin))); } }
private void Shoot() { // shoot GameObject cannonball = ObjectPoolHelper.Instantiate(pCannonball, transform.position, Quaternion.identity); cannonball.GetComponent <CannonballController> ().Init(fort.transform.position, true, fortImpactDamage); }
void Update() { if (transform.position.y < -1) { ObjectPoolHelper.Destroy(gameObject); } }
private void SpawnEnemy(GameObject enemyPrefab) { float spawnPointX = Random.Range( leftGroundSpawn.transform.position.x, rightGroundSpawn.transform.position.x); GameObject newEnemy = ObjectPoolHelper.Instantiate( enemyPrefab, new Vector3(spawnPointX, 0.2f, leftGroundSpawn.transform.position.z), Quaternion.identity); gameController.NofityNewEnemySpawn(newEnemy); }
void Update() { transform.Translate(Vector3.up * liftSpeed * Time.deltaTime); if (timer > 0f) { timer -= Time.deltaTime; } if (timer <= 0f) { ObjectPoolHelper.Destroy(gameObject); } }
private void ReportImpact() { if (!isEnemy) { GameObject.FindGameObjectWithTag("GameController") .GetComponent <SkillActionController> () .CallbackCannonballHit(endPosition); } else { // report the impact to the game controller or the fort? GameObject.FindGameObjectWithTag("Fort").GetComponent <FortController> ().DoDamage(fortDamage); ObjectPoolHelper.Destroy(gameObject); } }
void Update() { Animation += Time.deltaTime; if (Animation > flightTime) { ReportImpact(); ObjectPoolHelper.Destroy(gameObject); } Animation = Animation % flightTime; transform.position = MathParabola.Parabola( startPosition, endPosition, maxHeight, Animation / flightTime); }
/* * CANNONBALL */ private bool ShootCannonball(Vector3 target) { // verify valid target if (target.y < 0) { Debug.LogWarning("Cannot shoot at the target location."); return(false); } GameObject cannonball = ObjectPoolHelper.Instantiate( pCannonball, fort.transform.position + new Vector3(0, 1.2f, 0), Quaternion.identity); cannonball.GetComponent <CannonballController> ().Init(target, false, 0f); return(true); }
public void DealDamage(Damage damage) { float damageAfterResists = GetComponent <EnemyDamageResistances> ().GetDamageAfterResistances(damage); int damageInt = (int)damageAfterResists; GameObject fct = ObjectPoolHelper.Instantiate( pFloatingCombatText, transform.position + new Vector3(0, 1f, 0), Quaternion.identity); fct.GetComponent <FloatingCombatTextController> ().SetText(damageInt.ToString()); currentHealth -= damageInt; if (currentHealth <= 0) { Kill(); } UpdateHealthBarUI(); }
void Explode() { fort.GetComponent <FortController> ().DoDamage(fortImpactDamage); ObjectPoolHelper.Destroy(gameObject); }