Esempio n. 1
0
    void Start()
    {
        speed = Random.Range(2.0f, 4.0f);


        followingplayer = FindObjectOfType <FollowingPlayer>();
        targetPosition  = followingplayer.playerDirection;
        startPosition   = followingplayer.transform.position;

        if ((targetPosition.x >= 40f))
        {
            randomPos = Random.Range(-8.0f, -10.0f);
        }
        if ((targetPosition.x) >= 38f)
        {
            randomPos = Random.Range(-6.0f, -8.0f);
        }
        else if ((targetPosition.x) < 38f)
        {
            randomPos = Random.Range(-4.0f, -6.0f);
        }

        startPosition = startPosition + new Vector3(-1.0f, 0, 0);

        startTime = Time.time;

        distanceLength = Vector3.Distance(startPosition, targetPosition);
        targetPosition = new Vector3(targetPosition.x + randomPos, targetPosition.y, targetPosition.z);
    }
Esempio n. 2
0
 void Start()
 {
     bossHpMax        = hp;
     bossHp           = bossHpMax;
     followingPlayer  = GetComponentInChildren <FollowingPlayer>();
     canvasController = FindObjectOfType <CanvasController>();
     canvasController.OnBossHpSlider();
 }
    private void JumpWallJumpConnection(PathFindingNode pfNode, ConnectedNode cNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
    {
        if (cNode.preJumpWallJumpDirectionSpeed > followingPlayerScript.maxSpeed)
        {
            cNode.preJumpWallJumpDirectionSpeed = followingPlayerScript.maxSpeed;
        }
        else if (cNode.preJumpWallJumpDirectionSpeed < -followingPlayerScript.maxSpeed)
        {
            cNode.preJumpWallJumpDirectionSpeed = -followingPlayerScript.maxSpeed;
        }
        Vector2 jumpWallJumpPlatformSizeDiv2 = cNode.jumpWallJumpPlatform.transform.lossyScale / 2f;
        Vector2 jumpWallJumpPlatformPos      = cNode.jumpWallJumpPlatform.transform.position;

        cNode.firstJumpWallJumpHit.x = jumpWallJumpPlatformPos.x + (jumpWallJumpPlatformSizeDiv2.x + pathfindingGameObjectSize.x / 2f) *
                                       (cNode.preJumpWallJumpDirectionSpeed > 0f ? -1f : 1f);
        cNode.onPlatformValue        = Math.Abs((cNode.firstJumpWallJumpHit.x - cNode.preJumpWallJumpStartX) / cNode.preJumpWallJumpDirectionSpeed);
        cNode.firstJumpWallJumpHit.y = pfNode.objectOnFromPlatformY + followingPlayerScript.CalculateJumpY(cNode.onPlatformValue);
        if (cNode.firstJumpWallJumpHit.y < jumpWallJumpPlatformPos.y - jumpWallJumpPlatformSizeDiv2.y ||
            cNode.firstJumpWallJumpHit.y > jumpWallJumpPlatformPos.y + jumpWallJumpPlatformSizeDiv2.y ||
            cNode.preJumpWallJumpDirectionSpeed == 0f)
        {
            cNode.onPlatformValue = 1;
        }
        JumpVisualization(cNode.onPlatformValue, cNode.preJumpWallJumpStartX, pfNode.objectOnFromPlatformY,
                          cNode.preJumpWallJumpDirectionSpeed, pfNode, followingPlayerScript, pathfindingGameObjectSize);

        if (cNode.jumpWallJumpY > cNode.firstJumpWallJumpHit.y)
        {
            cNode.jumpWallJumpY = cNode.firstJumpWallJumpHit.y;
        }
        else if (cNode.jumpWallJumpY < jumpWallJumpPlatformPos.y - jumpWallJumpPlatformSizeDiv2.y)
        {
            cNode.jumpWallJumpY = jumpWallJumpPlatformPos.y - jumpWallJumpPlatformSizeDiv2.y;
        }
        StraightFallVisualization(cNode.firstJumpWallJumpHit.y, cNode.jumpWallJumpY, cNode.firstJumpWallJumpHit.x, pathfindingGameObjectSize);

        if (cNode.postJumpWallJumpDirectionSpeed > followingPlayerScript.maxSpeed)
        {
            cNode.postJumpWallJumpDirectionSpeed = followingPlayerScript.maxSpeed;
        }
        else if (cNode.postJumpWallJumpDirectionSpeed < -followingPlayerScript.maxSpeed)
        {
            cNode.postJumpWallJumpDirectionSpeed = -followingPlayerScript.maxSpeed;
        }
        cNode.onPlatformValue2 = 1;
        if (cNode.objectOnToPlatformY <= cNode.jumpWallJumpY + followingPlayerScript.jumpHeight)
        {
            cNode.onPlatformValue2 = followingPlayerScript.CalculateXFromYInJump(cNode.objectOnToPlatformY - cNode.jumpWallJumpY);
        }
        JumpVisualization(cNode.onPlatformValue2, cNode.firstJumpWallJumpHit.x, cNode.jumpWallJumpY,
                          cNode.postJumpWallJumpDirectionSpeed, pfNode, followingPlayerScript, pathfindingGameObjectSize);
    }
    private void OnSceneGUI()
    {
        PathFindingData pfData = (PathFindingData)target;
        FollowingPlayer followingPlayerScript     = pfData.pathfindingGameObject.GetComponent <FollowingPlayer>();
        Vector3         pathfindingGameObjectSize = pfData.pathfindingGameObject.transform.lossyScale;

        foreach (PathFindingNode pfNode in pfData.pathFindingNodes)
        {
            pfNode.objectOnFromPlatformY = pfData.CalculateGameObjectOnPlatformY(pfNode.platformGameObject, pfData.pathfindingGameObject);

            if (!pfNode.showConnectionHandles)
            {
                continue;
            }

            Handles.color = Color.green;
            Handles.DrawWireCube(pfNode.platformGameObject.transform.position, pfNode.platformGameObject.transform.lossyScale);

            foreach (ConnectedNode cNode in pfNode.connectedNodes)
            {
                cNode.objectOnFromPlatformY = pfNode.objectOnFromPlatformY;
                cNode.objectOnToPlatformY   = pfData.CalculateGameObjectOnPlatformY(cNode.platformGameObject, pfData.pathfindingGameObject);
                if (!cNode.showConnectionHandles)
                {
                    continue;
                }
                Handles.color = Color.blue;
                Handles.DrawWireCube(cNode.platformGameObject.transform.position, cNode.platformGameObject.transform.lossyScale);

                Handles.color = Color.red;
                switch (cNode.connectionType)
                {
                case ConnectedNode.ConnectionType.Jump:
                    JumpConnection(pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);
                    break;

                case ConnectedNode.ConnectionType.Fall:
                    FallConnection(pfData, pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);
                    break;

                case ConnectedNode.ConnectionType.JumpWallJump:
                    JumpWallJumpConnection(pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);
                    break;

                case ConnectedNode.ConnectionType.FallWallJump:
                    FallWallJumpConnection(pfData, pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);
                    break;
                }
            }
        }
    }
 private void JumpConnection(PathFindingNode pfNode, ConnectedNode cNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
 {
     if (cNode.jumpDistance > followingPlayerScript.maxSpeed)
     {
         cNode.jumpDistance = followingPlayerScript.maxSpeed;
     }
     else if (cNode.jumpDistance < -followingPlayerScript.maxSpeed)
     {
         cNode.jumpDistance = -followingPlayerScript.maxSpeed;
     }
     cNode.onPlatformValue = 1;
     if (cNode.objectOnToPlatformY <= pfNode.objectOnFromPlatformY + followingPlayerScript.jumpHeight)
     {
         cNode.onPlatformValue = followingPlayerScript.CalculateXFromYInJump(cNode.objectOnToPlatformY - pfNode.objectOnFromPlatformY);
     }
     JumpVisualization(cNode.onPlatformValue, cNode.jumpStartX, pfNode.objectOnFromPlatformY, cNode.jumpDistance, pfNode, followingPlayerScript, pathfindingGameObjectSize);
 }
    void Start()
    {
        levelIndex = Application.loadedLevel;           //Getting current level index for saving needs;

        //contadorDeColisoes = 0;
        rb = GetComponent <Rigidbody>();

        playerPosition = GameObject.Find("Sphere").transform;
        //Acessa a variável integerToChange presente em MainCamera
        referenceScript = GameObject.FindWithTag("MainCamera").GetComponent <FollowingPlayer>();
        referenceBool   = GameObject.FindWithTag("MainCamera").GetComponent <FollowingPlayer>();
        //Para acessar os scripts de controle anexados à esfera
        downReference  = GameObject.Find("Sphere").GetComponent <DOWN_controller> ();
        upReference    = GameObject.Find("Sphere").GetComponent <UP_controller> ();
        rightReference = GameObject.Find("Sphere").GetComponent <RIGHT_controller> ();
        leftReference  = GameObject.Find("Sphere").GetComponent <LEFT_controller> ();

        pointLight1 = GameObject.Find("Point light").GetComponent <PointLight1> ();
        pointLight2 = GameObject.Find("Point light (1)").GetComponent <PointLight2> ();
        fiatLux1    = GameObject.FindWithTag("planetag").GetComponent <Fiat_Lux1> ();
        fiatLux2    = GameObject.FindWithTag("gem2").GetComponent <Fiat_Lux2> ();

        //lightningEmitter = GameObject.FindWithTag ("lightning_emitter");
        lightningEmitter.SetActive(false);
        //show1Star.SetActive (false); //Mantem as estrelas apagadas até "timer=true"
        //show2Stars.SetActive (false);
        //show3Stars.SetActive (false);

        //Fade-in das estrelas / Seta cor transparente nos sprites
        //starColor = new Color (1, 1, 1, 0);
        //star1.color = starColor;
        //star2.color = starColor;
        //star3.color = starColor;

        source = GetComponent <AudioSource>();
    }
Esempio n. 7
0
 void Start()
 {
     rb             = GetComponent <Rigidbody>();
     referenceFloat = GameObject.FindWithTag("MainCamera").GetComponent <FollowingPlayer>();
     //cameraButtonOn = 0;
 }
    private void FallVisualization(float onPlatformValue, float fallStartX, float fallDirectionSpeed, PathFindingNode pfNode, ConnectedNode cNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
    {
        float visualStep = 0.1f;

        for (float currentVisualStep = 0f; currentVisualStep < onPlatformValue; currentVisualStep += visualStep)
        {
            Handles.DrawWireCube(
                new Vector3(fallStartX + currentVisualStep * fallDirectionSpeed, pfNode.objectOnFromPlatformY +
                            followingPlayerScript.CalculateFallY(currentVisualStep)), pathfindingGameObjectSize);
        }
    }
    private void JumpVisualization(float onPlatformValue, float jumpStartX, float jumpStartY, float jumpDistance, PathFindingNode pfNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
    {
        float visualStep = 0.1f;

        for (float currentVisualStep = 0f; currentVisualStep < onPlatformValue; currentVisualStep += visualStep)
        {
            Handles.DrawWireCube(new Vector3(jumpStartX + currentVisualStep * jumpDistance,
                                             jumpStartY + followingPlayerScript.CalculateJumpY(currentVisualStep)), pathfindingGameObjectSize);
        }
    }
    private void FallWallJumpConnection(PathFindingData pfData, PathFindingNode pfNode, ConnectedNode cNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
    {
        if (cNode.preFallWallJumpDirectionSpeed > followingPlayerScript.maxSpeed)
        {
            cNode.preFallWallJumpDirectionSpeed = followingPlayerScript.maxSpeed;
        }
        else if (cNode.preFallWallJumpDirectionSpeed < -followingPlayerScript.maxSpeed)
        {
            cNode.preFallWallJumpDirectionSpeed = -followingPlayerScript.maxSpeed;
        }
        Vector2 fallWallJumpPlatformPos      = cNode.fallWallJumpWall.transform.position;
        Vector2 fallWallJumpPlatformSizeDiv2 = cNode.fallWallJumpWall.transform.lossyScale / 2f;

        cNode.fallWallJumpStartX = pfNode.platformGameObject.transform.position.x + (pfNode.platformGameObject.transform.lossyScale.x / 2 +
                                                                                     pfData.pathfindingGameObject.transform.lossyScale.x / 2) * (cNode.preFallWallJumpDirectionSpeed > 0 ? 1 : -1);
        cNode.firstFallWallJumpHit.x = fallWallJumpPlatformPos.x + (fallWallJumpPlatformSizeDiv2.x + pathfindingGameObjectSize.x / 2f) *
                                       (cNode.preFallWallJumpDirectionSpeed > 0f ? -1f : 1f);
        cNode.onPlatformValue        = Math.Abs((cNode.firstFallWallJumpHit.x - cNode.fallWallJumpStartX) / cNode.preFallWallJumpDirectionSpeed);
        cNode.firstFallWallJumpHit.y = pfNode.objectOnFromPlatformY + followingPlayerScript.CalculateFallY(cNode.onPlatformValue);
        if (cNode.firstFallWallJumpHit.y < fallWallJumpPlatformPos.y - fallWallJumpPlatformSizeDiv2.y ||
            cNode.firstFallWallJumpHit.y > fallWallJumpPlatformPos.y + fallWallJumpPlatformSizeDiv2.y || cNode.preFallWallJumpDirectionSpeed == 0f)
        {
            cNode.onPlatformValue = 1f;
        }
        FallVisualization(cNode.onPlatformValue, cNode.fallWallJumpStartX, cNode.preFallWallJumpDirectionSpeed, pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);

        if (cNode.fallWallJumpY > cNode.firstFallWallJumpHit.y)
        {
            cNode.fallWallJumpY = cNode.firstFallWallJumpHit.y;
        }
        else if (cNode.fallWallJumpY < fallWallJumpPlatformPos.y - fallWallJumpPlatformSizeDiv2.y)
        {
            cNode.fallWallJumpY = fallWallJumpPlatformPos.y - fallWallJumpPlatformSizeDiv2.y;
        }
        StraightFallVisualization(cNode.firstFallWallJumpHit.y, cNode.fallWallJumpY, cNode.firstFallWallJumpHit.x, pathfindingGameObjectSize);

        if (cNode.postFallWallJumpDirectionSpeed > followingPlayerScript.maxSpeed)
        {
            cNode.postFallWallJumpDirectionSpeed = followingPlayerScript.maxSpeed;
        }
        else if (cNode.postFallWallJumpDirectionSpeed < -followingPlayerScript.maxSpeed)
        {
            cNode.postFallWallJumpDirectionSpeed = -followingPlayerScript.maxSpeed;
        }
        cNode.onPlatformValue2 = 1;
        if (cNode.objectOnToPlatformY <= cNode.fallWallJumpY + followingPlayerScript.jumpHeight)
        {
            cNode.onPlatformValue2 = followingPlayerScript.CalculateXFromYInJump(cNode.objectOnToPlatformY - cNode.fallWallJumpY);
        }
        JumpVisualization(cNode.onPlatformValue2, cNode.firstFallWallJumpHit.x, cNode.fallWallJumpY, cNode.postFallWallJumpDirectionSpeed,
                          pfNode, followingPlayerScript, pathfindingGameObjectSize);
    }
 private void FallConnection(PathFindingData pfData, PathFindingNode pfNode, ConnectedNode cNode, FollowingPlayer followingPlayerScript, Vector3 pathfindingGameObjectSize)
 {
     if (cNode.fallDirectionSpeed > followingPlayerScript.maxSpeed)
     {
         cNode.fallDirectionSpeed = followingPlayerScript.maxSpeed;
     }
     else if (cNode.fallDirectionSpeed < -followingPlayerScript.maxSpeed)
     {
         cNode.fallDirectionSpeed = -followingPlayerScript.maxSpeed;
     }
     cNode.fallStartX = pfNode.platformGameObject.transform.position.x + (pfNode.platformGameObject.transform.lossyScale.x / 2 +
                                                                          pfData.pathfindingGameObject.transform.lossyScale.x / 2) * (cNode.fallDirectionSpeed > 0 ? 1 : -1);
     cNode.onPlatformValue = 1;
     if (cNode.objectOnToPlatformY < pfNode.objectOnFromPlatformY)
     {
         cNode.onPlatformValue = followingPlayerScript.CalculateXFromYInFall(cNode.objectOnToPlatformY - pfNode.objectOnFromPlatformY);
     }
     FallVisualization(cNode.onPlatformValue, cNode.fallStartX, cNode.fallDirectionSpeed, pfNode, cNode, followingPlayerScript, pathfindingGameObjectSize);
 }