Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        /*
         * layerOn = DJ_Util.isLayerOn(gameObject.GetComponent<DJ_BeatActivation>());
         * if (layerOn)
         * {
         *  gameObject.GetComponent<MeshRenderer>().enabled = true;
         *  gameObject.GetComponent<BoxCollider>().enabled = true;
         * }
         * onBeat = DJ_Util.activateWithNoSound(gameObject.GetComponent<DJ_BeatActivation>());
         */

        if (_activationScript.instrument1)
        {
            fadeOutSpeed = DJ_BeatManager.GetNextLayerOneOn();;
        }
        if (_activationScript.instrument2)
        {
            fadeOutSpeed = DJ_BeatManager.GetNextLayerTwoOn();;
        }
        if (_activationScript.instrument3)
        {
            fadeOutSpeed = DJ_BeatManager.GetNextLayerThreeOn();;
        }
        if (_activationScript.instrument4)
        {
            fadeOutSpeed = DJ_BeatManager.GetNextLayerFourOn();;
        }

        onBeat = DJ_Util.activateWithSound(gameObject.GetComponent <DJ_BeatActivation>());
        if (onBeat)
        {
            gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 1);
            gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 2);
            //goes to target when it reaches its target then shrink
            HOTween.To(transform, .2f, target.OnComplete(Shrink));
            retracting = false;
            //gameObject.renderer.material = dangerShader;
        }

        if (fadeOut)
        {
            currAlpha        = gameObject.GetComponent <Renderer>().material.GetFloat("_Alpha");
            lerpA            = Mathf.Lerp(currAlpha, fadeOutAlpha, fadeOutSpeed * Time.deltaTime);
            currGlowStrength = gameObject.GetComponent <Renderer>().material.GetFloat("_GlowStrength");
            lerpG            = Mathf.Lerp(currGlowStrength, fadeOutGlow, fadeOutSpeed * Time.deltaTime);
            gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", lerpA);
            gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", lerpG);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (firstTime)
        {
            firstTime = false;

            DJ_BeatManager.ActivateLayerOne();
            DJ_BeatManager.ActivateLayerTwo();
            DJ_BeatManager.ActivateLayerThree();
            DJ_BeatManager.ActivateLayerFour();

            this.gameObject.SetActive(false);
        }
    }
Exemplo n.º 3
0
 private void Shrink()
 {
     if (gameObject.GetComponent <DJ_BeatActivation>().instrument1)
     {
         HOTween.To(transform, DJ_BeatManager.GetNextLayerOneOn(), origin);
     }
     else if (gameObject.GetComponent <DJ_BeatActivation>().instrument2)
     {
         HOTween.To(transform, DJ_BeatManager.GetNextLayerTwoOn(), origin);
     }
     else if (gameObject.GetComponent <DJ_BeatActivation>().instrument3)
     {
         HOTween.To(transform, DJ_BeatManager.GetNextLayerThreeOn(), origin);
     }
     else if (gameObject.GetComponent <DJ_BeatActivation>().instrument4)
     {
         HOTween.To(transform, DJ_BeatManager.GetNextLayerFourOn(), origin);
     }
     retracting = true;
     fadeOut    = true;
     //gameObject.renderer.material = safeShader;
 }
Exemplo n.º 4
0
 public void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.CompareTag(DJ_Tag.DJ_Player.ToString()))
     {
         if (layer1)
         {
             DJ_BeatManager.ActivateLayerOne();
         }
         if (layer2)
         {
             DJ_BeatManager.ActivateLayerTwo();
         }
         if (layer3)
         {
             DJ_BeatManager.ActivateLayerThree();
         }
         if (layer4)
         {
             DJ_BeatManager.ActivateLayerFour();
         }
         gameObject.SetActive(false);
     }
 }
Exemplo n.º 5
0
    //void OnEnable()
    //{
    //    //UnityEditor.EditorApplication.update += Animate;
    //    laserGO.transform.parent = this.transform;
    //    Wall1.transform.parent = this.transform;
    //    Wall2.transform.parent = this.transform;

    //    Position = (EndPos + StartPos) / 2;

    //    Debug.Log("Enabling lazer animation");
    //}

    //void OnDisable()
    //{
    //    UnityEditor.EditorApplication.update -= Animate;
    //    Debug.Log("Disabling lazer animation");
    //}

    /// <summary>
    /// do the in editor animation
    /// </summary>
    public void Animate()
    {
        //calc the vector perpendicular to the direction of the animation path
        Vector3 right = Vector3.Cross(Dir, Vector3.up);

        //change the positions of the walls based on the gap distance
        //and offset part of the scale
        Wall1.transform.position = Position - right * (gapDist / 2 + Wall1.transform.localScale.x / 2)
                                   + Vector3.up * heightOffGround;
        Wall2.transform.position = Position + right * (gapDist / 2 + Wall2.transform.localScale.x / 2)
                                   + Vector3.up * heightOffGround;

        lightSource.position = Wall1.transform.position;
        target.position      = Wall2.transform.position;

        //make sure the laser object is centered between the walls
        laserGO.transform.position = (Wall2.transform.position + Wall1.transform.position) / 2;


        //set the scale of the laser so that it spans the distance betweens the  walls
        Vector3 scale = laserGO.transform.localScale;

        scale.y = (Vector3.Distance(Wall1.transform.position, Wall2.transform.position) - Wall1.transform.localScale.x) / 2;

        laserGO.transform.localScale = scale;

        laserTilePos.X = Mathf.RoundToInt(laserGO.transform.position.x);
        laserTilePos.Y = Mathf.RoundToInt(laserGO.transform.position.z);

        layerOn = DJ_Util.isLayerOn(gameObject.GetComponent <DJ_BeatActivation>());
        if (layerOn)
        {
            laserGO.GetComponent <MeshRenderer>().enabled         = true;
            laserGO.GetComponent <CapsuleCollider>().enabled      = true;
            lightSource.GetComponent <ParticleRenderer>().enabled = true;
        }

        onBeat = DJ_Util.activateWithNoSound(gameObject.GetComponent <DJ_BeatActivation>());
        if (moving == false && onBeat == true)
        {
            moving = true;

            if (gameObject.GetComponent <DJ_BeatActivation>().instrument1)
            {
                timeTillNextBeat = DJ_BeatManager.GetNextLayerOneOn();
            }
            else if (gameObject.GetComponent <DJ_BeatActivation>().instrument2)
            {
                timeTillNextBeat = DJ_BeatManager.GetNextLayerTwoOn();
            }
            else if (gameObject.GetComponent <DJ_BeatActivation>().instrument3)
            {
                timeTillNextBeat = DJ_BeatManager.GetNextLayerThreeOn();
            }
            else if (gameObject.GetComponent <DJ_BeatActivation>().instrument4)
            {
                timeTillNextBeat = DJ_BeatManager.GetNextLayerFourOn();
            }
        }

        if (moving)
        {
            currAnimationTime += Time.deltaTime;
            // Go to starting Position
            if (easeOut)
            {
                Position = Vector3.Lerp(Position, startPos, currAnimationTime * timeTillNextBeat);
                if (Vector3.Distance(Position, startPos) < .001f)
                //if (currAnimationTime > animationTime)
                {
                    currAnimationTime = 0.0f;
                    easeOut           = false;
                    easeIn            = true;
                    Position          = startPos;
                    moving            = false;
                }
            }
            // go to ending position
            else if (easeIn)
            {
                Position = Vector3.Lerp(Position, endPos, currAnimationTime * timeTillNextBeat);
                if (Vector3.Distance(Position, endPos) < .001f)
                //if (currAnimationTime > animationTime)
                {
                    currAnimationTime = 0.0f;
                    easeOut           = true;
                    easeIn            = false;
                    Position          = endPos;
                    moving            = false;
                }
            }
        }

        // GLOW when laser hovers over

        if (DJ_TileManagerScript.tileMap.ContainsKey(laserTilePos))
        {
            if (laserGO.GetComponent <CapsuleCollider>().enabled)
            {
                DJ_TileManagerScript.tileMap[laserTilePos].tile.transform.GetChild(0).GetComponent <Renderer>().material.SetFloat("_GlowStrength", 10.5f);
            }
        }

        /*
         * if (prevLaserTilePos.X > laserTilePos.X)
         * {
         *  int distanceX = prevLaserTilePos.X - laserTilePos.X;
         *  if (distanceX > 1)
         *  {
         *      Debug.Log("distanceX1 = " + distanceX);
         *      for (int j = 0; j < distanceX; j++)
         *      {
         *          DJ_Point temp = new DJ_Point(prevLaserTilePos.X + j + 1, prevLaserTilePos.Y);
         *          if (DJ_TileManagerScript.tileMap.ContainsKey(temp))
         *          {
         *              DJ_TileManagerScript.tileMap[temp].tile.transform.GetChild(0).renderer.material.SetFloat("_GlowStrength", 10.5f);
         *          }
         *      }
         *  }
         * }
         * else if (laserTilePos.X > prevLaserTilePos.X)
         * {
         *  int distanceX = laserTilePos.X - prevLaserTilePos.X;
         *  if (distanceX > 1)
         *  {
         *      Debug.Log("distanceX2 = " + distanceX);
         *      for (int j = 0; j < distanceX; j++)
         *      {
         *          DJ_Point temp = new DJ_Point(laserTilePos.X + j + 1, laserTilePos.Y);
         *          if (DJ_TileManagerScript.tileMap.ContainsKey(temp))
         *          {
         *              DJ_TileManagerScript.tileMap[temp].tile.transform.GetChild(0).renderer.material.SetFloat("_GlowStrength", 10.5f);
         *          }
         *      }
         *  }
         * }
         *
         * if (prevLaserTilePos.Y > laserTilePos.Y)
         * {
         *  int distanceZ = prevLaserTilePos.Y - laserTilePos.Y;
         *  Debug.Log("distanceZ1 = " + distanceZ);
         *  if (distanceZ > 1)
         *  {
         *      Debug.Log("distanceZ1 = " + distanceZ);
         *      for (int j = 0; j < distanceZ; j++)
         *      {
         *          DJ_Point temp = new DJ_Point(prevLaserTilePos.X, prevLaserTilePos.Y + j + 1);
         *          if (DJ_TileManagerScript.tileMap.ContainsKey(temp))
         *          {
         *              DJ_TileManagerScript.tileMap[temp].tile.transform.GetChild(0).renderer.material.SetFloat("_GlowStrength", 10.5f);
         *          }
         *      }
         *  }
         * }
         * else if (laserTilePos.Y > prevLaserTilePos.Y)
         * {
         *  int distanceZ = laserTilePos.Y - prevLaserTilePos.Y;
         *  Debug.Log("distanceZ1 = " + distanceZ);
         *  if (distanceZ > 1)
         *  {
         *      Debug.Log("distanceZ2 = " + distanceZ);
         *      for (int j = 0; j < distanceZ; j++)
         *      {
         *          DJ_Point temp = new DJ_Point(laserTilePos.X, laserTilePos.Y + j + 1);
         *          if (DJ_TileManagerScript.tileMap.ContainsKey(temp))
         *          {
         *              DJ_TileManagerScript.tileMap[temp].tile.transform.GetChild(0).renderer.material.SetFloat("_GlowStrength", 10.5f);
         *          }
         *      }
         *  }
         * }
         * Debug.Log("previous = " + prevLaserTilePos);
         * prevLaserTilePos = laserTilePos;
         *
         * Debug.Log("current = " + laserTilePos);
         */
    }
Exemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        CurrentBGType = _CurrBGType;

        campos.x = Camera.main.transform.position.x;
        campos.y = Camera.main.transform.position.y;
        campos.z = Camera.main.transform.position.z;

        if (_CurrBGType == BGType.Tiles)
        {
            //set position of tile "folder"
            SetTilesPosition();

            for (int i = 0; i < _currStrength.Length; ++i)
            {
                _currStrength[i] -= _decStrengthAmount[i];
            }

            if ((DJ_BeatManager.synth1 /*|| DJ_BeatManager.synth1Threshold*/) && DJ_BeatManager.layerThreeActive)
            {
                _currStrength[0]     += _incStrengthAmount[0];
                _incStrengthAmount[0] = 1.0f / DJ_BeatManager.GetNextLayerThreeOn();
                _decStrengthAmount[0] = _incStrengthAmount[0] / 100.0f;
            }
            if ((DJ_BeatManager.synth2 /*|| DJ_BeatManager.synth2Threshold*/) && DJ_BeatManager.layerFourActive)
            {
                _currStrength[1]     += _incStrengthAmount[1];
                _incStrengthAmount[1] = 1.0f / DJ_BeatManager.GetNextLayerFourOn();
                _decStrengthAmount[1] = _incStrengthAmount[1] / 100.0f;
            }
            if ((DJ_BeatManager.snare /*|| DJ_BeatManager.snareThreshold*/) && DJ_BeatManager.layerTwoActive)
            {
                _currStrength[2]     += _incStrengthAmount[2];
                _incStrengthAmount[2] = 1.0f / DJ_BeatManager.GetNextLayerTwoOn();
                _decStrengthAmount[2] = _incStrengthAmount[2] / 100.0f;
            }

            for (int i = 0; i < _currStrength.Length; ++i)
            {
                _currStrength[i] = Mathf.Clamp(_currStrength[i], _minStrength, _maxStrength);
            }

            //update the values in the shader
            for (int i = 0; i < _currStrength.Length; ++i)
            {
                BGTileGO[i].GetComponent <Renderer>().sharedMaterial.SetFloat("_GlowStrength", _currStrength[i]);
            }

            //_rot.y += .00005f;

            //c_o_l.transform.rotation = _rot;
            campos.y = -campos.y;
            BGCamera.transform.position      = campos;
            BGCamera.transform.localRotation = Camera.main.transform.localRotation;
            //Quaternion _r = BGCamera.transform.localRotation;
            //float dist = 180 - _r.x;
            //_r.x = 180 + dist;
            //BGCamera.transform.localRotation = _r;
            Vector3 _target = DJ_PlayerManager.player.transform.position;
            _target.y = 0.0f;
            BGCamera.transform.rotation = Quaternion.LookRotation(_target - BGCamera.transform.position);
            //Quaternion _r2 = BGCamera.transform.rotation;
            //float _dist2 = 180 - _r2.x;
            //_r2.x = 180 + _dist2;
            //BGCamera.transform.rotation = _r2;
            BGCamera.fieldOfView = Camera.main.fieldOfView;

            Camera.main.clearFlags = CameraClearFlags.Nothing;
        }
        else
        {
            Camera.main.clearFlags = CameraClearFlags.Nothing;
        }
    }