Beispiel #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == "Player")
        {
            boxCol.enabled = false;
            //graphics.SetActive(true);

            LevelManager.instance.currentCheckpoint = this.gameObject;
            currentDirection = IntoLine.instance.direction;
//			LevelManager.instance.currentTag = player.tag;

//			foreach(GameObject stateObj in objectsToRemove)
//			{
//				LevelManager.instance.stateObjects.Remove(stateObj);
//			}
//			foreach(PlatformController platformObj in platformsToRemove)
//			{
//				LevelManager.instance.platforms.Remove(platformObj);
//			}
//			foreach(Lever leverObj in leversToRemove)
//			{
//				LevelManager.instance.levers.Remove(leverObj);
//			}
//			foreach(FallingPlatform fallObj in fallingToRemove)
//			{
//				LevelManager.instance.fallingPlatforms.Remove(fallObj);
//			}
        }
    }
Beispiel #2
0
    //Handles the transformation of player step by step
    public IEnumerator TransformPlayer(IntoLine.Direction newDirection)
    {
        //Stop shooting rays on both portals
        shootRays            = false;
        otherWater.shootRays = false;

        //Calculating entrance point on water portal
        CalculatePosition();

        yield return(new WaitForEndOfFrame());

        //Making player invisible to ensure that he is not seen outsite mask
        playerRender.enabled = false;

        //Setting the new directionState for the player
        IntoLine.instance.direction = newDirection;

        yield return(new WaitForEndOfFrame());

        //Making player visible again
        playerRender.enabled = true;

        //Changing the player's position based on whether he is going to a rotated or a nonrotated water portal
        playerCol.transform.position = (otherWater.rotated)?new Vector3(otherPortal.position.x, otherPortal.position.y - offsetInWater, playerCol.transform.position.z):new Vector3(otherPortal.position.x - offsetInWater, otherPortal.position.y, playerCol.transform.position.z);

        //Offset to make it look like comming out of water
        playerCol.transform.Translate(new Vector3(0f, -2f, 0f));

        //Setting the player's velocity
        CalculateVelocity();

        //We start shooting rays again
        shootRays = true;

        yield return(new WaitForSeconds(0.5f));

        //Resetting hitCount and hit booleans and starts to shoot rays on opposing portal again
        hitCount             = 0;
        otherWater.shootRays = true;
        hitBot = true;
        hitTop = true;
    }
Beispiel #3
0
    void Update()
    {
        playerDirection = GameObject.Find("Player").GetComponent <IntoLine>().direction;

        if (!IntoLine.instance.transforming)
        {
            pltCanChange = true;
        }

        switch (platform)
        {
        case Platform.Move:
            UpdateRaycastOrigins();
            CalculateRaySpacing();

            velocity = CalculatePlatformMovement();
            CalculatePassengerMovement(velocity);
            MovePassengers(true);
            transform.Translate(velocity);
            MovePassengers(false);

            if (IntoLine.instance.transforming && pltCanChange)
            {
                StartCoroutine(StartStop(Platform.Move));
            }
            break;

        case Platform.Stop:
            if (IntoLine.instance.transforming && pltCanChange && !elevator)
            {
                StartCoroutine(StartStop(Platform.Stop));
            }
            break;
        }

        if (elevator == false && !onAndOff)
        {
            platform = Platform.Move;
        }
    }
Beispiel #4
0
    void Update()
    {
        if (hasKey)
        {
            playerDirection = GameObject.Find("Player").GetComponent <IntoLine>().direction;
            AdjustGravity();
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            if (hasKey)
            {
                DropKey();
            }
        }
        if (noTransKey)
        {
            if (IntoLine.instance.transforming)
            {
                transform.parent.position = transform.parent.transform.parent.transform.parent.position;
                DropKey();
            }
        }
    }