Example #1
0
    void Update()
    {
        bool rightDown = Input.GetKeyDown(KeyCode.RightArrow);
        bool leftDown  = Input.GetKeyDown(KeyCode.LeftArrow);

        // двигаемся по плоскости
        if (_navMeshAgent.enabled && (rightDown || leftDown))
        {
            GameObject     surface         = ((Component)_navMeshAgent.navMeshOwner).gameObject;
            CubeController cube            = surface.GetComponentInParent <CubeController>();
            Vector3        nextDestination = FindNextDestination(cube.Position, rightDown ? Direction.RIGHT : Direction.LEFT);
            _navMeshAgent.SetDestination(nextDestination);
        }

        // Стартуем прыжок
        if (_navMeshAgent.enabled && Input.GetKey(KeyCode.Space))
        {
            SwichMoveType(false);
        }


        // прыгаем
        if (_characterController.enabled)
        {
            CollisionFlags collisionFlags = _characterController.Move(_navMeshAgent.speed * _sceneController.GravityDirection.GetOppositeVector() * Time.deltaTime);

            if (CheckCollision(collisionFlags))
            {
                _sceneController.ChangeGravityClockwise();
                _sceneController.ChangeGravityClockwise();
                SwichMoveType(true);
            }
        }
    }
Example #2
0
 public override void PlayerEnteredTrigger(CubeController player)
 {
     if (player != null)
     {
         player.shouldReset = true;
     }
 }
Example #3
0
    // ------------------------------------------------------------------------------------------------

    void Start()
    {
        gameManager    = GameObject.Find("Game Manager").GetComponent <GameManager>();
        cubeController = GameObject.Find("Cube").GetComponent <CubeController>();

        gameManager.SfxclpPlay("sfxclpProjectile");
    }
Example #4
0
    private void Awake()
    {
        if (_cubeInfoSO == null)
        {
            Debug.LogError("Need to add a CubeInfoScriptableObject to this controller!");
            enabled = false;
        }

        _controller  = GetComponent <CubeController>();
        rb           = _controller.GetRigidbody();
        targetHeight = _cubeInfoSO.jumpHeight;

        //particle effects on player

        GameObject tempObj;

        //consistant names needed for sanity. fix all of them later
        tempObj = Instantiate(_cubeInfoSO.slidingEffects[0]);
        tempObj.transform.parent        = transform;
        tempObj.transform.localPosition = Vector3.down * 0.4f;
        _movingEffect = tempObj.GetComponent <ParticleSystem>();

        tempObj = Instantiate(_cubeInfoSO.poppedEffects[0]);
        tempObj.transform.parent        = transform;
        tempObj.transform.localPosition = Vector3.zero;
        tempObj.transform.rotation      = transform.rotation;
        _poppedEffect = tempObj.GetComponent <ParticleSystem>();

        _controller.onRespawn.AddListener(OnRespawn);
    }
Example #5
0
    private void Update()
    {
        if (previewCube != null && Camera.main != null)
        {
            if (GridController.IsGridEnabled())                                                                                                                                                                       // Position cube in front of the controller in invisible grid by rounding the x,y,z position
            {
                previewCube.transform.position = new Vector3(Mathf.RoundToInt((transform.position.x + transform.forward.x * 2) / GridController.GridSize) * GridController.GridSize + (GridController.GridSize / 2),  //* previewCube.transform.localScale.x,
                                                             Mathf.RoundToInt((transform.position.y + transform.forward.y) / GridController.GridSize) * GridController.GridSize - (GridController.GridSize / 2),      // * previewCube.transform.localScale.y + previewCube.transform.localScale.y,
                                                             Mathf.RoundToInt((transform.position.z + transform.forward.z * 2) / GridController.GridSize) * GridController.GridSize - (GridController.GridSize / 2)); // * previewCube.transform.localScale.z);
            }
            else
            {
                previewCube.transform.position = new Vector3((transform.position.x + transform.forward.x * 2),
                                                             (transform.position.y + transform.forward.y),
                                                             (transform.position.z + transform.forward.z * 2));
            }
            previewCube.GetComponent <Renderer>().material.color = Colorpicker.cubeColor;
        }


        if (!GetComponent <VRTK_ControllerEvents>().triggerPressed || previewCube.GetComponent <CubeCollisionCheck>().isColliding())
        {
            return;
        }
        GameObject placedCube = Instantiate(previewCube, previewCube.transform.position, previewCube.transform.rotation) as GameObject;         // Spawn new cube on preview position

        //placedCube.transform.localScale = Vector3.one;
        placedCube.transform.SetParent(GameObject.Find("PlacedCubes").transform);
        CubeController.CubePlaced(placedCube);
        placedCube.GetComponent <Renderer>().material.color = Colorpicker.cubeColor;
        Destroy(placedCube.GetComponent <CubeCollisionCheck>());
    }
Example #6
0
    // ------------------------------------------------------------------------------------------------

    void Start()
    {
        spawnManager   = GameObject.Find("Spawn Manager").GetComponent <SpawnManager>();
        cubeController = GameObject.Find("Cube").GetComponent <CubeController>();
        navNavMesh     = GameObject.Find("Nav Mesh").GetComponent <NavMeshSurface>();

        goArrWallDestructible = GameObject.FindGameObjectsWithTag("WallDestructible");
        goArrWallTimed        = GameObject.FindGameObjectsWithTag("WallTimed");
        goArrTranslator       = GameObject.FindGameObjectsWithTag("Translator");
        goArrRotator          = GameObject.FindGameObjectsWithTag("Rotator");
        goArrSwitcher         = GameObject.FindGameObjectsWithTag("Switcher");
        goArrExchanger        = GameObject.FindGameObjectsWithTag("Exchanger");
        goSafeZonePlayer      = GameObject.FindWithTag("SafeZonePlayer");
        goSafeZoneTarget      = GameObject.FindWithTag("SafeZoneTarget");

        if (goSafeZonePlayer &&
            goSafeZoneTarget)
        {
            v3PositionSafeZonePlayerOrig = goSafeZonePlayer.transform.position;
            v3PositionSafeZoneTargetOrig = goSafeZoneTarget.transform.position;
            colSafeZonePlayer            = goSafeZonePlayer.GetComponent <SpriteRenderer>().color;
            colSafeZoneTarget            = goSafeZoneTarget.GetComponent <SpriteRenderer>().color;
        }

        transform.position = v3PositionInstantiate;

        fMetresPerSecY = Math.Abs((v3PositionPlay.y - v3PositionInstantiate.y) / fTransitionTime);
        fMetresPerSecZ = Math.Abs((v3PositionPlay.z - v3PositionInstantiate.z) / fTransitionTime);
    }
 private void Awake()
 {
     player      = FindObjectOfType <CubeController>();
     audioSource = GetComponent <AudioSource>();
     uIManager   = FindObjectOfType <UIManager>();
     health      = 6;
 }
 private void Reset()
 {
     this.cameraState             = CameraState.Default;
     this.cubeController          = CubeController.Default;
     this.animationEngine.Enabled = false;
     ResetAnimation();
 }
        public Form1()
        {
            InitializeComponent();

            this.timer1.Interval = 50;
            this.timer1.Enabled  = true;

            this.Width          = WIDTH;
            this.Height         = HEIGHT;
            this.DoubleBuffered = true;

            this.cameraState = CameraState.Default;

            this.keyboardState = new KeyboardState();

            // Define axes
            x_axis = new AxisX(3);
            y_axis = new AxisY(3);
            z_axis = new AxisZ(3);

            this.cube = new Cube(Color.Purple);

            this.cubeController = new CubeController();

            this.animationEngine           = new AnimationEngine(this.cameraState, this.cubeController);
            this.animationEngine.Finished += ResetAnimation;
        }
Example #10
0
    public void ExecuteIceBlastEffect(CubeController cube)
    {
        var allBricks = GetItemList <CubeController>();
        List <CubeController> damagedBricks = new List <CubeController>();

        cube.cubeEffectController.ManageFreezeEffect(false, cube, cube.hitCounter <= 0);
        foreach (var brick in allBricks)
        {
            if (brick.index >= cube.index - 1 &&
                brick.index <= cube.index + 1 &&
                brick.level >= cube.level - 1 &&
                brick.level <= cube.level + 1)
            {
                damagedBricks.Add(brick);
                if (brick == this)
                {
                    damagedBricks.Remove(brick);
                }
                continue;
            }
        }

        foreach (var brick in damagedBricks)
        {
            brick.OnGetDamage(null, MetaGameController.instance.damagePercentForFreezingBlast, DragonBonusType.Freezing);
        }
    }
Example #11
0
    /// <summary>
    /// Primary method for performing the WFC algorithm.
    /// </summary>
    public void PerformNextWFCStep()
    {
        if (SudokuBoardController.IsBoardValid())
        {
            // Select next cube with lowest entropy
            CubeController selectedCube        = SudokuBoardController.SelectLowestEntropyCube();
            int            nextAvailableNumber = SudokuBoardData.GetSudokuCubeData(selectedCube.CubeIndices).GetRandomAvailableNumber();
            // SudokuBoardData.GetSudokuCubeData(selectedCube.CubeIndices).GetRandomAvailableNumber();

            // Add cube data to backtrack stack + process cube selection
            BacktrackStack.Push(new BacktrackBoardUpdateData(nextAvailableNumber, selectedCube.CubeIndices));
            SudokuBoardController.SelectNumberForCube(nextAvailableNumber, selectedCube.CubeIndices);
        }
        else
        {
            // Get last cube selection and revert changes
            if (BacktrackStack.Count != 0)
            {
                BacktrackBoardUpdateData lastBoardUpdate = BacktrackStack.Pop();
                SudokuBoardController.RevertCubeUpdate(lastBoardUpdate.SelectedCubeData.CubeIndices,
                                                       lastBoardUpdate.SelectedCubeData.CubeNumber, lastBoardUpdate.InvalidCubeData);

                // If there are more backtracking info in stack, notify previous stack about the invalid cube result
                if (BacktrackStack.Count != 0)
                {
                    BacktrackStack.Peek().AddInvalidCubeData(lastBoardUpdate.SelectedCubeData.CubeIndices,
                                                             lastBoardUpdate.SelectedCubeData.CubeNumber);
                }
            }
        }
    }
Example #12
0
 public void onClickCube(CubeController cube)
 {
     //List<GameObject> aa = collectSameStartFromCell (cube.Me.rowId, cube.Me.colId, 99);
     if (!processing)
     {
         if (firstCube == null)
         {
             firstCube = cube;
             bc.gameObject.SetActive(true);
             bc.setBorder(cube.Me.colId, cube.Me.colId, cube.Me.rowId, cube.Me.rowId);
         }
         else
         {
             if (secondCube == null)
             {
                 secondCube = cube;
                 if (secondCube == firstCube)
                 {
                     firstCube  = null;
                     secondCube = null;
                     bc.gameObject.SetActive(false);
                 }
                 else
                 {
                     collectSelectCube();
                 }
             }
             else
             {
                 //Debug.Log ();
             }
         }
     }
 }
Example #13
0
 void startDrop()
 {
     for (int i = 0; i < col; i++)
     {
         List <GameObject> cellInCollum = ArrayHelper.getCellsInCollumn(i, row, CUBES);
         if (cellInCollum.Count == row)
         {
             continue;
         }
         else
         {
             //List<GameObject> cellsWillDrop = ArrayHelper.getCellsWillDrop (i, row, CUBES);
             cellInCollum.AddRange(instantiateToFillCube(i, row - cellInCollum.Count));
             for (int j = 0; j < cellInCollum.Count; j++)
             {
                 if (cellInCollum [j].GetComponent <CubeController> ())
                 {
                     CubeController cc         = cellInCollum [j].GetComponent <CubeController> ();
                     int            numberDrop = 0;
                     if (isFullToHighestStatic(cc.Me.colId))
                     {
                         numberDrop = getNumberDropWhithNull(cc.Me.rowId, cc.Me.colId);
                     }
                     else
                     {
                         numberDrop = getNumberDropWhithStatic(cc.Me.rowId, cc.Me.colId);
                     }
                     cc.drop(numberDrop);
                 }
             }
             disableConnect();
             StartCoroutine(waitToFill());
         }
     }
 }
Example #14
0
    private void Reset()
    {
        if (cubeController != null)
        {
            cubeController.Reset();
            cubeController = null;
        }
        if (elementsController != null)
        {
            elementsController.Reset();
            elementsController = null;
        }
        if (playerModel != null)
        {
            playerModel.Reset();
            playerModel = null;
        }
        if (gameStateModel != null)
        {
            gameStateModel.Reset();
            gameStateModel = null;
        }
        if (gameStateModel != null)
        {
            gameStateModel.Reset();
            gameStateModel = null;
        }

        RemoveEventListeners();
    }
Example #15
0
    void Start()
    {
        m_StartUI = GameObject.Find("Start_UI");
        m_GameUI  = GameObject.Find("Game_UI");

        m_Score_Label = GameObject.Find("Score_Label").GetComponent <UILabel>();
        m_Gem_Label   = GameObject.Find("Gem_Label").GetComponent <UILabel>();

        m_GameScore_Label = GameObject.Find("GameScore_Label").GetComponent <UILabel>();
        m_GameGem_Label   = GameObject.Find("GameGem_Label").GetComponent <UILabel>();

        m_LatestRun_Label = GameObject.Find("LatestRun_Label").GetComponent <UILabel>();

        m_CubeController = GameObject.Find("cube_books").GetComponent <CubeController>();

        m_PlayButton = GameObject.Find("play_btn");
        UIEventListener.Get(m_PlayButton).onClick = PlayButtonClick;

        m_Left = GameObject.Find("Left");
        UIEventListener.Get(m_Left).onClick = Left;
        m_Right = GameObject.Find("Right");
        UIEventListener.Get(m_Right).onClick = Right;
        Init();

        m_GameUI.SetActive(false);
    }
Example #16
0
 void Start()
 {
     _rb            = GetComponentInParent <Rigidbody>();
     _c             = GetComponentInParent <CubeController>();
     _groundControl = GetComponentInParent <CubeGroundControl>();
     _wheelRadius   = transform.localScale.z / 2;
 }
Example #17
0
    /*void ProcessInputMouseButton0() {
     *
     *  if (Input.GetMouseButtonDown(0)) {
     *      mouseOrigin = Input.mousePosition;
     *      isDraging = true;
     *  }
     *  if (!Input.GetMouseButton(0))
     *      isDraging = false;
     *
     *  if (isDraging) {
     *      Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);
     *
     *      rubiksCube.RotateRow(pos);
     *  }
     * } */

    void ClickOnCubeFace()
    {
        if (Input.GetMouseButtonDown(0))
        {
            mouseOrigin = Input.mousePosition;
            ray         = Camera.main.ScreenPointToRay(mouseOrigin);
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.transform.parent != null)
                {
                    cubeParent = hit.collider.transform.parent.gameObject.GetComponent <CubeController>();
                    if (cubeParent != null)
                    {
                        isRotating = true;
                    }
                }
            }
        }

        if (!Input.GetMouseButton(0))
        {
            isRotating = false;
        }

        if (isRotating)
        {
            Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);
            cubeParent.transform.RotateAround(cubeParent.transform.position, cubeParent.transform.right, -pos.y * rotationSpeed * Time.deltaTime);
        }
    }
Example #18
0
    public bool getIfCubeGrounded(Vector3 position)
    {
        bool       returnBool = false;
        GameObject returnObj  = null;

        for (int i = 0; i < mVectorList.Count; ++i)
        {
            if (mVectorList[i] == position)
            {
                returnObj = mCubeList[i];
                break;
            }
        }

        if (returnObj != null)
        {
            CubeController cubeController = returnObj.GetComponent <CubeController>();
            if (cubeController != null)
            {
                returnBool = cubeController.isGroundedCube();
            }
        }

        return(returnBool);
    }
Example #19
0
        private void UpdateCube(int x, int y, int z, int status)
        {
            CubeController cubeController = cubes[x, y, z].GetComponent <CubeController>();

            if (status == 1)
            {
                cubes[x, y, z].GetComponent <MeshRenderer>().enabled = true;
                cubeController.Activate();
            }
            else if (status == 0)
            {
                cubeController.Deactivate();
            }


            //			MeshRenderer cubeMesh = cubes[x,y,z].GetComponent<MeshRenderer>();
            //			cubeMesh.material.color = status == 1 ? Color.black : Color.white;


            //			if (status == 1) {
            //				cubes[x, y, z].gameObject.transform.localScale = Vector3.Lerp(
            //					cubes[x, y, z].gameObject.transform.localScale,
            //					new Vector3(.5f, .5f, .5f),
            //					.5f
            //				);
            //			} else {
            //				cubes[x, y, z].gameObject.transform.localScale = Vector3.Lerp(
            //					cubes[x, y, z].gameObject.transform.localScale,
            //					new Vector3(0f, 0f, 0f),
            //					.5f
            //				);
            //			}
        }
Example #20
0
    // Use this for initialization
    void Start()
    {
        loseGame.text = "";

        cubeCtrlScriptRef = cube.GetComponent <CubeController>();

        varForPrefab           = Resources.Load("prefabs/MainCube", typeof(GameObject)) as GameObject;
        numIterationsScriptRef = varForPrefab.GetComponent <numIterationsScript>();


        while ((mazeWidth = cell.GetComponent <MazeGenerator>()._width) == -1 || (mazeHeight = cell.GetComponent <MazeGenerator>()._height) == -1)
        {
        }
        mazeWidth  = cell.GetComponent <MazeGenerator>()._width;
        mazeHeight = cell.GetComponent <MazeGenerator>()._height;
        Debug.Log(mazeWidth);
        Debug.Log(mazeHeight);
        // for n * n mazes (n(n+2) - 1) / 2
        hitFactDenom = energyPenaltyDivFactor(mazeWidth, mazeHeight);

        energyHitFactor = (mazeWidth * (mazeWidth + 2) - 1) / hitFactDenom; // the denomitaor here scales out the large penalty do to errors ai will make
        // different function for non square mazes

        Debug.Log(hitFactDenom);
        Debug.Log(energyHitFactor);
    }
    private void Start()
    {
        CubeGlobalData.Instance.SetDimension(spawnCount);

        Vector3 lowerLeftFrontCubePosition = new Vector3(0.5f, 0.5f, 0.5f);

        for (int x = 0; x < spawnCount; x++)
        {
            for (int y = 0; y < spawnCount; y++)
            {
                for (int z = 0; z < spawnCount; z++)
                {
                    Vector3    coordinate = new Vector3(x, y, z);
                    GameObject cube       = Instantiate(m_cubePrefab, lowerLeftFrontCubePosition + coordinate, Quaternion.identity, transform);
                    cube.name = string.Format("{0} {1} {2}", x, y, z);
                    CubeController controller = cube.GetComponent <CubeController>();
                    controller.Coordinate = coordinate;

                    CubeGlobalData.Instance.AddCube(x, y, z, controller);
                }
            }
        }

        CubeGlobalData.Instance.boxMin = Vector3.zero;
        CubeGlobalData.Instance.boxMax = transform.GetChild(transform.childCount - 1).position + new Vector3(0.5f, 0.5f, 0.5f);
    }
Example #22
0
        public void CanRetrieveImageData()
        {
            // Arrange
            Cube cube = new Cube
            {
                CubeId        = 2,
                Name          = "Puzzle2",
                ImageData     = new byte[] { },
                ImageMimeType = "image/png"
            };
            Mock <ICubeRepository> mock = new Mock <ICubeRepository>();

            mock.Setup(i => i.Cubes).Returns(new List <Cube> {
                new Cube {
                    CubeId = 1,
                    Name   = "Puzzle1"
                },
                cube,
                new Cube
                {
                    CubeId = 3,
                    Name   = "Puzzle3"
                }
            }.AsQueryable());
            CubeController controller = new CubeController(mock.Object);

            // Action
            ActionResult result = controller.GetImage(2);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual(cube.ImageMimeType, ((FileResult)result).ContentType);
        }
    protected void FixedUpdate()
    {
        //drag to decrease horizontal velocity
        if (Mathf.Abs(horizontalVelocity) > 0.00001f)
        {
            horizontalVelocity -= DRAG * horizontalVelocity;
        }

        //get input; add it to horizontal velocity
        if (CameraInputController.cameraInput)
        {
            moveHorizontal = CameraInputController.GetAxisRaw() * BASE_CAMERA_TURN_ACCELERATION;
            //Debug.Log(CameraInputController.GetAxisRaw());
        }
        else
        {
            //Debug.Log(Input.GetAxisRaw("Horizontal"));
            moveHorizontal = Input.GetAxisRaw("Horizontal") * BASE_TURN_ACCELERATION;
        }
        horizontalVelocity += moveHorizontal * speedModifier;

        //apply velocity to player
        rb.velocity = new Vector3(horizontalVelocity, 0, forwardVelocity);

        //accelerate over time
        speedModifier  += SPEED_UP;
        forwardVelocity = BASE_SPEED * speedModifier * cameraModifier;

        //generate cubes in front of the player
        if (Random.Range(0f, 10f) / forwardVelocity < CubeController.SPAWN_FREQUENCY)
        {
            CubeController.GenerateCube(prefabCube, tf.position);
        }
    }
Example #24
0
 void Start()
 {
     _rb           = GetComponentInParent <Rigidbody>();
     _controller   = GetComponent <CubeController>();
     _wheelArray   = GetComponentsInChildren <CubeWheel>();
     _inputManager = GetComponentInParent <InputManager>();
 }
Example #25
0
    // ------------------------------------------------------------------------------------------------

    void Start()
    {
        sfxsrcGameManager = GetComponent <AudioSource>();

        // vfxclpNames.Add("vfxclpWallDestructible", vfxclpWallDestructible);

        // sfxclpNames.Add("sfxclpButton", sfxclpButton);
        // sfxclpNames.Add("sfxclpLevelClearedPartial", sfxclpLevelClearedPartial);
        // sfxclpNames.Add("sfxclpLevelCleared", sfxclpLevelCleared);
        // sfxclpNames.Add("sfxclpLevelFailed", sfxclpLevelFailed);
        // sfxclpNames.Add("sfxclpBoost", sfxclpBoost);
        // sfxclpNames.Add("sfxclpPowerUp", sfxclpPowerUp);
        // sfxclpNames.Add("sfxclpProjectile", sfxclpProjectile);
        // sfxclpNames.Add("sfxclpLaunch", sfxclpLaunch);
        // sfxclpNames.Add("sfxclpWarp", sfxclpWarp);
        // sfxclpNames.Add("sfxclpWallDestructible", sfxclpWallDestructible);
        // sfxclpNames.Add("sfxclpTranslator", sfxclpTranslator);
        // sfxclpNames.Add("sfxclpRotator", sfxclpRotator);
        // sfxclpNames.Add("sfxclpSwitcher", sfxclpSwitcher);
        // sfxclpNames.Add("sfxclpTargetObjectivePlayer", sfxclpTargetObjectivePlayer);
        // sfxclpNames.Add("sfxclpTargetObjectiveRandom", sfxclpTargetObjectiveRandom);
        // sfxclpNames.Add("sfxclpEnemyAttack1", sfxclpEnemyAttack1);
        // sfxclpNames.Add("sfxclpEnemyAttack2", sfxclpEnemyAttack2);
        // sfxclpNames.Add("sfxclpEnemySleep", sfxclpEnemySleep);

        goSpawnManager = GameObject.Find("Spawn Manager");
        cubeController = GameObject.Find("Cube").GetComponent <CubeController>();

        goScreenTitle.SetActive(true);
        bActiveScreenButton = true;

        fNumProjectileFlashAngFreq = 2f * Mathf.PI * fNumProjectileFlashFreq;
    }
Example #26
0
 public override void PlayerEnteredTrigger(CubeController player)
 {
     if (player != null)
     {
         player.goalReached = true;
     }
 }
Example #27
0
 private void Awake()
 {
     player = FindObjectOfType <CubeController>();
     interactionPrompt.SetActive(false);
     audioSource   = GetComponent <AudioSource>();
     isInteracting = false;
     uI            = FindObjectOfType <UIManager>();
 }
Example #28
0
 void sumDamage(CubeController cube, int num)
 {
     //Sound effect
     if (cube.bulletDamage + num <= cube.maxBulletDamage)
     {
         cube.bulletDamage = cube.bulletDamage + num;
     }
 }
Example #29
0
 void sumHealth(CubeController cube, int num)
 {
     //Sound effect
     if (cube.currentHealth + num <= cube.maxHealth)
     {
         cube.currentHealth = cube.currentHealth + num;
     }
 }
Example #30
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     mCurY = 0.55f;
 }
Example #31
0
 // Use this for initialization
 void Start()
 {
     gameManager = FindObjectOfType<GameManager> ();
     player = FindObjectOfType<CubeController> ();
 }
Example #32
0
        /// <summary>
        /// Draws a rectangle using point A and point D. 
        /// 
        /// Rectangle must be drawn on the coordinate that the points share, i.e., you
        /// cannot (or should not) draw a rectangle between a point at (0,0,7) and (1,2,3),
        /// as they have no common plane to drawn cleanly across at 90° angles.
        ///
        /// </summary>
        /// <param name="A">The first point to draw from (inside-originating corner).</param>
        /// <param name="D">The terminating point (outside-opposing corner).</param>
        public void DrawRectangle(Cube.AXIS axis, CubeController.Point A, CubeController.Point D)
        {
            // Draw the lines to the non-named points:
            //
            //                SIDE 1
            //         A _______________ B
            //          |               |
            // SIDE 4   |               |   SIDE 2
            //          |_______________|
            //          C               D
            //                SIDE 3
            switch (axis)
            {
                case AXIS.AXIS_X:
                                       // X IS FIXED FOR BOTH A AND D
                    DrawLine(A, new Point(A.X, A.Y, D.Z));  // Draw SIDE 1
                    DrawLine(D, new Point(A.X, A.Y, D.Z));  // Draw SIDE 2
                    DrawLine(D, new Point(A.X, D.Y, A.Z));  // Draw SIDE 3
                    DrawLine(A, new Point(A.X, D.Y, A.Z));  // Draw SIDE 4
                    break;

                case AXIS.AXIS_Y:           // Y IS FIXED FOR BOTH A AND D
                    DrawLine(A, new Point(A.X, A.Y, D.Z));  // Draw SIDE 1
                    DrawLine(D, new Point(A.X, A.Y, D.Z));  // Draw SIDE 2
                    DrawLine(D, new Point(D.X, A.Y, A.Z));  // Draw SIDE 3
                    DrawLine(A, new Point(D.X, A.Y, A.Z));  // Draw SIDE 4
                    break;

                case AXIS.AXIS_Z:                // Z IS FIXED FOR BOTH A AND D
                    DrawLine(A, new Point(D.X, A.Y, A.Z));  // Draw SIDE 1
                    DrawLine(D, new Point(D.X, A.Y, A.Z));  // Draw SIDE 2
                    DrawLine(D, new Point(A.X, D.Y, A.Z));  // Draw SIDE 3
                    DrawLine(A, new Point(A.X, D.Y, A.Z));  // Draw SIDE 4
                    break;

                default:
                    break;
            }
        }
Example #33
0
        /// <summary>
        /// Draws a circle at [center] with radius [radius]. 
        /// 
        /// Follows the Midpoint Circle Algorithm:
        /// http://csunplugged.org/wp-content/uploads/2014/12/Lines.pdf, pg 9.
        /// </summary>
        /// <param name="center"></param>
        /// <param name="radius"></param>
        public void DrawCircle(Cube.AXIS axis, CubeController.Point center, CubeController.Point rad)
        {
            int radius = int.MinValue;
            int E;  // E = -radius
            int A;  // A = +radius
            int B = 0;

            // Until B becomes greater than A, repeat the following rules in order:
            // Fill the pixel at coordinate (A + center.A, B+Center.B)

            // Increase E by (2*B + 1)
            // Increase B by 1
            // If E >= 0
            //      E -= (2 * A - 1)
            //      --A

            // This covers one octave, you must repeat 7 times with varying reflections
            // in order to cover the circle.

            // In three dimensions:
            switch (axis)
            {
                // On the Y-Z plane, fix to X coordinate
                // and draw for Y-Z.
                case AXIS.AXIS_X:
                    radius = (int)(Point.Distance(center.Y, rad.Y, center.Z, rad.Z));
                    E = -radius;
                    A = radius;
                    while (B < A)
                    {
                        SetVoxel(center.X,  A + center.Y,  B + center.Z);
                        SetVoxel(center.X,  A + center.Y, -B + center.Z);
                        SetVoxel(center.X, -A + center.Y,  B + center.Z);
                        SetVoxel(center.X, -A + center.Y, -B + center.Z);

                        SetVoxel(center.X,  B + center.Y,  A + center.Z);
                        SetVoxel(center.X,  B + center.Y, -A + center.Z);
                        SetVoxel(center.X, -B + center.Y,  A + center.Z);
                        SetVoxel(center.X, -B + center.Y, -A + center.Z);

                        E += ((2 * B) + 1);
                        ++B;
                        if (E >= 0)
                        {
                            E -= ((2 * A) - 1);
                            --A;
                        }
                    }
                    break;
                // On the X-Z plane, fix to Y coordinate
                // and draw for X-Z.
                case AXIS.AXIS_Y:
                    radius = (int)(Point.Distance(center.X, rad.X, center.Z, rad.Z));
                    E = -radius;
                    A = radius;
                    while (B < A)
                    {
                        SetVoxel( A + center.X, center.Y,  B + center.Z);
                        SetVoxel( A + center.X, center.Y, -B + center.Z);
                        SetVoxel(-A + center.X, center.Y,  B + center.Z);
                        SetVoxel(-A + center.X, center.Y, -B + center.Z);

                        SetVoxel( B + center.X, center.Y,  A + center.Z);
                        SetVoxel( B + center.X, center.Y, -A + center.Z);
                        SetVoxel(-B + center.X, center.Y,  A + center.Z);
                        SetVoxel(-B + center.X, center.Y, -A + center.Z);
                        E += ((2 * B) + 1);
                        ++B;
                        if (E >= 0)
                        {
                            E -= ((2 * A) - 1);
                            --A;
                        }
                    }
                    break;
                // On the X-Y plane, fix to Z coordinate
                // and draw for X-Y.
                case AXIS.AXIS_Z:
                    radius = (int)(Point.Distance(center.X, rad.X, center.Y, rad.Y));
                    E = -radius;
                    A = radius;
                    while (B < A)
                    {
                        SetVoxel( A + center.X,  B + center.Y, center.Z);
                        SetVoxel( A + center.X, -B + center.Y, center.Z);
                        SetVoxel(-A + center.X,  B + center.Y, center.Z);
                        SetVoxel(-A + center.X, -B + center.Y, center.Z);

                        SetVoxel( B + center.X,  A + center.Y, center.Z);
                        SetVoxel( B + center.X, -A + center.Y, center.Z);
                        SetVoxel(-B + center.X,  A + center.Y, center.Z);
                        SetVoxel(-B + center.X, -A + center.Y, center.Z);
                        E += ((2 * B) + 1);
                        ++B;
                        if (E >= 0)
                        {
                            E -= ((2 * A) - 1);
                            --A;
                        }
                    }
                    break;
                default:
                    break;
            }
        }
Example #34
0
 private void Start()
 {
     this.gameManager = Object.FindObjectOfType<GameManager>();
     this.player = Object.FindObjectOfType<CubeController>();
 }
Example #35
0
    void Start()
    {
        CubeController._instance = this;
        rotationQueue = new Queue<RotationQueueItem>();

        Randomize(20);
    }
Example #36
0
    // function to lift object
    void liftObjects()
    {

        // raycast to get the object in front of the player
        RaycastHit raycastHit;
        bool hit = Physics.Raycast(playerCamera.transform.position, playerCamera.transform.forward, out raycastHit);

        // check if the object is liftable
        if (hit && raycastHit.transform.gameObject.tag == "liftable")
        {

            // set the racast gameObject to a variable and get the cubeController
            liftObject = raycastHit.transform.gameObject;
            liftObjectScript = liftObject.GetComponent<CubeController>();

            // check if the current gravity of the player is the same as the direction
            if (liftObjectScript.gravityDirection == gravityOnNormals.currentDirection)
            {

                // set the script to not use gravity
                liftObjectScript.useGravity = false;

                // set objectPickedUp to true so the player script knows that an object is picked up 
                objectPickedUp = true;

                // call a fuction in the object's script to be picked up
                liftObjectScript.pickUpObject(this);
            }
        }
    }