Inheritance: NetworkBehaviour
Exemplo n.º 1
0
    /// <summary>
    /// Crée un objet Floor et renvoie son script
    /// </summary>
    /// <param name="floorNumber"></param>
    /// <returns>Script du Floor créé</returns>
    public static FloorScript CreateFloor(int floorNumber)
    {
        FloorScript floor = Instantiate(instance.floorPreFab, Vector3.zero, Quaternion.identity).GetComponent <FloorScript>();

        floor.Initialize(floorNumber);
        return(floor);
    }
Exemplo n.º 2
0
    private void IncreaseBlurSpeed()
    {
        GameObject  floor       = GameObject.Find("Floor");
        FloorScript floorScript = floor.GetComponent <FloorScript>();

        floorScript.blurSpeed *= 10;
    }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         Ray        ray       = Camera.main.ScreenPointToRay(Input.mousePosition);
         int        layermask = 1 << 13;
         if (Physics.Raycast(ray, out hit, Mathf.Infinity, layermask))
         {
             //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
             Debug.Log("Did Hit " + hit.transform.gameObject.tag);
             GameObject     gameObject = hit.transform.gameObject;
             ResourceScript r          = gameObject.GetComponent <ResourceScript>();
             UnitScript     u          = gameObject.GetComponent <UnitScript>();
             FloorScript    f          = gameObject.GetComponent <FloorScript>();
             if (r != null)
             {
                 //r.OnMouseDown2();
             }
             if (u != null)
             {
                 //u.OnMouseDown2();
             }
             if (f != null)
             {
                 //f.OnMouseDown2();
             }
         }
     }
 }
Exemplo n.º 4
0
    public void FloorClicked(FloorScript floorScript)
    {
        if (GameManager.instance.GameStarted && !GameManager.instance.GamePaused)
        {
            currentFloor = floorScript;

            if (floorScript.floorType == FloorType.BLACK || floorScript.floorType == FloorType.NULL)
                return;

            GetComponent<SpriteRenderer>().enabled = true;
            transform.position = floorScript.gameObject.transform.position + offset;

            if (floorScript.floorType == FloorType.WHITE)
            {
                foreach (var go in floorSelectorButtons)
                {
                    go.gameObject.SetActive(true);
                }
            }

            if (floorScript.floorType == FloorType.ORANGE)
            {
                foreach (var go in floorSelectorButtons)
                {
                    go.gameObject.SetActive(false);
                }

                floorSelectorButtons[0].gameObject.SetActive(true);
            }

        }
    }
Exemplo n.º 5
0
    public Floor(GameObject obj, int width, int length)
    {
        Object         = obj;
        Width          = width;
        Length         = length;
        ObjFloorScript = Object != null?Object.GetComponent <FloorScript>() : null;

        IsExisting = Object != null? true:false;
    }
Exemplo n.º 6
0
    //임시 실행하기 위해 장판 정보 로드
    void FloorUpload()
    {
        int FloorCount = FloorRoot.transform.childCount;

        for (int i = 0; i < FloorCount; i++)
        {
            GameObject floor = FloorRoot.transform.GetChild(i).gameObject;

            FloorScript floorInfo = floor.GetComponent <FloorScript>();

            switch (floorInfo.GetFloorKind)
            {
            case (int)FloorKind.START_FLOOR:
            {
                // 출발점 장판의 트랙 번호가 기존에 없으면 추가
                if (!(dicStartFloor.ContainsKey(floorInfo.trackNumber)))
                {
                    dicStartFloor.Add(floorInfo.trackNumber, floor);
                }
                break;
            }

            case (int)FloorKind.MIDDLE_FLOOR:
            {
                // 중간 장판의 트랙 번호가 기존에 있으면
                if (dicMiddleFloor.ContainsKey(floorInfo.trackNumber))
                {
                    // 해당 트랙 번호 딕셔너리에 장판 번호가 기존에 없으면 추가
                    if (!(dicMiddleFloor[floorInfo.trackNumber].ContainsKey(floorInfo.floorNumber)))
                    {
                        dicMiddleFloor[floorInfo.trackNumber].Add(floorInfo.floorNumber, floor);
                    }
                }
                // 중간 장판의 트랙 번호가 기존에 없으면 추가
                else
                {
                    Dictionary <int, GameObject> newDicMiddleFloor = new Dictionary <int, GameObject>();
                    newDicMiddleFloor.Add(floorInfo.floorNumber, floor);
                    dicMiddleFloor.Add(floorInfo.trackNumber, newDicMiddleFloor);
                }
                break;
            }

            case (int)FloorKind.END_FLOOR:
            {
                // 종착점 장판의 트랙 번호가 기존에 없으면 추가
                if (!(dicEndFloor.ContainsKey(floorInfo.trackNumber)))
                {
                    dicEndFloor.Add(floorInfo.trackNumber, floor);
                }
                break;
            }
            }
        }
    }
Exemplo n.º 7
0
 void workOutPlayerFloor()
 {
     foreach (FloorScript f in floors)
     {
         if (f.isObjectInRoom(CommonObjectsStore.player) == true)
         {
             playerFloor = f;
             return;
         }
     }
     playerFloor = null;
 }
Exemplo n.º 8
0
  // Use this for initialization
  void Start() {
    
    currentState = GameState.START_SCREEN;
    print("Now Playing...");
    spawnerManager = gameObject.GetComponent<SpawnerManager>();
    scoreManager = gameObject.GetComponent<ScoreManager>();
    floorManager = gameObject.GetComponent<FloorScript>();
    playerA = GameObject.FindGameObjectWithTag("PlayerA");
    characterManagerA = playerA.GetComponent<CharacterManager>();

    playerB = GameObject.FindGameObjectWithTag("PlayerB");
    characterManagerB = playerB.GetComponent<CharacterManager>();
    hud.enabled = false;
  
  }
Exemplo n.º 9
0
    public void LoadTrack()
    {
        string filePath = "";

#if UNITY_EDITOR
        filePath = EditorUtility.OpenFilePanel("Open Track File Dialog"
                                               , Application.dataPath
                                               , "xml");
#endif
        if (filePath.Length != 0)  // 파일 선택
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filePath);

            foreach (Transform child in FloorRoot.transform)  // 모든 오브젝트 삭제
            {
                Destroy(child.gameObject);
            }

            XmlNodeList nodeList = xmlDoc.SelectNodes("TrackInfo/Track");

            foreach (XmlNode node in nodeList)
            {
                GameObject floorObject = Resources.Load("Floor Resources/" + node.SelectSingleNode("FloorName").InnerText) as GameObject;

                Vector3 position = new Vector3(float.Parse(node.SelectSingleNode("X").InnerText),
                                               float.Parse(node.SelectSingleNode("Y").InnerText),
                                               float.Parse(node.SelectSingleNode("Z").InnerText));

                GameObject newFloor = Instantiate(floorObject, position, Quaternion.identity, FloorRoot.transform);

                newFloor.name = newFloor.name.Substring(0, newFloor.name.Length - 7);
                newFloor.transform.eulerAngles = new Vector3(90f, 0f, 0f);

                if (!(newFloor.name.Equals("MiddleFloor")))
                {
                    newFloor.transform.eulerAngles *= -1f;
                }

                FloorScript floorScript = newFloor.AddComponent <FloorScript>();
                floorScript.trackNumber = int.Parse(node.SelectSingleNode("TrackNumber").InnerText);
                floorScript.floorNumber = int.Parse(node.SelectSingleNode("FloorNumber").InnerText);
            }

            Debug.Log("Floor Xml File  Load Succes!");
        }
    }
Exemplo n.º 10
0
    void LoadMainOffice()
    {
        string       path = System.IO.Path.Combine(user_app_path, "mainoffice.txt");
        StreamReader f    = new StreamReader(path);
        string       line = f.ReadLine();

        string[] parts = line.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
        int      top   = -1;

        if (!int.TryParse(parts[1], out top))
        {
            Debug.Log("Error LoadMainOffice parse " + parts[1]);
        }
        int left = -1;

        if (!int.TryParse(parts[2], out left))
        {
            Debug.Log("Error LoadMainOffice parse " + parts[1]);
        }
        int bottom = -1;

        if (!int.TryParse(parts[3], out bottom))
        {
            Debug.Log("Error LoadMainOffice parse " + parts[1]);
        }
        int right = -1;

        if (!int.TryParse(parts[4], out right))
        {
            Debug.Log("Error LoadMainOffice parse " + parts[1]);
        }

        GameObject floor = GameObject.Find("Floor");

        main_floor = Instantiate(floor, new Vector3(left * 1.0f, 0, top * 1.0f), Quaternion.identity);
        FloorScript floor_script = (FloorScript)main_floor.GetComponent(typeof(FloorScript));

        floor_script.DoPosition(top, left, bottom, right);
        Debug.Log("main_floor instantiated, name is " + main_floor.name);
    }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        //numberOfKeys.text = keys.ToString();
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, length))
            {
                if (hit.collider.CompareTag("Door"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }

                    if (Inventory.keys[doorScript.index] == true)
                    {
                        doorScript.ChangeDoorState();
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                    }
                    else
                    {
                        FindObjectOfType <AudioManager>().Play("LockedDoor");
                    }

                    //Debug.Log("Colidi");
                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("FinalDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }

                    if (Inventory.keys[doorScript.index] == true && soundEmitter >= 4 && imagePuzzle.valorFinal == 5)
                    {
                        doorScript.ChangeDoorState();
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                    }
                    else
                    {
                        FindObjectOfType <AudioManager>().Play("LockedDoor");
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            finalDoorText.SetActive(true);
                            StartCoroutine(WaitForSec());
                        }
                    }

                    Debug.Log("Colidi");
                    //player.ChangeCameraStateTrue();
                }
                else if (hit.collider.CompareTag("Key"))
                {
                    Inventory.keys[hit.collider.GetComponent <KeyScript>().index] = true;
                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        uiObject.SetActive(true);
                        StartCoroutine("WaitForSec");
                    }
                    //Debug.Log("ColidiCarai");
                    //Destroy(gameObject);
                    FindObjectOfType <AudioManager>().Play("GetKey");

                    KeyScript keyScript = hit.collider.transform.GetComponent <KeyScript>();
                    keyScript.DestroyKey();
                    keys++;
                }

                //Interactable intercactable = hit.collider.GetComponent<Interactable>();

                else if (hit.collider.CompareTag("AnimInteractable"))
                {
                    PlayAnimation animation = hit.collider.transform.GetComponent <PlayAnimation>();
                    animation.AnimPlay();
                    Debug.Log("TaFuncionando"); //Não ta funcionando ;-; T-T
                }

                else if (hit.collider.CompareTag("Sink") && isCarryingWater == false)
                {
                    if (waterIsWorking)
                    {
                        isCarryingWater = true;
                        Debug.Log("PEGUEI A AGUA");
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            uiObject2.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                        glassIcon.SetActive(true);
                        trigger2.SetActive(true);
                    }
                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            uiObject3.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("Fire"))
                {
                    if (isCarryingWater == true)
                    {
                        FireScript fireParticles = hit.collider.transform.GetComponent <FireScript>();
                        fireParticles.DestroyFire();
                        Debug.Log("APAGUEI O FOGO");
                        glassIcon.SetActive(false);
                        xGlassIcon.SetActive(true);
                        fireplaceKey.SetActive(true);
                        isCarryingWater = false;
                    }

                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            text3.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("Regulator") && waterIsWorking == false)
                {
                    waterIsWorking = true;
                    Debug.Log("LIGUEI O REGISTRO");
                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        text.SetActive(true);
                        StartCoroutine("WaitForSec");
                    }
                    kitchenTable.SetActive(true);
                    normalTable.SetActive(false);
                    kitchenWater.SetActive(true);
                    //PoisonedWaterScript blackWater = hit.collider.transform.GetComponent<PoisonedWaterScript>();
                    //blackWater.DestroyWater();
                    //Debug.Log("RIP AGUA DA MORTE");
                    //waterTankKey.SetActive(true);
                    //normalWater.SetActive(true);
                    //fallingWater.SetActive(true);
                }

                else if (hit.collider.CompareTag("PoisonedWater"))
                {
                    if (waterIsWorking)
                    {
                        PoisonedWaterScript blackWater = hit.collider.transform.GetComponent <PoisonedWaterScript>();
                        blackWater.DestroyWater();
                        Debug.Log("RIP AGUA DA MORTE");
                        waterTankKey.SetActive(true);
                        normalWater.SetActive(true);
                        fallingWater.SetActive(true);
                    }

                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            text2.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("MovableFloor"))
                {
                    FloorScript floor = hit.collider.transform.GetComponent <FloorScript>();
                    floor.DestroyFloor();
                    //secretCompartmentKey.SetActive(true);
                }

                else if (hit.collider.CompareTag("Text"))
                {
                    PrintMessage text = hit.collider.transform.GetComponent <PrintMessage>();

                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        text.ShowText();
                        StartCoroutine(WaitForSec());
                    }
                    //text.TextOnScreen();
                }

                // if (hit.collider.gameObject.name == "Boiler")
                // {
                // boiler.SetActive(false);
                //}

                else if (hit.collider.CompareTag("RightDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }
                    else
                    {
                        doorScript.PuzzleDoor();
                        pm.canMove = false;
                        StartCoroutine(WrongDoorEvent());
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                        FindObjectOfType <AudioManager>().Play("Right");
                        doorScript.ChangeGroup();
                    }

                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("WrongDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }
                    else
                    {
                        Debug.Log(pm.transform.position);
                        doorScript.PuzzleDoor();
                        pm.canMove = false;
                        StartCoroutine(WrongDoorEvent());
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                        FindObjectOfType <AudioManager>().Play("Wrong");
                        //pm.SetPlayerSpeed(5);
                    }

                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("SoundPuzzle"))
                {
                    Inventory.soundPuzzleObjects[hit.collider.GetComponent <SoundPuzzleScript>().index] = true;

                    SoundPuzzleScript soundPuzzle = hit.collider.transform.GetComponent <SoundPuzzleScript>();
                    soundPuzzle.ActivateIcon();
                    soundPuzzle.AddIndex();
                    soundPuzzle.DestroyObject();
                    uiObject4.SetActive(true);
                    FindObjectOfType <AudioManager>().Play("GetKey");
                    StartCoroutine("WaitForSec");
                    // soundEmitter++;
                }

                else if (hit.collider.CompareTag("NoiseEmitter"))
                {
                    NoiseEmitterScript noiseEmitterScript = hit.collider.transform.GetComponent <NoiseEmitterScript>();

                    if (noiseEmitterScript == null)
                    {
                        return;
                    }


                    if (Inventory.soundPuzzleObjects[noiseEmitterScript.index] == true)
                    {
                        soundEmitter++;
                        noiseEmitterScript.ActivateObject();
                        print(soundEmitter);
                        FindObjectOfType <AudioManager>().Play("Right");
                    }
                }
                // =======================Xylophone========================

                if (hit.collider.name == "XyloA")
                {
                    FindObjectOfType <AudioManager>().Play("XyloA");
                }

                if (hit.collider.name == "XyloB")
                {
                    FindObjectOfType <AudioManager>().Play("XyloB");
                }

                if (hit.collider.name == "XyloC")
                {
                    FindObjectOfType <AudioManager>().Play("XyloC");
                }

                if (hit.collider.name == "XyloD")
                {
                    FindObjectOfType <AudioManager>().Play("XyloD");
                }

                if (hit.collider.name == "XyloE")
                {
                    FindObjectOfType <AudioManager>().Play("XyloE");
                }

                if (hit.collider.name == "XyloF")
                {
                    FindObjectOfType <AudioManager>().Play("XyloF");
                }

                if (hit.collider.name == "XyloG")
                {
                    FindObjectOfType <AudioManager>().Play("XyloG");
                }
            }
        }

        if (soundEmitter == 4)
        {
            painting.SetActive(true);
        }
    }
Exemplo n.º 12
0
    private IEnumerator SpawnMaze()
    {
        for (int w = 0; w < maze.GetLength(0); w++)
        {
            for (int l = 0; l < maze.GetLength(1); l++)
            {
                FloorScript F = Instantiate(CellPrefab, new Vector3(w * 10 * CellSize, 0, l * 10 * CellSize), Quaternion.identity).GetComponent <FloorScript>();
                F.transform.localScale = new Vector3(CellSize, CellSize, CellSize);
                if (w == 0 && l == 0 && GameObject.FindWithTag("Player") != null)
                {
                    GameObject.FindWithTag("Player").transform.position = F.transform.position;
                }
                F.WallLeft.SetActive(maze[w, l].UnbreakableWallLeft?maze[w, l].UnbreakableWallLeft : maze[w, l].WallLeft);

                //F.myLevel = 1;
                F.WallBottom.SetActive(maze[w, l].UnbreakableWallBottom ? maze[w, l].UnbreakableWallBottom : maze[w, l].WallBottom);
                F.MazeExit = maze[w, l].MazeExit;

                //F.CheckBlob(maze[w,l].ShouldBeWithBlob, maze[w,l].BlobType);
                if (maze[w, l].AmISanctuaryCenter)
                {
                    F.floortransform.SetActive(false);
                }
                if (maze[w, l].ShouldBeWithBlob)
                {
                    GlobalSettings.GameGlobalSettings.AllCellsWithBlobsFirstLevel.Add(F.gameObject);
                }
                F.bIsSanctuartyCenter = maze [w, l].AmISanctuaryCenter;
                if (maze[w, l].AmISanctuaryCenter)
                {
                    F.PlaceSanctuary(1);
                    SanctuaryCenter1 = F.gameObject;
                }

                if (maze[w, l].AmIInClosedSanctuary && !maze[w, l].AmISanctuaryCenter)
                {
                    GlobalSettings.GameGlobalSettings.ClosedSanctuaryFloors1.Add(F.gameObject);
                    //F.floortransform.SetActive(false);
                }
                if (maze[w, l].AmISanctuary)
                {
                    GlobalSettings.GameGlobalSettings.SanctuaryFloors1.Add(F.gameObject);
                }

                if (!maze[w, l].AmISanctuary)
                {
                    GlobalSettings.GameGlobalSettings.NotSanctuaryFloors1.Add(F.gameObject);
                }

                F.AmIInClosedSanctuary = maze[w, l].AmIInClosedSanctuary || maze[w, l].AmISanctuaryCenter;



                // if(maze[w,l].BarrierLeft){
                //     F.BarrierLeft.SetActive(true);
                //     F.BarrierLeft.GetComponent<BarrierScript>().myKeyBlob = FindBlobByString(maze[w,l].BarrierLeftObj);
                // }
                // else F.BarrierLeft.SetActive(false);

                // if(maze[w,l].BarrierBottom){
                //     F.BarrierBottom.SetActive(true);
                //     F.BarrierBottom.GetComponent<BarrierScript>().myKeyBlob = FindBlobByString(maze[w,l].BarrierBottomObj);
                // }
                // else F.BarrierBottom.SetActive(false);

                F.OnMyStart();
                //F.CheckBlob(false, "Green");
                if (WithDelay)
                {
                    yield return(null);
                }
            }
        }
        Vector3 newMazeStartingPoint  = SanctuaryCenter1.transform.position - new Vector3(0, 10f * CellSize, 0);
        Vector3 startingElevatorplace = SanctuaryCenter1.transform.position - new Vector3(0, 10f * CellSize, 0);

        for (int i = 0; i < ElevatorShaftLength; i++)
        {
            Vector3 curentFloorCenterPos = startingElevatorplace - new Vector3(0, 10f * CellSize * i, 0);

            GameObject GameObject1 = Instantiate(CellPrefab, curentFloorCenterPos, Quaternion.identity);
            GameObject GameObject2 = Instantiate(CellPrefab, curentFloorCenterPos + new Vector3(10 * CellSize, 0, 0), Quaternion.identity);
            GameObject GameObject3 = Instantiate(CellPrefab, curentFloorCenterPos + new Vector3(0, 0, 10 * CellSize), Quaternion.identity);
            GameObject1.transform.localScale = new Vector3(CellSize, CellSize, CellSize);
            GameObject2.transform.localScale = new Vector3(CellSize, CellSize, CellSize);
            GameObject3.transform.localScale = new Vector3(CellSize, CellSize, CellSize);
            GameObject1.GetComponent <FloorScript>().floortransform.SetActive(false);
            GameObject2.GetComponent <FloorScript>().floortransform.SetActive(false);
            GameObject3.GetComponent <FloorScript>().floortransform.SetActive(false);
            newMazeStartingPoint = curentFloorCenterPos;
            GameObject1.GetComponent <FloorScript>().AmIInClosedSanctuary = true;
            GameObject2.GetComponent <FloorScript>().AmIInClosedSanctuary = true;
            GameObject3.GetComponent <FloorScript>().AmIInClosedSanctuary = true;
            GameObject1.GetComponent <FloorScript>().OnMyStart();
            GameObject2.GetComponent <FloorScript>().OnMyStart();
            GameObject3.GetComponent <FloorScript>().OnMyStart();
        }

        newMazeStartingPoint -= new Vector3(0, 10f * CellSize, 0);

        for (int w = 0; w < secondmaze.GetLength(0); w++)
        {
            for (int l = 0; l < secondmaze.GetLength(1); l++)
            {
                FloorScript F = Instantiate(CellPrefabSecondLevel, newMazeStartingPoint + new Vector3(w * 10 * CellSize, 0, l * 10 * CellSize), Quaternion.identity).GetComponent <FloorScript>();
                if (w == 0 && l == 0)
                {
                    F.Celling.SetActive(false);
                }
                F.transform.localScale = new Vector3(CellSize, CellSize, CellSize);

                //if(w==0&&l==0&&GameObject.FindWithTag("Player")!=null) GameObject.FindWithTag("Player").transform.position = F.transform.position;
                F.WallLeft.SetActive(secondmaze[w, l].UnbreakableWallLeft?secondmaze[w, l].UnbreakableWallLeft : secondmaze[w, l].WallLeft);
                F.WallBottom.SetActive(secondmaze[w, l].UnbreakableWallBottom ? secondmaze[w, l].UnbreakableWallBottom : secondmaze[w, l].WallBottom);
                F.MazeExit = secondmaze[w, l].MazeExit;
                //F.myLevel = 2;
                //F.CheckBlob(maze[w,l].ShouldBeWithBlob, maze[w,l].BlobType);
                if (secondmaze[w, l].AmISanctuaryCenter)
                {
                    F.floortransform.SetActive(false);
                }
                if (secondmaze[w, l].ShouldBeWithBlob)
                {
                    GlobalSettings.GameGlobalSettings.AllCellsWithBlobsSecondLevel.Add(F.gameObject);
                }
                F.bIsSanctuartyCenter = secondmaze [w, l].AmISanctuaryCenter;
                if (secondmaze[w, l].AmISanctuaryCenter)
                {
                    F.PlaceSanctuary(2);
                    SanctuaryCenter2 = F.gameObject;
                }

                if (secondmaze[w, l].AmIInClosedSanctuary && !secondmaze[w, l].AmISanctuaryCenter)
                {
                    GlobalSettings.GameGlobalSettings.ClosedSanctuaryFloors2.Add(F.gameObject);
                    //F.floortransform.SetActive(false);
                }
                if (secondmaze[w, l].AmISanctuary)
                {
                    GlobalSettings.GameGlobalSettings.SanctuaryFloors2.Add(F.gameObject);
                }

                if (!secondmaze[w, l].AmISanctuary)
                {
                    GlobalSettings.GameGlobalSettings.NotSanctuaryFloors2.Add(F.gameObject);
                }

                F.AmIInClosedSanctuary = maze[w, l].AmIInClosedSanctuary || maze[w, l].AmISanctuaryCenter;



                // if(maze[w,l].BarrierLeft){
                //     F.BarrierLeft.SetActive(true);
                //     F.BarrierLeft.GetComponent<BarrierScript>().myKeyBlob = FindBlobByString(maze[w,l].BarrierLeftObj);
                // }
                // else F.BarrierLeft.SetActive(false);

                // if(maze[w,l].BarrierBottom){
                //     F.BarrierBottom.SetActive(true);
                //     F.BarrierBottom.GetComponent<BarrierScript>().myKeyBlob = FindBlobByString(maze[w,l].BarrierBottomObj);
                // }
                // else F.BarrierBottom.SetActive(false);

                F.OnMyStart();
                //F.CheckBlob(false, "Green");
                if (WithDelay)
                {
                    yield return(null);
                }
            }
        }



        yield return(new WaitForSeconds(0.5f));

        GlobalSettings.GameGlobalSettings.SpawnColorBlobs(GlobalSettings.GameGlobalSettings.AllBasicColorsToBePlaced1, GlobalSettings.GameGlobalSettings.AllCellsWithBlobsFirstLevel);

        yield return(null);
    }
Exemplo n.º 13
0
 void Awake()
 {
     instance = this;
 }
Exemplo n.º 14
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        bool hell = false;

        //collision with ff
        FerrofluidScript goo          = collision.gameObject.GetComponent <FerrofluidScript> ();
        HealthScript     playerHealth = GetComponent <HealthScript> ();
        FloorScript      floor        = collision.gameObject.GetComponent <FloorScript> ();
        PopUpScript      popUp        = collision.gameObject.GetComponent <PopUpScript> ();
        BossFight        boss         = collision.gameObject.GetComponent <BossFight> ();
        ShieldScript     shield       = collision.gameObject.GetComponent <ShieldScript> ();
        ShieldNumber     shieldnumber = collision.gameObject.GetComponent <ShieldNumber> ();
        FfScript         ffBottle     = collision.gameObject.GetComponent <FfScript> ();
        WingsCounter     wings        = collision.gameObject.GetComponent <WingsCounter> ();
        RobotArm         robot        = GetComponent <RobotArm> ();
        OrangeCell       orangeCell   = collision.gameObject.GetComponent <OrangeCell>();
        RedCell          redCell      = collision.gameObject.GetComponent <RedCell>();
        BlueCell         blueCell     = collision.gameObject.GetComponent <BlueCell>();
        MetalCell        metalCell    = collision.gameObject.GetComponent <MetalCell>();
        MazePlatform     maze         = collision.gameObject.GetComponent <MazePlatform>();


        //BridgePlatformScript bridge = GetComponent<BridgePlatformScript> ();

        if (collision.gameObject.tag == "orange")
        {
//			damagePlayer = true;
//			Debug.Log("shield not hit");
//			if(playerHealth != null)
//				playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false);

            if (shieldGO.activeSelf == true)
            {
                damagePlayer = false;
                shieldHits--;
                metalCell.hitByShield = true;
                Debug.Log("shield hit");
                //orangeCell = null;
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, true);
                }
            }
            else
            {
                damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "red")
        {
            damagePlayer = true;
            Debug.Log("shield not hit");
            if (playerHealth != null)
            {
                playerHealth.Damage(redCell.damage, respawnPosX, respawnPosY, false);
            }
        }

        if (collision.gameObject.tag == "blue")
        {
            damagePlayer = true;
            Debug.Log("shield not hit");
            if (playerHealth != null)
            {
                playerHealth.Damage(blueCell.damage, respawnPosX, respawnPosY, false);
            }
        }

        if (collision.gameObject.tag == "metal")
        {
            //			damagePlayer = true;
            //			Debug.Log("shield not hit");
            //			if(playerHealth != null)
            //				playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false);

            if (shieldGO.activeSelf == true)
            {
                damagePlayer = false;
                shieldHits--;
                metalCell.hitByShield = true;
                Debug.Log("shield hit");
            }
            else
            {
                damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false);
                }
            }
        }


        if (floor != null)
        {
            damagePlayer = true;
            hell         = true;
        }


        if (hell)
        {
            if (playerHealth != null)
            {
                playerHealth.Damage(floor.damage, respawnPosX, respawnPosY, false);
            }
        }
        if (collision.gameObject.name == "Checkpoint1")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint2")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint3")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint4")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }

//		if (collision.gameObject.name == "atomo") {
//			popUp.showPopUp = true;
//			popUp.gameObject.GetComponent<Renderer>().enabled = false;
//			Destroy(popUp.gameObject.GetComponent<Collider2D>());
//		}

        if (collision.gameObject.tag == "MovingPlatform")
        {
            this.transform.parent = collision.transform;
        }

//		if (collision.gameObject.tag == "lever"){
//			RobotArm.move = true;
//		}
//
//		if (collision.gameObject.tag == "lever1") {
//			RobotArm.move1 = true;
//		}

        if (collision.gameObject.tag == "Boss")
        {
            boss.gameObject.GetComponent <Renderer>().enabled = true;

            showPopUp = true;
            maxSpeed  = 0;

            if (i == 5)
            {
                maxSpeed = 25;
                Destroy(boss.gameObject);
                boss.gameObject.GetComponent <Renderer>().enabled = false;
            }
        }

        if (collision.gameObject.tag == "Door")
        {
            Application.LoadLevel("Hidrofobia");
        }

        if (wings != null)
        {
            wings.GetComponent <Renderer>().enabled          = false;
            wings.GetComponent <PolygonCollider2D>().enabled = false;
            wingsCounter = 7;
        }

        if (collision.gameObject.tag == "shield")
        {
            ShieldCounterManager.AddShield(shieldnumber.shieldNumber);
            Destroy(shieldnumber.gameObject);
            shieldFlag = true;
            Debug.Log("Shield available");
        }


        if (collision.gameObject.tag == "ffbottle")
        {
            FfCounterManager.AddFF(ffBottle.ffNumber);
            gunFlag = true;
            Destroy(ffBottle.gameObject);
        }

        //platform activator
        if (collision.gameObject.tag == "ActivatePlatform")
        {
            collision.gameObject.GetComponent <Animator>().enabled = true;
        }

        if (collision.gameObject.tag == "Boots")
        {
            collision.gameObject.GetComponent <Renderer>().enabled          = false;
            collision.gameObject.GetComponent <PolygonCollider2D>().enabled = false;
            time = 5;
        }

        if (collision.gameObject.tag == "box")
        {
            bool          founded = false;
            BoxController box     = collision.gameObject.GetComponent <BoxController>();
            box.Founded(true);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "Bridge1")
        {
            BridgePlatformScript.bridge1 = true;
        }
        if (collision.gameObject.tag == "Bridge2")
        {
            BridgePlatformScript.bridge2 = true;
        }
        if (collision.gameObject.tag == "Bridge3")
        {
            BridgePlatformScript.bridge3 = true;
        }
        if (collision.gameObject.tag == "Bridge4")
        {
            BridgePlatformScript.bridge4 = true;
        }
        if (collision.gameObject.tag == "Bridge5")
        {
            BridgePlatformScript.bridge5 = true;
        }
        if (collision.gameObject.tag == "Bridge6")
        {
            BridgePlatformScript.bridge6 = true;
        }
        if (collision.gameObject.tag == "Bridge7")
        {
            BridgePlatformScript.bridge7 = true;
        }
        if (collision.gameObject.name == "MetallicFloorFerroFluidMAP 159")
        {
            MazePlatform.ground = true;
            transform.parent    = collision.transform;
        }
    }
Exemplo n.º 15
0
    //If the building block collides...
    void OnCollisionEnter2D(Collision2D other)
    {
        //...Get the script from the other building;
        PredioScore otherPredioScore = other.transform.GetComponent <PredioScore>();

        //If the script exists... (If collided with another building).
        if (otherPredioScore != null)
        {
            //...If not already collided...
            if (!collidedWithOtherBuilding && !collidedWithGround)
            {
                //...If the other building has the same color...
                if (otherPredioScore._spriteRenderer.color == _spriteRenderer.color)
                {
                    //Set this to has the same parent from other building;
                    transform.parent = otherPredioScore.transform.parent;
                    //Fix the scale to not distorce with base in the parent;
                    transform.localScale = new Vector3(1, 1, 1);
                    //Stores the colision position;
                    fixedPos = transform.position;
                    //Stores the number of buildings with the same color that are togheter;
                    int score = transform.parent.parent.GetComponent <FloorScript>().CheckNumbOfChilds();
                    //Set the score canvas text to the score variable number;
                    _scoreText.text = score.ToString();
                    //Count the number of childs of each color in the rope script;
                    if (_goToThisFloor == "B")
                    {
                        _ropeMovement.numbOfChildsBlue += 1;
                    }
                    else if (_goToThisFloor == "R")
                    {
                        _ropeMovement.numbOfChildsRed += 1;
                    }
                    else if (_goToThisFloor == "G")
                    {
                        _ropeMovement.numbOfChildsGreen += 1;
                    }
                }
                //If the color is different...
                else
                {
                    //Destroy the building block in question
                    Destroy(gameObject);
                }
                //Set that collided with other building
                collidedWithOtherBuilding = true;
            }
        }

        //If collided with a floor...
        FloorScript otherFloor = other.transform.GetComponent <FloorScript>();

        if (otherFloor != null)
        {
            //...If wasn't collided before...
            if (!collidedWithGround && !collidedWithOtherBuilding)
            {
                //...If number of blue buildings is more than 0 and this build has to go to the blue floor...
                if (_ropeMovement.numbOfChildsBlue > 0 && _goToThisFloor == "B")
                {
                    //...Destroy the gameobject;
                    Destroy(gameObject);
                    //Cancel the realocation of score panel;
                    otherFloor.CheckNumbOfChilds();
                }
                //Same for red
                if (_ropeMovement.numbOfChildsRed > 0 && _goToThisFloor == "R")
                {
                    Destroy(gameObject);
                    otherFloor.CheckNumbOfChilds();
                }
                //Same for green
                if (_ropeMovement.numbOfChildsGreen > 0 && _goToThisFloor == "G")
                {
                    Destroy(gameObject);
                    otherFloor.CheckNumbOfChilds();
                }
                //If the floor that the build most go is the floor that he collided...
                if (_goToThisFloor == otherFloor.name)
                {
                    //...Check if the floor have any buildings already
                    if (_goToThisFloor == "B" && _ropeMovement.numbOfChildsBlue <= 0)
                    {
                        //...If this is the first building, add to the count of respective color.
                        _ropeMovement.numbOfChildsBlue += 1;
                    }
                    else if (_goToThisFloor == "R" && _ropeMovement.numbOfChildsRed <= 0)
                    {
                        //...If this is the first building, add to the count of respective color.
                        _ropeMovement.numbOfChildsRed += 1;
                    }
                    else if (_goToThisFloor == "G" && _ropeMovement.numbOfChildsGreen <= 0)
                    {
                        //...If this is the first building, add to the count of respective color.
                        _ropeMovement.numbOfChildsGreen += 1;
                    }
                    //Set the parent to the buildings container;
                    transform.parent = otherFloor.buildingsContainer;
                    //Fix the scale of the object;
                    transform.localScale = new Vector3(1, 1, 1);
                    //Set the score number;
                    int score = other.transform.GetComponent <FloorScript>().CheckNumbOfChilds();
                    //Set the score text;
                    _scoreText.text = score.ToString();
                    //Set the scale object to the scale of original object;
                    transform.localScale = buildGO.transform.localScale;
                    //Stores the position of the collision;
                    fixedPos = transform.position;
                }
                //If collided in a floor with the wrong collor...
                else
                {
                    //...Destroy object and recount the childs;
                    Destroy(gameObject);
                    otherFloor.CheckNumbOfChilds();
                }

                //Set the collision bool to true;
                collidedWithGround = true;
            }
        }
    }