public GameObject LoadLevel(string levelPath)
        {
            Level         level    = _serializer.Deserialize <Level>(levelPath);
            LevelEntities entities = level.ToScene(DreamSystem, SettingsSystem);

            OnLevelLoaded?.Invoke(entities);
            return(entities.gameObject);
        }
Example #2
0
        public override void Restore(EntityMemento memento, LevelEntities entities)
        {
            base.Restore(memento, entities);

            var triggerLuaMemento = (TriggerLuaMemento)memento;

            LuaScript = triggerLuaMemento.LuaScript;
            entities.Register(this);
        }
Example #3
0
        public override void Restore(EntityMemento memento, LevelEntities entities)
        {
            base.Restore(memento, entities);

            var spawnPointMemento = (SpawnPointMemento)memento;

            DayOneSpawn    = spawnPointMemento.DayOneSpawn;
            TunnelEntrance = spawnPointMemento.TunnelEntrance;
            entities.Register(this);
        }
Example #4
0
    void Awake()
    {
        GameObject gc_obj = GameObject.FindWithTag("LevelEntities");

        m_levelEntities    = gc_obj.GetComponent <LevelEntities>();
        m_gameController   = GameObject.FindWithTag("GameController").GetComponent <GameController>();
        m_directionChanged = false;
        m_contacts         = new ContactPoint2D[5];
        m_direction        = new Vector2();
        m_status           = BallStatus.BallAttached;
    }
Example #5
0
    void Start()
    {
        m_targetJoint = gameObject.GetComponent <TargetJoint2D> ();
        GameObject gc_obj = GameObject.FindWithTag("GameController");

        m_gameController = gc_obj.GetComponent <GameController> ();
        GameObject le = GameObject.FindWithTag("LevelEntities");

        m_levelEntities = le.GetComponent <LevelEntities>();
        SetPolyCollider();
        m_cannonAttached = false;
    }
Example #6
0
    void Start()
    {
        Debug.Log("GameController.Start");

        m_levelEnvironment = m_levelEnvironmentGO.GetComponent <LevelEnvironment>();
        m_levelEntities    = m_levelEntitiesGO.GetComponent <LevelEntities>();
        m_levelEnvAnimator = m_levelEnvironmentGO.GetComponent <Animator>();
        m_score            = m_scoreGO.GetComponent <TextMesh>();
        m_paddleNrText     = m_paddleNrTextGO.GetComponent <TextMesh>();
        m_levelEnvironment.SetLevelNumber(m_levelNumber);
        LoadConfig();
    }
        public override void Restore(EntityMemento memento, LevelEntities entities)
        {
            base.Restore(memento, entities);

            var triggerLinkMemento = (TriggerLinkMemento)memento;

            LinkedLevel        = triggerLinkMemento.LinkedLevel;
            ForcedLinkColor    = triggerLinkMemento.ForcedLinkColor;
            SpawnPointEntityID = triggerLinkMemento.SpawnPointEntityID;
            ForceFadeColor     = triggerLinkMemento.ForceFadeColor;
            PlayLinkSound      = triggerLinkMemento.PlayLinkSound;
            entities.Register(this);
        }
        private void spawnPlayerInDream(LevelEntities entities)
        {
            var allSpawns = entities.OfType <SpawnPoint>();

            if (!allSpawns.Any())
            {
                Debug.LogError("No spawn points in dream! Unable to spawn player.");
                return;
            }

            // handle a designated SpawnPoint being used
            if (!string.IsNullOrEmpty(_forcedSpawnID))
            {
                try
                {
                    SpawnPoint spawn = allSpawns.First(e => e.EntityID == _forcedSpawnID);
                    spawn.Spawn();
                    return;
                }
                catch (InvalidOperationException e)
                {
                    Debug.LogError($"Unable to find SpawnPoint with ID '{_forcedSpawnID}'");
                    throw;
                }
            }

            // spawn in a first day-designated spawn if it's the first day
            if (GameSave.CurrentJournalSave.DayNumber == 1)
            {
                var firstDaySpawns = allSpawns.Where(s => s.DayOneSpawn).ToList();
                if (firstDaySpawns.Any())
                {
                    RandUtil.RandomListElement(firstDaySpawns).Spawn();
                    return;
                }
            }

            // make sure we choose a spawn point that isn't a tunnel entrance
            var spawnPoints = allSpawns.Where(s => !s.TunnelEntrance).ToList();

            if (spawnPoints.Any())
            {
                RandUtil.RandomListElement(spawnPoints).Spawn();
                return;
            }

            // otherwise we'll have to spawn on a tunnel entrance... this shouldn't happen so warn the player
            Debug.LogWarning(
                "Unable to find a spawn point that isn't a tunnel entrance -- using a tunnel entrance instead.");
            RandUtil.RandomListElement(allSpawns).Spawn();
        }
Example #9
0
        public override void Restore(EntityMemento memento, LevelEntities entities)
        {
            base.Restore(memento, entities);

            var objMemento = (InteractiveObjectSpawnMemento)memento;

            LBDFile           = objMemento.LBDFile;
            EntityNumber      = objMemento.EntityNumber;
            IdleAnimation     = objMemento.IdleAnimation;
            PlayIdleAnimation = objMemento.PlayIdleAnimation;
            LuaScript         = objMemento.LuaScript;
            entities.Register(this);

            if (Application.isPlaying)
            {
                spawnObject();
            }
        }
Example #10
0
    void Start()
    {
        GameObject le = GameObject.FindWithTag("LevelEntities");

        m_levelEntities = le.GetComponent <LevelEntities>();
    }