예제 #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>());
         */

        onBeat = DJ_Util.activateWithSound(gameObject.GetComponent <DJ_BeatActivation>());
        if (onBeat)
        {
            if (gameObject.GetComponent <Collider>().enabled)
            {
                gameObject.GetComponent <Collider>().enabled  = false;
                gameObject.GetComponent <Renderer>().material = safeShader;
                //gameObject.renderer.material
            }
            else
            {
                gameObject.GetComponent <Collider>().enabled  = true;
                gameObject.GetComponent <Renderer>().material = dangerShader;
            }
        }
    }
    /// <summary>
    /// Accesses the tiles that are inside of DJ_LevelParser to instantiate tiles.
    /// </summary>
    /// <param name="_num">_num.</param>

    // Debug: Highlights adjacent tiles green.
    void getTilesNearLocation(DJ_Point playerTilePos)
    {
        //if the player has moved tiles, we need to update the closest ones
        if (!DJ_PlayerManager.prevPlayerTilePos.Equals(playerTilePos))
        {
            //reset the tile broke flag
            //tileBroke = false;

            DJ_PlayerManager.prevPlayerTilePos.X = playerTilePos.X;
            DJ_PlayerManager.prevPlayerTilePos.Y = playerTilePos.Y;

            //now get a ref to  the tiles around the  player
            //getNearbyTiles (playerTilePos, nearbyTiles, 1.0f);
            DJ_Util.GetNearbyTiles(playerTilePos, 1.0f, ref nearbyTiles);

            //Debugging view to see if tiles update correctly
            //			for (int i = 0; i < nearbyTiles.Count; ++i) {
            //				DJ_Point p = nearbyTiles [i];
            //				if (tileMap.ContainsKey (p)) {
            //					GameObject tile = tileMap [p];
            //					//(tile.GetComponentInChildren(typeof(MeshRenderer)) as MeshRenderer).material.color = Color.green;
            //				}
            //			}
            //(tileMap[playerTilePos].GetComponentInChildren(typeof(MeshRenderer)) as MeshRenderer).material.color = Color.red;
        }
    }
예제 #3
0
 // Update is called once per frame
 void Update()
 {
     // spring activates on beat
     onBeat = DJ_Util.activateWithSound(gameObject.GetComponent <DJ_BeatActivation>());
     if (onBeat)
     {
         _flipper.Flip();
         DJ_Point tilePos = new DJ_Point(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
         if (DJ_TileManagerScript.tileMap.ContainsKey(tilePos))
         {
             if (DJ_PlayerManager.playerTilePos.X == tilePos.X && DJ_PlayerManager.playerTilePos.Y == tilePos.Y && !DJ_PlayerManager.player.GetComponent <DJ_Movement>().isLerping)
             {
                 DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = height;
                 DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction       = direction;
                 DJ_PlayerManager.player.GetComponent <DJ_Movement>().maxMoveDistance = distance;
                 DJ_PlayerManager.player.GetComponent <DJ_Movement>().canMove         = true;
             }
         }
         gameObject.GetComponentInChildren <MeshRenderer>().GetComponent <Renderer>().material = dangerShader;
     }
     else
     {
         gameObject.GetComponentInChildren <MeshRenderer>().GetComponent <Renderer>().material = safeShader;
     }
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        _labelPos = LabelTransform.position;

        _labelPos.y = 0.0f;

        LabelTransform.position = _labelPos;

        CurrentEffectTime = 0.0f;

        _tilePos = new DJ_Point(0, 0);

        DJ_Util.GetTilePos(this.transform.position, _tilePos);

        LabelTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        LabelTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        BGTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        BGTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        _aspectRatio = TextTexture.width / TextTexture.height;

        //Quaternion _r = QuestionMark.rotation;
        //_r.y = LabelTransform.rotation.y;

        //QuestionMark.rotation = _r;

        SetupTextTexture();

        currQuestionAngle = (float)Random.Range(0.0f, Mathf.PI * 2.0f);
    }
예제 #5
0
    public void AddNeighbor(TileNode neighbor)
    {
        if (DJ_Util.GetDistance(pos, neighbor.pos, DJ_Distance.PATH) <= 1)
        {
            float dx = neighbor.pos.X - pos.X;
            float dy = neighbor.pos.Y - pos.Y;

            if (dx != dy)
            {
                if (dx > 0)
                {
                    neighbors[(int)DJ_Dir.RIGHT] = neighbor;
                }
                else if (dx < 0)
                {
                    neighbors[(int)DJ_Dir.LEFT] = neighbor;
                }
                else if (dy > 0)
                {
                    neighbors[(int)DJ_Dir.UP] = neighbor;
                }
                else if (dy < 0)
                {
                    neighbors[(int)DJ_Dir.DOWN] = neighbor;
                }
            }
        }
    }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     _startPos    = this.transform.position;
     StarAcquired = false;
     _angle       = 0.0f;
     _tilePos     = DJ_Util.GetTilePos(this.transform.position);
     _startRot    = this.transform.rotation;
 }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     state    = AnimationState.Hover;
     startPos = this.transform.localPosition;
     _tilePos = DJ_Util.GetTilePos(this.transform.parent.position);
     Beam.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
     Beam.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);
     _active        = false;
     _startRotation = this.transform.rotation;
     BlastOff       = false;
 }
예제 #8
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);
        }
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        _labelPos = LabelTransform.position;

        _labelPos.y = 0.0f;

        LabelTransform.position = _labelPos;

        CurrentEffectTime = 0.0f;

        _tilePos = new DJ_Point(0, 0);

        DJ_Util.GetTilePos(this.transform.position, _tilePos);

        Vector3 _pos = PlayTransform.position;

        _pos += -PlayTransform.forward * .002f;
        PlayTransform.position = _pos;
        PlayTransform.tag      = "level_select_button";

        Stars = new GameObject[NumberOfStars];

        StarTimers = new float[NumberOfStars];

        PlayTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        PlayTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        SpotlightTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        SpotlightTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        LabelTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        LabelTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        BGTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
        BGTransform.gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);

        for (int i = 0; i < Stars.Length; ++i)
        {
            Stars[i] = GameObject.Instantiate(StarGO) as GameObject;
            Stars[i].transform.parent = StarTransform;

            Stars[i].gameObject.GetComponent <Renderer>().material.SetFloat("_Alpha", 0.0f);
            Stars[i].gameObject.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.0f);
        }

        SetupTextTexture();
    }
예제 #10
0
    // TODO: DELETION?
    public void RespawnTile()
    {
        onBeat = DJ_Util.activateWithNoSound(gameObject.GetComponent <DJ_BeatActivation>());
        if (onBeat)
        {
            while (tilePool.Count > 0)
            {
                TileNode poolTile = tilePool.Pop();
                poolTile.tile.SetActive(true);

                tileMap.Add(new DJ_Point((int)poolTile.tile.transform.position.x, (int)poolTile.tile.transform.position.z), poolTile);
                poolTile.tile.GetComponent <DJ_TileScript>().fadeIn = true;
                (poolTile.tile.transform.GetChild(0).GetComponent(typeof(MeshRenderer)) as MeshRenderer).GetComponent <Renderer>().sharedMaterial.SetFloat("_Alpha", 0.0f);
                (poolTile.tile.transform.GetChild(0).GetComponent(typeof(MeshRenderer)) as MeshRenderer).GetComponent <Renderer>().sharedMaterial.SetFloat("_GlowStrength", 0.5f);
            }
        }
    }
예제 #11
0
    // Update is called once per frame
    void Update()
    {
        // Used for instant teleporting in the level select
        if (instantTeleport)
        {
            DJ_Point tilePos = new DJ_Point(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
            if (DJ_TileManagerScript.tileMap.ContainsKey(tilePos))

            {
                if (DJ_PlayerManager.playerTilePos.X == tilePos.X && DJ_PlayerManager.playerTilePos.Y == tilePos.Y && !DJ_PlayerManager.player.GetComponent <DJ_Movement>().isLerping)
                {
                    if (!(DJ_PlayerManager.player.GetComponent <DJ_Movement>().prevPrevTilePos.X == teleporter.gameObject.transform.position.x &&
                          DJ_PlayerManager.player.GetComponent <DJ_Movement>().prevPrevTilePos.Y == teleporter.gameObject.transform.position.z))
                    {
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction       = DJ_Dir.TP;
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(teleporter.gameObject.transform.position.x);
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(teleporter.gameObject.transform.position.z);
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 14;
                    }
                }
            }
        }

        // Used for teleporting during gameplay
        else
        {
            onBeat = DJ_Util.activateWithSound(gameObject.GetComponent <DJ_BeatActivation>());
            if (onBeat)
            {
                DJ_Point tilePos = new DJ_Point(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
                if (DJ_TileManagerScript.tileMap.ContainsKey(tilePos))
                {
                    if (DJ_PlayerManager.playerTilePos.X == tilePos.X && DJ_PlayerManager.playerTilePos.Y == tilePos.Y && !DJ_PlayerManager.player.GetComponent <DJ_Movement>().isLerping)
                    {
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction       = DJ_Dir.TP;
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(teleporter.gameObject.transform.position.x);
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(teleporter.gameObject.transform.position.z);
                        DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 8;
                    }
                }
            }
        }
    }
예제 #12
0
    /// <summary>
    /// Checks to see if the player has died. Respawns the character to the correct checkpoint.
    /// </summary>
    public void RespawnCharacter()
    {
        if (!player.GetComponent <DJ_Damageable>().isAlive)
        {
            player.GetComponent <DJ_Movement>().canMove = false;
            if (prevAlive)
            {
                Camera.main.GetComponent <DeathEffectScript>().Active            = true;
                Camera.main.GetComponent <DeathEffectScript>().CurrentEffectTime = 0.0f;
            }
            if (!allowRespawn && Camera.main.GetComponent <DeathEffectScript>().CurrentEffectTime > Camera.main.GetComponent <DeathEffectScript>().EffectDuration * .9f)
            {
                allowRespawn = true;
                //DJ_LevelManager.resetScene();
                if (Application.loadedLevelName.Equals("levelSelectStage"))
                {
                    player.transform.position = new Vector3(PlayerPrefs.GetInt("PlayerX"), 0.0f, PlayerPrefs.GetInt("PlayerY"));
                }
                else
                {
                    player.transform.position = new Vector3(spawnPoint.X, 0.0f, spawnPoint.Y);
                }

                player.gameObject.GetComponent <DJ_Movement>().targetTilePos.Set(DJ_Util.GetTilePos(player.transform.position));
                player.gameObject.GetComponent <DJ_Movement>().currentTilePos.Set(player.gameObject.GetComponent <DJ_Movement>().targetTilePos);
                // This was breaking teleporting in the level select
                //player.gameObject.GetComponent<DJ_Movement>().prevPrevTilePos = player.gameObject.GetComponent<DJ_Movement>().targetTilePos;
                player.gameObject.GetComponent <DJ_Movement>().prevTilePos.Set(player.gameObject.GetComponent <DJ_Movement>().targetTilePos);
                player.GetComponent <DJ_Movement>().Reset();
                player.GetComponent <DJ_Movement>().canMove   = false;
                player.GetComponent <DJ_Damageable>().isAlive = true;
                player.GetComponent <DJ_Damageable>().deathBy = DJ_Death.NONE;
                deathCount++;
            }
            if (allowRespawn && Camera.main.GetComponent <DeathEffectScript>().CurrentEffectTime > Camera.main.GetComponent <DeathEffectScript>().EffectDuration * 2.0f * .75f)
            {
                player.GetComponent <DJ_Movement>().canMove = true;
                allowRespawn = false;
            }
        }
        prevAlive = player.GetComponent <DJ_Damageable>().isAlive;
    }
예제 #13
0
    // Update is called once per frame
    void Update()
    {
        laserTilePos.X = Mathf.RoundToInt(laser.transform.position.x);
        laserTilePos.Y = Mathf.RoundToInt(laser.transform.position.z);
        //Debug.Log("laser tile pos = " + laserTilePos);

        Vector3 _temp = lightSource.position;

        _temp.y = laser.transform.position.y;
        lightSource.position = _temp;

        Vector3 _dir = (laser.transform.position - lightSource.position).normalized;

        _dir.y = 0.0f;
        targetSource.position = lightSource.position + _dir * lengthOfBeam;

        layerOn = DJ_Util.isLayerOn(gameObject.GetComponent <DJ_BeatActivation>());

        if (layerOn)
        {
            //laser.GetComponent<MeshRenderer>().enabled = true;
            laser.GetComponent <BoxCollider>().enabled            = true;
            lightSource.GetComponent <ParticleRenderer>().enabled = true;
        }

        onBeat = DJ_Util.activateWithNoSound(gameObject.GetComponent <DJ_BeatActivation>());

        //if (DJ_BeatManager.thresholdStartNote)
        if (onBeat)
        {
            changeLaserDirection();
        }
        else
        {
            //laser.transform.rotation = Quaternion.Slerp(laser.transform.rotation, rotationVector.transform.rotation, Time.deltaTime);
            //var newRotation = Quaternion.LookRotation(laser.transform.position + rotationVector.position, Vector3.up);
            //laser.transform.rotation = Quaternion.Slerp(laser.transform.rotation, newRotation, Time.deltaTime);

            /*
             * if (currentAngle <= targetAngle)
             * {
             *  laser.transform.RotateAround(transform.position, Vector3.up, 3);
             *  currentAngle += 3;
             *  if (currentAngle > 360)
             *      currentAngle = 0;
             *  Debug.Log("Current angle is " + currentAngle);
             * }
             * else
             * {
             *  Debug.Log("DONE");
             * }
             */
        }


        if (DJ_TileManagerScript.tileMap.ContainsKey(laserTilePos))
        {
            if (laser.GetComponent <BoxCollider>().enabled)
            {
                DJ_TileManagerScript.tileMap[laserTilePos].tile.transform.GetChild(0).GetComponent <Renderer>().material.SetFloat("_GlowStrength", 10.5f);
                //DJ_TileManagerScript._recentlyLaserVisitedTiles.Add(laserTilePos); //set the time remaining of the effect
                //DJ_TileManagerScript._tileLaserGlowTimes.Add(laserTilePos, 1.5f);
            }
        }
    }
예제 #14
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);
         */
    }
예제 #15
0
    public void Update()
    {
        //TODO: Peter's Temp fix
        //animationLength = 0.5f * .75f;
//		animationLength = DJ_BeatManager.metronome.GetInterval() * .75f;

        //update the current animation time
        currAnimationTime += Time.deltaTime;

        //save the current position of the GO so that we  can
        //modify it and  set the transform.position equal to
        //the  modified position
        currentPosition = transform.position;
        // sets the previous move
        prevCanMove = canMove;

        DJ_Util.GetTilePos(currentPosition, currentTilePos);
        //playerHeight = currentPosition.y;

        // Checks to see if the player should be falling
        checkFalling();

        // If true, activate falling to death
        if (isFalling)
        {
            fallingScript();
        }
        if (DJ_PlayerManager.player.GetComponent <DJ_Damageable>().isAlive)
        {
            // If the entity can move then apply a lerp based on the direction.
            if (canMove)
            {
                justLanded = false;
                if (direction != DJ_Dir.NONE)
                {
                    if (direction == DJ_Dir.TP)
                    {
                        isLerping = true;
                        canMove   = false;
                        prevPrevTilePos.Set(prevTilePos);
                        direction = DJ_Dir.NONE;
                    }
                    else
                    {
                        isLerping     = true;
                        prevDirection = direction;
                        canMove       = false;
                        prevPrevTilePos.Set(prevTilePos);
                        prevTilePos.Set(currentTilePos);
                        DJ_Util.GetNeighboringTilePos(prevTilePos, direction, maxMoveDistance, targetTilePos);
                    }
                }
                currAnimationTime = 0.0f;
            }
            if (currAnimationTime > animationLength)
            {
                maxMoveDistance = 1;
                heightOfHop     = 1;
                canMove         = true;
                isLerping       = false;
                //direction = DJ_Dir.NONE;
                justLanded = true;
                //snap the position
                prevTilePos.Set(targetTilePos);

                // Only update the player's position in the playerPref if in the level select
                // Used to respawn in the correction position whenever they die or come back.

                if (Application.loadedLevelName.Equals("levelSelectStage") && DJ_TileManagerScript.tileMap.ContainsKey(targetTilePos))
                {
                    PlayerPrefs.SetInt("PlayerX", targetTilePos.X);
                    PlayerPrefs.SetInt("PlayerY", targetTilePos.Y);
                    //Debug.Log("Flush this to hash table");
                    //Debug.Log("Flush Player hash table = " + targetTilePos);
                    PlayerPrefs.Flush();
                }
            }

            //else
            {
                DJ_Util.LerpTrajectory(ref currentPosition, prevTilePos, targetTilePos,
                                       heightOfHop, currAnimationTime, animationLength, playerHeight);
            }
            switch (DJ_PlayerManager.player.GetComponent <DJ_Damageable>().deathBy)
            {
            case DJ_Death.NONE: transform.position = currentPosition;
                break;

            case DJ_Death.FALLING: transform.position = currentPosition;
                break;

            case DJ_Death.FLATTEN: transform.position = new Vector3(currentPosition.x, 0, currentPosition.z);
                break;

            case DJ_Death.ELECTROCUTED: transform.position = currentPosition;
                break;
            }

            //transform.position = currentPosition;
        }
        switch (DJ_PlayerManager.player.GetComponent <DJ_Damageable>().deathBy)
        {
        case DJ_Death.NONE: transform.position = currentPosition;
            break;

        case DJ_Death.FALLING: transform.position = currentPosition;
            break;

        case DJ_Death.FLATTEN: transform.position = new Vector3(currentPosition.x, 0, currentPosition.z);
            break;

        case DJ_Death.ELECTROCUTED: transform.position = currentPosition;
            break;
        }
    }
예제 #16
0
    public DJ_Dir GetNextMove(DJ_Point from, DJ_Point to, float maxDist, DJ_Distance distanceType)
    {
        tilesVisited.Clear();
        currentCosts.Clear();

        tilesVisited.Add(from);

        currentCosts.Add(0.0f);

        if (tileMap.ContainsKey(from))
        {
            DJ_Dir prefDir = DJ_Util.GetPreferredDirection(from, to);

            float currentCost = 0.0f;

            //immediately return none if the preferred direction
            //happens to be none. This either means the positions, from
            //and to, are the same or that there is no path from "from" to "to"
            if (prefDir == DJ_Dir.NONE)
            {
                return(prefDir);
            }

            //Debug.Log("the preferred direction is " + prefDir.ToString());

            int index;

            if (tileMap[from].neighbors[(int)prefDir] != null && DJ_LevelManager.isTileAvailable(tileMap[from].neighbors[(int)prefDir].pos))
            {
                //push info  onto queue
                tilesVisited.Add(tileMap[from].neighbors[(int)prefDir].pos);
                currentCosts.Add(currentCost);

                if (GetNextMove(tileMap[from].neighbors[(int)prefDir].pos, to, 0.0f, maxDist, distanceType, currentCost + 1.0f))
                {
                    return(prefDir);
                }

                //remove info from queue
                index = tilesVisited.IndexOf(tileMap[from].neighbors[(int)prefDir].pos);
                currentCosts.RemoveAt(index);
                tilesVisited.Remove(tileMap[from].neighbors[(int)prefDir].pos);
            }

            for (int i = 0; i < tileMap[from].neighbors.Length; ++i)
            {
                if (tileMap[from].neighbors[i] != null && i != (int)prefDir && DJ_LevelManager.isTileAvailable(tileMap[from].neighbors[i].pos))
                {
                    tilesVisited.Add(tileMap[from].neighbors[i].pos);
                    currentCosts.Add(currentCost);

                    if (GetNextMove(tileMap[from].neighbors[i].pos, to, 0.0f, maxDist, distanceType, currentCost + 1.0f))
                    {
                        return(DJ_Util.GetPreferredDirection(from, tileMap[from].neighbors[i].pos));
                    }

                    index = tilesVisited.IndexOf(tileMap[from].neighbors[i].pos);
                    currentCosts.RemoveAt(index);
                    tilesVisited.Remove(tileMap[from].neighbors[i].pos);
                }
            }
        }

        return(DJ_Dir.NONE);
    }
예제 #17
0
    // Update is called once per frame
    void Update()
    {
        // Used for instant teleporting in the level select
        if (instantTeleport)
        {
            DJ_Point tilePos = new DJ_Point(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
            if (DJ_TileManagerScript.tileMap.ContainsKey(tilePos))
            {
                if (DJ_PlayerManager.playerTilePos.X == tilePos.X && DJ_PlayerManager.playerTilePos.Y == tilePos.Y && !DJ_PlayerManager.player.GetComponent <DJ_Movement>().isLerping)
                {
                    if (layerOneTile != null)
                    {
                        if (
                            //!(DJ_PlayerManager.player.GetComponent<DJ_Movement>().prevPrevTilePos.X == layerOneTile.transform.position.x &&
                            //DJ_PlayerManager.player.GetComponent<DJ_Movement>().prevPrevTilePos.Y == layerOneTile.transform.position.z ) &&
                            (TPRings != null && TPRings.BlastOff))
                        {
                            DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction       = DJ_Dir.TP;
                            DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(layerOneTile.transform.position.x);
                            DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(layerOneTile.transform.position.z);
                            DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 14;
                        }
                    }
                }
            }
        }
        // Used for teleporting during gameplay
        else
        {
            if (!returnOnly)
            {
                DJ_Point tilePos = new DJ_Point(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.z));
                if (DJ_TileManagerScript.tileMap.ContainsKey(tilePos))
                {
                    if (DJ_PlayerManager.playerTilePos.X == tilePos.X && DJ_PlayerManager.playerTilePos.Y == tilePos.Y && !DJ_PlayerManager.player.GetComponent <DJ_Movement>().isLerping)
                    {
                        onBeat = DJ_Util.activateWithSoundWithInstrument(gameObject.GetComponent <DJ_BeatActivation>());
                        switch (onBeat)
                        {
                        case DJ_Instrument.NONE:
                            break;

                        case DJ_Instrument.ONE:
                            if (layerOneTile != null)
                            {
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction = DJ_Dir.TP;

                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(layerOneTile.transform.position.x);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(layerOneTile.transform.position.z);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 8;
                            }
                            break;

                        case DJ_Instrument.TWO:
                            if (layerTwoTile != null)
                            {
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction       = DJ_Dir.TP;
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(layerTwoTile.transform.position.x);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(layerTwoTile.transform.position.z);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 8;
                            }
                            break;

                        case DJ_Instrument.THREE:
                            if (layerThreeTile != null)
                            {
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction = DJ_Dir.TP;

                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(layerThreeTile.transform.position.x);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(layerThreeTile.transform.position.z);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 8;
                            }
                            break;

                        case DJ_Instrument.FOUR:
                            if (layerFourTile != null)
                            {
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().direction = DJ_Dir.TP;

                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.X = Mathf.RoundToInt(layerFourTile.transform.position.x);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().targetTilePos.Y = Mathf.RoundToInt(layerFourTile.transform.position.z);
                                DJ_PlayerManager.player.GetComponent <DJ_Movement>().heightOfHop     = 8;
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
예제 #18
0
    private bool GetNextMove(DJ_Point from, DJ_Point to, float currDist, float maxDist, DJ_Distance distanceType, float currentCost)
    {
        if (from.Equals(to))
        {
            return(true);
        }

        if (!tileMap.ContainsKey(to) && DJ_Util.GetDistance(from, to, DJ_Distance.EUCLIDEAN) <= 1)
        {
            return(false);
        }

        if (currDist > maxDist)
        {
            return(true);
        }

        if (tileMap.ContainsKey(from))
        {
            DJ_Dir prefDir = DJ_Util.GetPreferredDirection(from, to);

            int index;

            //immediately return none if the preferred direction
            //happens to be none. This either means the positions, from
            //and to, are the same or that there is no path from "from" to "to"
            if (prefDir == DJ_Dir.NONE)
            {
                return(true);
            }

            if (tileMap[from].neighbors[(int)prefDir] != null && DJ_LevelManager.isTileAvailable(tileMap[from].neighbors[(int)prefDir].pos))
            {
                if (!tilesVisited.Contains(tileMap[from].neighbors[(int)prefDir].pos))
                {
                    tilesVisited.Add(tileMap[from].neighbors[(int)prefDir].pos);
                    currentCosts.Add(currentCost);
                }
                else
                {
                    index = tilesVisited.IndexOf(tileMap[from].neighbors[(int)prefDir].pos);

                    float currCost = currentCosts[index];

                    if (currentCost < currCost)
                    {
                        tilesVisited.RemoveAt(index);
                        currentCosts.RemoveAt(index);

                        tilesVisited.Add(tileMap[from].neighbors[(int)prefDir].pos);
                        currentCosts.Add(currentCost);
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (GetNextMove(tileMap[from].neighbors[(int)prefDir].pos, to, currDist + 1.0f, maxDist, distanceType, currentCost + 1.0f))
                {
                    return(true);
                }

                index = tilesVisited.IndexOf(tileMap[from].neighbors[(int)prefDir].pos);

                currentCosts.RemoveAt(index);
                tilesVisited.Remove(tileMap[from].neighbors[(int)prefDir].pos);
            }

            for (int i = 0; i < tileMap[from].neighbors.Length; ++i)
            {
                if (tileMap[from].neighbors[i] != null && i != (int)prefDir && DJ_LevelManager.isTileAvailable(tileMap[from].neighbors[i].pos))
                {
                    tilesVisited.Add(tileMap[from].neighbors[i].pos);
                    currentCosts.Add(currentCost);

                    if (GetNextMove(tileMap[from].neighbors[i].pos, to, currDist + 1.0f, maxDist, distanceType, currentCost + 1.0f))
                    {
                        return(true);
                    }

                    index = tilesVisited.IndexOf(tileMap[from].neighbors[i].pos);
                    currentCosts.RemoveAt(index);
                    tilesVisited.Remove(tileMap[from].neighbors[i].pos);
                }
            }
        }

        return(false);
    }
예제 #19
0
    // Update is called once per frame
    public override void Update()
    {
        // GLOW when laser hovers over

        if (_meshRender.GetComponent <Renderer>().material.GetFloat("_GlowStrength") > .5f)
        {
            float gStrength = transform.GetChild(0).GetComponent <MeshRenderer>().GetComponent <Renderer>().sharedMaterial.GetFloat("_GlowStrength");
            //tileMaterial.color = Color.Lerp(tileMaterial.color, originalColor, fadeInSpeed * Time.deltaTime);
            float gs = Mathf.Lerp(gStrength, 1.0f, 3 * Time.deltaTime);
            _meshRender.GetComponent <Renderer>().material.SetFloat("_GlowStrength", gs);
        }
        else
        {
            _meshRender.GetComponent <Renderer>().material.SetFloat("_GlowStrength", 0.5f);
        }


        base.Update();
        if (!gameObject.GetComponent <DJ_Damageable>().invulnerable)
        {
            onBeat = DJ_Util.activateWithNoSound(gameObject.GetComponent <DJ_BeatActivation>());
            if (onBeat)
            {
                //DJ_TileManagerScript.tilePool.Push(DJ_TileManagerScript.tileMap[new DJ_Point((int)transform.position.x, (int)transform.position.z)]);
                //DJ_TileManagerScript.tileMap.Remove(new DJ_Point((int)transform.position.x, (int)transform.position.z));
                //gameObject.SetActive(false);
                startDelayTimer = true;
            }
        }
        if (startDelayTimer)
        {
            currentTimer += Time.deltaTime;
            if (currentTimer > timerDelayMax)
            {
                DJ_TileManagerScript.tilePool.Push(DJ_TileManagerScript.tileMap[new DJ_Point((int)transform.position.x, (int)transform.position.z)]);
                DJ_TileManagerScript.tileMap.Remove(new DJ_Point((int)transform.position.x, (int)transform.position.z));
                gameObject.SetActive(false);
                startDelayTimer = false;
                currentTimer    = 0;
            }
        }


        //save the current position of the GO so that we  can
        //modify it and  set the transform.position equal to
        //the  modified position
        currentPosition = transform.position;

        if (fadeIn)
        {
            if (fadingTile)
            {
                if (transform.GetChild(0).GetComponent <MeshRenderer>().enabled == false)
                {
                    if (DJ_Util.isLayerOn(gameObject.GetComponent <DJ_BeatActivation>()))
                    {
                        transform.GetChild(0).GetComponent <MeshRenderer>().enabled = true;
                    }
                }
            }

            float currAlpha = transform.GetChild(0).GetComponent <MeshRenderer>().GetComponent <Renderer>().sharedMaterial.GetFloat("_Alpha");
            //tileMaterial.color = Color.Lerp(tileMaterial.color, originalColor, fadeInSpeed * Time.deltaTime);
            float a = Mathf.Lerp(currAlpha, 1.0f, fadeInSpeed * Time.deltaTime);

            _meshRender.GetComponent <Renderer>().sharedMaterial.SetFloat("_Alpha", a);

            if (currAlpha == 1)
            {
                fadeIn = false;
            }
        }

        transform.position = currentPosition;
    }