예제 #1
0
        public IntergrationField CreateIntergrationField(List <Tile> tiles, List <int> sectors, Tile destination, WorldArea area)
        {
            IntergrationField intergrationField = new IntergrationField();

            intergrationField.AddFields(sectors, worldData.multiLevelSectorManager.GetSectorWidthAtLevel(area, 0) * worldData.multiLevelSectorManager.GetSectorHeightAtLevel(area, 0), tiles, area);
            return(intergrationField);
        }
예제 #2
0
 public void Create(Tile _destination, List <int> _worldAreas, IntergrationField _intergrationField, FlowField _flowField, int _key)
 {
     worldAreas        = _worldAreas;
     destination       = _destination;
     intergrationField = _intergrationField;
     flowField         = _flowField;
     key = _key;
 }
예제 #3
0
        public void DrawIntegrationField(IntergrationField integrationfield)
        {
            if (integrationFieldHolder != null)
            {
                Destroy(integrationFieldHolder);
            }

            GameObject integrationTile = Resources.Load("Prefab/IntegrationTile") as GameObject;

            if (worldData.pathfinder.showIntergrationField)
            {
                integrationFieldHolder = new GameObject();
                for (int x = 0; x < worldData.worldAreas.Count; x++)
                {
                    for (int i = 0; i < worldData.worldAreas[x].sectorGrid[0].Length; i++)
                    {
                        if (integrationfield.field.ContainsKey(new IntVector2(x, i)))
                        {
                            MultiLevelSector sector    = worldData.worldAreas[x].sectorGrid[0][i];
                            Vector2          sectorPos = new Vector2(sector.left, sector.top);

                            for (int j = 0; j < sector.tilesInWidth * sector.tilesInHeight; j++)
                            {
                                int y = Mathf.FloorToInt((float)j / sector.tilesInWidth);

                                Vector2 node = sectorPos + new Vector2(j - (sector.tilesInWidth * y), y);

                                if (worldData.worldAreas[x].tileGrid[(int)node.x][(int)node.y] != null)
                                {
                                    GameObject b = Instantiate(integrationTile, worldData.tileManager.GetTileWorldPosition(worldData.worldAreas[x].tileGrid[(int)node.x][(int)node.y], worldData.worldAreas[x]), Quaternion.identity) as GameObject;

                                    int value = integrationfield.field[new IntVector2(x, i)][j];

                                    if (value * 3 >= worldData.colorLists.pathCostColors.Length - 2)
                                    {
                                        b.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material.color = worldData.colorLists.pathCostColors[worldData.colorLists.pathCostColors.Length - 2];
                                    }
                                    else
                                    {
                                        if (value < worldData.colorLists.pathCostColors.Length - 2)
                                        {
                                            b.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material.color = worldData.colorLists.pathCostColors[value * 3];
                                        }
                                    }

                                    b.transform.position  += Vector3.up * 0.15f;
                                    b.transform.parent     = integrationFieldHolder.transform;
                                    b.transform.localScale = new Vector3(worldData.pathfinder.tileSize, worldData.pathfinder.tileSize, worldData.pathfinder.tileSize);
                                }
                            }
                        }
                    }
                }
            }
        }