Exemple #1
0
    public void Teleport(GameObject player, Teleportal portal)
    {
        portal.playerIsComing = true;

        Smaterializator smat = player.GetComponent <Smaterializator>();

        if (smat == null)
        {
            player.GetComponent <Rigidbody>().velocity = Vector3.zero;
            player.transform.position = portal.transform.position;
        }
        else
        {
            StartCoroutine(ChagePositionAfterSmaterialization(player, smat, portal));
        }
    }
Exemple #2
0
    private void CreatePortals()
    {
        for (int i = 0; i < platformIndexes.Count - 1; i++)
        {
            int index = platformIndexes[i];
            platforms[index] = ReplaceHoledPlatformIfNeeded(platforms[index]);
            GameObject portalObject1 = Instantiate(portalPrefab, platforms[index].transform.position + Vector3.up * 0.2f, portalPrefab.transform.rotation, platforms[index].transform.parent);
            Teleportal portal1       = portalObject1.GetComponent <Teleportal>();

            platforms[index + 1] = ReplaceHoledPlatformIfNeeded(platforms[index + 1]);
            GameObject portalObject2 = Instantiate(portalPrefab, platforms[index + 1].transform.position + Vector3.up * 0.2f, portalPrefab.transform.rotation, platforms[index + 1].transform.parent);
            Teleportal portal2       = portalObject2.GetComponent <Teleportal>();

            portal1.otherPortal = portal2;
            portal2.otherPortal = portal1;
            portal2.IsGoingDown();
        }
    }
Exemple #3
0
    IEnumerator ChagePositionAfterSmaterialization(GameObject player, Smaterializator smat, Teleportal portal)
    {
        //Graphic Effect
        var emission = particle.emission;
        var vel      = particle.velocityOverLifetime;

        foreach (MeshRenderer rend in cones)
        {
            rend.material = ActivePortalDirectionMat;
        }
        emission.rateOverTime = 15;
        vel.y = downward ? -30 : 30;

        smat.FadeOut();



        while (smat.isFading)
        {
            yield return(0);
        }



        //Revert Graphic Effect
        foreach (MeshRenderer rend in cones)
        {
            rend.material = defaultMat;
        }
        emission.rateOverTime = 2;
        vel.y = downward ? -3 : 3;

        smat.FadeIn();

        //Logic
        player.GetComponent <Rigidbody>().velocity = Vector3.zero;
        player.transform.position = portal.transform.position;
    }