public GameObject CreateGate(Vector3 positionCenter, Quaternion rotation)
    {
        if (createdGate != null)
        {
            return(createdGate);
        }

        Vector3 position = positionCenter + new Vector3(0, GateSize.y * .25f, 0);

        position.y = 1.3f;
        GameObject newObject = Instantiate(GatePrefab, position, rotation);

        if (newObject != null)
        {
            newObject.name             = "Gate";
            newObject.transform.parent = gameObject.transform;
            newObject.tag = "Dummy";
            newObject.transform.localScale = RescaleToSameScaleFactor(GatePrefab);
            createdGate = newObject;
            createdGate.GetComponent <MeshCollider>().enabled = false;
            createdGate.transform.Rotate(0, 0, -90f);
            createdGateScript = createdGate.GetComponent <GateScript>();
            gateCreated       = true;
            if (treeCreated && gateCreated)
            {
                EventManager.TriggerEvent("world_created");
            }
            return(newObject);
        }
        return(null);
    }
Exemplo n.º 2
0
    void CheckForGates()    //analisa os gates passados por cada jogador
    {
        for (int j = 0; j < maxPlayers; j++)
        {
            //Para cada jogador, faz uma comparação se aquele jogador passou por x gates e faz a contagem dos gates de cada jogador
            for (int i = 0; i < Gates; i++)
            {
                ChildGateScript = this.gameObject.transform.GetChild(i).GetComponent <GateScript> ();
                if (ChildGateScript.Atravessado[j] == true)
                {
                    if (ChildGateScript.GateNumber == NextGate(CurrentGate[j]))
                    {
                        totalGatesCrossed [j]++;
                        CurrentGate[j]++;
                        ChildGateScript.Atravessado[j] = false;
                    }

                    else
                    {
                        ChildGateScript.Atravessado[j] = false;
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
 void CheckForGates()
 {
     for (int j = 0; j < maxPlayers; j++)
     {
         //Para cada jogador
         for (int i = 0; i < Gates; i++)
         {
             //Child = Transform.GetChild (i);
             ChildGateScript = this.gameObject.transform.GetChild(i).GetComponent <GateScript> ();
             if (ChildGateScript.Atravessado[j] == true)
             {
                 if (ChildGateScript.GateNumber == NextGate(CurrentGate[j]))
                 {
                     totalGatesCrossed [j]++;
                     CurrentGate[j]++;
                     ChildGateScript.Atravessado[j] = false;
                 }
                 else
                 {
                     ChildGateScript.Atravessado[j] = false;
                 }
             }
         }
     }
 }
    void CheckForInteractions()
    {
        //Grabs all colliders within 5 units
        Collider[] hitColliders = Physics.OverlapSphere(transform.position, 5.0f);

        //iterator to test if we need to clear the interactableobject
        int i = 0;

        foreach (Collider collider in hitColliders)
        {
            //Grabs the script from the colliders
            GateScript script = collider.GetComponent <GateScript>();

            //if there is no script
            if (script == null)
            {
                //increment iterator by one
                i++;

                //if i is not equal to the length than continue
                if (i != hitColliders.Length)
                {
                    continue;
                }

                //else if it is equal to the length clear the interactableobject
                InteractableObject = null;

                continue;
            }

            //if there is a script this is the new interactable object
            InteractableObject = collider;
        }
    }
Exemplo n.º 5
0
    // code that executes when anything has touched the switch
    void OnTriggerEnter2D(Collider2D collider)
    {
        // only deal with objects that are players or boxes
        if (/*collider.CompareTag("Player") ||*/ collider.CompareTag("Box"))
        {
            // if the correct player or box is on switch, activate and check switch controller
            if (collider.name.Contains(color))
            {
                activate = true;

                if (triggerObjects[0].CompareTag("KeySpawn"))
                {
                    foreach (GameObject triggerObject in triggerObjects)
                    {
                        KeySpawnScript ks = triggerObject.GetComponent <KeySpawnScript>();
                        ks.CheckAllSwitches();
                    }
                }
                else if (triggerObjects[0].CompareTag("Gate"))
                {
                    foreach (GameObject triggerObject in triggerObjects)
                    {
                        GateScript gs = triggerObject.GetComponent <GateScript>();
                        gs.GateOpen();
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
    void CollisionHandler(Collision2D other)
    {
        if (other.gameObject.name == "Soul")
        {
            if (!isCarrying && currentTool == 0)
            {
                isCarrying = true;
                Destroy(other.gameObject);
                if (carrySoul != null)
                {
                    downSprite = carrySoul;
                    upSprite   = carrySoulUp;
                    UpdateFacing();
                }
            }
        }

        if (other.gameObject.name == "Gate")
        {
            if (GateScript.breakState < 2)
            {
                if (isCarrying)
                {
                    isCarrying = false;
                    Global.Instance.UpdateScore();
                    RestoreSprite();
                }
            }

            if (GateScript.breakState > 0 && currentTool == 2)
            {
                GateScript.Fix();
            }
        }
    }
Exemplo n.º 7
0
 void DefineGateNumbers()     // da a cada gate o seu numero correto
 {
     for (int i = 0; i < Gates; i++)
     {
         ChildGateScript            = this.gameObject.transform.GetChild(i).GetComponent <GateScript> ();
         ChildGateScript.GateNumber = i;
     }
 }
Exemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     spriteRenderer = GetComponent <SpriteRenderer>();
     originalSprite = spriteRenderer.sprite;
     _instance      = this;
     breakState     = 1;
     Fix();
 }
Exemplo n.º 9
0
    void SpawnGate()
    {
        currentGate = Instantiate(gateSource);
        GateScript gScript = currentGate.GetComponent <GateScript> ();

        currentGate.GetComponent <SpriteRenderer>().color = gateColor;
        gScript.slime    = slime;
        gScript.gameMech = gameObject;
    }
Exemplo n.º 10
0
    void DefineGateNumbers()
    {
        for (int i = 0; i < Gates; i++)
        {
            //Child = Transform.GetChild (i);
            ChildGateScript = this.gameObject.transform.GetChild(i).GetComponent <GateScript> ();

            ChildGateScript.GateNumber = i + 1;
        }
    }
Exemplo n.º 11
0
 void Start()
 {
     // Get the attached object's renderer and set the material.
     rMyRenderer          = GetComponent <Renderer>();
     rMyRenderer.material = mNotPressed;
     // Save the scale of the attached object to a vector.
     vScale = transform.localScale;
     // Get the GateScript component of the 'gate' object reference.
     gateScript = gate.GetComponent <GateScript>();
 }
Exemplo n.º 12
0
    void addEnemies(GateScript room)
    {
        List <GameObject> monsters = new List <GameObject>();

        for (int i = 0; i < difficulty; i++)
        {
            monsters.Add(enemies[Random.Range(0, enemies.Length)]);
        }
        room.addMonsters(monsters);
    }
Exemplo n.º 13
0
    void Awake()
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;

        playercontroller = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        gate = GameObject.FindGameObjectWithTag("Finish").GetComponent <GateScript>();

        playerstats = GameObject.FindGameObjectWithTag("Player").GetComponent <Stats>();

        nav = GetComponent <NavMeshAgent>();
    }
Exemplo n.º 14
0
    public void PlaceGate()
    {
        GateScript closedGate = null;

        closedGate = shutGate.Instance() as GateScript;
        float position_x = 2935f;
        float position_y = 444f;

        Vector2 closedGateLocation = new Vector2(position_x, position_y);

        closedGate.SetPosition(closedGateLocation);
        AddChild(closedGate);
    }
Exemplo n.º 15
0
    private void Update()
    {
        if (trainingMode && manipulationInProgress)
        {
            // Calculate distance of manipulated object and gate
            gateScript = ObjectCollectionManager.Instance.GetCreatedGateScript();

            if (gateScript == null || manipulatedObject == null)
            {
                return;
            }

            if (gateScript.objectInsideGate(manipulatedObject))
            {
                if (uiController.greekEnabled)
                {
                    if (!audioSource.isPlaying)
                    {
                        audioSource.Play();
                    }
                }
                else
                {
                    if (!TextToSpeech.Instance.IsSpeaking())
                    {
                        TextToSpeech.Instance.StartSpeaking("Apple inside the Circle");
                    }
                }

                if (!objectInGateDetected)
                {
                    freeToRelease        = false;
                    objectInGateDetected = true;
                    //Reset Timer
                    timer = 0.0f;
                }
                else
                {   //Refresh Timer
                    timer += Time.deltaTime;
                    if (timer > timerForGate)
                    {
                        freeToRelease = true;
                        if (gateScript != null)
                        {
                            gateScript.enableCollider();
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 16
0
    // code that executes when anything has left the switch
    void OnTriggerExit2D(Collider2D collider)
    {
        // deactivate switch on exit
        activate = false;

        // if trigger is keyspawn, deactivate all keys
        if (triggerObject.CompareTag("KeySpawn"))
        {
            KeySpawnScript ks = triggerObject.GetComponent <KeySpawnScript>();
            ks.DespawnKeys();
        }
        else if (triggerObject.CompareTag("Gate"))
        {
            GateScript gs = triggerObject.GetComponent <GateScript>();
            gs.GateClose();
        }
    }
Exemplo n.º 17
0
    // external function to check all switches
    public void CheckAllSwitches()
    {
        // for each switch, get their script and check their status
        foreach (GameObject obj in mySwitches)
        {
            SwitchScript ss = obj.GetComponent <SwitchScript>();

            // if false, can return immediately since all switches need to be true
            if (ss.CheckSwitch() == false)
            {
                return;
            }
        }

        // if all switches are pressed, open gate
        GateScript gs = gate.GetComponent <GateScript>();

        gs.GateOpen();
    }
Exemplo n.º 18
0
    public void OpenGate()
    {
        GateScript wayIsOpen = null;

        wayIsOpen = openGate.Instance() as GateScript;
        float position_x = 2864f;
        float position_y = 411f;

        Vector2 openGateLocation = new Vector2(position_x, position_y);

        wayIsOpen.SetPosition(openGateLocation);
        if (canOpen)
        {
            var gatewayNode = GetNode("Gateway");
            RemoveChild(gatewayNode);
            AddChild(wayIsOpen);
            canOpen = false;
        }
    }
Exemplo n.º 19
0
 void CheckForGates()
 {
     for (int i = 0; i < Gates; i++)
     {
         //Child = Transform.GetChild (i);
         ChildGateScript = this.gameObject.transform.GetChild(i).GetComponent <GateScript> ();
         if (ChildGateScript.Atravessado == true)
         {
             if (ChildGateScript.GateNumber == CurrentGate + 1)
             {
                 CurrentGate++;
                 ChildGateScript.Atravessado = false;
             }
             else
             {
                 ChildGateScript.Atravessado = false;
             }
         }
     }
 }
Exemplo n.º 20
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            PlayerScript.damageflag = true;
            PlayerScript.PlayerDamage(this.transform.parent.GetComponent <EnemyScript>().enemyAttack);
            //other.gameObject.GetComponent<PlayerScript>().playerHP -= this.transform.parent.GetComponent<EnemyScript>().enemyAttack;
        }

        else if (other.gameObject.tag == "Gate")
        {
            GateScript.GateDamage(this.transform.parent.GetComponent <EnemyScript>().enemyAttack);
        }

        else if (other.gameObject.tag == "WallwithHP")
        {
            //ObstacleScript.damage_flag = 2;
            other.gameObject.GetComponent <ObstacleScript>().obstacleHP -= this.transform.parent.GetComponent <EnemyScript>().enemyAttack;
        }
    }
Exemplo n.º 21
0
    public void PrepareSecondTurtorial()
    {
        turtorialStep = 2;
        AppearAppleDemo();
        // Create Gate and hide it
        Vector3 cameraPos = Camera.main.transform.position;
        Vector3 angles    = Camera.main.transform.eulerAngles;
        Vector3 pos       = new Vector3(cameraPos.x + Mathf.Sin((angles.y) * Mathf.Deg2Rad) * 1.3f,
                                        cameraPos.y,
                                        cameraPos.z + Mathf.Cos((angles.y) * Mathf.Deg2Rad) * 1.3f);
        Quaternion rot = Quaternion.LookRotation(Camera.main.transform.forward, Vector3.up);

        createdGate       = ObjectCollectionManager.Instance.CreateGate(pos, rot);
        createdGateScript = ObjectCollectionManager.Instance.GetCreatedGateScript();
        UtilitiesScript.Instance.DisableObject(createdGate);
        // Listen Events
        EventManager.StartListening("manipulation_started", ManipulationStarted);
        EventManager.StartListening("manipulation_finished", ManipulationFinished);
        // For greek audio feedback
        if (!feedbackTriggered)
        {
            feedbackTriggered = true;
            if (uiController.greekEnabled)
            {
                audioSource.Stop();
                audioSource.clip = uiController.GateIntoClip;
                audioSource.Play();
            }
            else
            {
                TextToSpeech.Instance.StopSpeaking();
                TextToSpeech.Instance.StartSpeaking("Now every time you move an object , a circle will be appeared. " +
                                                    "If you use your right hand, the circle will appear to the right, otherwise to the left." +
                                                    "Guidance points will also appear to guide you the circle. Your goal is to move the object with a turn of the body and your hand stretched out");
            }
        }
    }
Exemplo n.º 22
0
    void Start()
    {
        NodeTiles = new List <RoomTile>();
        Debug.Log("SpriteSheetName: " + SpriteSheet.name + ", Boss: " + BossRoom + ", Start: " + StarterRoom);
        TileSprites = Resources.LoadAll <Sprite>(SpriteSheet.name);

        for (int i = 0; i < tilemap.transform.childCount; i++)
        {
            GateScript gate = tilemap.transform.GetChild(i).GetComponent <GateScript>();
            if (gate != null)
            {
                Gates.Add(gate);
            }
            GateTriggerScript trigger = tilemap.transform.GetChild(i).GetComponent <GateTriggerScript>();
            if (trigger != null)
            {
                trigger.parentRoom = this;
            }
            RoomTile tile = tilemap.transform.GetChild(i).GetComponent <RoomTile>();
            //Debug.Log("TileID: " + tile.ID + ", TileNodeID: " + tile.NodeID);
            if (tile.Node)
            {
                bool Node = false;
                foreach (GenerationNode GenNode in FloorHandler.generationRooms[respresentedX, respresentedY].Nodes)
                {
                    if (GenNode.exitDirection == tile.Direction)
                    {
                        Node = true;
                    }
                }
                if (Node)
                {
                    tile.spriteRenderer.sprite = TileSprites[tile.NodeID];
                    if (gate != null)
                    {
                        gate.Node = true;
                    }
                }
                else
                {
                    if (tile.ColliderIfNotNode)
                    {
                        tilemap.transform.GetChild(i).GetComponent <BoxCollider2D>().enabled = true;
                        if (tile.DefaultLayer == false)
                        {
                            tilemap.transform.GetChild(i).gameObject.layer = 9;
                        }
                    }
                    if (gate != null)
                    {
                        gate.Node = false;
                        gate.GetComponent <Animator>().enabled = false;
                    }
                    tile.spriteRenderer.sprite = TileSprites[tile.ID];
                }
            }
            else if (!tile.Node)
            {
                if (tile.ColliderIfNotNode)
                {
                    tilemap.transform.GetChild(i).GetComponent <BoxCollider2D>().enabled = true;
                    if (tile.DefaultLayer == false)
                    {
                        tilemap.transform.GetChild(i).gameObject.layer = 9;
                    }
                }
                tile.spriteRenderer.sprite = TileSprites[tile.ID];
            }
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            Enemy TempEnemy = transform.GetChild(i).GetComponentInChildren <Enemy>();
            if (TempEnemy != null)
            {
                TempEnemy.OnDeath.AddListener(OnDeath);
                RoomEnemies.Add(TempEnemy);
                TotalSpawnedEnemiesInRoom++;
            }
        }
    }
Exemplo n.º 23
0
 // Use this for initialization
 void Start () {
     gateScript = gate.GetComponent<GateScript>();
 }
Exemplo n.º 24
0
 public void setRoom(GateScript room)
 {
     currentRoom = room;
 }
Exemplo n.º 25
0
    public void Load()
    {
        //https://www.sitepoint.com/saving-and-loading-player-game-data-in-unity/

        if (Directory.Exists("Saves") == false || File.Exists("Saves/save.binary") == false)
        {
            return;
        }

        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      saveFile  = File.Open("Saves/save.binary", FileMode.Open);

        localSaveModel = (SaveModel)formatter.Deserialize(saveFile);

        saveFile.Close();

        GameManager.instance.player.transform.position     = localSaveModel.Player.Position.GetVector();
        GameManager.instance.player.transform.eulerAngles  = localSaveModel.Player.Rotation.GetVector();
        GameManager.instance.player.playerValues.health    = localSaveModel.Player.Health;
        GameManager.instance.player.playerValues.maxHealth = localSaveModel.Player.MaxHealth;
        GameManager.instance.coinCount   = localSaveModel.Player.Coins;
        LevelManager.instance.hasGateKey = localSaveModel.HasKey;

        if (LevelManager.instance.hasGateKey)
        {
            UIManager.instance.ShowKeyImage();
        }
        else
        {
            UIManager.instance.HideKeyImage();
        }

        foreach (ObjectModel model in localSaveModel.MovableObjects)
        {
            if (MovableObjects.ContainsKey(model.Id))
            {
                GameObject go = MovableObjects[model.Id];
                go.transform.position    = model.Position.GetVector();
                go.transform.eulerAngles = model.Rotation.GetVector();
                go.SetActive(model.IsActive);
            }
        }

        foreach (ObjectModel model in localSaveModel.Haybales)
        {
            if (MovableObjects.ContainsKey(model.Id))
            {
                GameObject go = Haybales[model.Id];
                go.transform.position    = model.Position.GetVector();
                go.transform.eulerAngles = model.Rotation.GetVector();
                go.SetActive(model.IsActive);
            }
        }

        foreach (ObjectModel model in localSaveModel.Checkpoints)
        {
            if (Checkpoints.ContainsKey(model.Id))
            {
                GameObject go = Checkpoints[model.Id];
                go.transform.position    = model.Position.GetVector();
                go.transform.eulerAngles = model.Rotation.GetVector();
                go.SetActive(model.IsActive);
            }
        }

        foreach (FallingObjectModel model in localSaveModel.FallingObjects)
        {
            if (FallingObjects.ContainsKey(model.Id))
            {
                FallingObject obj = FallingObjects[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                obj.HasFallen             = model.HasFallen;
                obj.gameObject.SetActive(model.IsActive);
            }
        }

        foreach (FallingObjectModel model in localSaveModel.TrapObjects)
        {
            if (TrapObjects.ContainsKey(model.Id))
            {
                Breakable obj = TrapObjects[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                obj.Broke = model.HasFallen;
                obj.gameObject.SetActive(model.IsActive);
            }
        }

        foreach (EnemyModel model in localSaveModel.Enemies)
        {
            if (Enemies.ContainsKey(model.Id))
            {
                Peasant obj = Enemies[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                if (model.IsStunned)
                {
                    //    obj.PlayerDash(Vector3.zero);
                    obj.isDying = true;
                }
                else
                {
                    obj.ShouldGoAlive = true;
                }
                obj.gameObject.SetActive(model.IsActive);
            }
        }

        foreach (GateModel model in localSaveModel.Gates)
        {
            if (Gates.ContainsKey(model.Id))
            {
                GateScript obj = Gates[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                if (model.IsOpen)
                {
                    obj.Open();
                    UIManager.instance.HideKeyImage();
                }
                obj.gameObject.SetActive(model.IsActive);
            }
        }

        foreach (ObjectModel model in localSaveModel.Dashables)
        {
            if (Dashables.ContainsKey(model.Id))
            {
                Dashable obj = Dashables[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                obj.gameObject.SetActive(model.IsActive);
            }
        }

        foreach (ObjectModel model in localSaveModel.Coins)
        {
            if (Coins.ContainsKey(model.Id))
            {
                CoinPickup obj = Coins[model.Id];
                obj.transform.position    = model.Position.GetVector();
                obj.transform.eulerAngles = model.Rotation.GetVector();
                obj.gameObject.SetActive(model.IsActive);
            }
        }
    }
Exemplo n.º 26
0
 void OnApplicationQuit()
 {
     s_Instance = null;
 }
Exemplo n.º 27
0
 public void initialize(GameObject player, GateScript RS)
 {
     target  = player;
     this.RS = RS;
 }
Exemplo n.º 28
0
    public void LoadMaze(string filePath)
    {
        if (filePath == "")
        {
            return;
        }

        try
        {
            TextAsset binData = Resources.Load(filePath) as TextAsset;
            lines = binData.text.Split('\n');
        }
        catch (Exception e)
        {
            Debug.Log("could not load level");
        }

        // Generate Ground
        GameObject ground = Instantiate <GameObject>(Ground, new Vector3(5f, -0.5f, 5f) * WALL_SIZE, Quaternion.identity);

        ground.transform.localScale = Vector3.one * WALL_SIZE * LENGTH * 100;

        // Generate walls and stuff
        for (int i = 0; i < LENGTH; i++)
        {
            for (int j = 0; j < WIDTH; j++)
            {
                char tileChar = lines[i][j];



                switch (tileChar)
                {
                case (WALL_CHAR):
                    //GameObject wall = Instantiate<GameObject>(Wall, new Vector3(i, 0, j) * WALL_SIZE, Quaternion.identity);

                    GameObject wall = generateCube((int)UnityEngine.Random.Range(0, 8), new Vector3(i, 0, j) * WALL_SIZE, Vector3.zero);
                    wall.transform.localScale = Vector3.one * WALL_SIZE * 10;
                    wall.transform.parent     = gameObject.transform;
                    break;

                case (FLOOR_CHAR):
                    randomfloat = UnityEngine.Random.Range(0.0f, 10.0f);
                    if (randomfloat > 7.0f)
                    {
                        int        bloodint = ((int)randomfloat) % 3;
                        GameObject blood;
                        if (bloodint == 0)
                        {
                            blood = BloodFloor1;
                        }
                        else if (bloodint == 1)
                        {
                            blood = BloodFloor2;
                        }
                        else if (bloodint == 2)
                        {
                            blood = BloodFloor3;
                        }
                        else
                        {
                            blood = BloodFloor1;
                        }
                        GameObject floor = Instantiate <GameObject>(blood, new Vector3(i, -0.4995f, j) * WALL_SIZE, Quaternion.AngleAxis(90, Vector3.right));
                        floor.transform.localScale = Vector3.one * WALL_SIZE;
                        floor.transform.parent     = gameObject.transform;
                        break;
                    }
                    break;

                case (START_CHAR):
                    GameObject startWall = Instantiate <GameObject>(StartGate, new Vector3(i + 1, 0.75f, j) * WALL_SIZE, Quaternion.identity);
                    //GameObject startGate = Instantiate<GameObject>(StartGate, new Vector3(i - 1, 0, j) * WALL_SIZE, Quaternion.identity);

                    GameObject startGate = Instantiate <GameObject>(StartGate, new Vector3(i - 1, 0, j) * WALL_SIZE, Quaternion.Euler(new Vector3(0, 1, 1) * 90));



                    startWall.transform.localScale = Vector3.one * WALL_SIZE * 10;
                    startGate.transform.localScale = Vector3.one * WALL_SIZE * 10;

                    startWall.transform.parent = gameObject.transform;
                    startGate.transform.parent = gameObject.transform;

                    GateScript gs = startWall.GetComponent <GateScript>();
                    gs.SetDirection(-1);

                    //spawning player
                    GameObject harry = Instantiate <GameObject>(Harry, new Vector3(i, 0, j) * WALL_SIZE, Quaternion.identity);
                    harry.transform.Rotate(Vector3.down * 90);
                    harry.transform.parent = gameObject.transform;
                    break;

                case (FIN_CHAR):
                    GameObject finGate = Instantiate <GameObject>(StartGate, new Vector3(i - 1, 0, j) * WALL_SIZE, Quaternion.Euler(new Vector3(0, 1, 1) * 90));
                    finGate.transform.localScale = Vector3.one * WALL_SIZE * 10;
                    finGate.transform.parent     = gameObject.transform;
                    GateScript fgs    = finGate.GetComponent <GateScript>();
                    GameObject finish = Instantiate <GameObject>(Finish, new Vector3(i, 0, j) * WALL_SIZE, Quaternion.identity);
                    finish.transform.parent = gameObject.transform;
                    break;

                default: break;
                }
            }
        }
    }
Exemplo n.º 29
0
 public void updateGateCollision(GateScript gate)
 {
     gameManager.ResetSpeed();
 }
Exemplo n.º 30
0
    public void populateMaze()
    {
        for (int i = 0; i < 37; i++)
        {
            for (int j = 0; j < 37; j++)
            {
                char c = maze[i, j];
                if (c == 'x')
                {
                    GameObject star = (GameObject)Instantiate(StarSpace, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), StarSpace.transform.rotation);
                }
                else if (c == 'u')
                {
                    GameObject emerald = (GameObject)Instantiate(Emerald, new Vector3(getXCoordinate(i), 2.5f, getYCoordinate(j)), Emerald.transform.rotation);
                }
                else if (c == 'e')
                {
                    GameObject ruby = (GameObject)Instantiate(Ruby, new Vector3(getXCoordinate(i), 2.5f, getYCoordinate(j)), Ruby.transform.rotation);
                }
                else if (c == 'h')
                {
                    GameObject amythyst = (GameObject)Instantiate(Amythyst, new Vector3(getXCoordinate(i), 2.5f, getYCoordinate(j)), Amythyst.transform.rotation);
                }
                else if (c == 'a')
                {
                    GameObject sapphire = (GameObject)Instantiate(Sapphire, new Vector3(getXCoordinate(i), 2.5f, getYCoordinate(j)), Sapphire.transform.rotation);
                }

                else if (c == 'r')
                {
                    GameObject greenTree = (GameObject)Instantiate(GreenTree, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), GreenTree.transform.rotation);
                }
                else if (c == 'b')
                {
                    GameObject purpleTree = (GameObject)Instantiate(PurpleTree, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), PurpleTree.transform.rotation);
                }
                else if (c == 'g')
                {
                    GameObject redTree = (GameObject)Instantiate(RedTree, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), RedTree.transform.rotation);
                }
                else if (c == 'v')
                {
                    GameObject blueTree = (GameObject)Instantiate(BlueTree, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), BlueTree.transform.rotation);
                }

                else if (c == 't')
                {
                    GameObject stoneWall = (GameObject)Instantiate(StoneWall, new Vector3(getXCoordinate(i), 0, getYCoordinate(j)), StoneWall.transform.rotation);
                }

                else if (c == '2')
                {
                    GameObject gate = (GameObject)Instantiate(Gate, new Vector3(getXCoordinate(i), 0.0f, getYCoordinate(j)), Gate.transform.rotation);
                    //set text to 2
                    GateScript gs = gate.GetComponent <GateScript>();
                    gs.setText("2");
                }
                else if (c == '3')
                {
                    GameObject gate = (GameObject)Instantiate(Gate, new Vector3(getXCoordinate(i), 0.0f, getYCoordinate(j)), Gate.transform.rotation);
                    //set text to 3
                    GateScript gs = gate.GetComponent <GateScript>();
                    gs.setText("3");
                }
                else if (c == '4')
                {
                    GameObject gate = (GameObject)Instantiate(Gate, new Vector3(getXCoordinate(i), 0.0f, getYCoordinate(j)), Gate.transform.rotation);
                    //set text to 4
                    GateScript gs = gate.GetComponent <GateScript>();
                    gs.setText("4");
                }
                else if (c == '5')
                {
                    GameObject gate = (GameObject)Instantiate(Gate, new Vector3(getXCoordinate(i), 0.0f, getYCoordinate(j)), Gate.transform.rotation);
                    //set text to 5
                    GateScript gs = gate.GetComponent <GateScript>();
                    gs.setText("5");
                }
                else if (c == '6')
                {
                    GameObject gate = (GameObject)Instantiate(Gate, new Vector3(getXCoordinate(i), 0.0f, getYCoordinate(j)), Gate.transform.rotation);
                    //set text to 6
                    GateScript gs = gate.GetComponent <GateScript>();
                    gs.setText("6");
                }
            }
        }
    }
Exemplo n.º 31
0
 void Awake()
 {
     gate = transform.parent.GetComponent <GateScript>();
 }