private void SetProjectileInfo(LaserBolt bolt, float damageBuff, float critDamage)
 {
     bolt.speed     = projectileData.speed;
     bolt.damage    = (projectileData.damage + damageBuff) + critDamage;
     bolt.lifeTime  = projectileData.lifeTime;
     bolt.shooterID = shooterID;
 }
Beispiel #2
0
    public void OnObjectHit(GameObject other)
    {
        //Destroy(other);
        PlayerTurret player = other.GetComponent <PlayerTurret>();
        LaserBolt    laser  = other.GetComponent <LaserBolt>();

        if (player != null)
        {
            GameController.instance.GameOver();
            Instantiate(Resources.Load(ParticleLibrary.enemyExplosion), transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (laser != null)
        {
            if (laser.type == LaserBolt.FriendOrFoe.Friendly && !healthScript.bIsDead)
            {
                if (healthScript.TakeDamage(laser.powerLevel))
                {
                    Instantiate(Resources.Load(ParticleLibrary.enemyExplosion), transform.position, transform.rotation);
                    // Done in laser class
                    //Value script = GetComponent<Value>();
                    //ExpController.instance.GainExperience(script.ExpValue);
                    Destroy(gameObject);
                }
                else
                {
                    // Play hit sound
                }
            }
        }
    }
Beispiel #3
0
    public void fire()
    {
        bolt = (LaserBolt)Instantiate(Resources.Load("Bolt", typeof(LaserBolt)), this.transform.position, Quaternion.identity);
        switch ((int)(this.transform.eulerAngles.y) % 360)
        {
        case 0:
            bolt.direction = new Vector3(0, 0, 1);
            break;

        case 90:
            bolt.direction = new Vector3(1, 0, 0);
            break;

        case 180:
            bolt.direction = new Vector3(0, 0, -1);
            break;

        case 270:
            bolt.direction = new Vector3(-1, 0, 0);
            break;

        default:
            throw new Exception("Angle is negative. Fix the code");
        }
    }
Beispiel #4
0
 void AllocateLaserPower(GameObject bullet)
 {
     if (bullet != null)
     {
         LaserBolt laser = bullet.GetComponent <LaserBolt>();
         if (laser != null)
         {
             laser.powerLevel = turretData.power;
         }
     }
 }
Beispiel #5
0
    // Player hits anything - he dies
    // CHANGE TO LOSE LIFE SYSTEM
    public void OnObjectHit(GameObject other)
    {
        LaserBolt laser = other.GetComponent <LaserBolt>();

        if (laser != null)
        {
            if (laser.type == LaserBolt.FriendOrFoe.Friendly)
            {
                return;
            }
        }
        Instantiate(Resources.Load(ParticleLibrary.playerExplosion), transform.position, transform.rotation);
        Destroy(gameObject);
    }
    public override void Shoot(float damageBuff, float critDamage)
    {
        base.Shoot(damageBuff, critDamage);
        if (!isShooting)
        {
            return;
        }

        Quaternion rotation = aimAssist.CalculateAimDirection(point);

        if (canRecoilSway)
        {
            rotation = ApplyRocoilSway(rotation);
        }
        LaserBolt bolt = Instantiate(projectileData.prefab, point.position, rotation).GetComponent <LaserBolt>();

        SetProjectileInfo(bolt, damageBuff, critDamage);
        audioSystem.PlaySoundEffect(weaponSound);
    }
Beispiel #7
0
    void OnTriggerEnter(Collider collider)
    {
        LaserBolt bolt = collider.GetComponent <LaserBolt>();

        bolt.gameObject.transform.position = this.transform.position;
        Vector3 direction = bolt.direction;

        print(this.transform.eulerAngles.y);
        print(direction);
        print(bolt.direction);
        switch ((int)this.transform.eulerAngles.y)
        {
        case 0:
            print("Case 0");
            if (direction == Vector3.left)
            {
                bolt.direction = new Vector3(0, 0, -1);
            }
            else if (direction == Vector3.forward)
            {
                bolt.direction = new Vector3(1, 0, 0);
            }
            else
            {
                Destroy(bolt.gameObject);
                Destroy(this.gameObject);
            }
            break;

        case 90:
            if (direction == new Vector3(1, 0, 0))
            {
                bolt.direction = new Vector3(0, 0, -1);
            }
            else if (direction == new Vector3(0, 0, 1))
            {
                bolt.direction = new Vector3(-1, 0, 0);
            }
            else
            {
                Destroy(bolt.gameObject);
                Destroy(this.gameObject);
            }
            break;

        case 180:
            if (direction == new Vector3(1, 0, 0))
            {
                bolt.direction = new Vector3(0, 0, 1);
            }
            else if (direction == new Vector3(0, 0, -1))
            {
                bolt.direction = new Vector3(-1, 0, 0);
            }
            else
            {
                Destroy(bolt.gameObject);
                Destroy(this.gameObject);
            }
            break;

        case 270:
            if (direction == new Vector3(-1, 0, 0))
            {
                bolt.direction = new Vector3(0, 0, 1);
            }
            else if (direction == new Vector3(0, 0, -1))
            {
                bolt.direction = new Vector3(1, 0, 0);
            }
            else
            {
                Destroy(bolt.gameObject);
                Destroy(this.gameObject);
            }
            break;

        default:
            Destroy(bolt.gameObject);
            Destroy(this.gameObject);
            break;
        }
    }