Exemple #1
0
        void ScoutEffect(int q, int r, CubeScout scout)
        {
            Vector2Int curr = new Vector2Int(scout.Q, scout.R);
            Vector2Int next = new Vector2Int(q, r);

            if (structureStore.HasStructure(next[0], next[1]))
            {
                boardState.AddNode(q, r, scout.GetPlayer(), scout.GetDamage());
            }
            else
            {
                boardState.AddNode(q, r, scout.GetPlayer(), scout.GetInfluence());
            }
            if (scoutPos.ContainsKey(next))
            {
                RemoveScout(scout, curr);
                RemoveScout(scoutPos[next], next);
            }
            else if (structureStore.HasStructure(next[0], next[1]) && structureStore.GetStructure(next[0], next[1]).GetPlayer() != scout.GetPlayer())
            {
                RemoveScout(scout, curr);
            }
            else
            {
                scoutPos.Remove(curr);
                scout.SetCoords(next[0], next[1]);
                scoutPos[next] = scout;
            }
            scout.DecMoves();
            if (scout.GetMoves() <= 0)
            {
                RemoveScout(scout, next);
            }
        }
Exemple #2
0
        Vector2Int NextTile(CubeScout scout)
        {
            List <Vector2Int> neighbors = boardState.GetNeighbors(scout.Q, scout.R);
            List <Vector2Int> valid     = new List <Vector2Int>();

            foreach (var n in neighbors)
            {
                int totalWeight = 1;
                if (structureStore.HasStructure(n[0], n[1]))
                {
                    if (structureStore.GetStructure(n[0], n[1]).GetPlayer() == scout.GetPlayer())
                    {
                        totalWeight *= 0;
                    }
                    else
                    {
                        return(new Vector2Int(n[0], n[1]));
                    }
                }
                else
                {
                    if (boardState.GetNodeOwner(n[0], n[1]) != scout.GetPlayer())
                    {
                        totalWeight *= moveUnownedWeight;
                    }
                    if (!scout.HasVisited(n[0], n[1]))
                    {
                        totalWeight *= moveUnvisitedWeight;
                    }
                    Vector2Int home = scout.GetHome();
                    if (CalcDistance(home[0], home[1], n[0], n[1]) > CalcDistance(home[0], home[1], scout.Q, scout.R))
                    {
                        totalWeight *= moveAwayWeight;
                    }
                }
                for (int i = 0; i < totalWeight; i++)
                {
                    valid.Add(new Vector2Int(n[0], n[1]));
                }
            }
            return(valid.Count == 0 ? new Vector2Int(-1, -1) : valid[UnityEngine.Random.Range(0, valid.Count)]);
        }