Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (g == null)
        {
            return;
        }

        //Segue o mouse
        var mouseWPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        var cell      = g.WorldToCell(mouseWPos) + new Vector3Int(0, 1, 0);

        transform.position = g.GetCellCenterWorld(cell);

        if (Input.GetMouseButtonDown(0))
        {
            //Debug.Log("cell: " + cell);
            if (a.CheckNotBoundries(new Vector2Int(cell.x, -cell.y)))
            {
                var posVector = new Vector2Int(cell.x, -cell.y);
                Debug.Log("posVector: " + posVector);
                if (a.cells[posVector.x][posVector.y].plants == PuzzleCell.PlantType.P && tool == ToolType.Sun)
                {
                    a.ApplyGrowth(posVector, PuzzleCell.PlantType.P);
                    a.cells[posVector.x][posVector.y].showBroto = false;
                }
                else if (a.cells[posVector.x][posVector.y].plants == PuzzleCell.PlantType.S && tool == ToolType.Shadow)
                {
                    a.ApplyGrowth(posVector, PuzzleCell.PlantType.S);
                    a.cells[posVector.x][posVector.y].showBroto = false;
                }

                TurnController.Instance.PassTurn();
            }
        }

        //Teste de troca de ferramenta
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            tool = ToolType.Shadow;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            tool = ToolType.Sun;
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (defeated)
        {
            return;
        }

        if (interturns)
        {
            int victoryDegree = 0;
            List <List <PuzzleCell> > cellsAux = new List <List <PuzzleCell> >();;

            int count = 0;
            foreach (List <PuzzleCell> l in area.cells)
            {
                cellsAux.Add(new List <PuzzleCell>());
                foreach (PuzzleCell p in l)
                {
                    if (p.plants == PuzzleCell.PlantType.C)
                    {
                        cellsAux[count].Add(new PuzzleCell(p.plants, p.influenced, p.plantsToGrow.ToArray()));
                    }
                    else
                    {
                        cellsAux[count].Add(new PuzzleCell(p.plants, p.influenced));
                    }
                }
                count++;
            }

            int testCount = 0;
            for (int i = 0; i < area.cells.Count; i++)
            {
                for (int j = 0; j < area.cells[0].Count; j++)
                {
                    if (cellsAux[i][j].plants != PuzzleCell.PlantType.None)
                    {
                        Debug.Log(testCount++);
                        if (cellsAux[i][j].plants == PuzzleCell.PlantType.AV)
                        {
                            area.ApplyGrowth(new Vector2Int(i, j), cellsAux[i][j].plants);
                        }

                        /*else if (cellsAux[i][j].plants == PuzzleCell.PlantType.P) {
                         *  area.cells[i][j].turnsToGrow--;
                         *  if(area.cells[i][j].turnsToGrow <= 0) {
                         *      area.ApplyGrowth(new Vector2Int(i, j), cellsAux[i][j].plants);
                         *  }
                         * }
                         * else if (cellsAux[i][j].plants == PuzzleCell.PlantType.S) {
                         *  area.cells[i][j].turnsToGrow--;
                         *  if (area.cells[i][j].turnsToGrow <= 0) {
                         *      area.ApplyGrowth(new Vector2Int(i, j), cellsAux[i][j].plants);
                         *  }
                         * }*/
                        else if (cellsAux[i][j].plants == PuzzleCell.PlantType.C)
                        {
                            if (CheckOnClimax(area.cells[i][j]))
                            {
                                victoryDegree++;
                            }
                        }
                    }
                }
            }

            //Teste de vitória e derrota
            if (turnsLeft > 1)
            {
                if (CheckVictory())
                {
                    Debug.Log("Victory!");
                    Debug.Log("Victory Deegre: " + victoryDegree);
                }
                turnsLeft--;
                turnsText.text = "Turns Left: " + turnsLeft;
            }
            else
            {
                if (CheckVictory())
                {
                    Debug.Log("Victory!");
                }
                else
                {
                    Debug.Log("Defeat!");
                    GameDefeat();
                }
            }

            interturns = false;
        }
    }