示例#1
0
        public static Area Create(AuroraARE are)
        {
            GameObject gameObject;

            //get the resource reference for this object, which we'll use as it's in-engine name
            string name = are.Tag;

            //add the template component to the new object
            gameObject = new GameObject("Area");

            Area area = gameObject.AddComponent <Area>();

            area.template = are;

            gameObject.AddComponent <AreaManager>();

            return(area);
        }
示例#2
0
    public void Initialize()
    {
        initialized = true;

        StateSystem.stateSystem = this;

        AuroraObject.stateManager = this;

        // Initialize all AuroraObjects
        foreach (List <AuroraObject> objs in auroraObjects.Values)
        {
            foreach (AuroraObject obj in objs)
            {
                obj.Initialize();
            }
        }

        // This is called when we start the module
        // Load the first level
        currentModule = AuroraEngine.Resources.data.module;
        currentArea   = currentModule.are;

        // Move the player to the starting position
        GameObject.FindGameObjectWithTag("Player").transform.position = currentModule.entryPosition;

        // Play the background music
        //AudioSource source = GetComponent<AudioSource>();
        //if (currentModule.ambientMusic)
        //{
        //    source.clip = currentModule.ambientMusic;
        //    source.Play();
        //}
        currentModule.area.lastEntered = PC;
        try
        {
            currentModule.OnEnter();
        } catch
        {
        }
    }
示例#3
0
        public Module(string name, AuroraData data, bool instantiateModule)
        {
            this.moduleName = name;
            this.data       = data;

            if (!instantiateModule)
            {
                return;
            }

            if (stateManager == null)
            {
                stateManager = GameObject.Find("State System").GetComponent <StateSystem>();
            }
            if (loader == null)
            {
                loader = GameObject.Find("Loading System").GetComponent <LoadingSystem>();
            }

            ifo = data.Get <AuroraIFO>("module", ResourceType.IFO);
            Debug.Log(ifo);
            string areaName = ifo.Mod_Entry_Area;

            are = data.Get <AuroraARE>(areaName, ResourceType.ARE);
            git = data.Get <AuroraGIT>(areaName, ResourceType.GIT);

            entryPosition = new Vector3(ifo.Mod_Entry_X, ifo.Mod_Entry_Z, ifo.Mod_Entry_Y);

            Dictionary <string, Vector3> layout = Resources.LoadLayout(areaName, data);

            Debug.Log("Layout has " + layout.Count + " rooms.");

            area = Area.Create(are);

            GameObject parent = new GameObject("Models");

            parent.transform.SetParent(area.transform);

            foreach (var value in layout)
            {
                loader.AddAction(() =>
                {
                    Debug.Log("Loading room " + value.Key);
                    string resref = value.Key.ToLower();

                    GameObject room = Resources.LoadModel(resref);

                    if (SetupSkybox(room))
                    {
                        return;
                    }

                    // Set up the Navmesh
                    SetLayerRecursive(room, LayerMask.NameToLayer("NavMeshStatic"));

                    // Set the room's position and parent
                    room.transform.position = value.Value;
                    room.transform.SetParent(parent.transform);
                });
            }

            LoadCreatures();
            LoadPlaceables();

            loader.AddAction(() => data.aiManager.BakeNavMesh());

            LoadDoors();
            LoadTriggers();
            LoadEncounters();
            LoadSounds();
            LoadStores();
            LoadWaypoints();
            LoadCameras();

            loader.AddAction(() =>
            {
                // Load the music
                //int musicId = git.AreaProperties.MusicDay;
                //string musicResource = Resources.Load2DA("ambientmusic")[musicId, "resource"];

                //ambientMusic = Resources.LoadAudio(musicResource);
            });
        }