private void DrawItemHandler(object sender, DrawItemEventArgs ev) { if (this.Items.Count == 0 || ev.Index == -1) { return; } Rectangle bounds = ev.Bounds; // draw background ev.DrawBackground(); // draw border ev.Graphics.DrawRectangle(Pens.Gray, bounds); Sprite sprite = (Sprite)this.Items[ev.Index]; // find the area in which to put the text and draw. this.layoutRect.X = bounds.Left + Sprite.DefaultSize + (3 * ItemMargin); this.layoutRect.Y = bounds.Top + (ItemMargin * 2); this.layoutRect.Width = bounds.Right - ItemMargin - this.layoutRect.X; this.layoutRect.Height = bounds.Bottom - ItemMargin - this.layoutRect.Y; // draw sprite id if ((ev.State & DrawItemState.Selected) == DrawItemState.Selected) { this.pen.Brush = WhiteBrush; ev.Graphics.DrawString(sprite.ToString(), this.Font, WhiteBrush, this.layoutRect); } else { this.pen.Brush = BlackBrush; ev.Graphics.DrawString(sprite.ToString(), this.Font, BlackBrush, this.layoutRect); } this.destRect.Y = bounds.Top + ItemMargin; Bitmap bitmap = sprite.GetBitmap(); if (bitmap != null) { this.sourceRect.Width = bitmap.Width; this.sourceRect.Height = bitmap.Height; ev.Graphics.DrawImage(bitmap, this.destRect, this.sourceRect, GraphicsUnit.Pixel); } // draw sprite border ev.Graphics.DrawRectangle(this.pen, this.destRect); // draw focus rectangle ev.DrawFocusRectangle(); }
// Add Element to the foreground based on the previous Element void NewColumn(Vector3 position) { if ((!wasElement && Random.value < startElementStringChance) || (wasElement && Random.value < continueElementStringChance)) { wasElement = true; Sprite sprite = elements[Random.Range(0, elements.Length)]; GameObject element = new GameObject(sprite.ToString()); element.transform.parent = this.transform; element.AddComponent <Item>(); float height = Mathf.Clamp(Random.Range(-maxElementDistance, maxElementDistance) + previousElementHeight, minElementElevation, maxElementElevation); position.y += height; position.z = depth + Random.Range(-maxDepthVariation, maxDepthVariation); previousElementHeight = height; element.transform.position = position; element.transform.localScale *= Random.Range(minScale, 1) * Mathf.Max(depth / 4f, 1f); SpriteRenderer renderer = element.AddComponent <SpriteRenderer>(); renderer.sprite = sprite; renderer.sortingOrder = spriteOrder; if (overlap) { if (even) { renderer.sortingOrder += 1; } even = !even; } } else { wasElement = false; previousElementHeight = Random.Range(minElementElevation, maxElementElevation); } }
private void fromXmlToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog wizard = new OpenFileDialog(); wizard.Filter = "Xml | *.xml"; wizard.Title = "Select an attribute file to open"; wizard.RestoreDirectory = true; wizard.ShowDialog(); if (wizard.FileName != "") { XElement doc = XElement.Load(wizard.FileName); foreach (XElement child in doc.Elements()) { switch (child.Name.ToString()) { case "Sprite": Sprite s = new Sprite(); s.FromElement(child); OnSpriteAdded(s); listBoxSprites.Items.Add(s.ToString()); edittingBuff.Add(s); break; } } } wizard.Dispose(); }
private void Awake() { Sprite icon = upgradeSprites[Random.Range(0, upgradeSprites.Length)]; //随机获取贴图 upgradeName = icon.ToString(); //道具名称的储存 this.gameObject.GetComponent <SpriteRenderer>().sprite = icon; //贴图 }
public void EquipSprite() { skinSprite = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.GetComponentsInChildren <Image>(); textButton = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.GetComponentsInChildren <Text>(); buttonEquip = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.GetComponentsInChildren <Button>(); count = 1; textButton[0].text = "Equipped"; buttonEquip[0].interactable = false; spriteX = skinSprite[1].sprite; spriteO = skinSprite[2].sprite; CoinAndGamesData.CurrentSpriteEquippedX = spriteX.ToString(); CoinAndGamesData.CurrentSpriteEquippedO = spriteO.ToString(); if (MainMenu.loadNumber == 1) { SaveSystem.SaveSlot1(); } if (MainMenu.loadNumber == 2) { SaveSystem.SaveSlot2(); } if (MainMenu.loadNumber == 3) { SaveSystem.SaveSlot3(); } }
public void ChangeFace(Sprite img) { GetComponent <Image>().sprite = img; switch (img.ToString()) { case "Wood (UnityEngine.Sprite)": wood.SetActive(true); break; case "Water (UnityEngine.Sprite)": water.SetActive(true); break; case "Fire (UnityEngine.Sprite)": fire.SetActive(true); break; case "Elec (UnityEngine.Sprite)": elec.SetActive(true); break; default: break; } }
// Use this for initialization void Start() { Sprite icon = upgradeSprites[Random.Range(0, upgradeSprites.Length)]; upgradeName = icon.ToString(); this.gameObject.GetComponent <SpriteRenderer>().sprite = icon; }
private void ChaneImage() { prize = winItems[1]; Debug.Log("decoration"); img.GetComponent <Image>().sprite = prize; Debug.Log(prize.ToString()); }
private void WriteSprite(Sprite s, ListSet <Timeline> unboundClasses) { foreach (ICharacterReference cr in s.CharacterRefs) { this.WriteCharacter(cr.Character, unboundClasses); } if (s.HasClass && !(s.Class is AdobeClass) && !unboundClasses.Contains(s)) { unboundClasses.Add(s); } int id = this.characterMarshal.GetIDFor(s); WriteBuffer tagWriter = this.OpenTag(Tag.DefineSprite, s.ToString() + ";id=" + id.ToString()); tagWriter.WriteUI16((uint)id); tagWriter.WriteUI16(s.FrameCount); #if DEBUG this.LogMessage("char id=" + id); #endif foreach (Frame f in s.Frames) { if (f.HasLabel) { #if DEBUG this.LogMessage("frame label=" + f.Label); #endif WriteBuffer labelWriter = this.OpenTag(Tag.FrameLabel); labelWriter.WriteString(f.Label); this.CloseTag(); } foreach (IDisplayListItem dli in f.DisplayList) { switch (dli.Type) { case DisplayListItemType.PlaceObjectX: this.WritePlaceObjectTag((PlaceObject)dli); break; case DisplayListItemType.RemoveObjectX: this.WriteRemoveObjectTag((RemoveObject)dli); break; default: /* ISSUE 73 */ throw new SWFModellerException( SWFModellerError.UnimplementedFeature, "Unsupported tag in SWF sprite writer: " + dli.GetType().ToString()); } } this.WriteBodylessTag(Tag.ShowFrame); } this.WriteBodylessTag(Tag.End, id.ToString()); this.CloseTag(); /* DefineSprite */ }
private void fromBitmapToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog wizard = new OpenFileDialog(); wizard.Filter = "Bitmap | *.bmp"; wizard.Title = "Select a sprite file to open"; wizard.Multiselect = true; wizard.RestoreDirectory = true; wizard.ShowDialog(); if (wizard.FileName != null) { foreach (string s in wizard.FileNames) { if (s != "") { Sprite temp = new Sprite(s); listBoxSprites.Items.Add(temp.ToString()); edittingBuff.Add(temp); listBoxSprites.SelectedIndex = edittingBuff.IndexOf(temp); OnSpriteAdded(temp); } } } }
public void ChangeEyeSprite(Sprite partSprite, Sprite whiteSprite, int spriteID) { eyesImage.sprite = partSprite; eyeWhiteImage.sprite = whiteSprite; characterData.partSelection[(int)BodyPartType.Eyes] = spriteID; characterData.partSelection[(int)BodyPartType.EyeWhites] = spriteID; Debug.Log("Part: " + partSprite.ToString() + "Sprite ID: " + spriteID.ToString()); }
public void AdvancingTillLastFrameGivesEvent() { var animation = new Sprite(material, Vector2D.Half); bool endReached = false; animation.AnimationEnded += () => { endReached = true; }; AdvanceTimeAndUpdateEntities(animation.Material.Duration + 0.1f); Assert.IsTrue(endReached, animation.ToString()); }
public override string ToString() { return(name + "\n" + desc + "\n" + "Icon: " + icon.ToString() + "\n" + "Cooldown: " + cooldownCurr.ToString("##0.0") + " / " + cooldownMax.ToString("##0.0") + "\n" + "Charges: " + _charges + " / " + chargesMax + "\n" + "Effect: " + effect.Method.ToString()); }
public void FlipCard(Sprite startImage, Sprite endImage) { if (startImage != null && endImage != null) { Debug.Log(endImage.ToString()); Flip(startImage, endImage); } }
public string GetSpriteToDisplayName() { string s = ""; if (spriteToDisplay != null) { s = spriteToDisplay.ToString().Replace(" (UnityEngine.Sprite)", ""); } return(s); }
public override string ToString() { string s = sprite.ToString() + " -> "; foreach (Vector2 v in shape) { s += v + ","; } return(s); }
public void Start() { FieldInfo[] fieldInfos = this.GetType().GetFields(); foreach (FieldInfo fieldInfo in fieldInfos) { Sprite sprite = Resources.Load <Sprite>("Faces/" + fieldInfo.Name); Debug.Log(sprite.ToString()); fieldInfo.SetValue(this, sprite); } }
// This function will be called when user clicks to register void doRegister() { sprite = mybtn.GetComponent <Image>().sprite; if ((sprite.ToString().Substring(0, (sprite.ToString().Length) - 21)).Equals("check_off_tiny")) { role = "student"; } else { role = "teacher"; } string username = inputUsername.text; string password = inputPass.text; string name = inputName.text; FirebaseManager fbMgr = FirebaseManager.getInstance(); fbMgr.doRegister(username, password, (result, msg) => { Debug.Log(TAG + ":: doRegister:" + result + ", " + msg); if (result == true) { User newUser = new User(username, name, role); fbMgr.updateUserProfile(name); fbMgr.saveUser(newUser); doSendEmailVerification(); if (string.Compare(role, "student") == 0) { createGameData(name); } } else { Mainthread.wkr.AddJob(() => { mytext.text = msg; // Will run on main thread, hence issue is solved popupNoUserRecord.SetActive(true); }); } }); }
public string GetDescription() { if (spriteRef == null) { return(spriteVal != null?spriteVal.ToString() : "Null"); } else { return(spriteRef.Key); } }
public string GetDescription() { if (spriteRef == null) { return(spriteVal.ToString()); } else { return(spriteRef.key); } }
/*==============================================================*/ //立ち絵の作成 /*==============================================================*/ void CreateStand() { Sprite s_now_sprite = this.GetComponent <SpriteRenderer>().sprite; GameObject g_stand = GameObject.Find("Stand"); string s_for_work = s_now_sprite.ToString(); s_for_work = s_for_work.Substring(14, 1); g_stand.GetComponent <Anime>().Change(int.Parse(s_for_work)); }
void CreateGameObjSelect_BG(Sprite createSprite) { m_obj = new GameObject(); m_obj.name = createSprite.ToString(); m_obj.AddComponent <Image>().sprite = createSprite; m_obj.transform.parent = this.gameObject.transform; m_obj.transform.localScale = Vector3.one; m_obj.transform.localPosition = Vector3.zero; m_obj.GetComponent <Image>().SetNativeSize(); m_obj.GetComponent <Image>().raycastTarget = false; }
public override void Init(Vector2 pos) { sprite = new Sprite("Sprites/Placeholders/spr_test32", contentManager); sprite.Scale = new Vector2(1f, 1f); Depth = 5; Console.WriteLine("Depth: " + Depth.ToString()); //sprite.SetAnimationParameters(13, new Vector2(24, 39), 5, true); base.Init(pos); Console.WriteLine("Sprite: " + sprite.ToString()); Console.WriteLine("Position: " + Position.ToString()); }
/// <summary> /// 在房间里生成痕迹 /// </summary> public GameObject GenerateTrace(Sprite traceSprite, Vector2 position) { GameObject trace = new GameObject(traceSprite.ToString()); SpriteRenderer sr = trace.AddComponent <SpriteRenderer>(); sr.sprite = traceSprite; sr.sortingOrder = GameDate.RENDERERORDER_TRACES; sr.maskInteraction = SpriteMaskInteraction.VisibleInsideMask; trace.transform.SetParent(traceContainer); trace.transform.position = position; return(trace); }
public void CreateAnime(Sprite _sprite) { Sprite s_now_sprite = _sprite; string s_for_work = s_now_sprite.ToString(); //数値の切り取り s_for_work = s_for_work.Substring(14, 1); GameObject create_obj = GameObject.Find("Anime"); create_obj.GetComponent <SpriteChange>().SharingState(int.Parse(s_for_work)); create_obj.GetComponent <Animator>().Play("Move"); }
public static void addOrder(Sprite ord) { if (orderSprite == null) { newOrder = true; Debug.Log(ord.ToString()); orderSprite = ord; } else { //What to do if you can not grab any more coffe } }
/*==============================================================*/ // オブジェクトを作る // 引数 : 作りたいオブジェクト名、座標を求めるオブジェクト名 /*==============================================================*/ void CreateObject(string _create_name, string _existing_name) { GameObject create_obj = GameObject.Find(_create_name); Sprite s_now_sprite = this.GetComponent <SpriteRenderer>().sprite; string s_for_work = s_now_sprite.ToString(); s_for_work = s_for_work.Substring(14, 1); if (!Image_Data_Check(s_now_sprite)) { return; } create_obj.GetComponent <SpriteRenderer>().sprite = s_now_sprite; }
/// <summary> /// Automatically update the color and item texture in string mode so the engine can load the textures and colors /// </summary> public void OnValidate() { string path = itemSprite.ToString(); int index = path.IndexOf(" ", StringComparison.Ordinal); if (index < 0) { item.Sprite = "invisible"; } else { path = path.Substring(0, index); item.Sprite = path; } item.ItemColor = "#" + ColorUtility.ToHtmlStringRGBA(equipColor); }
public static uint TestVerticalRotate(Sprite start, Sprite expected, string[] args) { int degrees; // make sure the degrees input is there if (args.Length < 16) { Console.WriteLine("Too few arguments for " + "TestVerticalRotate: " + args.Length); Console.WriteLine("Missing degrees input"); Console.WriteLine("Test FAILED"); return(0); } // convert degrees to an integer try { degrees = Int32.Parse(args[15]); } catch (FormatException e) { Console.WriteLine("Could not read degrees for " + "TestVerticalRotate"); Console.WriteLine(e.Message); return(0); } //Console.WriteLine("Start: "+start); // call the function start.VerticalRotate(degrees); // see if it matches the expected result if (start.Equals(expected)) { Console.WriteLine("VerticalRotate(" + degrees + "): Success!"); return(1); } else { Console.WriteLine("VerticalRotate(" + degrees + "): FAIL!"); Console.WriteLine("Expected: " + expected.ToString()); Console.WriteLine("Actual: " + start.ToString()); return(0); } }
// Add a tile to the foreground GameObject InstantiateTile(Sprite sprite, Vector3 position) { GameObject tile = new GameObject(CleanSpriteName(sprite.ToString())); tile.transform.position = position; SpriteRenderer renderer = tile.AddComponent <SpriteRenderer>(); renderer.sprite = sprite; renderer.sortingOrder = -4; if (tile.name != "blank") { tile.AddComponent <BoxCollider2D>(); //tile.AddComponent<PolygonCollider2D>(); //collider.sharedMaterial = physicsMaterial; } tile.AddComponent <Item>(); tile.transform.parent = tilesObject.transform; return(tile); }
public void Save(int itemNum) { if (!Directory.Exists(Paths.DataPath + "Item")) { Directory.CreateDirectory(Paths.DataPath + "Item"); } using (XmlWriter writer = XmlWriter.Create(Paths.DataPath + "Item\\" + itemNum + ".xml", Logger.XmlWriterSettings)) { writer.WriteStartDocument(); writer.WriteStartElement("ItemEntry"); #region Basic data writer.WriteStartElement("General"); writer.WriteElementString("Name", Name); writer.WriteElementString("Description", Desc); writer.WriteElementString("ItemType", Type.ToString()); writer.WriteElementString("Price", Price.ToString()); writer.WriteElementString("Rarity", Rarity.ToString()); writer.WriteElementString("Sprite", Sprite.ToString()); writer.WriteElementString("Requirement", Req.ToString()); writer.WriteElementString("Req1", Req1.ToString()); writer.WriteElementString("Req2", Req2.ToString()); writer.WriteElementString("Req3", Req3.ToString()); writer.WriteElementString("Req4", Req4.ToString()); writer.WriteElementString("Req5", Req5.ToString()); writer.WriteElementString("Effect", Effect.ToString()); writer.WriteElementString("Effect1", Effect1.ToString()); writer.WriteElementString("Effect2", Effect2.ToString()); writer.WriteElementString("Effect3", Effect3.ToString()); writer.WriteElementString("ThrowEffect", ThrowEffect.ToString()); writer.WriteElementString("Throw1", Throw1.ToString()); writer.WriteElementString("Throw2", Throw2.ToString()); writer.WriteElementString("Throw3", Throw3.ToString()); writer.WriteEndElement(); #endregion Basic data writer.WriteEndElement(); writer.WriteEndDocument(); } }
public SpriteStatus getStatus(Sprite sprite, SpriteType spriteType) { SpriteStatus status = spriteDao.getStatus(sprite); string selected = spriteDao.getSelected(spriteType); if (status.Equals(SpriteStatus.SELECTED) && sprite.ToString().Equals(selected)) { return SpriteStatus.SELECTED; } else if (status.Equals(SpriteStatus.SELECTED) && selected.Equals("")) { spriteDao.setSelected(sprite, spriteType); return SpriteStatus.SELECTED; } else if (status.Equals(SpriteStatus.OWNED) || status.Equals(SpriteStatus.SELECTED)) { return SpriteStatus.OWNED; } else { return SpriteStatus.NOT_OWNED; } }
public SpriteStatus getStatus(Sprite sprite) { int status = PlayerPrefs.GetInt(sprite.ToString()); return (SpriteStatus) status; }
public void setSelected(Sprite sprite, SpriteType spriteType) { PlayerPrefs.SetString(spriteType.ToString(), sprite.ToString()); }
public void setStatus(Sprite sprite, int spriteStatus) { PlayerPrefs.SetInt(sprite.ToString(), spriteStatus); }