コード例 #1
0
 private bool CheckValidity(PheromoneDisplayer displayer, int teamId)
 {
     foreach (PheromoneDisplayOption option in displayOptions)
     {
         if (option.enabled && displayer.type == option.type && teamId == option.teamId)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
    public void UpdateCell(List <PheromoneDescriptor>[][][] pheromoneMaps, int x, int y)
    {
        // Removing all the displayers from the cell
        foreach (List <PheromoneDisplayer>[][] displayMap in displayMaps)
        {
            foreach (PheromoneDisplayer displayer in displayMap[x][y])
            {
                Destroy(displayer.gameObject);
            }
            displayMap[x][y] = new List <PheromoneDisplayer>();
        }

        // Adding all the needed displayers to the cell
        for (int i = 0; i < pheromoneMaps.Length; i++)
        {
            List <PheromoneDescriptor>[][] pheromoneMap = pheromoneMaps[i];
            List <PheromoneDisplayer>[][]  displayMap   = displayMaps[i];

            foreach (PheromoneDescriptor pheromone in pheromoneMap[x][y])
            {
                Color validityColor = CheckValidity(pheromone, i);
                if (validityColor != NULL_COLOR)
                {
                    PheromoneDisplayer newDisplayer = Instantiate(
                        displayerPrefab,
                        CoordConverter.PlanToWorld(CoordConverter.HexToPos(new Vector2Int(x, y)), displayerPrefab.transform.position.y),
                        displayerPrefab.transform.rotation);

                    newDisplayer.displayDirection = pheromone.direction;
                    newDisplayer.transform.LookAt(CoordConverter.PlanToWorld(CoordConverter.HexToPos(CoordConverter.MoveHex(new Vector2Int(x, y), newDisplayer.displayDirection)), newDisplayer.transform.position.y));
                    newDisplayer.SetColor(validityColor);

                    displayMap[x][y].Add(newDisplayer);
                }
            }
        }
    }