Exemplo n.º 1
0
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (this.HP > 0)
        {
            if (other.gameObject.GetComponent <Package>() != null)
            {
                Package collectedPackage = other.gameObject.GetComponent <Package>();
                this.HP += collectedPackage.LifePoints;
            }

            if (other.gameObject.GetComponent <Sheep>() != null)
            {
                Sheep collectedSheep = other.gameObject.GetComponent <Sheep>();
                this.Coins += collectedSheep.Coins;
                UpdateScore();
            }

            if (other.gameObject.GetComponent <NPCProjectile>() != null)
            {
                NPCProjectile encounteredProjectile = other.gameObject.GetComponent <NPCProjectile>();
                this.HP -= encounteredProjectile.Damage;
            }

            if (other.gameObject.GetComponent <BossProjectile>() != null)
            {
                BossProjectile encounteredProjectile = other.gameObject.GetComponent <BossProjectile>();
                this.HP -= encounteredProjectile.Damage;
            }
        }
    }
Exemplo n.º 2
0
    public void Attack()
    {
        if (!bSoundPlayed)
        {
            bSoundPlayed = true;
            if (AttackSound.Length > 0)
            {
                audioSource.PlayOneShot(AttackSound[UnityEngine.Random.Range(0, AttackSound.Length)]);
            }
        }

        Spine.Bone bone = skeletonAnimation.skeleton.FindBone("drag_head5");
        Vector3    weaponSlotPosition      = skeletonAnimation.transform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY, 0f));
        Vector2    ProjectileSpawnLocation = weaponSlotPosition;

        float angleStepSize = 360.0f / AmountOfProjectile;

        for (int angleStep = 0; angleStep < AmountOfProjectile; angleStep++)
        {
            float   rad = (angleStepSize * angleStep + AngleOffset) * Mathf.Deg2Rad;
            Vector2 Offset;
            Offset.x = -Radius *Mathf.Sin(rad);

            Offset.y = Radius * Mathf.Cos(rad);

            GameObject     go             = GameObject.Instantiate <GameObject>(Projectile, ProjectileSpawnLocation + Offset, Quaternion.identity);
            BossProjectile bossProjectile = go.GetComponent <BossProjectile>();
            bossProjectile.SetupVelocity(Offset);
        }

        AngleOffset += AngleStepBetweenAttack;
    }
 void fire()
 {
     for (int shotsfired = 0; shotsfired < 3; shotsfired++)
     {
         shotdirection = character.transform.position - transform.position;
         shotdirection.Normalize();
         BossProjectile p = Instantiate(bossprojectile, new Vector3(ProjectileSpawnPoint[shotsfired].position.x, ProjectileSpawnPoint[shotsfired].position.y, ProjectileSpawnPoint[shotsfired].position.z), ProjectileSpawnPoint[shotsfired].rotation) as BossProjectile;
         p.GetComponent <Rigidbody2D>().AddForce(shotdirection * projectileSpeed);
     }
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        //Choose from strategies randomly
        strategies = new Action[] { densePulse, slowPulseFastSingle, fastPulseSlowSingle, opposingSpirals, bulletCloud, threePulse, spiralSpew, hellSphere }; // slowPulseFastSingle, fastPulseSlowSingle, opposingSpirals, bulletCloud, ThreePulse, spiralSpew,
        int i = rand.Next(strategies.Length);
        int j = rand.Next(bullets.Length);

        Debug.Log("Strat no: " + i);
        Debug.Log("Bullet no: " + j);
        strategies[i]();
        standardBullet = bullets[j];
    }
Exemplo n.º 5
0
    public void FireInArcTowards(BossProjectile prefab, Vector3 target, float impactAfter = 1)
    {
        BossProjectile clone = Instantiate(prefab, transform.position, Quaternion.identity);

        clone.body = clone.GetComponent <Rigidbody>();

        var delta = target - transform.position;

        clone.body.velocity = VectorHelper.CalculateVelocity(delta, impactAfter / Time.fixedDeltaTime);

        // Look where you goin, chump
        clone.transform.forward = clone.body.velocity;
    }
Exemplo n.º 6
0
    public void FireStraightTowards(BossProjectile prefab, Vector3 target, float speed = 5f)
    {
        BossProjectile clone = Instantiate(prefab, transform.position, Quaternion.identity);

        clone.body = clone.GetComponent <Rigidbody>();

        var delta = target - transform.position;

        clone.body.velocity   = delta * speed;
        clone.body.useGravity = false;

        // Look where you goin, chump
        clone.transform.forward = clone.body.velocity;
    }
Exemplo n.º 7
0
    private TempRestart restart; //delete this later


    void Start()
    {
        FindObjectOfType <CameraFollow>().bossBattle   = true;
        FindObjectOfType <PlayerMovement>().bossBatlle = true;
        health         = startHealth;
        anim           = gameObject.GetComponent <Animator>();
        bossTeleport   = gameObject.GetComponent <BossTeleport>();
        bossProjectile = gameObject.GetComponent <BossProjectile>();
        bossVine       = gameObject.GetComponent <BossVine>();
        bossPulse      = gameObject.GetComponent <BossPulse>();
        bossHell       = gameObject.GetComponent <BossBulletHell>();
        restart        = gameObject.GetComponent <TempRestart>(); //Delete this later
        StartCoroutine(BeginFight());
    }
Exemplo n.º 8
0
    public void FireWaveStraightTowards(BossProjectile prefab, Vector3 target, int amount, float angle = 45, float speed = 5f)
    {
        Vector3 delta = target - transform.position;

        if (amount == 1)
        {
            FireStraightTowards(prefab, target, speed);
        }
        else
        {
            for (int i = 0; i < amount; i++)
            {
                Vector3 newTarget = transform.position + Quaternion.Euler(0, i / (amount - 1f) * angle - angle * 0.5f, 0) * delta;
                FireStraightTowards(prefab, newTarget, speed);
            }
        }
    }
Exemplo n.º 9
0
    private void Attack()
    {
        if (enemies.Count == 0)
        {
            return;
        }

        Enemy target = enemies[UnityEngine.Random.Range(0, enemies.Count)];

        BossProjectile instance = Instantiate(bossAttack, firingPoint.transform.position, firingPoint.transform.rotation);

        instance.SetTargetEnemy(target.gameObject);

        //GetComponent<AudioSource>().clip = shootSoundEffect;
        //GetComponent<AudioSource>().Play();
        shootSoundEffectSrc.Play();

        firingTimestamp = Time.time + attackRate;
    }
Exemplo n.º 10
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void OnCollisionEnter(Collision c)
    {
        if (c.gameObject.tag == "Ground")
        {
            jumping     = false;
            jumpReady   = true;
            attacking   = false;
            attackReady = true;
        }

        if (c.gameObject.tag == "Collectable")
        {
            gm.changeScore(1);
            Destroy(c.gameObject);
        }

        if (c.gameObject.tag == "Projectile")
        {
            Destroy(c.gameObject);
            gm.healthHurt();
            if (gm.getHealth() > 0)
            {
                rb.AddForce(new Vector3(0, jumpPower, 0));
            }
            else
            {
                gm.killPlayer(transform.position, this);
            }
        }

        if (c.gameObject.tag == "Enemy")
        {
            if (!attacking)
            {
                sfx.playSound(sfx.hurt);
                gm.healthHurt();
                if (c.gameObject.name == "BoomSkullEnemy" ||
                    c.gameObject.name == "BoomSkullEnemy(Clone)")
                {
                    gm.showExplosion(c.transform.position);
                    Destroy(c.gameObject);
                }
                if (gm.getHealth() > 0)
                {
                    rb.AddForce(new Vector3(0, jumpPower, 0));
                }
                else
                {
                    sfx.playSound(sfx.death1);
                    gm.killPlayer(transform.position, this);
                }
            }
            else
            {
                Destroy(c.gameObject);
                gm.transformPlayer(c.gameObject.name, this, transform.position);
            }
        }

        if (c.gameObject.tag == "Wall")
        {
            if (this.name == "JumperPlayer(Clone)")
            {
                walled = true;
            }
            else if (this.name == "BoomSkullPlayer(Clone)")
            {
                enterBoss    = true;
                fightingBoss = true;
                boomAttack();
            }
        }

        if (c.gameObject.tag == "Boss")
        {
            if (attacking)
            {
                BossProjectile bossShot = c.gameObject.GetComponent <BossProjectile> ();
                bossShot.towardsPlayer = false;
            }
            else
            {
                sfx.playSound(sfx.hurt);
                gm.healthHurt();
                Destroy(c.gameObject);
                if (gm.getHealth() > 0)
                {
                    rb.AddForce(new Vector3(0, jumpPower, 0));
                }
                else
                {
                    sfx.playSound(sfx.death1);
                    gm.killPlayer(transform.position, this);
                }
            }
        }
    }