Example #1
0
    public void CreateSlice(Vector3 rotation)
    {
        currentSlice = Instantiate(levelPrefab).GetComponent <SliceBoard>();
        currentSlice.transform.SetParent(slices.transform, false);
        currentSlice.NotifyObjectivesFilled += model.ObjectivesFilledNotification;

        model.SetSliceBoard(ref currentSlice, rotation);

        currentView.GetComponent <GetComponentsFadeAnimation>().StartReverseAnimating();
        currentSlice.GetComponent <GetComponentsFadeAnimation>().StartAnimating();
    }
Example #2
0
    //Get the new ball positions from the slice and place the balls to their new positions
    // It relies on the fact that any balltype/objectiveType combiantion is only present once.
    //If a level has two balls exactly similar, this function may not work anymore
    public void SetNewBallPositions(SliceBoard slice)
    {
        Dictionary <BallData, IntVector3> currentPositions = new Dictionary <BallData, IntVector3>();

        for (int x = 0; x < X_SIZE; x++)
        {
            for (int y = 0; y < Y_SIZE; y++)
            {
                for (int z = 0; z < Z_SIZE; z++)
                {
                    if (balls[x, y, z].BallType == BallType.NORMAL)
                    {
                        currentPositions.Add(balls[x, y, z], new IntVector3(x, y, z));
                    }
                }
            }
        }

        FaceModel faceModel = FaceModel.ModelsDictionary[slice.face];

        var newPositions = slice.GetBallsPositions();
        var filledTiles  = slice.GetFilledTiles();

        foreach (var pair in currentPositions)
        {
            bool wasFilled = filledTiles.Contains(pair.Key.ObjectiveType);
            if (newPositions.ContainsKey(pair.Key) || wasFilled)
            {
                balls.Set(pair.Value, BallData.GetEmptyBall());
            }
        }
        foreach (var pair in currentPositions)
        {
            IntVector3 newPosition;
            if (newPositions.TryGetValue(pair.Key, out newPosition))
            {
                IntVector3 realPosition = new IntVector3();
                realPosition[faceModel.axes[0]] = newPosition.X;
                realPosition[faceModel.axes[1]] = newPosition.Y;
                realPosition[faceModel.axes[2]] = pair.Value[faceModel.axes[2]];

                balls.Set(realPosition, pair.Key);
            }
        }
        CheckLevelCompleted();
        HasChanged.Invoke(this);
    }
Example #3
0
    public void SetSliceBoard(ref SliceBoard slice, Vector3 rotation)
    {
        CubeFace face = CameraController.GetFace(rotation);

        TileData[,] faceTiles = faces[(int)face];
        BallData[,] ballData  = GetPlaneBoardData(face);
        int faceRotation = FaceModel.GetRotation(face, rotation);

        BoardData data = new BoardData();

        data.balls = ballData.Rotate(faceRotation);
        Assert.IsNotNull(data.balls);
        data.tiles = faceTiles.Rotate(faceRotation);

        slice.rotation = faceRotation;
        slice.face     = face;
        slice.SetData(data, objectivesFilled);
    }