Esempio n. 1
0
    public static bool DetectWin()
    {
        bool win = false;

        // in artist mode, you only win if you meet the goals of all hexagons with goals
        if (State.gameMode == GameMode.artist && (State.gameActivity == GameActivity.play || State.gameActivity == GameActivity.test))
        {
            GameObject[] hexagons     = GameObject.FindGameObjectsWithTag("Hexagon");
            int          goalsDefined = 0;
            int          goalsMet     = 0;
            foreach (GameObject h in hexagons)
            {
                ActorHexagon ah = h.GetComponent <ActorHexagon>();
                if (ah != null && ah.goalColor != ColorID.white)
                {
                    goalsDefined++;
                    if (ah.hexagonColor == ah.goalColor)
                    {
                        goalsMet++;
                    }
                }
            }
            win = (goalsMet != 0 && goalsDefined != 0 && goalsDefined == goalsMet);
        }

        return(win);
    }
Esempio n. 2
0
    public static void SetHexagonHoverColor(int hexagonID, ColorID colorID)
    {
        ActorHexagon target = GetHexagonActor(hexagonID);

        if (target != null)
        {
            target.SetHoverColor(colorID);
        }
    }
Esempio n. 3
0
 public Player(ActorHexagon h, ColorID c)
 {
     hexagon             = h;
     color               = c;
     nextMoveTime        = Time.realtimeSinceStartup;
     isBot               = false;
     moveDirection       = new Vector2(1f, -1f);
     changeDirectionTime = Time.realtimeSinceStartup + Random.Range(0.5f, 2f);
 }
Esempio n. 4
0
 public void AddPetal(int rotation, ActorHexagon petal)
 {
     if (petal != null)
     {
         petals.Add(rotation, petal);
     }
     else
     {
         Debug.LogError("Attempt to add null petal not allowed");
     }
 }
Esempio n. 5
0
 public static void ResetGrid()
 {
     Debug.Log("Resetting grid...");
     GameObject[] hexagons = GameObject.FindGameObjectsWithTag(HexagonTag);
     foreach (GameObject h in hexagons)
     {
         ActorHexagon ah = h.GetComponentInChildren <ActorHexagon>();
         if (ah != null)
         {
             ah.SetColor(0, ColorID.white);
             ah.SetGoalColor(ColorID.white);
             ah.SetHoverColor(ColorID.white);
         }
     }
 }
Esempio n. 6
0
 public static void EnterEditMode()
 {
     State.gameActivity = GameActivity.edit;
     GameObject[] hexagons = GameObject.FindGameObjectsWithTag(HexagonTag);
     foreach (GameObject h in hexagons)
     {
         ActorHexagon ah = h.GetComponentInChildren <ActorHexagon>();
         if (ah != null)
         {
             ColorID currentGoalColor = ah.goalColor;
             ah.SetGoalColor(ColorID.white);
             ah.SetColor(0, currentGoalColor);
         }
     }
 }
Esempio n. 7
0
    private static void FindNeighbors(ActorHexagon hexagon, int ID, int offset)
    {
        int neighbor = 0;

        // north
        neighbor = ID + columnCount;
        if (neighbor < (columnCount * rowCount))
        {
            hexagon.AddPetal(0, GameObject.Find(HexagonTag + neighbor.ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }

        // south
        neighbor = ID - columnCount;
        if (neighbor >= 0)
        {
            hexagon.AddPetal(3, GameObject.Find(HexagonTag + neighbor.ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }

        // northwest
        neighbor = ID - 1;
        if ((neighbor >= 0) && (neighbor % columnCount != (columnCount - 1)) && ((neighbor + offset) < rowCount * columnCount))
        {
            hexagon.AddPetal(5, GameObject.Find(HexagonTag + (neighbor + offset).ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }

        // northeast
        neighbor = ID + 1;
        if ((neighbor < columnCount * rowCount) && (neighbor % columnCount != 0) && ((neighbor + offset) < rowCount * columnCount))
        {
            hexagon.AddPetal(1, GameObject.Find(HexagonTag + (neighbor + offset).ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }

        // southwest
        neighbor = ID - (columnCount - offset) - 1;
        if ((neighbor >= 0) && (neighbor % columnCount != (columnCount - 1)))
        {
            hexagon.AddPetal(4, GameObject.Find(HexagonTag + neighbor.ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }

        // southeast
        neighbor = ID - (columnCount - offset) + 1;
        if ((neighbor > 0) && (neighbor % columnCount != 0))
        {
            hexagon.AddPetal(2, GameObject.Find(HexagonTag + neighbor.ToString()).GetComponent <ActorHexagon>() as ActorHexagon);
        }
    }
Esempio n. 8
0
    private static void GetCurrentBoardData()
    {
        // get the current hexagon state
        GameObject[] hexagons = GameObject.FindGameObjectsWithTag(ActorGridManager.HexagonTag);
        foreach (GameObject hex in hexagons)
        {
            ActorHexagon h = hex.GetComponent <ActorHexagon>();
            if (h)
            {
                // always give priority to the goal color
                if (h.goalColor != ColorID.white)
                {
                    if (!State.gameBoard.presetBoard.ContainsKey(h.hexagonID))
                    {
                        State.gameBoard.presetBoard.Add(h.hexagonID, (int)h.goalColor);
                    }
                }
                else
                {
                    if (h.hexagonColor != ColorID.white)
                    {
                        if (!State.gameBoard.presetBoard.ContainsKey(h.hexagonID))
                        {
                            State.gameBoard.presetBoard.Add(h.hexagonID, (int)h.hexagonColor);
                        }
                    }
                }
            }
        }

        // set the solution to the history
        State.gameBoard.seedsPlantedSolution = new Queue <GameStep>(seedsPlantedHistory);

        // set the goal to the solution
        SetScoreGoal(seedsPlanted, State.gameBoard.seedsPlantedSolution.Count);
    }