コード例 #1
0
    private void _RocketFiring()
    {
        // Once rockets start to fire...
        // Will only allow to fire rockets if not overheated
        // If overheated, the rocket incrementor will be reset
        // Once not overheated, the incrementor's control is released back to _Rockets()
        if (rocketIncrementor > 0 && !heatModel.overheated_Rockets)
        {
            rocketTimer += Time.deltaTime;
            if (rocketTimer >= gameModel.t_Rockets_FireRate)
            {
                rocketTimer -= gameModel.t_Rockets_FireRate;

                Vector3 newRocketDir = Vector3.Normalize(Random.insideUnitSphere);
                Vector3 newRocketPos = player.position + newRocketDir;

                GameObject g = assetManager.Make(MyGameAsset.SFX, newRocketPos);
                g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_RocketLaunch);

                g = assetManager.Make(MyGameAsset.Rocket, newRocketPos);
                g.GetComponent <Behavior_RocketsAlt>().Restart(newRocketPos, newRocketDir);
                //g.GetComponent<Behavior_Rocket>().ultimatePath = rocketPitch.up;
                rocketIncrementor++;
            }

            if (rocketIncrementor >= gameModel.i_Rockets_RocketCountMax || (playModel.leftStation != Stations.Rockets && playModel.rightStation != Stations.Rockets))
            {
                rocketIncrementor = 0;
            }
        }
        else if (heatModel.overheated_Rockets || playModel.currentPlayerState != PlayerState.Alive)
        {
            rocketIncrementor = 0;
        }
    }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Blocker")
        {
            GameObject g = assets.Make(MyGameAsset.SFX, transform.position);
            g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_EnemyBulletHit);

            SCG_EventManager.instance.Fire(new Event_BonusPoints(1));
            SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(null, 0, transform.position, this));
        }
        else if (other.tag == "Enemy")
        {
            GameObject g = assets.Make(MyGameAsset.SFX, transform.position);
            g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_EnemyBulletHit);

            Enemy_Base e = other.gameObject.GetComponent <Enemy_Base>();
            if (e != null)
            {
                //Debug.Log("Hit!");
                SCG_EventManager.instance.Fire(new Event_BonusPoints(2));
                if (bounced)
                {
                    SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(e, gameModel.d_Guns_Damage * 3, transform.position, this));
                }
                else
                {
                    SCG_EventManager.instance.Fire(new Event_PlayerBulletHit(e, gameModel.d_Guns_Damage, transform.position, this));
                }
            }
        }
    }
コード例 #3
0
    public void EventHandler(SCG_Event e)
    {
        Event_EnemyBulletHit bH = e as Event_EnemyBulletHit;

        if (bH != null)
        {
            oneShotSource.PlayOneShot(gameModel.sfx_EnemyBulletHit);
        }

        Event_PlayerShieldBlock sB = e as Event_PlayerShieldBlock;

        if (sB != null)
        {
            oneShotSource.PlayOneShot(gameModel.sfx_Shield_Block);
        }

        Event_PlayerExplode pE = e as Event_PlayerExplode;

        if (pE != null)
        {
            oneShotSource.PlayOneShot(gameModel.sfx_ShipExplode);
        }

        Event_LanceHit lH = e as Event_LanceHit;

        if (lH != null)
        {
            GameObject g = gameAssets.Make(MyGameAsset.SFX, lH.location);
            g.GetComponent <AudioSource>().PlayOneShot(gameModel.sfx_LanceHit);
        }
    }
コード例 #4
0
ファイル: Test_Swarm.cs プロジェクト: christopher0chung/LGSky
 private void ForceCleanup()
 {
     for (int i = _swarm.Count - 1; i >= 0; i--)
     {
         assetManager.Make(MyGameAsset.BulletExplosion, _swarm[i].transform.position);
     }
     SCG_EventManager.instance.Unregister <Event_EnemyDeath>(EnemyDeathEventHandler);
     SCG_EventManager.instance.Unregister <Event_DumpReg>(EnemyDeathEventHandler);
     Destroy(this.gameObject);
 }
コード例 #5
0
    private void _FiringController(bool shoot, bool release)
    {
        if (!heatModel.overheated_Guns)
        {
            heatModel.active_Guns = shoot;
            if (shoot)
            {
                shootTimer += Time.deltaTime;
                float lerpedTime   = Mathf.Lerp(gameModel.t_Guns_TimeBetweenShots_Min, gameModel.t_Guns_TimeBetweenShots_Max, heatModel.heat_Guns / 100);
                float lerpedSpread = Mathf.Lerp(gameModel.f_Guns_BulletDispersion_Max, gameModel.f_Guns_BulletDispersion_Min, heatModel.heat_Guns / 100);
                if (shootTimer - gameModel.t_Guns_SpinUpTime >= lerpedTime)
                {
                    shootTimer -= lerpedTime;
                    GameObject bullet;

                    Vector3 rando = Random.insideUnitCircle * lerpedSpread;


                    if (leftRightBarrel)
                    {
                        bullet = assetManager.Make(MyGameAsset.Bullet, guns.position - guns.right * .1f + guns.up * .7f);
                    }
                    else
                    {
                        bullet = assetManager.Make(MyGameAsset.Bullet, guns.position + guns.right * .1f + guns.up * .7f);
                    }

                    bullet.GetComponent <Rigidbody>().AddForce(guns.up * gameModel.s_Guns_BulletSpeed + rando, ForceMode.Impulse);
                    leftRightBarrel = !leftRightBarrel;
                    //myAS.PlayOneShot(gameModel.sfx_Gun_Shot);
                }
            }
            if (release)
            {
                shootTimer = 0;
            }
        }
        else
        {
            shootTimer            = 0;
            heatModel.active_Guns = false;
        }
    }
コード例 #6
0
 public void EventHandler(SCG_Event e)
 {
     if (playModel.shieldSize == gameModel.f_Shield_Cutoff_Min)
     {
         Event_PlayerShieldBlock psb = e as Event_PlayerShieldBlock;
         if (psb != null)
         {
             float outCome = Random.Range(0.000f, 1.0000f);
             if (outCome <= bouncePerc)
             {
                 GameObject bullet = assetManager.Make(MyGameAsset.Bullet, ServiceLocator.instance.Player.position + (Vector3)playModel.shieldDirection);
                 bullet.transform.localScale = Vector3.one * 5;
                 bullet.GetComponent <Behavior_Bullet>().bounced = true;
                 bullet.GetComponent <Rigidbody>().AddForce((Vector3)playModel.shieldDirection * gameModel.s_Guns_BulletSpeed * 2.8f, ForceMode.Impulse);
             }
         }
     }
 }