private void putInFolderInThread(UnityGoogleDrive.Data.File file) { GoogleDriveFiles.CreateRequest request; PhotoSession.PhotoFolder folder = instance.getFolder(instance.folderNameGlobal, instance.folderDateGlobal); string p = Path.Combine(datapath, folder.folderName + "_" + folder.data + "_" + folder.modelid + "_" + folder.userid); foreach (var link in folder.files) { string path = Path.Combine(p, link.name); Sprite sprite = SpriteLoader.GetSpriteFromFileWithCompression(path); var filen = new UnityGoogleDrive.Data.File() { Name = GenerateName() + GetId(link.id + 1), Content = sprite.texture.EncodeToPNG(), Parents = new List <string> { file.Id } }; request = GoogleDriveFiles.Create(filen); request.Fields = new List <string> { "id", "name", "size", "createdTime" }; request.Send().OnDone += instance.PrintResult; } instance.folderNameGlobal = ""; }
public static JobComponent ScheduleJobControllerInWorld( WorldComponent worldComponent, Job job) { GameObject entityObject = new GameObject(); JobComponent entityComponent = entityObject.AddComponent <JobComponent>(); entityObject.transform.SetParent(worldComponent.transform); IndicatorBar bar = IndicatorBar.Instantiate(entityObject); bar.GetSizeCallback = new IndicatorBar.GetSize( () => { return(job.CurrentStage().CurrentProgress()); } ); entityObject.name = job.id + "_indicator"; entityComponent.job = job; PolygonCollider2D collider = entityObject.AddComponent <PolygonCollider2D>(); collider.points = new Vector2[] { new Vector2(-0.5f, -0.5f), new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f) }; entityComponent.spriteRenderer = entityObject.AddComponent <SpriteRenderer>(); entityComponent.spriteRenderer.sprite = SpriteLoader.GetSprite("test"); return(entityComponent); }
public SpriteLoader(string spritesFolder) { if (Instance == null) { Instance = this; } else { Debug.LogError("Only one instance of 'SpriteUtilities' is allowed."); } try { DirectoryInfo dir = new DirectoryInfo(Path.Combine(Application.streamingAssetsPath, spritesFolder)); FileInfo[] fileInfo = dir.GetFiles("*.png"); foreach (FileInfo file in fileInfo) { loadSpriteSheet(file); } } catch (DirectoryNotFoundException) { Debug.LogError("Invalid sprites directory, no Sprite loaded."); } buildPlaceholderSprite(); }
public void Init() { Gallery.SetActive(true); SwitchCallButtons(UnityVideo.success); nameText.text = HomePageControll.MODEL.name; carnumberText.text = VideoCallPhotoManager.FolderDate; orderNumber.text = VideoCallPhotoManager.FolderName; Transform element; Dictionary <string, Sprite> dict = VideoCallPhotoManager.GetPhotoSprites(); foreach (var link in dict) { element = Instantiate(galleryElement.transform, new Vector3(0, 0, 0), Quaternion.identity); element.SetParent(container.transform); element.localScale = new Vector3(1, 1, 1); //element.gameObject.GetComponent<GalleryElement>().SetSprite = link.Value; element.gameObject.GetComponent <GalleryElement>().SetMiniSprite = SpriteLoader.GetSpriteFromFile(link.Key + "mini"); element.gameObject.GetComponent <GalleryElement>().Link = link.Key; element.gameObject.SetActive(true); elements.Add(element); } element = Instantiate(galleryElement.transform, new Vector3(0, 0, 0), Quaternion.identity); element.SetParent(container.transform); element.localScale = new Vector3(1, 1, 1); element.gameObject.SetActive(true); nullObject = element.gameObject; elements.Add(element); }
public IReadOnlyList <IModel> Load(string name, IFileSystem fileSystem, Scene scene, BinaryReader reader, bool computeCRC) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } //Check if we can actually load this if (!SpriteLoader.IsSpriteFile(reader)) { return(null); } var loader = new SpriteLoader(reader); var spriteFile = loader.ReadSpriteFile(); uint crc = 0; if (computeCRC) { crc = loader.ComputeCRC(); } var model = new SpriteModel(name, crc, spriteFile); if (scene != null) { model.ResourceContainer = new SpriteModelResourceContainer(scene, model); scene.AddContainer(model.ResourceContainer); } return(new[] { model }); }
/* * Loads the sprite data and index files from the cache location. * This can be edited to use an archive such as config or media to load from the cache. * * @param archive */ public static void loadSprites(StreamLoader streamLoader) { //try { RS2Sharp.Stream index = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.idx")); RS2Sharp.Stream data = new RS2Sharp.Stream(UnityClient.ReadAllBytes(signlink.findcachedir() + "sprites.dat")); DataInputStream indexFile = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(index.buffer), Ionic.Zlib.CompressionMode.Decompress)); DataInputStream dataFile = new DataInputStream(new Ionic.Zlib.GZipStream(new MemoryStream(data.buffer), Ionic.Zlib.CompressionMode.Decompress)); int totalSprites = indexFile.ReadInt(); UnityEngine.Debug.Log("Sprites loaded: " + totalSprites); if (cache == null) { cache = new SpriteLoader[totalSprites]; sprites = new Sprite[totalSprites]; } for (int i = 0; i < totalSprites; i++) { int id = indexFile.ReadInt(); if (cache[id] == null) { cache[id] = new SpriteLoader(); } cache[id].readValues(indexFile, dataFile); createSprite(cache[id]); } //indexFile.Close(); //dataFile.Close(); //} catch (Exception e) { // e.printStackTrace(); //} }
public EditForm(SpriteLoader spriteLoader) { InitializeComponent(); this.sprLoader = spriteLoader; switch (spriteLoader.SpriteHeader.Type) { case SprType.VP_PARALLEL_UPRIGHT: radioButton1.Checked = true; break; case SprType.FACING_UPRIGHT: radioButton2.Checked = true; break; case SprType.VP_PARALLEL: radioButton3.Checked = true; break; case SprType.ORIENTED: radioButton4.Checked = true; break; case SprType.VP_PARALLEL_ORIENTED: radioButton5.Checked = true; break; default: radioButton1.Checked = true; break; } }
private IEnumerator LateSaveCapturedPhoto(string photoPath) { yield return(null); Debug.Log("CaptureDeviceCamHandle on path: " + photoPath); byte[] bytes = File.ReadAllBytes(photoPath); File.Delete(photoPath); Sprite photoSprite = SpriteLoader.GetSpriteFromBytes(bytes); if (photoSprite == null) { Debug.LogError("CaptureDeviceCam complete, but sprite is null in path:\n" + photoPath); yield break; } Sprite rotatedSprite = TextureRotator.RotateSprite(photoSprite); bytes = rotatedSprite.texture.EncodeToJPG(); string photoName = "Vsm-Appraiser-devicePhoto-" + DateStringConverter.GetMDHMSMDate() + ".jpg"; photoPath = Path.Combine(GlobalSettings.cloudStorageUploadPath, photoName); File.WriteAllBytes(photoPath, bytes); Debug.Log("CaptureDeviceCamHandle replaced by new path " + photoPath); //CardAdditionalScreen.DeviceCameraCaptureHandle(photoPath, rotatedSprite); }
public IModel Load(string name, IFileSystem fileSystem, BinaryReader reader, Delegates.AddModel addModelCallback, bool computeCRC) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } //Check if we can actually load this if (!SpriteLoader.IsSpriteFile(reader)) { return(null); } var loader = new SpriteLoader(reader); var spriteFile = loader.ReadSpriteFile(); uint crc = 0; if (computeCRC) { crc = loader.ComputeCRC(); } return(new SpriteModel(name, crc, spriteFile)); }
public async override Task Load(ResourcePool pool, CancellationToken token) { buffer = await pool.GetBuffer(); var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, buffer); tileSet.LoadTileMap(loader, mapIndices, depth); sprites = loader.Load(); }
void Start() { InventoryController = GameObject.Find("---InventoryController"); TouchController = GameObject.Find("---TouchController").GetComponent <TouchController>(); AllMachines = GameObject.Find("---ClothInMachineController").GetComponent <AllMachines>(); FinalCameraController = GameObject.Find("Main Camera").GetComponent <FinalCameraController>(); SubwayMovement = GameObject.Find("---StationController").GetComponent <SubwayMovement>(); LostAndFound = GameObject.Find("Lost&Found_basket").GetComponent <LostAndFound>(); SpriteLoader = GameObject.Find("---SpriteLoader").GetComponent <SpriteLoader>(); AdsController = GameObject.Find("---AdsController").GetComponent <AdsController>(); InventorySlotMgt = GameObject.Find("---InventoryController").GetComponent <InventorySlotMgt>(); //AudioManager = GameObject.Find("---AudioManager").GetComponent<AudioManager>(); LevelManager = FinalCameraController.LevelManager; startPos = transform.position; // selfButton.onClick.AddListener(AddClothToInventory); //currentSprite = GetComponent<SpriteRenderer>().sprite; myImage = GetComponent <Image>(); startSprite = GetComponent <Image>().sprite; if (!FinalCameraController.isTutorial) { returnConfirmButton.gameObject.SetActive(false); } }
public void onSelectedBodyChanged(int idx) { if (government != null) { for (int i = 0; i < buttons.Count; i++) { Destroy(buttons[i]); buttons[i] = null; } buttons.Clear(); selectedBody = government.bodies[idx]; foreach (Power pow in government.powers) { foreach (Stage stage in pow.stages) { if (stage.requiredBodies.Contains(selectedBody.id)) { GameObject go = Instantiate(templateButton); //go.GetComponentInChildren<Text>().text = stage.id; go.SetActive(true); go.transform.SetParent(buttonPanel.transform); buttons.Add(go); go.GetComponent <Button>().image.sprite = SpriteLoader.getSprite(stage.icon); go.GetComponent <Tooltip>().title = pow.name + "_" + stage.name; string tooltip = stage.requirementType == Stage.RequirementType.All ? "Require all of:\n" : "Requires any of:\n"; foreach (string body in stage.requiredBodies) { tooltip += "\t" + body + "\n"; } go.GetComponent <Tooltip>().text = tooltip; go.GetComponent <Button>().onClick.AddListener( () => { GameObject window = WindowManager.openEmptyWindow("add_law"); WindowWidget wid = window.GetComponent <WindowWidget>(); if (wid == null) { Debug.LogError("Failure!"); } else { //wid.minimumSize = new Size2(200, 400); wid.content.AddComponent <AddLawWidget>(); wid.GetComponent <ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.Unconstrained; wid.minimumSize = new Size2(400, 100); wid.resizePanel.maxSize = new Vector2(2000, 400); } //window.GetComponent<WindowWidget>().setContent(content); //GameObject go = new GameObject(); //go.AddComponent<DynamicWindow>(); } ); } } } } }
private void Awake() { spriteLoader = this.gameObject.GetComponent <SpriteLoader>(); // Get button components from canvas filterPanel = canvasOperation[0].transform.Find("Filter_Panel").GetComponent <Image>(); fmPanelIn = canvasInOut[0].transform.Find("FM_Panel").GetComponent <Image>(); fmPanelOut = canvasInOut[1].transform.Find("FM_Panel").GetComponent <Image>(); // change the parameter to true if buttons are inactive on start filterBtns = filterPanel.GetComponentsInChildren <Button>(true); fmBtnsIn = fmPanelIn.GetComponentsInChildren <Button>(true); fmBtnsOut = fmPanelOut.GetComponentsInChildren <Button>(true); layerBtns = new Button[layerObjs.Length]; layers = new Layer[layerBtns.Length]; // get buttons from layer gameobjects for (int i = 0; i < layerObjs.Length; i++) { layerBtns[i] = layerObjs[i].GetComponentInChildren <Button>(); } // reference layer scripts in Array for (int i = 0; i < layerBtns.Length; i++) { layers[i] = layerBtns[i].GetComponent <Layer>(); } }
/***************** * Public methods *****************/ /// <summary> /// Entry for this mod. /// </summary> /// <param name="helper">Helper.</param> public override void Entry(IModHelper helper) { Util.Init(Helper, Monitor); Config = Helper.ReadConfig <QualityProductsConfig>(); if (Config.IsAnythingEnabled()) { if (Config.IsCookingEnabled()) { Helper.Events.Display.MenuChanged += OnCrafting; } Helper.Events.GameLoop.Saved += OnSaved; Helper.Events.GameLoop.Saving += OnSaving; Helper.Events.GameLoop.SaveLoaded += OnSaveLoaded; Helper.Events.World.LocationListChanged += OnLoadLocation; Helper.Events.World.ObjectListChanged += OnPlacingProcessor; if (Config.EnableMeadTextures && SpriteLoader.Init(Helper, Monitor, Config)) { PatchManager.ApplyAll( typeof(SObjectDrawPatch), typeof(SObjectDraw2Patch), typeof(SObjectDrawInMenuPatch), typeof(SObjectDrawWhenHeld), typeof(FurnitureDrawPatch) ); } } }
// Use this for initialization void Start() { State = TurnState.Draw; m_CurrentPlayer = 0; DiceObject diceObject = Resources.Load <DiceObject>("Prefabs/Dice"); List <DiceObject> dice = new List <DiceObject>(); SpriteLoader.Load(); DiceFaceLoader.Load(); DiceFace[] faces = new DiceFace[6]; for (int i = 1; i < 7; i++) { faces[i - 1] = DiceFaceLoader.Get("DebugCat-" + i); //new PlayFace(i, i, i, FaceType.Play, Color.black, Color.cyan, "DEFAULT-" + i, MaterialLoader.Get("DebugCat")); DiceFaceLoader.Serialise(faces[i - 1]); } for (int i = 0; i < 18; i++) { DiceObject instance = GameObject.Instantiate <DiceObject>(diceObject); instance.SetFaces(faces); instance.transform.position = new Vector3(-10.0f, 2.0f, -10.0f); instance.GetComponent <Rigidbody>().isKinematic = true; dice.Add(instance); } m_Players = new List <BasePlayer>(); CreatePlayer(dice, typeof(ControllingPlayer)); }
private void MoveFileToFolder(string screenshotName) { if (string.IsNullOrEmpty(VideoCallPhotoManager.FolderDate)) { VideoCallPhotoManager.FolderDate = System.DateTime.Now.Year.ToString() + "-" + System.DateTime.Now.Month.ToString() + "-" + System.DateTime.Now.Day.ToString() + "_" + System.DateTime.Now.Hour + "-" + System.DateTime.Now.Minute + "-" + System.DateTime.Now.Second; } string oldPathToFile = photoNames[photoNames.Count - 1]; string newPathToFile = Path.Combine(Application.persistentDataPath, PhotoChecking.GetInstance.GetFolderName); if (!GlobalParameters.isSameSession) { Directory.CreateDirectory(newPathToFile); } SavePhotoSessionController.AddFile(FolderName, screenshotName); SavePhotoSessionController.Sawe(); try { File.Move(oldPathToFile, Path.Combine(newPathToFile, screenshotName)); Debug.Log("agora_: " + screenshotName + " move To: " + newPathToFile); photoNames[photoNames.Count - 1] = newPathToFile; photoSprites.Add(Path.Combine(newPathToFile, screenshotName), null); }catch (IOException e) { Debug.Log("File did not saved: " + e); Debug.Log(newPathToFile); return; } SpriteLoader.SaweSpriteMini(Path.Combine(newPathToFile, screenshotName)); }
public static Species GetSpecies(string name = "") { GradientColorKey[] colorKeys = new GradientColorKey[3]; float position = 0.0f; for (int i = 0; i < 3; i++) { colorKeys[i] = new GradientColorKey(Constants.GetRandomPastelColor(), position); position += 0.50f; } GradientAlphaKey[] alphaKeys = new GradientAlphaKey[2] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) }; Gradient g = new Gradient(); g.alphaKeys = alphaKeys; g.colorKeys = colorKeys; Sprite[] sprites = SpriteLoader.GetRandomSetOfAlienSprites().ToArray(); if (name == "") { name = MarkovGenerator.GenerateMarkovWord(StringLoader.GetAllStrings("SpeciesButterfly"), 1)[0]; } return(new Species(name, sprites, g)); }
public static void Initialize(ContentManager inputContent) { content = inputContent; SpriteLoader spritesLoading = new SpriteLoader(); spritesInfo = spritesLoading.SpritesInfo(); }
public void SetupCanvasIcon() { Vector2 anchor = new Vector2(x, y); GameObject canvasSprite = CanvasUtil.CreateImagePanel ( _canvas, SpriteLoader.GetSprite(spriteName), new CanvasUtil.RectData(Vector2.zero, Vector2.zero, anchor, anchor + new Vector2(1f / 15f, 0.1f)) ); // Add a canvas group so we can fade it in and out canvasGroup = canvasSprite.AddComponent <CanvasGroup>(); canvasGroup.blocksRaycasts = false; canvasGroup.interactable = false; if (!BingoUI.globalSettings.alwaysDisplay) { canvasGroup.gameObject.SetActive(false); } GameObject text = CanvasUtil.CreateTextPanel ( canvasSprite, "0", 23, TextAnchor.LowerCenter, new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one) ); textPanel = text.GetComponent <Text>(); textPanel.color = Color.black; }
public CursorSequence(SpriteLoader loader, string cursorSrc, string palette, MiniYaml info) { sprites = loader.LoadAllSprites(cursorSrc); var d = info.ToDictionary(); start = Exts.ParseIntegerInvariant(d["start"].Value); this.palette = palette; if ((d.ContainsKey("length") && d["length"].Value == "*") || (d.ContainsKey("end") && d["end"].Value == "*")) { length = sprites.Length - start; } else if (d.ContainsKey("length")) { length = Exts.ParseIntegerInvariant(d["length"].Value); } else if (d.ContainsKey("end")) { length = Exts.ParseIntegerInvariant(d["end"].Value) - start; } else { length = 1; } if (d.ContainsKey("x")) { Exts.TryParseIntegerInvariant(d["x"].Value, out Hotspot.X); } if (d.ContainsKey("y")) { Exts.TryParseIntegerInvariant(d["y"].Value, out Hotspot.Y); } }
private void CreateUpperPanel() { upperPanelObject = new GameObject("Upper Panel", typeof(UnityEngine.UI.Image)); upperPanelObject.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width, Relative.UPPER_PANEL_HEIGTH); upperPanelObject.transform.position = new Vector2(Screen.width / 2f, Screen.height - Relative.UPPER_PANEL_HEIGTH / 2f); upperPanelObject.GetComponent <UnityEngine.UI.Image>().color = Color.black; upperPanelObject.transform.SetParent(infoObject.transform); backArrowImage = new Image.Builder() .SetName(Names.BACK_ARROW_ICON_NAME) .AddOnClickListener(History.GoBack) .SetImage(SpriteLoader.LoadSprite("back_arrow_ico")) .SetParent(upperPanelObject.transform) .SetSize(size: Vector2.one * Relative.BUTTON_HEIGHT, additionalClickableArea: 2f) .SetPosition(new Vector2(Relative.BUTTON_MARGIN + Relative.BUTTON_HEIGHT / 2f, Screen.height - Relative.BUTTON_MARGIN - Relative.BUTTON_HEIGHT / 2f)) .SetRotationPoint(UI.RotationPoint.Center) .build(); GameObject upperPanelText = new GameObject("Text", typeof(Text)); upperPanelText.transform.SetParent(upperPanelObject.transform); upperPanelText.GetComponent <RectTransform>().sizeDelta = new Vector2(Screen.width - 4 * Relative.BUTTON_MARGIN - Relative.BUTTON_HEIGHT / 2f, Relative.UPPER_PANEL_HEIGTH); upperPanelText.GetComponent <RectTransform>().position = new Vector2(Screen.width / 2f + 2 * Relative.BUTTON_MARGIN + Relative.BUTTON_HEIGHT / 4f, Screen.height - Relative.UPPER_PANEL_HEIGTH / 2f); upperPanelText.GetComponent <Text>().font = Resources.Load <Font>("fonts/Roboto-Regular"); upperPanelText.GetComponent <Text>().fontSize = Relative.SMALL_FONT_SIZE; upperPanelText.GetComponent <Text>().alignment = TextAnchor.MiddleLeft; upperPanelText.GetComponent <Text>().color = Color.white; upperPanelText.GetComponent <Text>().text = LocalizationManager.Instance.GetLocalizedValue("rock_fortress_city_tustan"); upperPanelObject.SetActive(false); scrollablePanelObject.GetComponent <ScrollRect>().onValueChanged.AddListener( (Vector2 value) => upperPanelObject.SetActive(value.y < textContentToAllRatio) ); }
public void CreateWorld(MapDescriptor descriptor, MapController map, PortalController portals, CameraController camera, Transform parent) { GameObject[, ][] worldTemplate = descriptor.Map; for (int x = 0; x < worldTemplate.GetLength(0); x++) { for (int y = 0; y < worldTemplate.GetLength(1); y++) { foreach (GameObject mapObj in worldTemplate[x, y]) { MapObjectBehaviour behaviour = Object.Instantiate(mapObj, new Vector3(x, y), Quaternion.identity).GetComponent <MapObjectBehaviour>(); behaviour.gameObject.SetActive(true); behaviour.transform.SetParent(parent); behaviour.AssignDescriptor(mapObj.GetComponent <MapObjectBehaviour>().CopyDescriptor()); behaviour.Initialize(); if (isPlayer(behaviour)) { handleSetupPlayer(behaviour, map); } if (isPortal(behaviour)) { handleSetupPortal(behaviour, portals); } } } } Sprite background = new SpriteLoader().Load(descriptor.BackgroundSprite); camera.SetBackground(background); }
private SpawnPattern InterperetPattern(JToken obj) { if (obj.Type == JTokenType.String) { return(presets[obj.ToString()]); } switch (obj["type"].ToString()) { case "spiral": return(new SpiralPattern(BulletManager.Instance.EnemyBullets, SpriteLoader.LoadSprite("redBullet"), obj["speed"].ToObject <float>(), obj["amount"].ToObject <int>(), obj["interval"].ToObject <double>(), obj["rotations"].ToObject <int>(), obj["distance"].ToObject <int>())); case "linear": return(new LinearPattern(BulletManager.Instance.EnemyBullets, SpriteLoader.LoadSprite("redBullet"), obj["speed"].ToObject <float>(), obj["amount"].ToObject <int>(), obj["interval"].ToObject <double>())); case "surround": return(new SurroundPattern(BulletManager.Instance.EnemyBullets, SpriteLoader.LoadSprite("redBullet"), obj["speed"].ToObject <float>(), obj["amount"].ToObject <int>(), obj["interval"].ToObject <float>(), obj["fireCount"].ToObject <int>())); case "rotate": return(new RotateScreenPattern(obj["rotationSpeed"].ToObject <float>(), obj["pauseDelay"].ToObject <float>())); case "flipX": return(new FlipXScreenPattern(obj["rotationSpeed"].ToObject <float>(), obj["pauseDelay"].ToObject <float>())); case "flipY": return(new HorizontalRotationPattern(obj["rotationSpeed"].ToObject <float>(), obj["pauseDelay"].ToObject <float>())); case "none": return(new NoShootPattern(BulletManager.Instance.EnemyBullets, obj["time"].ToObject <double>())); } return(null); }
public static TestBackground Instantiate() { // Create GameObject GameObject obj = new GameObject(); obj.name = NAME; obj.tag = Tags.UNTAGGED; // Add TestBackground Component TestBackground beatsObj = obj.AddComponent <TestBackground>(); // Create SpriteData Texture2D texture = SpriteLoader.GetTexture(Sprites.SANDBOX_BACKGROUND); if (Screens.width / texture.width > Screens.height / texture.height) { beatsObj._data = new SpriteFlatData(NAME, texture, Screens.width, 0f, ScaleType.SCALED_WIDTH); } else { beatsObj._data = new SpriteFlatData(NAME, texture, 0f, Screens.height, ScaleType.SCALED_HEIGHT); } // Add Sprite Component SpriteFlat sprite = obj.AddComponent <SpriteFlat>(); sprite.Setup(beatsObj._data); beatsObj._sprite = sprite; // Return instantiated BeatsObject return(beatsObj); }
void Awake() { instance = this; tileUVMap = new Dictionary <string, Vector2[]>(); Sprite[] sprites = Resources.LoadAll <Sprite>("New Sprites"); float imageWidth = 0f; float imageHeight = 0f; foreach (Sprite sprite in sprites) { if (sprite.rect.x + sprite.rect.width > imageWidth) { imageWidth = sprite.rect.x + sprite.rect.width; } if (sprite.rect.y + sprite.rect.height > imageHeight) { imageHeight = sprite.rect.y + sprite.rect.height; } } foreach (Sprite sprite in sprites) { Vector2[] uvs = new Vector2[4]; uvs[0] = new Vector2(sprite.rect.x / imageWidth, sprite.rect.y / imageHeight); uvs[1] = new Vector2((sprite.rect.x + sprite.rect.width) / imageWidth, sprite.rect.y / imageHeight); uvs[2] = new Vector2(sprite.rect.x / imageWidth, (sprite.rect.y + sprite.rect.height) / imageHeight); uvs[3] = new Vector2((sprite.rect.x + sprite.rect.width) / imageWidth, (sprite.rect.y + sprite.rect.height) / imageHeight); tileUVMap.Add(sprite.name, uvs); } }
public GalaxyFeature(string _name, GalaxyFeatureType _featureType, Color _iconColor) { name = _name; featureType = _featureType; iconColor = new Color(_iconColor.r * 0.5f, _iconColor.g * 0.5f, _iconColor.b * 0.5f); icon = SpriteLoader.GetFeatureSprite(featureType.ToString()); }
/// <summary> /// Resets values. /// </summary> public static void ResetValues() { DebugEx.Verbose("Assets.Common.DockWidgets.Textures.ResetValues()"); tab = new SpriteLoader("Common/Textures/UI/DockWidgets/Tab"); tabDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/TabDisabled"); tabHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/TabHighlighted"); tabPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/TabPressed"); tabActive = new SpriteLoader("Common/Textures/UI/DockWidgets/TabActive"); tabActiveDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/TabActiveDisabled"); tabActiveHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/TabActiveHighlighted"); tabActivePressed = new SpriteLoader("Common/Textures/UI/DockWidgets/TabActivePressed"); icon = new SpriteLoader("Common/Textures/UI/DockWidgets/Icon"); pageBackground = new SpriteLoader("Common/Textures/UI/DockWidgets/PageBackground"); maximizeButton = new SpriteLoader("Common/Textures/UI/DockWidgets/MaximizeButton"); maximizeButtonDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/MaximizeButtonDisabled"); maximizeButtonHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/MaximizeButtonHighlighted"); maximizeButtonPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/MaximizeButtonPressed"); closeButton = new SpriteLoader("Common/Textures/UI/DockWidgets/CloseButton"); closeButtonDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/CloseButtonDisabled"); closeButtonHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/CloseButtonHighlighted"); closeButtonPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/CloseButtonPressed"); unlockedButton = new SpriteLoader("Common/Textures/UI/DockWidgets/UnlockedButton"); unlockedButtonDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/UnlockedButtonDisabled"); unlockedButtonHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/UnlockedButtonHighlighted"); unlockedButtonPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/UnlockedButtonPressed"); lockedButton = new SpriteLoader("Common/Textures/UI/DockWidgets/LockedButton"); lockedButtonDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/LockedButtonDisabled"); lockedButtonHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/LockedButtonHighlighted"); lockedButtonPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/LockedButtonPressed"); contextMenuButton = new SpriteLoader("Common/Textures/UI/DockWidgets/ContextMenuButton"); contextMenuButtonDisabled = new SpriteLoader("Common/Textures/UI/DockWidgets/ContextMenuButtonDisabled"); contextMenuButtonHighlighted = new SpriteLoader("Common/Textures/UI/DockWidgets/ContextMenuButtonHighlighted"); contextMenuButtonPressed = new SpriteLoader("Common/Textures/UI/DockWidgets/ContextMenuButtonPressed"); }
public EditForm(SpriteLoader spriteLoader) { InitializeComponent(); sprLoader = spriteLoader; switch (spriteLoader.SpriteHeader.Type) { case SprType.VP_PARALLEL_UPRIGHT: radioParallelUpright.Checked = true; break; case SprType.FACING_UPRIGHT: radioFacingUpright.Checked = true; break; case SprType.VP_PARALLEL: radioParallel.Checked = true; break; case SprType.ORIENTED: radioOriented.Checked = true; break; case SprType.VP_PARALLEL_ORIENTED: radioParallelOriented.Checked = true; break; default: radioParallelUpright.Checked = true; break; } }
public Map PrepareMap(string uid) { LoadScreen.Display(); if (!AvailableMaps.ContainsKey(uid)) { throw new InvalidDataException("Invalid map uid: {0}".F(uid)); } var map = new Map(AvailableMaps[uid].Path); // Reinit all our assets LoadInitialAssets(); foreach (var pkg in Manifest.Packages) { FileSystem.Mount(pkg); } // Mount map package so custom assets can be used. TODO: check priority. FileSystem.Mount(FileSystem.OpenPackage(map.Path, int.MaxValue)); Rules.LoadRules(Manifest, map); SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder); SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); return(map); }
private void CaptureWebCamHandle(string pathToPhoto) { if (string.IsNullOrEmpty(pathToPhoto)) { Debug.Log("agora_: CaptureWebCamHandle has empty path!"); return; } Debug.Log("agora_:CaptureWebCamHandle on path: " + pathToPhoto); Sprite photoSprite = SpriteLoader.GetSpriteFromFile(pathToPhoto); if (photoSprite == null) { Debug.LogError("agora_: CaptureWebCam complete, but sprite is null in path:\n" + pathToPhoto); return; } photoImage.sprite = photoSprite; rephotoButtonObj.SetActive(true); photoImageObj.SetActive(true); webCamImageObj.SetActive(false); //CardAdditionalScreen.WebCamCaptureHandle(pathToPhoto, photoSprite); }
public Map PrepareMap(string uid) { LoadScreen.Display(); if (!AvailableMaps.ContainsKey(uid)) { throw new InvalidDataException("Invalid map uid: {0}".F(uid)); } var map = new Map(AvailableMaps[uid].Path); LoadTranslations(map); // Reinit all our assets InitializeLoaders(); FileSystem.LoadFromManifest(Manifest); // Mount map package so custom assets can be used. TODO: check priority. FileSystem.Mount(FileSystem.OpenPackage(map.Path, null, int.MaxValue)); Rules.LoadRules(Manifest, map); SpriteLoader = new SpriteLoader(Rules.TileSets[map.Tileset].Extensions, SheetBuilder); // TODO: Don't load the sequences for assets that are not used in this tileset. Maybe use the existing EditorTilesetFilters. SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequences); return(map); }
public void LoadTileMap(SpriteLoader loader, Point[,] mapIndices, int depth) { for (int i = 0; i < mapIndices.GetLength(0); ++i) { for (int j = 0; i < mapIndices.GetLength(1); ++j) { Point tileCoord = mapIndices[i, j]; loader.AddSprite( Texture, new Vector2(i * TileWidth, j * TileHeight), new Rectangle(tileCoord.X * TileWidth, tileCoord.Y * TileHeight, TileWidth, TileHeight), depth); } } }
//see Triangle2DDrawTest for a general tutorial of the resource loading pattern public override void OnLoad(GameState state) { base.OnLoad(state); var tex = Texture.Allocate(); tex.LoadImageFile("assets/sprite-example.png"); var loader = new SpriteLoader(BufferUsageHint.DynamicDraw, VertexBuffer.Allocate()); //TODO: test depth sorting loader.AddSprite( tex, new Vector2(0, 0), //sprite position (top-left corner) new Rectangle(0, 0, 48, 21) //source rectangle in sprite sheet ); sprites = new DrawableSet(loader.Load()); }
protected Dictionary<string, Sprite> m_pSpriteDict = new Dictionary<string, Sprite>(); // 记录所有Sprite的字典 // 显示加载完毕,通知回调函数 public void AddSpriteByLoader(SpriteLoader pLoader) { foreach (Sprite sp in pLoader.LoadedSprite) { AddSprite(sp); } /* m_pLoadedResList.Add(pLoader); if (pLoader.bNeedDestory) { m_pClearList.Add(pLoader.name); } */ //CRuntimeLogger.LogWarning(string.Format("yzlTest UIResLoaded Done {0}", pLoader.name)); }
public CursorSequence(SpriteLoader loader, string cursorSrc, string palette, MiniYaml info) { sprites = loader.LoadAllSprites(cursorSrc); var d = info.ToDictionary(); start = Exts.ParseIntegerInvariant(d["start"].Value); this.palette = palette; if ((d.ContainsKey("length") && d["length"].Value == "*") || (d.ContainsKey("end") && d["end"].Value == "*")) length = sprites.Length - start; else if (d.ContainsKey("length")) length = Exts.ParseIntegerInvariant(d["length"].Value); else if (d.ContainsKey("end")) length = Exts.ParseIntegerInvariant(d["end"].Value) - start; else length = 1; if (d.ContainsKey("x")) Exts.TryParseIntegerInvariant(d["x"].Value, out Hotspot.X); if (d.ContainsKey("y")) Exts.TryParseIntegerInvariant(d["y"].Value, out Hotspot.Y); }
void Start() { IconLoader = FindObjectOfType<SpriteLoader>(); //Potion Items items.Add (new Item ("attack", 1, "Food", 15, 2, true, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); items.Add (new Item ("Defense", 2, "Soda", 20, 1, false, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); items.Add (new Item ("Map", 3, "food3", 22, 1, false, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); items.Add (new Item ("Sword", 4, "food4", 23, 1, true, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); items.Add (new Item ("Sword", 5, "food5", 23, 1, true, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); items.Add (new Item ("Map", 6, "food6", 24, 1, false, Item.ItemType.Potion,IconLoader.ItemImage(20),0)); //QuestItems items.Add (new Item ("Bill of Sale", 10, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(18),1)); items.Add (new Item ("Rat Tail Stew", 11, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(4),2)); items.Add (new Item ("Potato Plant", 12, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(2),2)); items.Add (new Item ("Loaf of Bread", 13, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(3),2)); items.Add (new Item ("Wheel of Cheese", 14, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(0),2)); items.Add (new Item ("Rack of Beef", 15, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(1),2)); items.Add (new Item ("Flask of Water", 16, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(9),2)); items.Add (new Item ("Jar of Milk", 17, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(3),2)); items.Add (new Item ("Chicken", 18, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(7),2)); items.Add (new Item ("Fish", 21, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(6),3)); items.Add (new Item ("Fishing Pole", 22, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(11),3)); items.Add (new Item ("Iron Ore", 31, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(20),4)); items.Add (new Item ("Gold Ore", 32, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(20),4)); items.Add (new Item ("Ruby", 33, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(19),4)); items.Add (new Item ("Saphire", 34, "N/A", 0, 1, true, Item.ItemType.QuestItem,IconLoader.ItemImage(20),4)); items.Add (new Item ("Axe", 41, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(14),5)); items.Add (new Item ("Mining Pick", 42, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(12),5)); items.Add (new Item ("Shovel", 43, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(10),5)); items.Add (new Item ("Hoe", 44, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),5)); items.Add (new Item ("Blacksmith Hammer", 51, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(13),6)); items.Add (new Item ("Broken Armor", 52, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),6)); items.Add (new Item ("Torch", 53, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(17),6)); items.Add (new Item ("Wooden Sword", 61, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(16),7)); items.Add (new Item ("Wooden Shield", 62, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(15),7)); items.Add (new Item ("Wooden Knight", 63, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),7)); items.Add (new Item ("Child's Doll", 64, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(8),7)); items.Add (new Item ("Pet Pig", 71, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(21),8)); items.Add (new Item ("Stone Dragon Idol", 72, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),8)); items.Add (new Item ("Dragon's Tail", 73, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),8)); items.Add (new Item ("Bandits Signet Ring", 74, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),8)); items.Add (new Item ("Bronze Key", 81, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),9)); items.Add (new Item ("Silver Key", 82, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),9)); items.Add (new Item ("Gold Key", 83, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),9)); items.Add (new Item ("Skeleton Key", 84, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),9)); items.Add (new Item ("Wagon Wheel", 91, "N/A", 0, 1, false, Item.ItemType.QuestItem,IconLoader.ItemImage(20),10)); items.Add(new Fairy("Heal Fairy I",92,"heals 5 HP every second.",5,1,true,Item.ItemType.Fairy,IconLoader.ItemImage(20),11,0,10,10,Fairy.FairyType.Heal,0)); items.Add(new Fairy("Gear Protection Fairy I",93,"Protects gear 3 times.",5,1,true,Item.ItemType.Fairy,IconLoader.ItemImage(20),11,3,10,10,Fairy.FairyType.GearProtection,1)); items.Add(new Fairy("Defense Fairy I",94,"Boost HP by 3.",5,1,true,Item.ItemType.Fairy,IconLoader.ItemImage(20),11,3,10,10,Fairy.FairyType.DefenseBoost,2)); items.Add(new Fairy("Attack Fairy I",95,"Boost Attack by 3.",5,1,true,Item.ItemType.Fairy,IconLoader.ItemImage(20),11,3,10,10,Fairy.FairyType.AttackBoost,3)); }
public ArchetypeBasedBombWorldObjectViewModel(IPackageRepository packageRepository, SpriteLoader spriteLoader) : base(packageRepository, spriteLoader) { }
public WorldEditorTerrainToolsViewModel(IPackageRepository repository, SpriteLoader spriteLoader) { this._repository = repository; this._spriteLoader = spriteLoader; this._isGridVisible = false; this._tiles = new ObservableCollection<TileViewModel>(); foreach (var asset in repository.Assets.Where(x => x.Type == EditorAssetTypes.TerrainTileDefinition).OrderBy(x => x.Key)) { var tileData = _repository.GetAssetData<TerrainTileDefinitionResource>(asset.Id); _tiles.Add(new TileViewModel() { Key = tileData.Key, Sprite = _spriteLoader.LoadSprite(tileData.SpriteKey) }); } this.SelectedTile = _tiles.FirstOrDefault(); this.SelectedTool = TerrainEditorTools.Paint; SetToolCommand = new DelegateCommand<String>(x => { if (x == "Fill") SelectedTool = TerrainEditorTools.Fill; else if (x == "Paint") SelectedTool = TerrainEditorTools.Paint; else if (x == "EyeDropper") SelectedTool = TerrainEditorTools.EyeDropper; }); }
public ArchetypeBasedRetractableSpikeWorldObjectViewModel(IPackageRepository packageRepository, SpriteLoader spriteLoader) : base(packageRepository, spriteLoader) { }
public ConcreteWorldObjectViewModel(SpriteLoader spriteLoader) { this._spriteLoader = spriteLoader; }
public ArchetypeBasedScriptedSearchableWorldObjectViewModel(IPackageRepository packageRepository, SpriteLoader spriteLoader) : base(packageRepository, spriteLoader) { }
public ArchetypeBasedConcreteWorldObjectViewModel(IPackageRepository packageRepository, SpriteLoader spriteLoader) { this._packageRepository = packageRepository; this._spriteLoader = spriteLoader; }
public TerrainWorldObjectViewModel(IPackageRepository packageRepository, SpriteLoader spriteLoader) { this._packageRepository = packageRepository; this._spriteLoader = spriteLoader; this._tiles = new ObservableCollection<Tile>(); }