Esempio n. 1
0
    // Use this for initialization
    public void init(GameManager owner, int type)
    {
        bossType  = type;
        this.name = "Boss";
        m         = owner;

        if (bossType == 1)
        {
            speed           = m.bossSpeed;
            chargeSpeed     = m.bossSpeed * this.chargeMultiplier;
            this.bossHealth = 100;
            var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);                   // Create a quad object for holding the gem texture.
            model1 = modelObject.AddComponent <BossModel> ();                                   // Add a marbleModel script to control visuals of the gem.
            model1.init(this);
            this.bossHit  = m.bossHit;
            this.bossHitX = m.bossHitX;
            this.bossDead = m.bossDead;
            BoxCollider2D bossbody  = gameObject.AddComponent <BoxCollider2D> ();
            Rigidbody2D   bossRbody = gameObject.AddComponent <Rigidbody2D> ();
            bossRbody.gravityScale = 0;
            bossbody.isTrigger     = true;
            transform.localScale   = new Vector3(2f, 2f, 1);
        }
        else if (bossType == 2)
        {
            speed           = 1.8f;
            this.speed      = m.bossSpeed;
            this.charge     = false;
            this.flicker    = false;
            chargeSpeed     = m.bossSpeed * this.chargeMultiplier;
            this.bossHealth = 100;
            var modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad);                   // Create a quad object for holding the gem texture.
            model2 = modelObject.AddComponent <Boss2Model>();                                   // Add a marbleModel script to control visuals of the gem.
            model2.init(this);

            BoxCollider2D bossbody  = gameObject.AddComponent <BoxCollider2D> ();
            Rigidbody2D   bossRbody = gameObject.AddComponent <Rigidbody2D> ();
            bossRbody.gravityScale = 0;
            bossbody.isTrigger     = true;

            transform.localScale = new Vector3(3f, 3f, 1);

            GameObject shieldObject = new GameObject();
            BossShield shield       = shieldObject.AddComponent <BossShield>();
            shield.init(this);
            shield.transform.position = new Vector3(this.transform.position.x + 3.5f, this.transform.position.y + 2.7f, 0);

            shieldDead    = false;
            this.bossHit  = m.bossHit;
            this.bossHitX = m.bossHitX;
            this.bossDead = m.bossDead;
        }
    }
Esempio n. 2
0
    public void init(BossShield owner)
    {
        this.owner = owner;

        transform.parent        = owner.transform;                      // Set the model's parent to the gem.
        transform.localPosition = new Vector3(0, 0, 0);                 // Center the model on the parent.
        name = "Boss Model";                                            // Name the object.

        mat             = GetComponent <Renderer>().material;
        mat.shader      = Shader.Find("Sprites/Default");                               // Tell the renderer that our textures have transparency. // Get the material component of this quad object.
        mat.mainTexture = Resources.Load <Texture2D>("Textures/Boss2shield");           // Set the texture.  Must be in Resources folder.
    }
Esempio n. 3
0
    private void CheckTarget()
    {
        RaycastHit hitInfo;

        // Boss shield layer
        if (targetLayer == 9 && Physics.Raycast(transform.position, Direction, out hitInfo, maxLength, 1 << 16, QueryTriggerInteraction.Collide))
        {
            GenerateRay(hitInfo.point);

            BossShield shield = hitInfo.transform.GetComponent <BossShield>();
            if (shield != null)
            {
                shield.CreateEnemyRay(hitInfo.point, Direction);
            }
        }
        else if (Physics.Raycast(transform.position, Direction, out hitInfo, maxLength, 1 << targetLayer))
        {
            GenerateRay(hitInfo.point);
        }
        else if (Physics.Raycast(transform.position, Direction, out hitInfo, maxLength, 1 << 10))
        {
            GenerateRay(hitInfo.point);

            // Check for destructible item
            PolyExplosionThreeDimensional destructible = hitInfo.transform.gameObject.GetComponent <PolyExplosionThreeDimensional>();
            if (destructible != null)
            {
                destructible.DecrementHealth(Damage);
                SpawnDeathParticle(hitInfo.transform.position);
            }
        }
        else
        {
            float distanceOffset = UnityEngine.Random.Range(0f, lengthOffset);

            //Define first an last point.
            GenerateRay(transform.position + Direction * (maxLength + distanceOffset));
        }

        // Check if the hit-object can take damage
        if (hitInfo.transform != null && hitInfo.transform.gameObject.GetComponent <MonoBehaviour>() is IDamageable)
        {
            try
            {
                (hitInfo.transform.gameObject.GetComponent <MonoBehaviour>() as IDamageable).TakeDamage(Damage, this.OwnerScript);
            }
            catch (Exception e)
            {
                Debug.Log("<color='ff0000'>[PerlinRay]: Hit info IDamageable error.</color>\n" + e.ToString());
            }
            SpawnDeathParticle(hitInfo.transform.position);
        }
    }
Esempio n. 4
0
    void Shield()
    {
        GameObject obj = GameManager.Inst().ObjManager.MakeObj("BossLaser");

        obj.transform.position = BigBulletPos.transform.position;
        obj.transform.rotation = BigBulletPos.transform.rotation;

        BossShield bullet = obj.gameObject.GetComponent <BossShield>();

        bullet.Fall();

        GameManager.Inst().SodManager.PlayEffect("Bs_Normal");
    }
Esempio n. 5
0
    protected override void Start()
    {
        base.Start();
        spawnCount++;

        // Set boss health based on the playercount
        if (PlayerManager.PlayerCount == 1)
        {
            MaxHealth = (int)(lifeSetting.onePlayer * Health);
            Health    = MaxHealth;

            BossShield s = GetComponentInChildren <BossShield>();
            if (s != null)
            {
                s.gameObject.SetActive(false);
            }
        }
        else if (PlayerManager.PlayerCount == 2)
        {
            MaxHealth = (int)(lifeSetting.twoPlayers * Health);
            Health    = MaxHealth;
        }
        else if (PlayerManager.PlayerCount == 3)
        {
            MaxHealth = (int)(lifeSetting.threePlayers * Health);
            Health    = MaxHealth;
        }

        // Add health value when the boss is spawned more often.
        if (spawnCount > 1)
        {
            MaxHealth = MaxHealth + ((spawnCount - 1) * additionHealthPerWave);
            Health    = MaxHealth;
        }

        turbineParticles = GetComponentsInChildren <ParticleSystem>();

        // Fire spawn event.
        OnBossSpawned();
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        xpos    = transform.position.x;
        ypos    = transform.position.y;
        targetx = m.GetTargetX();
        targety = m.GetTargetY();

        if (bossType == 1)
        {
            if (!usingBlades)
            {
                if ((targety - this.transform.position.y) <= 0 && !charge)
                {
                    float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(targety - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2)));
                    float sign  = (targetx - this.transform.position.x) / Mathf.Abs(targetx - this.transform.position.x);
                    transform.eulerAngles = new Vector3(0, 0, 180 + (sign * angle));
                }
                else if ((targety - this.transform.position.y) > 0 && !charge)
                {
                    float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(targety - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2)));
                    float sign  = (targetx - this.transform.position.x) / Mathf.Abs(targetx - this.transform.position.x);
                    transform.eulerAngles = new Vector3(0, 0, 0 + (sign * angle * -1));
                }
                else
                {
                    transform.Translate(Vector3.up * chargeSpeed * Time.deltaTime);
                    charging = charging - Time.deltaTime;

                    if (charging <= 0)
                    {
                        charge = false;



                        chargecd = 1;
                    }
                }
            }

            if (!usingBlades)
            {
                if ((Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2))) >= 3.5f)
                {
                    slow = true;
                    int x = Random.Range(0, 550);
                    if (x == 0)
                    {
                        if (bossHealth >= 50)
                        {
                            if (chargecd <= 0)
                            {
                                if (!charge)
                                {
                                    charge   = true;
                                    charging = 1.3f;
                                }
                            }
                        }
                        else
                        {
                            if (swirlCooldown <= 0)
                            {
                                swirling   = true;
                                swirlangle = 0;
                            }
                        }
                    }
                    if (swirling && bulletCooldown <= 0)
                    {
                        FireSwirl(swirlangle);
                        swirlangle     = swirlangle + 10;
                        bulletCooldown = .05f;
                        if (swirlangle == 360)
                        {
                            swirling      = false;
                            swirlCooldown = 1;
                        }
                    }
                    else if ((Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2))) >= 5.5f && !swirling)
                    {
                        slow = false;
                        if (beamCooldown <= 0)
                        {
                            FireBeam();
                            beamCooldown = 1;
                        }
                        beamCooldown = beamCooldown - Time.deltaTime;
                    }
                    else if (bulletCooldown <= 0)
                    {
                        FireBullet();
                        bulletCooldown = .6f;
                    }
                    else
                    {
                        chargecd       = chargecd - Time.deltaTime;
                        bulletCooldown = bulletCooldown - Time.deltaTime;
                        swirlCooldown  = swirlCooldown - Time.deltaTime;
                    }
                }
                else if ((Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2))) < 3.5f)
                {
                    if (bladeCooldown <= 0)
                    {
                        SpawnBlades();
                        usingBlades   = true;
                        bladeDuration = 1f;
                        bladeCooldown = 1.5f;
                    }
                    else if (!usingBlades)
                    {
                        bladeCooldown = bladeCooldown - Time.deltaTime;
                    }
                }
            }

            if (usingBlades)
            {
                bladeDuration = bladeDuration - Time.deltaTime;

                if (bladeDuration <= 0)
                {
                    usingBlades = false;
                    blade.Retract();
                }
            }

            if (this.bossHealth <= 0)
            {
                //Destroy (this.gameObject);
                if (this.bossType == 1)
                {
                    m.PlayEffect(bossDead);
                }
            }
        }
        else if (bossType == 2)
        {
            if ((targety - this.transform.position.y) <= 0 && !charge)
            {
                float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(targety - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2)));
                float sign  = (targetx - this.transform.position.x) / Mathf.Abs(targetx - this.transform.position.x);
                transform.eulerAngles = new Vector3(0, 0, 180 + (sign * angle));
            }
            else if ((targety - this.transform.position.y) > 0 && !charge)
            {
                float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(targety - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((targetx - this.transform.position.x), 2) + Mathf.Pow((targety - this.transform.position.y), 2)));
                float sign  = (targetx - this.transform.position.x) / Mathf.Abs(targetx - this.transform.position.x);
                transform.eulerAngles = new Vector3(0, 0, 0 + (sign * angle * -1));
            }
            if (shieldDead)
            {
                shieldcharge = shieldcharge - Time.deltaTime;
                if (shieldcharge <= 0)
                {
                    shieldDead = false;
                    GameObject shieldObject = new GameObject();
                    BossShield shield       = shieldObject.AddComponent <BossShield>();
                    shield.init(this);
                    shield.transform.position = new Vector3(this.transform.position.x - .5f, this.transform.position.y + .5f, 0);
                }
            }
            else
            {
                int x = Random.Range(0, 7);
                if (!charge)
                {
                    if (attackCD <= 0)
                    {
                        attackCD = 1.5f;
                        if (x < 5)
                        {
                            FireTracer();
                        }
                        else
                        {
                            charge = true;
                            StartCoroutine(flickerRoutine());
                            this.m.PlayEffect(this.m.charging);
                            recharging = 1.5f;
                        }
                    }
                }
                else
                {
                    recharging = recharging - Time.deltaTime;
                    if (recharging <= 0)
                    {
                        charge = false;
                        StopCoroutine(flickerRoutine());
                        this.model2.mat.mainTexture = Resources.Load <Texture2D>("Textures/boss2d0");
                        if (x < 3)
                        {
                            FireAOE();
                        }
                        else
                        {
                            FireBurst();
                        }
                    }
                }

                attackCD = attackCD - Time.deltaTime;
            }
        }
    }