private void buttonClick() { var asset = Assets.Load <Sprite>(spriteName[index]); // if (!AssetList.Contains(asset)) AssetList.Add(asset); if (asset != null) { Sprite prefab = (Sprite)asset.asset; if (prefab != null) { // Sprite temp = Sprite.Create(prefab, new Rect(0, 0, prefab.width, prefab.height), new Vector2(0, 0)); sprite.sprite = prefab; sprite.SetNativeSize(); // spriteImage = Instantiate(prefab) as Sprite; // testpanel.transform.SetParent(GameObject.Find("Canvas").transform); // ReleaseAssetOnDestroy.Register(p, asset); // GameObject.Destroy(go, 10); } } index++; if (index >= spriteName.Count) { index = 0; } }
public object LoadResource(string name, string extension, System.Type type, out DestroyMethod destroyMethod) { string assetName = uiPath + name + extension; destroyMethod = DestroyMethod.None; string packageName = name.Substring(0, name.LastIndexOf('_')); if (!assets.ContainsKey(packageName)) { Debug.LogError("LoadResource No Package:" + packageName); return(null); } #if UNITY_EDITOR Asset asset = Assets.Load(assetName, type); if (asset != null) { assets[packageName].AddAsset(asset); return(asset.asset); } #else if (Assets.ContainsAsset(assetName)) { Asset asset = Assets.Load(assetName, type); if (asset != null) { assets[packageName].AddAsset(asset); return(asset.asset); } } #endif return(null); }
Character GetCharacter(string character) { if (charactersOnScene.ContainsKey(character)) { return(charactersOnScene[character]); } else { Transform newCharacter = Instantiate(Assets.Load <GameObject>(Assets.CHARACTER, character), charactersContainer).transform; charactersOnScene.Add(character, newCharacter.GetComponent <Character>()); switch (CurrentSpeech.character) { case Assets.CHARACTER_PLAYER: newCharacter.SetPositionAndRotation(playerPosition.position, playerPosition.rotation); newCharacter.localScale = playerPosition.localScale; break; default: newCharacter.SetPositionAndRotation(opponentPosition.position, opponentPosition.rotation); newCharacter.localScale = opponentPosition.localScale; break; } newCharacter.gameObject.SetActive(false); return(charactersOnScene[character]); } }
private void Awake() { TextAsset json = Assets.Load <TextAsset>(Assets.EPISODE_PREVIEW, "Preview"); EpisodePreview preview = EpisodePreview.FromJson(json.text); json = Assets.Load <TextAsset>(Assets.EPISODE, preview.previews[0].assetName); CurrentEpisode = Episode.FromJson(json.text); BranchIndex = 0; SpeechIndex = 0; }
void LoadSyphere() { var asset = Assets.Load <GameObject>(sypherePath); if (asset != null) { var prefab = asset.asset; if (prefab != null) { syphereobj = Instantiate(prefab) as GameObject; ReleaseAssetOnDestroy.Register(syphereobj, asset); // GameObject.Destroy(go, 10); } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); int windowWidth = GraphicsDevice.Viewport.Width; int windowHeight = GraphicsDevice.Viewport.Height; Assets.CreateWhitePixel(graphics.GraphicsDevice, Content); Assets.Load(Content); world.Initialize(this, Content, new Rectangle(0, 0, 2560, 1440), new Rectangle(0, 0, displayWidth, displayHeight), graphics.GraphicsDevice); mouse.Initialize(Content); world.loadContent(); }
void LoadPrefab() { var asset = Assets.Load <GameObject>(assetPath); if (asset != null) { var prefab = asset.asset; if (prefab != null) { testpanel = Instantiate(prefab, GameObject.Find("Canvas").transform) as GameObject; // testpanel.transform.SetParent(GameObject.Find("Canvas").transform); ReleaseAssetOnDestroy.Register(testpanel, asset); // GameObject.Destroy(go, 10); } } }
protected override void LoadContent() { base.LoadContent(); TextureAtlas atlas = new TextureAtlas("shapes", Assets.Load <Texture2D>("shapes")); atlas.CreateRegion("box", 10, 10, 100, 100); Sprite sprite = Assets.Add("PlayerSprite", new Sprite(atlas["box"])); //CurrentWorld = new World(); //CurrentWorld.AddSystems(new RenderSystem()); //CurrentWorld.CreateEntity("Player", new Component[] { new PositionComponent() { }, new RendererComponent() { Sprite = sprite}}); //CurrentWorld = ECS.World.LoadFromFile("testW"); //CurrentWorld.Init(); //CurrentWorld.SaveToFile("testW"); }
private void Init() { Music = new MusicPlayer(); Sounds = new SoundManager(); Assets = new Assets(); Assets.Load(); var vm = new SFML.Window.VideoMode(1000, 750, 32); var style = Styles.Close; var settings = new ContextSettings(0, 0, 8); Window = new SFML.Graphics.RenderWindow(vm, "", style, settings); Window.SetView(View); Window.SetVerticalSyncEnabled(true); Window.Closed += (sender, e) => { IsAppExited = true; }; Window.LostFocus += (sender, e) => { IsPaused = true; }; Window.GainedFocus += (sender, e) => { IsPaused = false; }; Window.SetMouseCursorVisible(true); var splash = new Space("Splash", true); var menu = new Space("Menu"); var inGame = new Space("InGame"); var gameOver = new Space("GameOver"); // ----- ----- ----- Splash ----- ----- ----- var images = new SplashImage[] { new SplashImage(Assets.Textures["sfml"], 3, 1, 1), new SplashImage(Assets.Textures["rsas"], 5, 1, 1) }; SplashImage.Prepare(images, e => { splash.IsActive = false; menu.IsActive = true; }); foreach(var image in images) splash.Add(image); // ----- ----- ----- Menu ----- ----- ----- var btnStart = new MenuButton("Play", 40, new Vector(100, 100)); var btnQuit = new MenuButton("Quit", 40, new Vector(100, 200)); var btnDiffEasy = new MenuButton("Easy", 30, new Vector(250, 100)); var btnDiffMedium = new MenuButton("Medium", 30, new Vector(250, 150)); var btnDiffHard = new MenuButton("Hard", 30, new Vector(250, 200)); var infoText = "- Instructions -\n" + "- Run, shoot and survive as long as possible.\n" + "- Collect white powersups to recover health.\n" + "- New weapons are unlocked after each 1000 kills.\n" + "\n" + "- Use WASD keys to move, and mouse to aim and shoot.\n" + "- Use the numbers keys to change weapons.\n" + "- During gameplay, press ESC to pause or F1 to give up."; var btnInfoText = new MenuButton(infoText, 20, new Vector(450, 125)); var highscoreList = new HighscoreList(new Vector2f(50, 300)); Difficulty = RSaS.Difficulty.Medium; btnDiffMedium.Text.Color = Color.Red; btnStart.Click += e => { if (IsGameOver) { IsGameOver = false; InitInGame(inGame); } Music.Play("music"); menu.IsActive = false; inGame.IsActive = true; IsOSCursorVisible = false; }; btnQuit.Click += e => { IsAppExited = true; }; btnDiffEasy.Click += e => { if (!IsGameOver) return; Difficulty = RSaS.Difficulty.Easy; btnDiffEasy.Text.Color = Color.Red; btnDiffMedium.Text.Color = Color.White; btnDiffHard.Text.Color = Color.White; }; btnDiffMedium.Click += e => { if (!IsGameOver) return; Difficulty = RSaS.Difficulty.Medium; btnDiffEasy.Text.Color = Color.White; btnDiffMedium.Text.Color = Color.Red; btnDiffHard.Text.Color = Color.White; }; btnDiffHard.Click += e => { if (!IsGameOver) return; Difficulty = RSaS.Difficulty.Hard; btnDiffEasy.Text.Color = Color.White; btnDiffMedium.Text.Color = Color.White; btnDiffHard.Text.Color = Color.Red; }; menu.Add(btnStart); menu.Add(btnQuit); menu.Add(btnDiffEasy); menu.Add(btnDiffMedium); menu.Add(btnDiffHard); menu.Add(btnInfoText); menu.Add(highscoreList); }