Beispiel #1
0
    //if bullet hits ship
    void OnTriggerEnter2D(Collider2D collider)
    {
        PlayerBullet pBullet = collider.gameObject.GetComponent <PlayerBullet>(); // if ship hit by own bullet (bullet hell)
        EnemyBullet  eBullet = collider.gameObject.GetComponent <EnemyBullet>();  // if ship hit by enemy bullet
        BossBullet   bBullet = collider.gameObject.GetComponent <BossBullet>();   // if ship hit by boss bullet
        BossLeft     bLeft   = collider.gameObject.GetComponent <BossLeft>();     // if ship hits boss left gun
        BossRight    bRight  = collider.gameObject.GetComponent <BossRight>();    // if ship hits boss right gun
        BossCore     bCore   = collider.gameObject.GetComponent <BossCore>();     // if ship hits boss core
        Upgrade      upgrade = collider.gameObject.GetComponent <Upgrade>();      // if ship hits an upgrade

        if (pBullet || eBullet || bBullet || bLeft || bRight || bCore)
        {
            laserCount--;
            AudioSource.PlayClipAtPoint(deathSound, transform.position);
            if (laserCount == 0)
            {
                Destroy(gameObject);
                GameObject shipExploding = Instantiate(explosion, transform.position, Quaternion.identity) as GameObject;
                Destroy(shipExploding, 1.0f);
                canvas.SetActive(true);
            }
        }

        if (upgrade)
        {
            laserCount++;
        }
    }
Beispiel #2
0
 // Each State have access to boss FSM (to change states), projectile, animator and enemy AI
 public BossState(BossFSM bossFSM, BossBullet projectile, Animator animator, NavMeshAgent pathFinder)
 {
     bossAnimator   = animator;
     bossFSMObject  = bossFSM;
     bossProjectile = projectile;
     bossPathFinder = pathFinder;
 }
Beispiel #3
0
    private void SpawnMeteor()
    {
        for (int i = 0; i < meteorCount; i++)
        {
            // Generate different angles
            float angleX = Random.Range(0, maxAngle);
            float angleZ = Random.Range(0, maxAngle);

            // Get X and Z component offset
            float difX = Mathf.Tan(angleX * Mathf.Deg2Rad) * height;
            float difZ = Mathf.Tan(angleZ * Mathf.Deg2Rad) * height;

            // Target and Spawn Pos
            Vector3 targetPos = new Vector3(nullAttackPoint.position.x + Random.Range(-radius, radius), nullAttackPoint.position.y, nullAttackPoint.position.z + Random.Range(-radius, radius));
            Vector3 spawnPos  = new Vector3(targetPos.x + difX, height, targetPos.z + difZ);

            /*
             * FOR TESTING PURPOSES
             * GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
             * cube.transform.position = targetPos;
             */

            // Spawn
            BossBullet ob = UnityEngine.Object.Instantiate(bossProjectile, spawnPos, Quaternion.identity);
            ob.transform.LookAt(targetPos);
        }
    }
Beispiel #4
0
        private void LaunchChargedAttack()
        {
            if (_chargedBullet == null)
            {
                return;
            }

            Vector2 launchPosition = _dualArmAttackPosition.GetGlobalPosition();
            float   launchAngle    = -Mathf.Rad2Deg(Mathf.Atan2(
                                                        launchPosition.x - PlayerVariables.LastPlayerPosition.x,
                                                        launchPosition.y - PlayerVariables.LastPlayerPosition.y
                                                        )) - 90;

            float   xVelocity      = Mathf.Cos(Mathf.Deg2Rad(launchAngle));
            float   yVelocity      = Mathf.Sin(Mathf.Deg2Rad(launchAngle));
            Vector2 launchVelocity = new Vector2(xVelocity, yVelocity);

            _dualArmAttackPosition.RemoveChild(_chargedBullet);
            _bulletHolder.AddChild(_chargedBullet);

            _chargedBullet.SetMode(RigidBody2D.ModeEnum.Rigid);
            _chargedBullet.LaunchBullet(launchVelocity.Normalized());
            _chargedBullet.SetAsDynamicBullet();
            _chargedBullet.SetGlobalPosition(launchPosition);
            _chargedBullet.SetGlobalScale(Vector2.One * _attackVariable_1);

            _chargedEffectDestroy.DestroyNode();

            _attackVariable_1     = 0;
            _chargedEffectDestroy = null;
            _chargedBullet        = null;
        }
Beispiel #5
0
    void PlayAttack03Effect()
    {
        GameObject go = GameObject.Instantiate(bossBulletPrefab, attack03Pos.position, attack03Pos.rotation) as GameObject;
        BossBullet bb = go.GetComponent <BossBullet>();

        bb.Damage = attackArray[2];
    }
Beispiel #6
0
    public override IEnumerator AttackRoutine(CharacterEntity player, BossController boss)
    {
        var bullets = new BossBullet[bulletsCount];

        for (int i = 0; i < bulletsCount; i++)
        {
            var angle = i * (360f / bulletsCount) - 90;

            var bullet = Instantiate(bulletPrefab, boss.transform.position, Quaternion.Euler(0, 0, angle));

            bullets[i] = bullet;
        }

        for (float t = 0; t < prepareTime; t += Time.deltaTime)
        {
            var p = (t / prepareTime);
            for (int i = 0; i < bulletsCount; i++)
            {
                var delta = bullets[i].transform.up * p * prepareDistance;
                bullets[i].transform.position = boss.transform.position + delta;
            }

            yield return(null);
        }

        for (int i = 0; i < bulletsCount; i++)
        {
            bullets[i].Fire(bulletSpeed);
        }

        isFinished = true;
    }
Beispiel #7
0
    public void ShowAttack03Effect()
    {
        GameObject go =
            GameObject.Instantiate(attack03Effect, attack03Pos.position, transform.rotation) as GameObject;
        BossBullet bb = go.GetComponent <BossBullet>();

        bb.Damage = damageArray[2];
    }
    void FireBullet()                                                   //I made this take x and y because I was thinking about it and different enemies will need to fire from different parts of their models
    {
        GameObject bulletObject = new GameObject();
        BossBullet bullet       = bulletObject.AddComponent <BossBullet>();

        bullet.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, 0);
        bullet.transform.rotation = new Quaternion(this.transform.rotation.x, this.transform.rotation.y, this.transform.rotation.z, this.transform.rotation.w);
    }
Beispiel #9
0
    void FireSwirl(int angle)                                                   //I made this take x and y because I was thinking about it and different enemies will need to fire from different parts of their models
    {
        GameObject bulletObject = new GameObject();
        BossBullet bullet       = bulletObject.AddComponent <BossBullet>();

        bullet.init(this);
        bullet.transform.position    = new Vector3(this.transform.position.x, this.transform.position.y, 0);
        bullet.transform.eulerAngles = new Vector3(0, 0, angle);
    }
 private void TryShoot()
 {
     if (lastShotTime + shootCoolDown < Time.time)
     {
         lastShotTime = Time.time;
         BossBullet bullet = Instantiate(prefabBossBullet, bulletSpawnPoint.transform.position, bulletSpawnPoint.transform.rotation, null);
         bullet.Fire(shotdamage, shotSpeed);
     }
 }
Beispiel #11
0
    void Fire()
    {
        fireCooldownCounter = fireCooldown;

        BossBullet tb = Instantiate(bullet, bulletPoint.position, transform.rotation);

        tb.damage = bulletDamage;
        tb.speed  = bulletSpeed;
        Destroy(tb.gameObject, 5f);
    }
Beispiel #12
0
 void FireBurst()
 {
     for (int x = 0; x <= 360; x = x + 10)
     {
         GameObject bulletObject = new GameObject();
         BossBullet bullet       = bulletObject.AddComponent <BossBullet>();
         bullet.init(this);
         bullet.transform.position    = new Vector3(this.transform.position.x, this.transform.position.y, 0);
         bullet.transform.eulerAngles = new Vector3(this.transform.position.x, this.transform.position.y, x);
     }
 }
Beispiel #13
0
        private void CreateChargedAttack()
        {
            // Charged Bullet
            _chargedBullet = (BossBullet)chargedBulletPrefab.Instance();
            _dualArmAttackPosition.AddChild(_chargedBullet);
            _chargedBullet.SetMode(RigidBody2D.ModeEnum.Kinematic);
            _chargedBullet.SetGlobalPosition(_dualArmAttackPosition.GetGlobalPosition());
            _chargedBullet.SetAsStaticBullet();

            // Charged Bullet Effect
            _chargedEffectDestroy = (DestroyNodeForced)chargingEffectPrefab.Instance();
            _dualArmAttackPosition.AddChild(_chargedEffectDestroy);
        }
Beispiel #14
0
    public void init(BossBullet 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 = "BossBullet 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/bossBullet");            // Set the texture.  Must be in Resources folder.
        //mat.color = new Color(1,1,1);
    }
Beispiel #15
0
    public Rage(BossFSM bossFSM, BossBullet projectile, Animator animator, NavMeshAgent pathFinder, Transform bossZero, Boss bossObject) : base(bossFSM, projectile, animator, pathFinder)
    {
        bossReference = bossObject;

        bossZeroPoint    = bossZero;
        frontAttackPoint = bossZeroPoint.GetChild(0).transform;

        // Shooting delay
        delayAttackTime = 2f;

        // Angle to rotate
        angleToRotate = (360 / pointsCount) * Mathf.Deg2Rad;
    }
Beispiel #16
0
        private void LaunchBullet()
        {
            BossBullet bossBulletInstance = (BossBullet)bulletPrefab.Instance();

            _bulletHolder.AddChild(bossBulletInstance);

            bossBulletInstance.SetGlobalPosition(_bossAttackPoint.GetGlobalPosition());

            float   xVelocity    = Mathf.Cos(Mathf.Deg2Rad(_currentAngle));
            float   yVelocity    = Mathf.Sin(Mathf.Deg2Rad(_currentAngle));
            Vector2 launchVector = new Vector2(xVelocity, yVelocity);

            bossBulletInstance.LaunchBullet(launchVector.Normalized());
        }
Beispiel #17
0
    // Update is called once per frame
    void Update()
    {
        shotTimer += Time.deltaTime;
        if (shotTimer > shotTimerMax)
        {
            PlayerMovement player = FindObjectOfType <PlayerMovement>();

            Vector2 direction = player.transform.position - transform.position;
            direction.Normalize();
            BossBullet  proj            = Instantiate(projectilePrefab, direction, Quaternion.identity).GetComponent <BossBullet>();
            Rigidbody2D rigidBodyBullet = proj.GetComponent <Rigidbody2D>();
            proj.transform.position  = transform.position;
            rigidBodyBullet.velocity = direction * projectileSpeed * 2;
            shotTimer = 0;
        }
    }
Beispiel #18
0
        private void LaunchSingleArmAttack(Vector2 attackPosition)
        {
            BossBullet bulletInstance = (BossBullet)singleArmBulletPrefab.Instance();

            _bulletHolder.AddChild(bulletInstance);

            float   xVelocity      = Mathf.Cos(Mathf.Deg2Rad(_attackVariable_1));
            float   yVelocity      = Mathf.Sin(Mathf.Deg2Rad(_attackVariable_1));
            Vector2 launchVelocity = new Vector2(xVelocity, yVelocity);

            bulletInstance.SetGlobalPosition(attackPosition);
            bulletInstance.LaunchBullet(launchVelocity);

            _attackVariable_1 += singeArmAttackAngleDiff;
            _attackVariable_1  = ExtensionFunctions.To360Angle(_attackVariable_1);
        }
Beispiel #19
0
    public virtual void CreateBlock()
    {
        GameObject mgr = GameObject.Find("ShootMgr");

        TetrisPos = GameObject.Find("ShootMgr").GetComponent <TetrisMgr>().TetrisPos;
        int   iCurrentY = GameObject.Find("BOSS").GetComponent <BossBehavior>().iCurrentMoveIndex / 2;
        float xPos      = 0;
        float yPos      = 0;

        for (int i = 0; i < transform.childCount; i++)
        {
            BossBullet pbullet = transform.GetChild(i).GetComponent <BossBullet>();
            pbullet.iXPos  = 25 - (int)(Blocksize.x) + pbullet.iXPos2;
            pbullet.iYPos  = 4 - (int)(Blocksize.y) + pbullet.iYPos2;
            pbullet.TetMgr = mgr.GetComponent <TetrisMgr>();
        }
    }
Beispiel #20
0
    // Start is called before the first frame update
    void Start()
    {
        point     = new List <Transform>();
        cloneList = new List <GameObject>();

        for (int i = 0; i < transform.childCount; i++)
        {
            point.Add(transform.GetChild(i));
        }

        for (int i = 0; i < point.Count; i++)
        {
            BossBullet clone = Instantiate(bossBullet, point[i].position, point[i].rotation);
            clone.gameObject.SetActive(false);
            cloneList.Add(clone.gameObject);
        }
    }
Beispiel #21
0
    // Update is called once per frame
    void Update()
    {
        healthText.text = "Boss Health: " + health.ToString();
        if (health <= 0)
        {
            healthText.text = "Boss Health: 0";

            _particles.transform.position = gameObject.transform.position;
            _particles.Play();
            GameManager end = FindObjectOfType <GameManager>();
            end.OpenWin();
            Destroy(gameObject);
        }
        if (health <= 70 && health >= 31)
        {
            Boss3BulletSpawner[] weapons = FindObjectsOfType <Boss3BulletSpawner>();
            for (int i = 0; i < weapons.Length; i++)
            {
                Destroy(weapons[i]);
            }
            shotTimer += Time.deltaTime;
            if (shotTimer > shotTimerMax)
            {
                PlayerMovement player = FindObjectOfType <PlayerMovement>();

                Vector2 direction = player.transform.position - transform.position;
                direction.Normalize();
                BossBullet  proj            = Instantiate(projectilePrefab, direction, Quaternion.identity).GetComponent <BossBullet>();
                Rigidbody2D rigidBodyBullet = proj.GetComponent <Rigidbody2D>();
                proj.transform.position   = new Vector2(transform.position.x, transform.position.y + 7.0f);
                proj.transform.localScale = proj.transform.localScale * 2;
                rigidBodyBullet.velocity  = direction * projectileSpeed * 2;
                shotTimer = 0;
            }
        }
        if (health <= 30)
        {
            transform.position = new Vector2(transform.position.x, transform.position.y - 0.001f);
            if (transform.position.y <= -4)
            {
                PlayerMovement player = FindObjectOfType <PlayerMovement>();
                Destroy(player);
            }
        }
    }
Beispiel #22
0
    public void BossBulletClass(AnotherVec2 a_vcDir, float a_fSpeed, char c)
    {
        Random BbRandom = new Random();

        int nBbPosX = BbRandom.Next(10, 65);

        if (BliPool.Count == 0)
        {
            BbMake(nMAKE_DEFAULT_COUNT);
        }

        BossBullet Bbullet = BbliPool[BbliPool.Count - 1];

        BbliPool.RemoveAt(BbliPool.Count - 1);

        Bbullet.Init(4.0F, nBbPosX, 15, a_vcDir, a_fSpeed, c);
        BbliActive.Add(Bbullet);
    }
Beispiel #23
0
    /// <summary>
    ///
    /// </summary>
    void attack2()
    {
        foreach (var item in m_dirsList)
        {
            Vector3 dir = item;

            GameObject go = Instantiate(m_cloneBullet);
            if (go != null)
            {
                go.transform.localPosition = transform.localPosition;

                BossBullet bullect = go.GetComponent <BossBullet>();
                if (bullect != null)
                {
                    bullect.Init(dir, 2f);
                }
            }
        }
    }
    void Launch2()
    {
        //Tao projectile

        float xSpread = Random.Range(-1, 2);

        float             ySpread = Random.Range(-1, 1);
        Vector2           direction1;
        List <GameObject> projectileObject = new List <GameObject>();

        for (int i = 0; i < 10; i++)
        {
            GameObject newProjectileObject = Instantiate(projectilePrefab2, rigidbody2d.position + Vector2.left * 0f + Vector2.up * 0f, Quaternion.identity);

            projectileObject.Add(newProjectileObject);
            xSpread = Random.Range(-1, 2);
            ySpread = Random.Range(-1, 2);
            if (xSpread <= 0)
            {
                xSpread = Random.Range(-1.5f, -0.5f);
            }
            else if (xSpread > 0)
            {
                xSpread = Random.Range(0.5f, 1.5f);
            }
            if (ySpread <= 0)
            {
                ySpread = Random.Range(-1.5f, -0.5f);
            }
            else if (ySpread > 0 || (ySpread == 0 && xSpread == 0))
            {
                ySpread = Random.Range(0.5f, 1.5f);
            }

            Debug.Log("xSpread: " + xSpread + " ySpread: " + ySpread);

            direction1 = new Vector2(xSpread, ySpread);
            BossBullet projectile1 = newProjectileObject.GetComponent <BossBullet>();
            projectile1.SetDirection(direction1);
        }
        //animator.SetTrigger("Launch");
    }
Beispiel #25
0
    /// <summary>
    /// 向角色发起定向攻击
    /// </summary>
    void attack1()
    {
        foreach (var item in LevelManager.Instance.AllPlayerList)
        {
            GameObject go = Instantiate(m_cloneBullet);
            if (go != null)
            {
                go.transform.localPosition = transform.localPosition;

                BossBullet bullect = go.GetComponent <BossBullet>();
                if (bullect != null)
                {
                    Actor   target = item;
                    Vector3 dir    = target.transform.localPosition - transform.localPosition;

                    bullect.Init(dir);
                }
            }
        }
    }
Beispiel #26
0
        private void LaunchBullets()
        {
            _isOffsetUsed = !_isOffsetUsed;

            for (int i = 0; i < bulletsInEachRow; i++)
            {
                BossBullet bossBulletInstance = (BossBullet)bulletPrefab.Instance();
                _bulletHolder.AddChild(bossBulletInstance);

                float   indexRatio    = (float)i / bulletsInEachRow;
                Vector2 finalPosition = _spawnLeftMostPoint.GetGlobalPosition().LinearInterpolate(_spawnRightMostPoint.GetGlobalPosition(), indexRatio);
                if (_isOffsetUsed)
                {
                    finalPosition.x += bulletGapOffset;
                }

                bossBulletInstance.SetGlobalPosition(finalPosition);
                bossBulletInstance.LaunchBullet(bulletDefaultVelocity.Normalized());
            }
        }
Beispiel #27
0
        private void LaunchBullet()
        {
            float currentShotAngle = _currentAngle;
            float angleDiff        = 360.0f / eachShotBulletCount;

            for (int i = 0; i < eachShotBulletCount; i++)
            {
                BossBullet bossBulletInstance = (BossBullet)bulletPrefab.Instance();
                _bulletHolder.AddChild(bossBulletInstance);

                bossBulletInstance.SetGlobalPosition(_bossAttackPoint.GetGlobalPosition());

                float   xVelocity    = Mathf.Cos(Mathf.Deg2Rad(currentShotAngle));
                float   yVelocity    = Mathf.Sin(Mathf.Deg2Rad(currentShotAngle));
                Vector2 launchVector = new Vector2(xVelocity, yVelocity);
                bossBulletInstance.LaunchBullet(launchVector.Normalized());

                currentShotAngle += angleDiff;
                currentShotAngle  = ExtensionFunctions.To360Angle(currentShotAngle);
            }
        }
Beispiel #28
0
        private void LaunchSprayShot()
        {
            float angleDiff         = 360.0f / totalSprayShotBullets;
            float currentSprayAngle = _currentRotationAmount;

            for (int i = 0; i < totalSprayShotBullets; i++)
            {
                BossBullet bossBulletInstance = (BossBullet)bulletPrefab.Instance();
                _bulletHolder.AddChild(bossBulletInstance);

                bossBulletInstance.SetGlobalRotationDegrees(currentSprayAngle + rotationOffset);
                bossBulletInstance.SetGlobalPosition(_bossAttackPoint.GetGlobalPosition());

                float   xVelocity    = Mathf.Cos(Mathf.Deg2Rad(currentSprayAngle));
                float   yVelocity    = Mathf.Sin(Mathf.Deg2Rad(currentSprayAngle));
                Vector2 launchVector = new Vector2(xVelocity, yVelocity);
                bossBulletInstance.LaunchBullet(launchVector);

                currentSprayAngle += angleDiff;
            }
        }
Beispiel #29
0
 public Sorcerer(BossFSM bossFSM, BossBullet projectile, Animator animator, NavMeshAgent pathFinder, Transform starAttackPointParent) : base(bossFSM, projectile, animator, pathFinder)
 {
     starAttackPoints = starAttackPointParent;
 }
Beispiel #30
0
 private void OnGetBullet(BossBullet bullet)
 {
     bullet.gameObject.SetActive(true);
     bullet.OnDeath += pool.ReleaseObject;
 }