示例#1
0
    public void LoadData()
    {
        if (transData == null)
        {
            GameObject obj = GameObject.FindGameObjectWithTag("TransitionData");
            transData = obj.GetComponentInChildren <DataTransition>();
        }

        if (levelConfig == null)
        {
            levelConfig = SingletonJsonLoadable <ConfigurationLevelDataPair> .Instance;
        }

        levelConfig.Configure("LevelData/" + transData.nextLevelPath, "LevelData/" + transData.nextLevelPath);
        levelConfig.Load();

        startingMoment = levelConfig.data.startingMoment;
        startingMoment.BuildLevel(levelConfig.data.levelAsString);

        moments = new List <List <LevelMoment> >();

        List <LevelMoment> startingTimeline = new List <LevelMoment>
        {
            startingMoment.DeepCopyLevelMoment()
        };

        moments.Add(startingTimeline);
    }
示例#2
0
    public void WormHole(LevelMoment moment)
    {
        Vector2Int i = moment.GetIndex();

        if (moments.Count < (i.x + 2))
        {
            List <LevelMoment> timeline     = new List <LevelMoment>();
            List <LevelMoment> prevTimeline = moments[i.x];

            LevelMoment prevStart = LevelData.Instance.startingMoment;
            LevelMoment newStart  = prevStart.DeepCopyLevelMoment();

            newStart.phase = i.x + 1;

            newStart.PhaseInLemmings();

            for (int l = 0; l < newStart.y; l++)
            {
                for (int k = 0; k < newStart.z; k++)
                {
                    for (int m = 0; m < newStart.x; m++)
                    {
                        char key = newStart.level[m, l, k];
                        if (key == GameBoardCubeDictionary.WORMHOLE_IN)
                        {
                            newStart.Remove(new Vector3Int(m, l, k), key);
                        }
                    }
                }
            }

            newStart.RecieveTimeTraveler();
            timeline.Add(newStart);

            moments.Add(timeline);

            Vector2Int j = new Vector2Int(i.x + 1, 0);
            if (TimeLineCreatedEvent != null)
            {
                TimeLineCreatedEvent(j);
            }
            else
            {
                AddToEvent(j);
            }
        }
    }
示例#3
0
    private void CheckBuilding()
    {
        //if (!Input.GetKeyDown(KeyCode.N)) return;

        if (isWin)
        {
            return;
        }
        bool changed = false;

        //Find next map to update. (for not just go linearly)
        LevelMoment prevMoment = FindOldMoment();

        if (prevMoment == null)
        {
            updating = false;
            return;
        }


        LevelMoment nextMoment = prevMoment.DeepCopyLevelMoment();

        if (prevMoment.terminalBuffer == 0)
        {
            prevMoment.terminalBuffer++;
        }

        nextMoment.Age();

        //Keep track of saved and dead lemming count
        Vector2Int lemCounts = new Vector2Int(nextMoment.savedLemmings.Count, nextMoment.deadLemmings.Count);

        //Go one past the last moment
        if ((lemCounts.x > 0) || (lemCounts.y > 0))
        {
            changed = true;
        }

        nextMoment.goal -= lemCounts.x;
        nextMoment.fail -= lemCounts.y;

        List <Lemming> movingLemmings = new List <Lemming>();

        movingLemmings.AddRange(nextMoment.lemmings);
        movingLemmings.AddRange(nextMoment.phasedLemmings);

        nextMoment.lemmings       = new List <Lemming>();
        nextMoment.savedLemmings  = new List <Lemming>();
        nextMoment.deadLemmings   = new List <Lemming>();
        nextMoment.phasedLemmings = new List <Lemming>();



        foreach (Lemming lem in movingLemmings)
        {
            Vector3Int pos = lem.position;

            Vector3Int forwardIndex = lem.position + lem.direction;
            Vector3Int belowIndex   = new Vector3Int(pos.x, pos.y - 1, pos.z);

            GameBlock current = null;
            GameBlock move    = null;
            GameBlock below   = null;

            current = GetBlock(prevMoment, pos);

            changed |= true;

            move  = GetBlock(prevMoment, forwardIndex);
            below = GetBlock(prevMoment, belowIndex);

            Vector3Int prevPos = lem.position;
            if (below != null)
            {
                below.overMoveBehaviour.Move(nextMoment, prevMoment, lem, below);
            }
            if ((move != null) && (prevPos == lem.position))
            {
                move.enterMoveBehaviour.Move(nextMoment, prevMoment, lem, move);
            }
            current.exitMoveBehaviour.Move(nextMoment, prevMoment, lem, below);

            Vector3Int lPos = lem.position;;
            char       key  = nextMoment.level[lPos.x, lPos.y, lPos.z];

            if (key == GameBoardCubeDictionary.END_ZONE)
            {
                nextMoment.savedLemmings.Add(lem);
            }
            else if (CheckDead(lem))
            {
                if (nextMoment.LemmingInPhase(lem))
                {
                    nextMoment.deadLemmings.Add(lem);
                }
            }
            else
            {
                if (nextMoment.LemmingInPhase(lem))
                {
                    nextMoment.lemmings.Add(lem);
                }
                else
                {
                    nextMoment.phasedLemmings.Add(lem);
                }
            }
        }

        if (changed)
        {
            if (nextMoment.HasTimeTraveler())
            {
                nextMoment.lemmings.Remove(nextMoment.timeTraveler);
            }
        }

        ProcessSpawners(nextMoment);
        nextMoment.RecieveTimeTraveler();

        LevelData.Instance.CheckPast(nextMoment);

        //If a new moment was created, add it to the timeline, call event

        if ((MomentBuiltEvent != null))
        {
            List <LevelMoment> timeline = levelData.moments[nextMoment.phase];
            Vector2Int         i        = new Vector2Int(nextMoment.phase, nextMoment.time);
            timeline.Add(nextMoment);
            MomentBuiltEvent(i);
        }
    }