Esempio n. 1
0
    private void Shoot()
    {
        // shoot
        GameObject cannonball = ObjectPoolHelper.Instantiate(pCannonball, transform.position, Quaternion.identity);

        cannonball.GetComponent <CannonballController> ().Init(fort.transform.position, true, fortImpactDamage);
    }
    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 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);
    }
    /*
     *	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);
    }
Esempio n. 5
0
    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();
    }