/// <summary>
            /// Computes positions for this Tile and caches
            /// them.
            /// </summary>
            public void ComputePositions()
            {
                Positions = new PositionsContainer[Pool._placer.ObjectsToPlace.Count];
                UnityEngine.Terrain t = Tile.MeshManager.ActiveTerrain;
                float amp             = TerraConfig.Instance.Generator.Amplitude;

                for (int i = 0; i < Positions.Length; i++)
                {
                    ObjectDetailNode objectPlacementData = Pool._placer.ObjectsToPlace[i];
                    Vector2[]        samples             = objectPlacementData.SamplePositions(Tile.Random);
                    List <Vector3>   worldPositions      = new List <Vector3>((int)(Positions.Length * 0.66f));

                    for (var j = 0; j < samples.Length; j++)
                    {
                        Vector2 pos    = samples[j];
                        float   height = t.terrainData.GetInterpolatedHeight(pos.x, pos.y);
                        float   angle  = Vector3.Angle(Vector3.up, t.terrainData.GetInterpolatedNormal(pos.x, pos.y)) / 90;
                        Vector2 world  = MathUtil.NormalToWorld(Tile.GridPosition, pos);

                        if (objectPlacementData.ShouldPlaceAt(world.x, world.y, height / amp, angle))
                        {
                            worldPositions.Add(new Vector3(world.x, height, world.y));
                        }
                    }

                    Positions[i] = new PositionsContainer(worldPositions.ToArray(), objectPlacementData);
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Computes positions for this TerrainTile and caches
            /// them.
            /// </summary>
            public void ComputePositions()
            {
                Positions = new PositionsContainer[Pool.Placer.ObjectsToPlace.Count];

                for (int i = 0; i < Positions.Length; i++)
                {
                    ObjectPlacementType type      = Pool.Placer.ObjectsToPlace[i];
                    Vector3[]           locations = Pool.Placer.GetFilteredGrid(Tile, type, 1).ToArray();
                    Positions[i] = new PositionsContainer(locations, type);
                }
            }
Exemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

            IChangedPositionHandler chpHandler       = new PositionsContainer();
            IUserPreferencesHandler userPrefsHandler = new PreferencesContainer(DataRepos.Instance.Preferences);

            EventService.Instance.Add(new AndroidEventPropagator(
                                          HttpContext.Current.Server.MapPath("~/App_Data/Logs")));

            EventService.Instance.SetPositionsContainer(chpHandler);
            EventService.Instance.SetUserPreferencesHandler(userPrefsHandler);
        }