Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (GameProperties.editMode == EditMode.kEditModePrefabs)
        {
            if (this.editingPrefab != null)
            {
                if (this.isPressingRotateKey)
                {
                    this.rotationX -= Input.GetAxis("Mouse X") * this.rotationXSpeed * 0.02f;
                    this.editingPrefab.transform.rotation = Quaternion.Euler(0.0f, this.rotationX, 0.0f);
                }
                else
                {
                    Vector3    screenCoordinates = Input.mousePosition;
                    GameObject floor             = LevelPropertiesScript.sharedInstance().floor;
                    Vector3    position          = this.worldCoordinatesFromScreenCoordinates(screenCoordinates, (floor.transform.position + Vector3.up * floor.transform.localScale.y * 0.5f));
                    this.editingPrefab.transform.position = position;
                }


                if (Input.GetMouseButtonDown(0))
                {
                    if (this.editingPrefab.tag == "DominosCollection")
                    {
                        MakeDominos makeDominos = this.editingPrefab.GetComponent <MakeDominos>();
                        makeDominos.saveStateAsOriginal();
                    }

                    if (MominoScript.sharedInstance() != null)
                    {
                        MominoScript.sharedInstance().updateCurrentFloor();
                    }

                    this.editingPrefab            = null;
                    this.timeSinceEditing         = 0.0;
                    this.hasToGoBackToEditDominos = true;
                }
            }

            if (this.hasToGoBackToEditDominos)
            {
                this.timeSinceEditing += Time.deltaTime;
                if (timeSinceEditing > 0.25)
                {
                    GameProperties.editMode       = EditMode.kEditModeDominos;
                    this.hasToGoBackToEditDominos = false;
                }
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                if (this.editingPrefab != null)
                {
                    this.instances.Remove(this.editingPrefab);
                    Destroy(this.editingPrefab);
                    this.editingPrefab            = null;
                    GameProperties.editMode       = EditMode.kEditModeDominos;
                    this.hasToGoBackToEditDominos = false;
                }
            }
        }

        if (GameProperties.gameType != GameType.kGameTypeMominoTargets)
        {
            if (Input.GetButtonDown("ChangeCamera"))
            {
                Instantiate(this.mouseClick);
                LevelPropertiesScript.sharedInstance().changeCamera();
            }
        }

        if (Input.GetButtonDown("ChangeColor"))
        {
            Instantiate(this.mouseClick);
            LevelPropertiesScript.sharedInstance().changeCurrentColor();
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        int   nButtons = this.prefabs.Length;
        float currY    = (Screen.height - nButtons * this.buttonsHeight - (nButtons - 1) * this.buttonsSep) / 2;
        float startX   = (Screen.width - this.buttonsWidth - this.buttonsRightOffset);

        if (GameProperties.gameType != GameType.kGameTypeMominoTargets)
        {
            for (int i = 0; i < nButtons; i++)
            {
                if (GUI.Button(new Rect(startX, currY, this.buttonsWidth, this.buttonsHeight), this.prefabs[i].name))
                {
                    Instantiate(this.mouseClick);
                    LevelPropertiesScript.sharedInstance().setWasPaused();
                    GameProperties.editMode = EditMode.kEditModePrefabs;
                    this.editingPrefab      = (GameObject)Instantiate(this.prefabs[i], new Vector3(0, 0, 0), Quaternion.identity);

                    if (this.editingPrefab.tag == "DominosCollection")
                    {
                        MakeDominos makeDominos = this.editingPrefab.GetComponent <MakeDominos>();
                        makeDominos.applyCurrentColor();
                    }

                    this.rotationX = 0.0f;
                    this.instances.Add(this.editingPrefab);
                }
                currY += (this.buttonsSep + this.buttonsHeight);
            }


            if (GUI.Button(new Rect(startX, 15.0f, this.buttonsWidth, this.buttonsHeight), ("Color (x): " + LevelPropertiesScript.sharedInstance().currentColorName())))
            {
                Instantiate(this.mouseClick);
                LevelPropertiesScript.sharedInstance().setWasPaused();
                LevelPropertiesScript.sharedInstance().changeCurrentColor();
            }

            if (GameProperties.gameType != GameType.kGameTypeGod)
            {
                bool shoot = MominoScript.sharedInstance().shoot;
                if (GUI.Button(new Rect(startX - this.buttonsWidth - this.buttonsRightOffset, 15.0f, this.buttonsWidth, this.buttonsHeight), (shoot ? "Stop (q)" : "Continue (q)")))
                {
                    Instantiate(this.mouseClick);
                    MominoScript.sharedInstance().shoot = !shoot;
                }
            }

            if (GUI.Button(new Rect(startX - (this.buttonsWidth + this.buttonsRightOffset) * 2, 15.0f, this.buttonsWidth, this.buttonsHeight), "Camera (c)"))
            {
                Instantiate(this.mouseClick);
                LevelPropertiesScript.sharedInstance().setWasPaused();
                LevelPropertiesScript.sharedInstance().changeCamera();
            }
        }
        else
        {
            if (!GameProperties.IsTactil())
            {
                if (GUI.Button(new Rect(startX, 15.0f, this.buttonsWidth, this.buttonsHeight), ("Color (x): " + LevelPropertiesScript.sharedInstance().currentColorName())))
                {
                    Instantiate(this.mouseClick);
                    LevelPropertiesScript.sharedInstance().setWasPaused();
                    LevelPropertiesScript.sharedInstance().changeCurrentColor();
                }

                if (GameProperties.gameType != GameType.kGameTypeGod)
                {
                    bool shoot = MominoScript.sharedInstance().shoot;
                    if (GUI.Button(new Rect(startX - this.buttonsWidth - this.buttonsRightOffset, 15.0f, this.buttonsWidth, this.buttonsHeight), (shoot ? "Stop (q)" : "Continue (q)")))
                    {
                        Instantiate(this.mouseClick);
                        MominoScript.sharedInstance().shoot = !shoot;
                    }
                }
            }
        }


        Event e = Event.current;

        this.isPressingRotateKey = (e.alt || e.command || e.control);
    }