Пример #1
0
 private void Shoot(Enemy enemy)
 {
     if (_bulletCount > 0)
     {
         _bulletCount--;
         _armorViewer.Show(_bulletCount);
         enemy.AddDamage(_defaultDamage);
         _playerAnimator.SetBool("Shoot", true);
         StartCoroutine(FinishShoot());
     }
 }
Пример #2
0
        private void OnTriggerEnter(Collider other)
        {
            Enemy e = other.gameObject.GetComponent <Enemy>();

            if (other.gameObject.CompareTag("Enemy") || e != null)
            {
                e.AddDamage(damageAmount);
                damageAmount = 0; // only one time
                Destroy(gameObject);
            }
        }
Пример #3
0
    private void Shoot(Enemy enemy)
    {
        if (_bulletCount > 0 && _currentShootSpeed == _shootSpeed)
        {
            _bulletCount--;
            _currentShootSpeed = 0;
            _armorViewer.Show(_bulletCount);
            _armorViewer.ReloadShow(_currentShootSpeed, _shootSpeed);
            enemy.AddDamage(_defaultDamage);
            _playerAnimator.SetBool("Shoot", true);

            StartCoroutine(FinishShoot());
            StartCoroutine(ShootDelay());
        }
    }
Пример #4
0
        /// <summary>
        /// Colliding for scene object - wall or player platform
        /// </summary>
        /// <param name="collisionInfo"></param>
        private void OnCollisionEnter(Collision collisionInfo)
        {
            //Debug.Log("Projectile OnCollisionEnter");
            ContactPoint cp = collisionInfo.contacts[0];

            // Checking and calculate the next direction to move
            if (useStickToplatformEffect && collisionInfo.gameObject.CompareTag("Player"))
            {
                _lastDirection = _projectileRigidbody.velocity;
                if (_playerRigidbody == null)
                {
                    _playerRigidbody = collisionInfo.gameObject.GetComponent <Rigidbody>();
                }
                // about 0.15f sec
                StartCoroutine(StickingToPlatformEffect(_playerRigidbody, cp.normal));
            }
            else
            {
                // calculate with Vector3.Reflect
                _velocity = Vector3.Reflect(_direction, cp.normal);
                // bounce effect to speed up ball
                _projectileRigidbody.velocity = _velocity.normalized * speed;
            }

            // Checking type of colliding object (may be it is enemy)
            // TODO: checking only tag and use GetComponent if CompareTag is true
            // during moving/copy paste to an another PC project folder some tag can be disappear!
            Enemy e = collisionInfo.gameObject.GetComponent <Enemy>();

            if (collisionInfo.gameObject.CompareTag("Enemy") || e != null)
            {
                //Debug.Log("AddDamage: " + e);
                e.AddDamage(DamageAmount);
            }

            // Touch the back wall is the end of game session!
            if (collisionInfo.gameObject.CompareTag("BackWall"))
            {
                DestroyEffects();
                DestroyState();
            }
        }
Пример #5
0
    // Ball collision with other objects
    private void OnTriggerEnter(Collider other)
    {
        //Check for a collision with an enemy
        Enemy potentialEnemy = other.GetComponent <Enemy>();

        if (potentialEnemy != null && direction != Vector3.zero && triggerEnabled)
        {
            Enemy enemy = potentialEnemy;
            enemy.AddDamage(Mathf.RoundToInt(GameManager.i.ballManager.GetDamages() * damageModifier));
            enemy.Slow(0.2f, 1);
            GameManager.i.momentumManager.IncrementMomentum(GameManager.i.momentumManager.momentumGainedPerEnemyHit);
        }

        //Check for a collision with a player (To pick the ball when it's on the ground)
        PlayerController potentialPlayer = other.GetComponent <PlayerController>();

        if (potentialPlayer != null && canBePicked)
        {
            potentialPlayer.TakeBall(this, 0);
        }

        //Check for a collision with a player (Ball belong to an enemy and is "spiky")
        if (potentialPlayer != null && state == BallMoveState.Spiky)
        {
            potentialPlayer.Push(direction.normalized, 5);
            potentialPlayer.AddDamage(20);
        }

        //Check for a destructible object
        // TODO


        //Check for an activable Object
        ActivableObject potentialActObject = other.GetComponent <ActivableObject>();

        if (potentialActObject != null)
        {
            potentialActObject.Activate();
            //Diminish the Momentum of the value
        }
    }
Пример #6
0
    private void GenerateDunkExplosion(Vector3 position, float radius, float power, int damages)
    {
        float trueRadius  = radius * GameManager.i.momentumManager.momentum;
        float truePower   = power * GameManager.i.momentumManager.momentum;
        int   trueDamages = Mathf.RoundToInt(damages + (1 * GameManager.i.momentumManager.momentum));

        Collider[] colliders = Physics.OverlapSphere(position, trueRadius);
        foreach (Collider hit in colliders)
        {
            Enemy potentialEnemy = hit.gameObject.GetComponent <Enemy>();
            if (potentialEnemy != null)
            {
                potentialEnemy.DisableNavmeshAgent();
                potentialEnemy.AddDamage(trueDamages);
                Rigidbody rb = hit.GetComponent <Rigidbody>();

                if (rb != null)
                {
                    //rb.AddForce(new Vector3(0, 5000, 0));
                    Debug.DrawRay(position, Vector3.up, Color.green, 10f);
                    rb.AddExplosionForce(truePower, position, trueRadius, 3.0F);
                }
            }
            DestructibleObject potentialDestructibleObject = hit.gameObject.GetComponent <DestructibleObject>();
            if (potentialDestructibleObject != null)
            {
                potentialDestructibleObject.Damage(1);
            }
        }

        Vector3 spawnPosition = new Vector3(transform.position.x, 0.05f, transform.position.z) + transform.forward * 2;

        spawnPosition.y = 0.05f;
        GameObject dunkFXRef = Instantiate(groundDunkEffect, spawnPosition, Quaternion.Euler(-90, 0, 0));

        dunkFXRef.transform.localScale = new Vector3(trueRadius, trueRadius, trueRadius);
        Destroy(dunkFXRef, 2);
    }
Пример #7
0
    private void AttackMotionCB(params object[] param)
    {
        switch (status.GetTable.attackType)
        {
        case eAttackType.Type_Normal: {
            Enemy targetEnemy = (Enemy)param[0];
            if (targetEnemy != null)
            {
                targetEnemy.AddDamage(
                    new DamageParam(-status.GetDamage, status.GetTable.damageTime,
                                    status.GetTable.damageNum, status.GetTable.towerType));
            }

            LoadAttackEffect();

            if (targetEnemy.GetStatus.GetHP.Equals(0))
            {
                status.ResetEnemy();
            }
        }

        break;

        case eAttackType.Type_Piercing: {
            List <Enemy> enemyList = (List <Enemy>)param[0];
            if (enemyList != null)
            {
                for (int i = 0; i < enemyList.Count; i++)
                {
                    enemyList[i].AddDamage(
                        new DamageParam(-status.GetDamage, status.GetTable.damageTime,
                                        status.GetTable.damageNum, status.GetTable.towerType));
                }
            }

            LoadAttackEffect();
        }

        break;

        case eAttackType.Type_Explosion: {
            LoadAttackEffect((Transform)param[0],
                             new SpriteEffect.EffectCompleteCB(ExplosionTargetEffectCompleteCB));
        }

        break;

        case eAttackType.Type_Area: {
            List <Enemy> enemyList = (List <Enemy>)param[0];
            if (enemyList != null)
            {
                for (int i = 0; i < enemyList.Count; i++)
                {
                    enemyList[i].AddDamage(
                        new DamageParam(-status.GetDamage, status.GetTable.damageTime,
                                        status.GetTable.damageNum, status.GetTable.towerType));
                }
            }
        }

        break;
        }
    }