Пример #1
0
 public TestTileCollisions()
 {
     this.levelScene = (LevelScene)Systems.scene;
     this.roomScene  = (RoomScene)this.levelScene.rooms[0];
     this.character  = Systems.localServer.MyCharacter;
     this.tilemap    = this.roomScene.tilemap;
 }
Пример #2
0
 public Player(LevelScene _levelScene) : base(_levelScene)
 {
     Sprite       = Sprites.GetSprite("spr_player_idle");
     SpriteWidth  = Sprite.Width;
     SpriteHeight = Sprite.Height;
     Origin       = new Vector2(SpriteWidth / 2, SpriteHeight / 2);
     Depth        = .75f;
 }
Пример #3
0
        public async void Start(Canvas Tela)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                //Debug.WriteLine("Criando HuD");
                // Interface
                interfaceManager = new InterfaceManager(Tela);
                //Debug.WriteLine("HuD Criada");

                // Carregando itens
                Encyclopedia.LoadEncyclopedia();
                QuestList.LoadQuests();

                // Criar o scenario e instanciar o player
                scene = new LevelScene(interfaceManager.CanvasChunck01);

                // Banco de dados
                //Debug.WriteLine("Carregando banco de dados");
                QuestList.LoadQuests();
                Encyclopedia.LoadNPC();
                CraftingEncyclopedia.LoadCraftings();
                // Quests
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[1]);
                player._Questmanager.ReceiveNewQuest(QuestList.allquests[2]);
                player._Questmanager.actualQuest = player._Questmanager.allQuests[1];

                // Criando HuD
                interfaceManager.GenerateHUD();

                // Crafting
                CraftingStation = new Crafting();

                player._Inventory.AddToBag(new Slot(2, 90));
                player._Inventory.AddToBag(new Slot(13, 1));
                player._Inventory.AddToBag(new Slot(21, 1));
                player._Inventory.AddToBag(new Slot(22, 1));
                player._Inventory.AddToBag(new Slot(23, 1));
                player._Inventory.AddToBag(new Slot(24, 1));
                player._Inventory.AddToBag(new Slot(18, 2));

                foreach (Mob mob in mobs)
                {
                    mob.Start();
                }
                // Update
                TUpdate = new Task(Update);
                TUpdate.Start();
            });

            // Carrega interface



            // Draw
            //TDraw = new Task(Draw);
            //TDraw.Start();
        }
    void HandlePreviewCamera(GameObject r, LevelScene scene)
    {
        var camera = r.GetComponentInChildren <Camera>();

        if (camera != null)
        {
            scene.previewPosition    = camera.transform.position;
            scene.previewOrientation = camera.transform.rotation;
        }
    }
Пример #5
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        levelScene = target as LevelScene;

        levelScene.Update(ref levelScene.titre, "Titre");
        if (levelScene.titre.Length > 50)
        {
            levelScene.titre = levelScene.titre.Substring(0, 50);
        }
        levelScene.Update(ref levelScene.available, "Available");
    }
Пример #6
0
        private void OnTitleScreenSkipped(object sender, EventArgs e)
        {
            if (!transitionIsActive)
            {
                var titleScreen = sender as TitleScreen;
                titleScreen.SceneSkipped -= OnTitleScreenSkipped;

                var levelScene = new LevelScene();
                levelScene.GameWon  += OnGameWon;
                levelScene.GameOver += OnGameOver;

                StartTransitionToNextScene(levelScene);
            }
        }
    void HandleSun(GameObject r, LevelScene scene)
    {
        var lights = r.GetComponentsInChildren <Light>();

        foreach (var l in lights)
        {
            if (l.type != LightType.Directional)
            {
                continue;
            }

            scene.sunDirection = l.transform.forward;
        }
    }
    protected override IEnumerator LoadScene(LevelScene scene, Action<float, string> progressDelegate)
    {
        /* 
         * Old Chinese trick: When loading scene, some of the components in this scene may not be initialized by unity
         * In this situation, object.GetComponent<>() will not work on some game objects. 
         * That is why we can just skip one frame and let unity finally do it's job.
         */
        yield return null;

        /*
         * When loading scene, make sure LevelRoot knows about what scene it is currently in.
         * Find LevelDescriptor with the corresponding ID and assign it to the CurrentLevel property of the LevelRoot
         */
        scene.LevelRoot.CurrentLevel = LevelManagementService.Levels.FirstOrDefault(level => level.Id == scene.Id);
        yield break;
    }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        GameObject gameManagerObject = GameObject.FindGameObjectWithTag(Tags.GAME_MANAGER);
        if (gameManagerObject == null) {
            gameManagerObject = GameObject.Instantiate(Resources.Load(Prefabs.GAME_MANAGER) as GameObject);
            gameManager = gameManagerObject.GetComponent<GameManager>();
        }
        else {
            //  increment stamina accordingly
            GameObject playerObject = GameObject.FindGameObjectWithTag(Tags.PLAYER);
            Player player = playerObject.GetComponent<Player>();
            player.totalStamina += GameManager.staminaAddition;
            player.stamina = player.totalStamina;
        }

        levelScene = GameObject.FindGameObjectWithTag(Tags.LEVEL_SCENE).GetComponent<LevelScene>();
        levelScene.SpawnDoor(GameManager.day);
    }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        GameObject gameManagerObject = GameObject.FindGameObjectWithTag(Tags.GAME_MANAGER);

        if (gameManagerObject == null)
        {
            gameManagerObject = GameObject.Instantiate(Resources.Load(Prefabs.GAME_MANAGER) as GameObject);
            gameManager       = gameManagerObject.GetComponent <GameManager>();
        }
        else
        {
            //  increment stamina accordingly
            GameObject playerObject = GameObject.FindGameObjectWithTag(Tags.PLAYER);
            Player     player       = playerObject.GetComponent <Player>();
            player.totalStamina += GameManager.staminaAddition;
            player.stamina       = player.totalStamina;
        }

        levelScene = GameObject.FindGameObjectWithTag(Tags.LEVEL_SCENE).GetComponent <LevelScene>();
        levelScene.SpawnDoor(GameManager.day);
    }
 protected override IEnumerator UnloadScene(LevelScene scene, Action<float, string> progressDelegate) {
     yield break;
 }
Пример #12
0
	void Awake()
	{
		Instance = this;
	}
Пример #13
0
        public override void ImGuiLayout()
        {
            //MainTab
            if (ImGui.BeginMainMenuBar())
            {
                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Save"))
                    {
                        _game.Exit();
                    }
                    ImGui.MenuItem("Load");
                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("View"))
                {
                    ImGui.Checkbox("Editor Tile Grid", ref viewTileGrid);
                    ImGui.EndMenu();
                }

                if (RunningGame)
                {
                    if (ImGui.MenuItem("Stop Run"))
                    {
                        RunningGame = false;
                        gameRunner  = null;
                    }
                }
                else if (ImGui.MenuItem("Run"))
                {
                    gameRunner = new GameRunner(_game._graphics, _game.spriteBatch, _game.Content);
                    LevelScene ls = new LevelScene(gameRunner, TileLayers);
                    ls.Backgrounds          = BackgroundList.ToArray();
                    gameRunner.CurrentScene = ls;

                    RunningGame = true;
                }

                ImGui.EndMainMenuBar();
            }

            if (!RunningGame)
            {
                TilePallateWindow();
                //Tile Layers window
                if (ImGui.BeginTabBar("Layers"))
                {
                    TileLayerWindow();
                    BackgroundTab();
                    ImGui.EndTabBar();
                }


                GameWindow();
            }
            else
            {
                ImGui.Begin("GameWindow", ref RunningGame, ImGuiWindowFlags.AlwaysAutoResize);

                ImGui.Image(levelTexture, new Num.Vector2(Screen.GameWidth, Screen.GameHeight) * 3);

                ImGui.End();
            }
        }
Пример #14
0
 public Entity(LevelScene _levelScene)
 {
     levelScene = _levelScene;
 }
Пример #15
0
 public TestCollideDetect()
 {
     this.levelScene = (LevelScene)Systems.scene;
     this.roomScene  = (RoomScene)this.levelScene.rooms[0];
     this.character  = Systems.localServer.MyCharacter;
 }
Пример #16
0
 private void UnregisterLevelSceneHandlers(LevelScene levelScene)
 {
     levelScene.GameWon  -= OnGameWon;
     levelScene.GameOver -= OnGameOver;
 }
Пример #17
0
 public TestPhysicsMovement()
 {
     this.levelScene = (LevelScene)Systems.scene;
     this.roomScene  = (RoomScene)this.levelScene.rooms[0];
     this.character  = Systems.localServer.MyCharacter;
 }
Пример #18
0
    /// <summary>
    /// Creates the actual JamEntry which stores information about the game.
    /// </summary>
    public void DrawJamCreation()
    {
        //Provide Name
        //Provide Creator
        //Provide Scenes
        //Provide Controls
        creatorName = EditorGUILayout.TextField("Name of Team", creatorName);
        entryName   = EditorGUILayout.TextField("Name of Entry", entryName);
        identifier  = EditorGUILayout.TextField("Entry Identifier", identifier);

        DrawDivider();

        #region Scene List
        for (int i = 0; i < scenes.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            scenes[i].scene = EditorGUILayout.ObjectField("Scene [" + i + "]", scenes[i].scene, typeof(Object), false);
            EditorGUILayout.BeginHorizontal();

            GUIStyle style = EditorStyles.miniButtonRight;
            style.fixedWidth = 35;

            if (GUILayout.Button("Remove"))
            {
                scenes.RemoveAt(i);
            }
            if (i > 0)
            {
                if (GUILayout.Button("^", style))
                {
                    LevelScene temp = scenes[i - 1];
                    scenes[i - 1] = scenes[i];
                    scenes[i]     = temp;
                }
            }
            if (i < scenes.Count - 1)
            {
                if (GUILayout.Button("V", style))
                {
                    LevelScene temp = scenes[i + 1];
                    scenes[i + 1] = scenes[i];
                    scenes[i]     = temp;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
        }


        if (scenes.Count < 1 || scenes[scenes.Count - 1] != null)
        {
            spareScene = EditorGUILayout.ObjectField("New Scene", spareScene, typeof(Object), false);

            if (spareScene != null)
            {
                LevelScene scene = new LevelScene();
                scene.scene     = spareScene;
                scene.LevelName = spareScene.name;
                //Debug.Log("Scene.scene: " + scene.scene + "\nScene.LevelName: " + spareScene.name);

                scenes.Add(scene);
                spareScene = null;
            }
        }
        else
        {
        }
        #endregion

        DrawDivider();

        #region Create JamEntry Button
        if (GUILayout.Button("Create JamEntry Resource!"))
        {
            #region Creator Name & Entry Name Field Checking
            bool jamNameValid = false;
            bool creatorValid = false;
            if (creatorName.Length > 0 && creatorName.Length < 50)
            {
                creatorValid = true;
            }
            else
            {
                Debug.LogError("Creator Name is invalid.\nLength is zero or longer than 50 characters.\n");
            }
            if (entryName.Length > 0 && entryName.Length < 50)
            {
                jamNameValid = true;
            }
            else
            {
                Debug.LogError("Jam Entry Name is invalid.\nLength is zero or longer than 50 characters.\n");
            }
            #endregion

            if (jamNameValid && creatorValid)
            {
                CreateJamEntry();
            }
        }
        #endregion
    }
    public void Serialize(ref ByteStream levelBits, GameObject excludeRoot = null)
    {
        // Make sure that we have our map components.
        EnsureMapComponentsLoaded();

        meshManager.Clear();

        var scene = new LevelScene();

        scene.root.name = scene.name = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
        int id = 0;

        int.TryParse(RenderSettings.skybox.name, out id);
        if (id < 5)
        {
            id = 11;
        }
        scene.skyboxId = id;

        // Grab a copy of the world...
        var rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();

        foreach (GameObject r in rootObjects)
        {
            if (r == excludeRoot)
            {
                continue;
            }

            OptimizeLevelGeometry(r);

            HandleSun(r, scene);
            HandlePreviewCamera(r, scene);

            var item = SerializeGameObject(r, true);
            if (item != null)
            {
                scene.root.children.Add(item);
            }
        }

        meshManager.FinalizeProxies();

        // Now generate some static GOs and add to the scene. We generate
        // separate GOs for renderable, collidable or both geometry.
        foreach (var pm in meshManager.Proxies)
        {
            var staticGo = new GameObject();

            staticGo.name = "StaticMesh_" + (pm.material != null ? pm.material.name : "Invisible");

            var mf = staticGo.AddComponent <MeshFilter>();
            mf.sharedMesh = pm.mesh;

            if ((pm.type & ProxyMeshInfo.MeshTypes.IsVisual) != 0)
            {
                var mr = staticGo.AddComponent <MeshRenderer>();
                mr.material = pm.material;

                // Need to actually set these values to get lightmapping...
                mr.lightmapIndex       = 0;
                mr.lightmapScaleOffset = new Vector4(1, 1, 0, 0);

                staticGo.name += "_R";
            }

            if ((pm.type & ProxyMeshInfo.MeshTypes.IsCollider) != 0)
            {
                staticGo.AddComponent <MeshCollider>();

                staticGo.name += "_MC";
            }

            var levelRoot = SerializeGameObject(staticGo);
            if (levelRoot != null)
            {
                scene.root.children.Add(levelRoot);
            }

            levelRoot.mesh.Flags |= LevelMesh.MeshFlags.IsStatic;

            GameObject.DestroyImmediate(staticGo);
        }

        // Do final propagation of max vertex counts.
        foreach (var c in scene.root.children)
        {
            if (c.LargestChildVertexCount > scene.root.LargestChildVertexCount)
            {
                scene.root.LargestChildVertexCount = c.LargestChildVertexCount;
            }
        }

        // Actually write to stream.
        Profiler.BeginSample("Serialize");

        var sh = new SerializerHelper();

        sh.Stream = new ByteStream();

        // Write header info - Marble it Up Level v5
        // v1 - initial format
        // v2 - added lightmaps
        // v3 - added level timing
        // v4 - added map hash
        // v5 - added map author
        sh.Stream.WriteByte((byte)'m');
        sh.Stream.WriteByte((byte)'u');
        sh.Stream.WriteByte((byte)'l');
        sh.Stream.WriteByte((byte)'6');

        if (GameObject.Find("StartPad") == null)
        {
            sh.Stream.WriteByte((byte)'M'); // Multiplayer
            sh.Stream.WriteByte((byte)'1'); // TODO - Encode MP Mode support
        }
        else
        {
            sh.Stream.WriteByte((byte)'S'); // Singleplayer
            sh.Stream.WriteByte((byte)'0'); // Unused MP Mode support
        }

        float       silver = 45, gold = 20, diamond = 15;
        LevelTiming lt = GameObject.FindObjectOfType <LevelTiming>();

        if (lt != null)
        {
            silver  = (float)(Math.Truncate(100 * lt.SilverTime) / 100f);
            gold    = (float)(Math.Truncate(100 * lt.GoldTime) / 100f);
            diamond = (float)(Math.Truncate(100 * lt.DiamondTime) / 100f);
        }
        sh.Stream.WriteSingle(silver);
        sh.Stream.WriteSingle(gold);
        sh.Stream.WriteSingle(diamond);

        string author = "";

        if (lt != null)
        {
            author = lt.Author;
        }
        sh.Stream.WriteString(author);

        PlayModifiers phym       = GameObject.FindObjectOfType <PlayModifiers>();
        string        physParams = "";

        if (phym != null)
        {
            physParams = phym.ToJSON();
        }
        sh.Stream.WriteString(physParams);

        var hashStream = new SerializerHelper();

        hashStream.Write(scene);
        string hash = "000-" + UnityEngine.Random.Range(0, int.MaxValue);

        using (System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
        {
            hash = Convert.ToBase64String(sha1.ComputeHash(hashStream.Stream.Buffer));
        }
        sh.Stream.WriteString(hash);

        // And write the scene.
        sh.Write(scene);

        // Also, write the lightmaps.
        SerializeLightmaps(ref sh);

        levelBits = sh.Stream;

        // If you want to enable compression of level files, this is
        // where to do it.
        //levelBits.Buffer = SerializerHelper.Compress(levelBits.Buffer);

        levelSize = levelBits.Position / 1024;
        Debug.Log("Serialized level, length = " + levelSize + "kb");

        Profiler.EndSample();
    }
Пример #20
0
 public void SetMap(LevelScene map)
 {
     mapTarget    = map;
     image.sprite = map.sprite;
 }
 public void SetLevel(LevelScene pLevel)
 {
     level = pLevel;
 }