Example #1
0
 // Let's return the colors to the state they were before us
 public void Undo(GridStates states)
 {
     for (int i = myStart; i < myEnd; i++)
     {
         states.currentState.colors[i] = startMemento.colors[i];
     }
 }
Example #2
0
    public void ShouldBePaused()
    {
        GridStates stateBeforePause = grid.CurrenteStateName;

        grid.Pause();
        Assert.AreEqual(GridStates.Paused, grid.CurrenteStateName);

        grid.Pause();
        Assert.AreEqual(stateBeforePause, grid.CurrenteStateName);
    }
Example #3
0
    // Let's Modify the colors in a Range
    public void Do(GridStates states)
    {
        startMemento = new CubeGridMemento(states.currentState);

        for (int i = myStart; i < myEnd; i++)
        {
            states.currentState.colors[i] = myColor;
            Debug.Log(myColor);
        }
    }
Example #4
0
    public void Reset()
    {
        Destroy(cableObjectParent);
        DestroyAllCableTiles();

        this.State        = GridStates.Unsolved;
        cableObjectParent = new GameObject("Cables");
        CableTileGrid     = new GameObject[this.columnSize, this.rowSize];
        FillWCableTiles();
        ShuffleGrid(CableTileGrid);
        TimedEvaluator.GetComponent <CountdownTimer>().Reset();
    }
Example #5
0
 public void SetStatus(GridStates status, string statusDescription = null)
 {
     this.Status = status;
     if (String.IsNullOrEmpty(statusDescription))
     {
         this.StatusDescription = status.ToString();
     }
     else
     {
         this.StatusDescription = statusDescription;
     }
 }
Example #6
0
    private void Start()
    {
        GridStates states        = new GridStates(startColors);
        var        firstCommand  = new CubeCommand(0, 60, Color.red);
        var        secondCommand = new CubeCommand(0, 36, Color.green);
        var        thirdCommand  = new CubeCommand(24, 48, Color.blue);
        var        fourthCommand = new CubeCommand(12, 15, Color.yellow);

        firstCommand.Do(states);
        secondCommand.Do(states);
        thirdCommand.Do(states);
        fourthCommand.Do(states);
        states.Render(cubes);
    }
Example #7
0
    public IEnumerator PlaceObjects(GameObject obj)
    {
        State = GridStates.PlacingObjectMode;

        while (State == GridStates.PlacingObjectMode)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction * 10, out hit))
            {
                Vec2 newPosition = new Vec2((int)hit.point.x, (int)hit.point.z);

                Node node = GetPlayerAvailableNode(newPosition.X, newPosition.Z);

                if (node != null)
                {
                    obj.transform.position = new Vector3(node.Position.X, hit.point.y + 0.5f, node.Position.Z);
                }
                else
                {
                    Debug.Log("Node Unavailable..");
                }

                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    State = GridStates.IdleMode;
                    SetPlayerTileUnavailable(node);

                    obj.GetComponent <StarWarsObject>().SetLane();
                    obj.GetComponent <StarWarsObject>().InitializeObject();
                }

                if (Input.GetKeyDown(KeyCode.Mouse1))
                {
                    State = GridStates.IdleMode;
                    Destroy(obj);
                }
            }

            yield return(null);
        }
    }
Example #8
0
    /// <summary>
    /// Evaluate this grid.
    /// </summary>
    public void RunEvaluation()
    {
        for (int i = 0; i < (this.rowSize * this.columnSize); i++)
        {
            UnityGridEvaluator.Instance.Evaluate(this);
        }

        if (this.State == GridStates.Solved)
        {
            GameManager.Win();
            Debug.Log("Win");
        }
        else
        {
            GameManager.Lose();
            Debug.Log("Lose");
            this.State = GridStates.None;
        }
    }
Example #9
0
    private void InitializeGrid(Vec2 position)
    {
        GridNodes = new Node[WIDTH, HEIGHT];
        GridLanes = new Lane[HEIGHT];

        for (int z = 0; z < HEIGHT; z++)
        {
            GridLanes[z] = new Lane();

            for (int x = 0; x < WIDTH; x++)
            {
                GridNodes[x, z] = new Node(new Vec2(x * OFFSET, z * OFFSET) + position);

                Node node = GridNodes[x, z];

                SetNodeAvailability(x, node);

                DEBUG_InstantiateNode(node);
            }
        }

        State = GridStates.IdleMode;
    }
Example #10
0
    public void SetState(GridStates state)
    {
        // can only set newgame when its gameover
        if(state == GridStates.NewGame)
        {
            State = new NewGameState();
            return;
        }

        if (CurrenteStateName == GridStates.GameOver) return;

        switch (state)
        {
            case GridStates.ReadyForNextGroup:
                {
                    State = new ReadyForNextGroupState(_setting, this, _groupFactory, OnDeleteEndEvent);
                }
                break;
            case GridStates.Deleted:
                {
                    State = new DeletedState(this);
                }
                break;
            case GridStates.Deleting:
                {
                    State = new DeletingState(this);
                }
                break;
            case GridStates.Dropped:
                {
                    State = new DroppedState(this);
                }
                break;
            case GridStates.Dropping:
                {
                    State = new DroppingState(this);
                }
                break;
            case GridStates.GameOver:
                {
                    State = new GameOverState();
                }
                break;
            case GridStates.OnControlGroup:
                {
                    State = new OnControlGroupState(this);
                }
                break;
            case GridStates.OnFix:
                {
                    State = new OnFixState(this);
                }
                break;
            case GridStates.Paused:
                {
                    State = new PausedState();
                }
                break;
        }
    }
Example #11
0
    public void SetState(GridStates state)
    {
        // can only set newgame when its gameover
        if (state == GridStates.NewGame)
        {
            State = new NewGameState();
            return;
        }

        if (CurrenteStateName == GridStates.GameOver)
        {
            return;
        }

        switch (state)
        {
        case GridStates.ReadyForNextGroup:
        {
            State = new ReadyForNextGroupState(_setting, this, _groupFactory, OnDeleteEndEvent);
        }
        break;

        case GridStates.Deleted:
        {
            State = new DeletedState(this);
        }
        break;

        case GridStates.Deleting:
        {
            State = new DeletingState(this);
        }
        break;

        case GridStates.Dropped:
        {
            State = new DroppedState(this);
        }
        break;

        case GridStates.Dropping:
        {
            State = new DroppingState(this);
        }
        break;

        case GridStates.GameOver:
        {
            State = new GameOverState();
        }
        break;

        case GridStates.OnControlGroup:
        {
            State = new OnControlGroupState(this);
        }
        break;

        case GridStates.OnFix:
        {
            State = new OnFixState(this);
        }
        break;

        case GridStates.Paused:
        {
            State = new PausedState();
        }
        break;
        }
    }
 public BattleGrid()
 {
     States = new GridStates[COLS, ROWS];
     ships = new List<Ship>();
 }