public void takeHit(TempProjectile p)
 {
     if (p != null)
     {
         health -= p.damageAmount;
         if (health <= 0)
         {
             DoDead();
         }
         else if (hitParticles != null)
         {
             GameObject go =
                 Instantiate(hitParticles, transform.position, Quaternion.identity);
             Destroy(go, 3);
         }
     }
 }
示例#2
0
    protected virtual void Awake()
    {
        #region applying stats
        //health
        maxHealth = baseMaxHealth;
        health    = baseHealth;

        if (health > maxHealth)
        {
            health = maxHealth;
        }

        //movement
        moveSpeed = baseMoveSpeed;
        canFly    = baseCanFly;

        //regular shot
        stunAmount            = baseStunAmount;
        fastestSecondsPerShot = baseFastestSecondsPerShot;
        secondsPerShot        = baseSecondsPerShot;

        if (secondsPerShot < fastestSecondsPerShot)
        {
            secondsPerShot = fastestSecondsPerShot;
        }

        projectileSpeed = baseProjectileSpeed;
        projectileRange = baseProjectileRange;

        projectile = baseProjectile;

        //charged shot
        maxCharges = baseMaxCharges;
        charges    = baseCharges;

        if (charges > maxCharges)
        {
            charges = maxCharges;
        }

        chargeDamageMult   = baseChargeDamageMult;
        chargeSplashRadius = baseChargeSplashRadius;

        fastestChargeTime = baseFastestChargeTime;
        chargeTime        = baseChargeTime;

        chargedProjectile = baseChargedProjectile;
        #endregion applying stats

        #region Filling out Items

        foreach (Item item in startingItems)
        {
            items.Add(item);
        }
        #endregion Filling out Items

        rb2D           = GetComponent <Rigidbody2D>();
        rb2D.sleepMode = RigidbodySleepMode2D.NeverSleep;
        velocity       = Vector2.zero;
    }
示例#3
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        if (isStunned)
        {
            return;
        }

        #region BossPhases
        if (health < startingHealth * 0.75f && currentPhase == 1)
        {
            Debug.Log("Moved a phase");
            isRotating = true;
            currentPhase++;
        }
        else if (health < startingHealth * 0.5f && currentPhase == 2)
        {
            Debug.Log("Moved a phase");
            rotationSpeed += rotationSpeedIncrease;
            rotationSpeed *= -1;
            smashCooldown -= smashCooldownDecreaseAmount;
            currentPhase++;
            changeColourCooldown -= colourChangeCDDecrease;
        }
        else if (health < startingHealth * 0.25f && currentPhase == 3)
        {
            Debug.Log("Moved a phase");
            rotationSpeed   *= -1;
            rotationSpeed   += rotationSpeedIncrease;
            projectileSpeed += projectileSpeedIncrease;
            spawnMinionCD   -= orcSpawnCDDecrease;
            currentPhase++;
            changeColourCooldown -= colourChangeCDDecrease;
        }
        #endregion


        if (isRotating)
        {
            PillarParent.transform.Rotate(Vector3.forward * (rotationSpeed * Time.deltaTime));
            foreach (Transform go in PillarParent.transform)
            {
                go.rotation = Quaternion.identity;
            }
        }

        healthText.text = health.ToString();

        //if (spawnMinionTimer > 0)
        //{
        //    spawnMinionTimer -= Time.deltaTime;
        //}
        //else
        //{
        //    //pick a random number from 1 to 100
        //    int rng = Random.Range(0, 101);
        //    //if the random number is less than the chance percentage of spawning an orc
        //    if (rng < chanceOfSpawningEnemy)
        //    {
        //        //spawn an orc in one of the orc spawn points
        //        bool wantToSpawn = false;
        //        int randomSpawn = 0;
        //        while (!wantToSpawn)
        //        {
        //            randomSpawn = Random.Range(0, minionsToSpawn.Length);
        //            if (Vector2.Distance(minionsToSpawn[randomSpawn].transform.position, player.transform.position) <= 25.0f)
        //            {
        //                continue;
        //            }
        //            else
        //                wantToSpawn = true;
        //        }
        //        rng = Random.Range(0, minionsToSpawn.Length);
        //        if (minions[rng])
        //            Instantiate(minionsToSpawn[rng], orcSpawns[randomSpawn].transform.position, Quaternion.identity);
        //    }
        //    //reset orc spawn timer
        //    orcSpawnTimer = orcSpawnCooldown;
        //}
        if (changeColourTimer > 0)
        {
            changeColourTimer -= Time.deltaTime;
        }
        else
        {
            ChangeColour();
            changeColourTimer = changeColourCooldown;
        }
        if (smashTimer > 0)
        {
            smashTimer -= Time.deltaTime;
        }
        else
        {
            //do the thing
            //for (int i = 0; i < numberOfProjectiles; i++)
            //{
            //    float angle = i * Mathf.PI * 2 / numberOfProjectiles;
            //    Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * circleRadius;
            //    GameObject go = Instantiate(projectile, pos, Quaternion.identity);
            //    go.tag = "OrcKingProjectile";
            //}
            if (canStartNewSmash)
            {
                for (int i = 0; i < numberOfProjectiles; i++)
                {
                    float   j     = ((float)(i * 1) / numberOfProjectiles);
                    float   angle = j * (Mathf.PI) * 2.0f;
                    float   x     = Mathf.Sin(angle) * circleRadius;
                    float   y     = Mathf.Cos(angle) * circleRadius;
                    Vector3 pos   = new Vector3(x, y, 0) + transform.position;

                    GameObject go = Instantiate(projectile, pos, Quaternion.identity);
                    go.transform.rotation = Quaternion.AngleAxis(Mathf.Rad2Deg * -angle, Vector3.forward);
                    TempProjectile tp = go.GetComponent <TempProjectile>();
                    go.layer         = LayerMask.NameToLayer("BossProjectile");
                    go.tag           = "OrcKingProjectile";
                    tp.damageAmount  = 1;
                    tp.speed         = projectileSpeed;
                    canStartNewSmash = false;
                }
            }
            smashy2Timer -= Time.deltaTime;

            if (smashy2Timer <= 0)
            {
                for (float i = 0.5f; i < numberOfProjectiles; i++)
                {
                    float   j     = ((float)(i * 1) / numberOfProjectiles);
                    float   angle = j * (Mathf.PI) * 2.0f;
                    float   x     = Mathf.Sin(angle) * circleRadius;
                    float   y     = Mathf.Cos(angle) * circleRadius;
                    Vector3 pos   = new Vector3(x, y, 0) + transform.position;

                    GameObject go = Instantiate(projectile, pos, Quaternion.identity);
                    go.transform.rotation = Quaternion.AngleAxis(Mathf.Rad2Deg * -angle, Vector3.forward);
                    TempProjectile tp = go.GetComponent <TempProjectile>();
                    go.layer         = LayerMask.NameToLayer("BossProjectile");
                    go.tag           = "OrcKingProjectile";
                    tp.damageAmount  = 1;
                    tp.speed         = projectileSpeed;
                    smashTimer       = smashCooldown;
                    canStartNewSmash = true;
                    smashy2Timer     = smashy2TimeDelay;
                }
            }
        }
    }