Esempio n. 1
0
    public void HandlePortal(MovingCube blockToTeleport, Collider col)
    {
        if (portals.Count <= 1)
        {
            return;
        }



        if (blockToTeleport.canGoThruPortals)
        {
            print("handle portal");

            blockToTeleport.canGoThruPortals = false;

            PortalCube        currentPortal    = col.GetComponent <PortalCube>();
            List <PortalCube> allPortals       = portals;
            List <PortalCube> potentialPortals = new List <PortalCube>();

            for (int i = 0; i < allPortals.Count; i++)
            {
                if (allPortals[i] != currentPortal)
                {
                    potentialPortals.Add(allPortals[i]);
                }
            }

            portalToComeOutOf = potentialPortals[Random.Range(0, potentialPortals.Count)];


            StartCoroutine(portalBuffer(blockToTeleport));
        }
    }
Esempio n. 2
0
    private IEnumerator portalBuffer(MovingCube blockToTeleport)
    {
        yield return(new WaitForSeconds(.5f));

        blockToTeleport.transform.position = portalToComeOutOf.transform.position;
        yield return(new WaitForSeconds(1f));

        blockToTeleport.canGoThruPortals = true;
    }
Esempio n. 3
0
    private void OnEnable()
    {
        //first cube that spawns automatically becomes the last cube
        if (LastCube == null)
        {
            //remember if you rename 'start' cube object in unity the whole game breaks
            LastCube = GameObject.Find("Start").GetComponent <MovingCube>();
        }

        CurrentCube = this;
    }
Esempio n. 4
0
    private void OnEnable()
    {
        if (LastCube == null)
        {
            LastCube = GameObject.Find("Start").GetComponent <MovingCube>();
        }

        CurrentCube = this;

        GetComponent <Renderer>().material.color = GetRandomColor();
    }
Esempio n. 5
0
    private void OnEnable()
    {
        if (LastCube == null)
        {
            LastCube = GameObject.Find("Start").GetComponent <MovingCube>();
        }

        CurrentCube = this;
        GetComponent <Renderer>().material.color = GetRandomColor();

        transform.localScale = new Vector3(LastCube.transform.localScale.x, transform.localScale.y, transform.localScale.z);
    }
Esempio n. 6
0
    protected void OnEnable()
    {
        if (LastCube == null)
        {
            LastCube = GameObject.Find("Start Cube").GetComponent <MovingForwardCube>();
        }

        Debug.Log(LastCube.ToString());

        if (reversed)
        {
            moveSpeed *= -1;
        }

        CurrentCube = this;
    }
Esempio n. 7
0
    public void SpawnCube()
    {
        GameObject cube = Instantiate(cubePrefab);

        currentCube = cube.GetComponent <MovingCube>();

        int index = Random.Range(0, cubeSpawnData.Length);

        Debug.Log("index = " + index);

        if (lastCube != null && lastCube.gameObject != GameObject.Find("Start"))
        {
            float x = cubeSpawnData[index].moveDirection == MoveDirection.X ? cubeSpawnData[index].spawnPoint.transform.position.x : lastCube.transform.position.x;
            float z = cubeSpawnData[index].moveDirection == MoveDirection.Z ? cubeSpawnData[index].spawnPoint.transform.position.z : lastCube.transform.position.z;

            cube.transform.position = new Vector3(x, lastCube.transform.position.y + cube.transform.localScale.y, z);
        }
        else
        {
            cube.transform.position = cubeSpawnData[index].spawnPoint.transform.position;
        }

        cube.GetComponent <MovingCube>().MoveDirection = cubeSpawnData[index].moveDirection;
    }
Esempio n. 8
0
 private void Awake()
 {
     //TODO: Move to Spawner
     CurrentCube = this;
 }
Esempio n. 9
0
 void Awake()
 {
     lastCube = GameObject.Find("Start").GetComponent <MovingCube>();
 }