Exemplo n.º 1
0
        //==============================================
        // DISPLAY FUNCTIONS

        // functions with two _'s interacts with gamecomponents
        private OceanTile __newTile(Vector3 init)
        {
            OceanTile t = new OceanTile(init, tileSize);

            _debug("Adding new tile");

            // always have something to stand on for now
            GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);

            __transform("Tile", convertToAbsCoords(t.Coor), t.Scale, plane);

            MeshCollider mc = plane.GetComponent <MeshCollider> ();

            mc.convex         = true;
            mc.sharedMaterial = pm;

            // initialize and display islands associated with tile
            GameObject water = null;

            if (testTile)
            {
                // create a plane instead of the oecan
                Color randColor = Random.ColorHSV();
                plane.GetComponent <Renderer> ().material.color = randColor;
            }
            else
            {
                water = Instantiate(waterObj);

                // modify the scale bc the size of plane is different from the tile size
                Vector3 scale = new Vector3(tileSize / 100f, 0.1f, tileSize / 100f);
                __transform("Ocean", convertToAbsCoords(t.Coor), scale, water);

                // we don't want meshrenderer to mess things up
                Destroy(plane.GetComponent <MeshRenderer> ());

                // set the ocean tile as child to keep the inspector clean
                __setAsParent(water, plane);

                t.waterObj = water;
            }

            allTiles.Add(init, t);
            totalTiles++;

            Vector3[] islePos = Seeder.Seed(t.Coor, t.Size);
            foreach (Vector3 p in islePos)
            {
                Debug.Log("Queued island");
                Island i = new Island(p, scale, method, textureType, textureDensity);

                t.activeIslands.Add(i);
                queuedIslands.Add(i);

                __instantiateTrash(i);
            }

            return(t);
        }
Exemplo n.º 2
0
        // Update is called once per frame
        void Update()
        {
            Vector3 position = GetComponent <Transform> ().position;

            // update current tile if needed and display its neighborhood
            if (curTile == Vector3.one || !inTile(curTile, position))
            {
                Vector3 key = GetTileKey(position);

                _debug("[update] In new tile, updating curTile with key: " + key);

                // get the new tile
                OceanTile tile = activeTiles.ContainsKey(key) ? activeTiles [key]
                                        : addUnexploredTile(position);

                // reset colors
                Color waterColor = oceanColor;
                Color refract    = refractColor;

                if (tile.activeIslands.Count != 0)
                {
                    waterColor   = Color.red;
                    waterColor.a = 0.5f;

                    refract   = Random.ColorHSV();
                    refract.a = 0.1f;

                    if (!firstIsland)
                    {
                        firstIsland = true;
                        __storySetUp(tile.activeIslands [0]);
                    }
                    __changeSkybox();
                }

                __changeWaterColor(tile.waterObj, waterColor, refract);

                curTile = tile.Coor;
            }

            __displayIslands();
        }
Exemplo n.º 3
0
        void OnEnable()
        {
            InitModules();
            InitResources();

            this.queuedIslands        = new List <Island> ();
            this.allUntexturedIslands = new List <Island> ();

            this.activeTiles = new Dictionary <Vector3, OceanTile> ();
            this.allTiles    = new Dictionary <Vector3, OceanTile> ();

            // allocate initial tile
            Transform t = GetComponent <Transform> ();

            // this will introduce an exception and make the first tile set at (0, 0)
            OceanTile firstTile = addUnexploredTile(GetTileKey(t.position));

            this.curTile = firstTile.Coor;
            this.scale   = new Vector3(minIslandSize, islandHeight, minIslandSize);

            // jumpstart the story
            _debug("Initialized");
        }