Exemple #1
0
 public void saveStateAsOriginal()
 {
     foreach (Transform dominoTransf in this.transform)
     {
         Domino domino = dominoTransf.gameObject.GetComponent <Domino>();
         domino.originalRotation      = dominoTransf.rotation;
         domino.originalPosition      = dominoTransf.position;
         domino.originalForwardVector = dominoTransf.forward;
         dominoTransf.gameObject.rigidbody.isKinematic = true;
         domino.hasCollided = false;
         CreateDominos.sharedInstance().addDomino(dominoTransf.gameObject);
     }
 }
Exemple #2
0
    void updateDominosInstances()
    {
        if (Input.GetButtonDown("Stop"))
        {
            shoot = (!shoot);
        }

        if (shoot)
        {
            if (this.movingDirection == MovementDirection.kMovementForwards)
            {
                Vector3 position = this.transform.position - this.transform.forward * 0.65f;
                position.y -= this.transform.localScale.y * 0.5f;
                CreateDominos.sharedInstance().instantiateDominoIfFarEnough(ref position, this.transform.rotation);
            }
        }
    }
Exemple #3
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);
        }
    }
Exemple #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);
         }
     }
 }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (GameProperties.gameType == GameType.kGameTypeGod)
        {
            if ((GameProperties.editMode != EditMode.kEditModeDominos) || GameProperties.paused || LevelPropertiesScript.sharedInstance().wasPaused())
            {
                return;
            }

            if (Input.GetMouseButton(0) || (Input.GetMouseButtonUp(0)))
            {
                Vector3 screenCoordinates = Input.mousePosition;

                if (CreateDominos.sharedInstance().positionIsOnGUI(screenCoordinates) || LevelPropertiesScript.sharedInstance().positionIsOnGUI(screenCoordinates) || EditModeScript.sharedInstance().positionIsOnGUI(screenCoordinates))
                {
                    return;
                }

                GameObject floor         = LevelPropertiesScript.sharedInstance().floor;
                Vector3    floorPosition = floor.transform.position;
                floorPosition.y = (floor.transform.position.y + floor.transform.localScale.y * 0.5f);

                Vector3 position = CreateDominos.sharedInstance().worldCoordinatesFromScreenCoordinates(screenCoordinates, floorPosition);

                if (!this.positionIsValid(position))
                {
                    return;
                }

                if (Input.GetMouseButtonDown(0))
                {
                    this.mouseLastDominoPosition    = position;
                    this.mouseNDominosCurrentMotion = 0;
                    this.mouseLastDomino            = null;
                }

                Vector3 diffVector = (position - this.mouseLastDominoPosition);
                diffVector.y = 0.0f;
                float distanceWithLastDominoSqr = diffVector.sqrMagnitude;
                if (distanceWithLastDominoSqr >= (CreateDominos.dominosSeparation * CreateDominos.dominosSeparation))
                {
                    float   distanceWithLastDomino = Mathf.Sqrt(distanceWithLastDominoSqr);
                    Vector3 nextPosition           = this.mouseLastDominoPosition;
                    Vector3 moveVector             = (diffVector.normalized * CreateDominos.dominosSeparation);

                    this.mouseLastDominoAngle   = Quaternion.LookRotation(diffVector);
                    this.mouseLastDominoAngle.x = 0.0f;
                    this.mouseLastDominoAngle.z = 0.0f;
                    int        nDominos = (int)(distanceWithLastDomino / CreateDominos.dominosSeparation);
                    Quaternion rotation = this.mouseLastDominoAngle;
                    for (int i = 0; i < nDominos; i++)
                    {
                        if (i == 0)
                        {
                            if (this.mouseLastDomino != null)
                            {
                                Domino mouseLastDominoAttributes = this.mouseLastDomino.GetComponent <Domino>();
                                rotation = mouseLastDominoAttributes.originalRotation;
                                if (this.mouseNDominosCurrentMotion == 1)
                                {
                                    rotation = this.mouseLastDominoAngle;
                                }
                                else
                                {
                                    rotation = Quaternion.Lerp(rotation, this.mouseLastDominoAngle, 0.5f);
                                }

                                this.mouseLastDomino.transform.rotation    = rotation;
                                mouseLastDominoAttributes.originalRotation = rotation;
                            }
                        }

                        nextPosition += moveVector;
                        Vector3 p = new Vector3(nextPosition.x, nextPosition.y, nextPosition.z);

                        float      f            = (0.5f + (0.5f * i / nDominos));
                        Quaternion nextRotation = Quaternion.Lerp(rotation, this.mouseLastDominoAngle, f);
                        GameObject domino       = CreateDominos.sharedInstance().instantiateDomino(ref nextPosition, nextRotation);

                        nextPosition.x = p.x;
                        nextPosition.y = p.y;
                        nextPosition.z = p.z;

                        if (domino != null)
                        {
                            this.mouseNDominosCurrentMotion++;
                            this.mouseLastDomino = domino;
                        }
                    }

                    this.mouseLastDominoPosition = nextPosition;
                }

                if (Input.GetMouseButtonUp(0))
                {
                    if (this.mouseNDominosCurrentMotion == 0)
                    {
                        Ray        ray = Camera.main.ScreenPointToRay(screenCoordinates);
                        Vector3    pos;
                        GameObject selectedDomino = CreateDominos.rayCastWithDominos(ray, out pos);
                        if (selectedDomino != null)
                        {
                            CreateDominos.sharedInstance().removeDomino(selectedDomino);
                        }
                        else
                        {
                            CreateDominos.sharedInstance().instantiateDomino(ref position, this.mouseLastDominoAngle);
                        }
                    }

                    this.mouseNDominosCurrentMotion = 0;
                    this.mouseLastDomino            = null;
                }
            }
        }
    }