コード例 #1
0
 void Explode()
 {
     _billboard.SetActive(false);
     _mesh.SetActive(false);
     GlobalSoundManager.instance.PlayStopEmp(false);
     GlobalSoundManager.instance.PlayClip(GlobalSounds.EmpExplode, SourcePosition.Center, 1);
     _camController.AddScreenShake(3.0f, 5.0f, 0.2f, true);
     _targetThruster.Discharge();
     _destroy = true;
 }
コード例 #2
0
    void Explode()
    {
        GameObject       cam  = GameObject.FindGameObjectWithTag("MainCamera");
        CameraController camC = null;

        if (cam)
        {
            camC = cam.GetComponent <CameraController>();
        }
        if (camC)
        {
            camC.AddScreenShake(10.0f, 2.0f, 0.5f, true);
        }
        Instantiate(ExplosionPrefab, transform.position, Quaternion.identity);
        GlobalSoundManager.instance.PlayClip(GlobalSounds.GrenadeExplode, SourcePosition.Center, 1);
        ObjectController objCont = this.GetComponent <ObjectController>();

        if (objCont != null)
        {
            objCont.Destroy();
        }
    }
コード例 #3
0
    void Update()
    {
        if (UpgradeTimer < 1.5f)
        {
            if (!floorAnimator.active)
            {
                floorAnimator.ActivateUpgradeAnimation();
            }
        }
        //Move Wall
        float leftVolume  = 0;
        float rightVolume = 0;

        float wallForce = 0;

        for (int i = 0; i < NumThrusters; i++)
        {
            wallForce  += LeftThrusters[i].Thrust;
            leftVolume += LeftThrusters[i].Thrust;

            wallForce   -= RightThrusters[i].Thrust;
            rightVolume += RightThrusters[i].Thrust;
        }
        float moveMult = MovementMultiplier + UpgradeMultiplier * _upgradeLevel * _upgradeLevel;

        _movement += wallForce * moveMult * Time.deltaTime;
        _movement -= MovementDampener * _movement * Time.deltaTime;

        if (Mathf.Abs(transform.position.z) < MaxFieldWidth)
        {
            transform.position += new Vector3(0, 0, _movement) * Time.deltaTime;
        }

        GlobalSoundManager.instance.SetThrusterVolume(true, leftVolume * 2);
        GlobalSoundManager.instance.SetThrusterVolume(false, rightVolume * 2);
        _camera.AddScreenShake((leftVolume + rightVolume) * 0.4f, 2, 0.3f);

        //Upgrade Thrusters
        _upgradeTimer += Time.deltaTime;
        if (_upgradeTimer > UpgradeTime && _upgradeLevel <= 2)
        {
            _upgradeLevel++;
            for (int i = 0; i < NumThrusters; i++)
            {
                LeftThrusters[i].UpgradeLevel = _upgradeLevel;
                Instantiate(UpgradePrefab, LeftThrusters[i].transform.position - new Vector3(0, 0, 1), Quaternion.identity);
                RightThrusters[i].UpgradeLevel = _upgradeLevel;
                Instantiate(UpgradePrefab, RightThrusters[i].transform.position + new Vector3(0, 0, 1), Quaternion.identity);
                if (_upgradeLevel == 1)
                {
                    GlobalSoundManager.instance.PlayClip(GlobalSounds.Thruster1, SourcePosition.Center, 1);
                }
                else if (_upgradeLevel == 2)
                {
                    GlobalSoundManager.instance.PlayClip(GlobalSounds.Thruster2, SourcePosition.Center, 1);
                }
            }
            _upgradeTimer = 0;
        }
        else if (_upgradeLevel > 2)
        {
            _upgradeTimer = 0;
        }

        //end state
        if (transform.position.z > FieldWidth)
        {
            //left player wins
            LeftWon = true;
        }
        else if (transform.position.z < -FieldWidth)
        {
            //right player wins
            RightWon = true;
        }

        if (LeftWon)
        {
            foreach (var thruster in RightThrusters)
            {
                Instantiate(ExplosionPrefab, thruster.transform.position, Quaternion.identity);
            }
        }
        else if (RightWon)
        {
            foreach (var thruster in LeftThrusters)
            {
                Instantiate(ExplosionPrefab, thruster.transform.position, Quaternion.identity);
            }
        }
    }