Example #1
0
        public void buttonGoToNow()
        {
            world.audioStore.playClick();
            //It only stores deltas, gotta play forward all of them as ASAP as possible
            while (snapshotIndex < map.stats.snapshots.Count - 1)
            {
                snapshotIndex += 1;
                StatSnapshot shot = map.stats.snapshots[snapshotIndex];

                for (int i = 0; i < shot.hexColIndices.Count; i++)
                {
                    int[]   loc = shot.hexColIndices[i];
                    float[] col = shot.hexColValues[i];
                    hexes[loc[0], loc[1]].sprite.color = new Color(col[0], col[1], col[2]);
                }
            }
        }
Example #2
0
        public void Update()
        {
            float time  = Time.time;
            float delta = time - lastStep;

            if (delta > betweenSteps)
            {
                //if (snapshotIndex >= map.stats.snapshots.Count)
                //{
                //    snapshotIndex = 0;
                //}

                StatSnapshot shot = map.stats.snapshots[snapshotIndex];

                //int gameTurn = shot.day - map.options.burnInSteps;
                int gameTurn = shot.day;


                title.text = "Turn: " + gameTurn;
                if (gameTurn < 0)
                {
                    title.text += " (World Gen)";
                }

                for (int i = 0; i < shot.hexColIndices.Count; i++)
                {
                    int[]   loc = shot.hexColIndices[i];
                    float[] col = shot.hexColValues[i];
                    hexes[loc[0], loc[1]].sprite.color = new Color(col[0], col[1], col[2]);
                }

                if (!paused && snapshotIndex < map.stats.snapshots.Count - 1)
                {
                    snapshotIndex += 1;
                }
                lastStep = time;
            }
        }
        public void turnTick()
        {
            StatSnapshot snapshot = new StatSnapshot();

            snapshot.day = map.turn;
            snapshots.Add(snapshot);

            float pop = 0;

            if (prevColours == null)
            {
                prevColours = new float[map.sizeX][][];
                for (int i = 0; i < prevColours.Length; i++)
                {
                    prevColours[i] = new float[map.sizeY][];
                    for (int j = 0; j < prevColours[i].Length; j++)
                    {
                        prevColours[i][j] = new float[3];
                    }
                }
            }
            float[][][] colours = new float[map.sizeX][][];
            for (int i = 0; i < colours.Length; i++)
            {
                colours[i] = new float[map.sizeY][];
                for (int j = 0; j < colours[i].Length; j++)
                {
                    colours[i][j] = new float[3];
                }
            }

            for (int i = 0; i < map.sizeX; i++)
            {
                for (int j = 0; j < map.sizeY; j++)
                {
                    bool delta = false;
                    if (map.landmass[i][j] == false)
                    {
                        colours[i][j][0] = 0;
                        colours[i][j][1] = 0;
                        colours[i][j][2] = 0.25f;
                    }
                    else if (map.grid[i][j].owner == null)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            colours[i][j][k] = map.grid[i][j].purity;
                        }
                    }
                    else
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            colours[i][j][k] = map.grid[i][j].owner.color[k] * map.grid[i][j].purity;
                        }
                    }
                    for (int k = 0; k < 3; k++)
                    {
                        if (colours[i][j][k] != prevColours[i][j][k])
                        {
                            delta = true;
                        }
                    }
                    if (delta)
                    {
                        snapshot.hexColIndices.Add(new int[] { i, j });
                        snapshot.hexColValues.Add(new float[] { colours[i][j][0], colours[i][j][1], colours[i][j][2] });
                    }
                }
            }
            prevColours = colours;
        }