示例#1
0
    public int minRequiredDominos()
    {
        int nDominos = 0;
        LevelPropertiesScript properties = LevelPropertiesScript.sharedInstance();
        ArrayList             placesToGo = new ArrayList(properties.powerups.Count);

        foreach (GameObject powerup in properties.powerups)
        {
            placesToGo.Add(powerup.transform.position);
        }

        Vector3 nextPos = MominoScript.sharedInstance().gameObject.transform.position;

        while (placesToGo.Count > 0)
        {
            float   minDistance     = float.MaxValue;
            Vector3 closestPosition = nextPos;
            foreach (Vector3 position in placesToGo)
            {
                float dist = Vector3.SqrMagnitude(position - nextPos);
                if (dist < minDistance)
                {
                    closestPosition = position;
                    minDistance     = dist;
                }
            }

            nextPos = closestPosition;
            placesToGo.Remove(closestPosition);
            nDominos += (int)(Mathf.Sqrt(minDistance) / CreateDominos.dominosSeparation);
        }

        return(nDominos);
    }
示例#2
0
    void displayPauseMenu()
    {
        float buttonsHeight = (GameProperties.IsTactil() ? 80.0f : 50.0f);
        float buttonsSep    = (GameProperties.IsTactil() ? 20.0f : 10.0f);
        float buttonsWidth  = (GameProperties.IsTactil() ? 180.0f : 150.0f);
        int   nButtons      = 3;

        float currY = (Screen.height - nButtons * buttonsHeight - (nButtons - 1) * buttonsSep) / 2;

        if (GUI.Button(new Rect((Screen.width - buttonsWidth) / 2, currY, buttonsWidth, buttonsHeight), "Resume", this.buttonsStyle))
        {
            Instantiate(this.mouseClick);
            this.resume();
        }
        currY += (buttonsSep + buttonsHeight);

        if (GUI.Button(new Rect((Screen.width - buttonsWidth) / 2, currY, buttonsWidth, buttonsHeight), "Reset", this.buttonsStyle))
        {
            Instantiate(this.mouseClick);
            CreateDominos.sharedInstance().reset();
            EditModeScript.sharedInstance().reset();
            if (MominoScript.sharedInstance() != null)
            {
                MominoScript.sharedInstance().reset();
            }

            if (GameProperties.gameType == GameType.kGameTypeMominoTargets)
            {
                this.resetPowerups();
            }
            this.dominosFalling = false;
            this.enableFirstCamera();
            this.floor.transform.localScale = this.defaultFloorSize();

            this.resume();
        }
        currY += (buttonsSep + buttonsHeight);

        if (GUI.Button(new Rect((Screen.width - buttonsWidth) / 2, currY, buttonsWidth, buttonsHeight), "Exit", this.buttonsStyle))
        {
            Instantiate(this.mouseClick);
            this.resume();
            Application.LoadLevel(0);
        }
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        this.labelsStyle             = new GUIStyle();
        labelsStyle.normal.textColor = Color.black;
        if (GameProperties.IsTactil())
        {
            labelsStyle.fontSize = 15;
        }

        switch (GameProperties.gameType)
        {
        case GameType.kGameTypeMominoTargets:
            this.maxNDominos = (int)(ShortestPathScript.sharedInstance().minRequiredDominos() * 1.35f);
            break;

        case GameType.kGameTypeGod:
            this.maxNDominos = 1000;
            break;

        case GameType.kGameTypeMomino:
        default:
            this.maxNDominos = -1;
            break;
        }

        if (this.allSteps == null)
        {
            this.allSteps = new HashSet <GameObject>();
        }

        if (GameProperties.gameType == GameType.kGameTypeMominoTargets)
        {
            ShortestPathScript.sharedInstance().calculateCheckpoints();
            ShortestPathScript.sharedInstance().instantiatePath();
        }

        MominoScript.sharedInstance().reset();
        MominoScript.sharedInstance().gameObject.SetActive(GameProperties.gameType != GameType.kGameTypeGod);

        this.enableFirstCamera();
    }
示例#4
0
 void updateState()
 {
     if (this.state == PowerupState.kPowerupStateDefault)
     {
         MominoScript momino     = MominoScript.sharedInstance();
         GameObject   lastDomino = ((momino == null) ? null : CreateDominos.sharedInstance().lastDomino);
         if (lastDomino != null)
         {
             if (Vector3.SqrMagnitude(this.transform.position - lastDomino.transform.position) < (this.haloMinSize * this.haloMinSize))
             {
                 this.setState(PowerupState.kPowerupStateWaiting);
             }
         }
     }
     else if ((this.state == PowerupState.kPowerupStateWaiting) && LevelPropertiesScript.sharedInstance().dominosFalling)
     {
         if (Vector3.SqrMagnitude(this.transform.position - LevelPropertiesScript.sharedInstance().dominosFallingPosition) < (this.haloMinSize * this.haloMinSize))
         {
             this.setState(PowerupState.kPowerupStateCorrect);
         }
     }
 }
示例#5
0
 void OnDestroy()
 {
     MominoScript.singleton = null;
 }
示例#6
0
 void Awake()
 {
     MominoScript.singleton = this;
 }
示例#7
0
 void OnDestroy()
 {
     MominoScript.singleton = null;
 }
示例#8
0
 void Awake()
 {
     MominoScript.singleton = this;
 }
示例#9
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();
        }
    }
示例#10
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);
    }