public GetSpriteIdByName ( string name ) : int | ||
name | string | Case sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension |
Результат | int |
public static void Notify(string header, string text, string spriteID, UINotificationController.NotificationColor color = UINotificationController.NotificationColor.SILVER) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName(spriteID); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, encounterIconCollection, spriteIdByName, color, false, false); }
private static void Notify(string header, string text) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName("LostItems/NuclearThrone/NuclearThroneSprite/Nuclear Talisman2"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, encounterIconCollection, spriteIdByName, UINotificationController.NotificationColor.PURPLE, false, false); }
private void createOverLayer(string spriteName) { _overSpr = new tk2dSprite[_needNum]; for (int i = 0; i < _needNum; ++i) { GameObject tempGobj = new GameObject("overBG"); tk2dSprite spr = tempGobj.AddComponent <tk2dSprite>(); tk2dSpriteCollectionData tScd = GameManager.resourceManager.getSpriteCollection(spriteName); spr.SetSprite(tScd, tScd.GetSpriteIdByName(spriteName)); spr.renderer.material = tScd.FirstValidDefinition.material; spr.Build(); tempGobj.transform.parent = _transforms[i]; _v = tempGobj.transform.localPosition; _v.x = 0.0f; _v.y = 0.0f; _v.z = -0.1f; tempGobj.transform.localPosition = _v; _overSpr[i] = spr; spr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); } }
private void Notify(string header, string text) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName("CakeMod/Resources/StrangePotion"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, null, spriteIdByName, UINotificationController.NotificationColor.PURPLE, false, true); }
private static void Notify(string header, string text) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName("NevernamedsItems/Resources/JammomasterSprites/alljammedmode_icon"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, null, spriteIdByName, UINotificationController.NotificationColor.PURPLE, false, true); }
private static void Notify(string header, string text) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName("BunnyMod/Resources/death_mark"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, encounterIconCollection, spriteIdByName, UINotificationController.NotificationColor.SILVER, false, false); }
private void Notify(string header, string text) { tk2dSpriteCollectionData IconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteID = IconCollection.GetSpriteIdByName("Items/Resources/pet_rock"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, IconCollection, spriteID, UINotificationController.NotificationColor.SILVER, false, false); }
private static void Notify(string header, string text) { //isSingleLine = false; tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.Instance.EncounterIconCollection; int spriteIdByName = encounterIconCollection.GetSpriteIdByName("BunnyMod/Resources/Artifacts/glass"); GameUIRoot.Instance.notificationController.DoCustomNotification(header, text, null, spriteIdByName, UINotificationController.NotificationColor.PURPLE, false, true); }
public int?GetSpriteDefinitionIndex(string name) { int id = CollectionData.GetSpriteIdByName(name); if (id == -1) { return(null); } return(id); }
/// <summary> /// Switches the sprite collection and sprite. /// Simply set the <see cref="tk2dBaseSprite.spriteId">spriteId</see> property when you don't need to switch the sprite collection. /// This will be deprecated in a future release, use SetSprite instead. /// </summary> /// <param name='newCollection'> /// A reference to the sprite collection to switch to. /// </param> /// <param name='spriteName'> /// Sprite name. /// </param> public bool SwitchCollectionAndSprite(tk2dSpriteCollectionData newCollection, string spriteName) { int spriteId = newCollection.GetSpriteIdByName(spriteName, -1); if (spriteId != -1) { SwitchCollectionAndSprite(newCollection, spriteId); } return(spriteId != -1); }
/// <summary> /// Sets the sprite by name. The sprite will be selected from the current collection. /// </summary> public bool SetSprite(string spriteName) { int spriteId = collection.GetSpriteIdByName(spriteName, -1); if (spriteId != -1) { SetSprite(spriteId); } return(spriteId != -1); }
/// <summary> /// Adds a tk2dBaseSprite derived class as a component to the gameObject passed in, setting up necessary parameters /// and building geometry. Shorthand using sprite name /// </summary> public static T AddComponent <T>(GameObject go, tk2dSpriteCollectionData spriteCollection, string spriteName) where T : tk2dBaseSprite { int spriteId = spriteCollection.GetSpriteIdByName(spriteName, -1); if (spriteId == -1) { Debug.LogError(string.Format("Unable to find sprite named {0} in sprite collection {1}", spriteName, spriteCollection.spriteCollectionName)); return(null); } else { return(AddComponent <T>(go, spriteCollection, spriteId)); } }
/// <summary> /// Sets sprite by name from the new collection. /// </summary> public bool SetSprite(tk2dSpriteCollectionData newCollection, string spriteName) { int spriteId = newCollection.GetSpriteIdByName(spriteName, -1); if (spriteId != -1) { SetSprite(newCollection, spriteId); } else { Debug.LogError("SetSprite - Sprite not found in collection: " + spriteName); } return(spriteId != -1); }
/// <summary> /// Sets the sprite by name. The sprite will be selected from the current collection. /// </summary> public bool SetSprite(string spriteName) { int spriteId = collection.GetSpriteIdByName(spriteName, -1); if (spriteId != -1) { SetSprite(spriteId); } else { CustomDebug.LogError("SetSprite - Sprite not found in collection: " + spriteName); } return(spriteId != -1); }
/* * public void changeBackground(BackgroundData bgData) * { * for(int i = 0; i < _needNum; ++i) * { * tk2dSpriteCollectionData scd = GameManager.resourceManager.getSpriteCollection(bgData.id); * _sprites[i].SwitchCollectionAndSprite(scd, scd.GetSpriteIdByName(bgData.id)); * } * * _width = _sprites[0].GetBounds().extents.x*2.0f; * _height = _sprites[0].GetBounds().extents.y*2.0f; * * resetPosition(); * * //_hasOverLayer = (bgData.baseEffect != BackgroundData.NONE); * * if(_hasOverLayer) * { * foreach(tk2dSprite spr in _overSpr) * { * tk2dSpriteCollectionData scd = GameManager.resourceManager.getSpriteCollection(bgData.baseEffect); * spr.SwitchCollectionAndSprite(scd, scd.GetSpriteIdByName(bgData.baseEffect)); * spr.renderer.enabled = true; * } * } * else * { * foreach(tk2dSprite spr in _overSpr) * { * spr.renderer.enabled = false; * } * } * } */ public void changeBackground(string id) { for (int i = 0; i < _needNum; ++i) { tk2dSpriteCollectionData scd = GameManager.resourceManager.getSpriteCollection(id); _sprites[i].SetSprite(scd, scd.GetSpriteIdByName(id)); } _width = _sprites[0].GetBounds().extents.x *2.0f; _height = _sprites[0].GetBounds().extents.y *2.0f; resetPosition(); _hasOverLayer = false; }
public static void SetupSprite(this Gun gun, tk2dSpriteCollectionData collection = null, string defaultSprite = null, int fps = 0) { AmmonomiconController.ForceInstance.EncounterIconCollection.Handle(); ETGMod.Databases.Items.ProjectileCollection.Handle(); collection = collection ?? ETGMod.Databases.Items.WeaponCollection; collection.Handle(); if (defaultSprite != null) { gun.encounterTrackable.journalData.AmmonomiconSprite = defaultSprite; } gun.UpdateAnimations(collection); gun.GetSprite().SetSprite(collection, gun.DefaultSpriteID = collection.GetSpriteIdByName(gun.encounterTrackable.journalData.AmmonomiconSprite)); if (fps != 0) { gun.SetAnimationFPS(fps); } }
bool ProcessSpriteImport(List <ClipEditor.FrameGroup> frameGroups, string spriteNames) { tk2dSpriteCollectionData coll = frameGroups[0].spriteCollection; // make new list List <int> spriteIds = new List <int>(); List <int> frameCounts = new List <int>(); int lineNumber = 1; string[] lines = spriteNames.Split('\n'); foreach (string line in lines) { if (line.Trim().Length != 0) { string spriteName = line; int frameCount = 1; int splitIndex = line.LastIndexOf(';'); if (splitIndex != -1) { spriteName = line.Substring(0, splitIndex); string frameCountStr = line.Substring(splitIndex + 1, line.Length - 1 - splitIndex); if (!System.Int32.TryParse(frameCountStr, out frameCount)) { Debug.LogError("Parse error in line " + lineNumber.ToString()); return(false); } frameCount = Mathf.Max(frameCount, 1); } int spriteId = coll.GetSpriteIdByName(spriteName, -1); if (spriteId == -1) { Debug.LogError(string.Format("Unable to find sprite '{0}' in sprite collection", spriteName)); return(false); } spriteIds.Add(spriteId); frameCounts.Add(frameCount); } lineNumber++; } List <ClipEditor.FrameGroup> newFrameGroups = new List <ClipEditor.FrameGroup>(); for (int i = 0; i < spriteIds.Count; ++i) { if (i < frameGroups.Count && frameGroups[i].spriteId == spriteIds[i]) { if (frameGroups[i].frames.Count != frameCounts[i]) { frameGroups[i].SetFrameCount(frameCounts[i]); } newFrameGroups.Add(frameGroups[i]); } else { ClipEditor.FrameGroup fg = new ClipEditor.FrameGroup(); fg.spriteCollection = coll; fg.spriteId = spriteIds[i]; fg.SetFrameCount(frameCounts[i]); newFrameGroups.Add(fg); } } frameGroups.Clear(); foreach (ClipEditor.FrameGroup fg in newFrameGroups) { frameGroups.Add(fg); } operations = AnimEditOperations.ClipContentChanged; return(true); }
/// <summary> /// Resolves a sprite name and returns a unique id for the sprite. /// Convenience alias of <see cref="tk2dSpriteCollectionData.GetSpriteIdByName"/> /// </summary> /// <returns> /// Unique Sprite Id. /// </returns> /// <param name='name'>Case sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension</param> public int GetSpriteIdByName(string name) { InitInstance(); return(collectionInst.GetSpriteIdByName(name)); }
public void place() { patternIndex2 = 0; GameObject go; go = this.gameObject; //if (go.transform.childCount > 0) //{ // Transform[] ch = go.GetComponentsInChildren<Transform>(); // foreach (Transform c in ch) // { // DestroyImmediate(c.gameObject); // } //} spriteCollection = go.transform.parent.GetComponent<tk2dSprite>().Collection; selectedSpriteName = go.transform.parent.GetComponent<tk2dSprite>().CurrentSprite.name; tk2dStaticSpriteBatcher batcher; //if (!this.gameObject.GetComponent<tk2dStaticSpriteBatcher>()) //{ // batcher = this.gameObject.AddComponent<tk2dStaticSpriteBatcher>(); //} //else //{ batcher = this.gameObject.GetComponent<tk2dStaticSpriteBatcher>(); //} batcher.batchedSprites = new tk2dBatchedSprite[points.Length]; GameObject o = GameObject.CreatePrimitive(PrimitiveType.Quad); for (int i = 0; i < batcher.batchedSprites.Length; ++i) { tk2dBatchedSprite bs = new tk2dBatchedSprite(); // assign sprite collection and sprite Id for this batched sprite bs.spriteCollection = spriteCollection; bs.spriteId = spriteCollection.GetSpriteIdByName(selectedSpriteName); Vector3 pos = points[i].position; o.transform.position = pos; o.transform.LookAt(gameObject.transform); patternIndex2++; Debug.Log("poot"); if (patternIndex2 == patternbools.Length) { patternIndex2 = 0; } if (patternbools[patternIndex2] == false) { pos = new Vector3(0f, 0f, 0f); } // Just lookat o.transform.LookAt(gameObject.transform); Quaternion q = o.transform.rotation; Quaternion qr = Quaternion.Euler(new Vector3(0f, 0f, o.transform.rotation.eulerAngles.z)); // Debug.Log(points[i].position); bs.relativeMatrix.SetTRS(pos, q , Vector3.one * spriteScale); //Quaternion.identity // bs.position = pos; //bs.rotation = qr; //bs.localScale = Vector3.one * spriteScale; batcher.batchedSprites[i] = bs; //bs.rotation = qr; // batcher.batchedSprites[i].localScale = Vector3.one * spriteScale; i = i + stepSize; } // Don't create colliders when you don't need them. It is very expensive to // generate colliders at runtime. batcher.SetFlag(tk2dStaticSpriteBatcher.Flags.GenerateCollider, false); batcher.Build(); boolupdate = false; // return; }
/// <summary> /// Resolves a sprite name and returns a unique id for the sprite. /// Convenience alias of <see cref="tk2dSpriteCollectionData.GetSpriteIdByName"/> /// </summary> /// <returns> /// Unique Sprite Id. /// </returns> /// <param name='name'>Case sensitive sprite name, as defined in the sprite collection. This is usually the source filename excluding the extension</param> public int GetSpriteIdByName(string name) { return(collection.GetSpriteIdByName(name)); }
public void create(int scrollType, float scrollSpeed, Transform parent, string spriteName, float depth, bool useOverLayer = false) { _scrollSpeed = scrollSpeed; // 첫번째 이미지를 가져온다... GameObject gobj = new GameObject("background"); gobj.transform.parent = parent; // tk2dSprite spr = gobj.AddComponent <tk2dSprite>(); tk2dSpriteCollectionData scd = GameManager.resourceManager.getSpriteCollection(spriteName); spr.SetSprite(scd, scd.FirstValidDefinitionIndex); spr.renderer.material = scd.FirstValidDefinition.material; spr.Build(); _scrollType = scrollType; _width = spr.GetBounds().extents.x *2.0f; _height = spr.GetBounds().extents.y *2.0f; _needNum = Mathf.RoundToInt((GameManager.me.tk2dGameCamera.targetResolution.y) / _height) + 2; _indexNum = new int[_needNum]; _sprites = new tk2dSprite[_needNum]; _transforms = new Transform[_needNum]; _vectors = new Vector3[_needNum]; _tempNum = new int[_needNum]; int i = 0; for (i = 0; i < _needNum; ++i) { _vectors[i] = Vector3.zero; if (i == 0) { _sprites[i] = spr; } else { GameObject tempGobj = new GameObject("background"); tempGobj.transform.parent = parent; // _sprites[i] = tempGobj.AddComponent <tk2dSprite>(); tk2dSpriteCollectionData tScd = GameManager.resourceManager.getSpriteCollection(spriteName); _sprites[i].SetSprite(tScd, tScd.GetSpriteIdByName(spriteName)); _sprites[i].renderer.material = tScd.FirstValidDefinition.material; _sprites[i].Build(); } _indexNum[i] = i; _transforms[i] = _sprites[i].transform; } _vectors[0] = _transforms[0].position; _vectors[0].x = GameManager.me.tk2dGameCamera.targetResolution.x / 2.0f; _vectors[0].y = GameManager.me.tk2dGameCamera.targetResolution.y / 2.0f; _vectors[0].z = depth; for (i = 0; i < _needNum; ++i) { _transforms[i].position = _vectors[0]; } _hasOverLayer = useOverLayer; if (useOverLayer) { createOverLayer(spriteName); } //createOverLayer(spriteName); resetPosition(); }
public override void Update() { if (base.healthHaver && ConnectedItem) { if (base.healthHaver.GetCurrentHealth() < ConnectedItem.cachedGregHealth) { // ETGModConsole.Log("Cached Greg Health (" + ConnectedItem.cachedGregHealth + ") was updated to " + base.healthHaver.GetCurrentHealth()); ConnectedItem.cachedGregHealth = base.healthHaver.GetCurrentHealth(); } else if (base.healthHaver.GetCurrentHealth() > ConnectedItem.cachedGregHealth) { // ETGModConsole.Log("Greg Companion Health (" + base.healthHaver.GetCurrentHealth() + ") was altered to match the cached " + ConnectedItem.cachedGregHealth); base.healthHaver.ForceSetCurrentHealth(ConnectedItem.cachedGregHealth); } } else if (base.healthHaver && ConnectedItemIfGoodMimic) { if (ConnectedItemIfGoodMimic.GetComponent <GoodMimicStoredGregHealth>()) { float cachedHP = ConnectedItemIfGoodMimic.GetComponent <GoodMimicStoredGregHealth>().cachedHealth; if (base.healthHaver.GetCurrentHealth() < cachedHP) { // ETGModConsole.Log("Cached Mimic Greg Health (" + cachedHP + ") was updated to " + base.healthHaver.GetCurrentHealth()); ConnectedItemIfGoodMimic.GetComponent <GoodMimicStoredGregHealth>().cachedHealth = base.healthHaver.GetCurrentHealth(); } else if (base.healthHaver.GetCurrentHealth() > cachedHP) { // ETGModConsole.Log("Mimic Greg Companion Health (" + base.healthHaver.GetCurrentHealth() + ") was altered to match the cached " + cachedHP); base.healthHaver.ForceSetCurrentHealth(cachedHP); } } } if (Owner.PlayerHasActiveSynergy("Scrambled Gregs") && base.aiActor && base.healthHaver && base.healthHaver.IsAlive) { if (Owner && Owner.IsInCombat && !isOnScramblerCooldown) { Projectile projectile2 = (PickupObjectDatabase.GetById(445) as Gun).DefaultModule.projectiles[0]; GameObject gameObject = SpawnManager.SpawnProjectile(projectile2.gameObject, base.GetComponent <tk2dSprite>().WorldCenter, Quaternion.Euler(0f, 0f, base.GetComponent <tk2dSprite>().WorldCenter.GetVectorToNearestEnemy(0, 7, Owner).ToAngle()), true); Projectile component = gameObject.GetComponent <Projectile>(); if (component != null) { component.Owner = Owner; component.Shooter = Owner.specRigidbody; //COMPANION SHIT component.TreatedAsNonProjectileForChallenge = true; component.baseData.damage *= Owner.stats.GetStatValue(PlayerStats.StatType.Damage); component.baseData.speed *= Owner.stats.GetStatValue(PlayerStats.StatType.ProjectileSpeed); component.baseData.force *= Owner.stats.GetStatValue(PlayerStats.StatType.KnockbackMultiplier); component.AdditionalScaleMultiplier *= Owner.stats.GetStatValue(PlayerStats.StatType.PlayerBulletScale); component.UpdateSpeed(); base.HandleCompanionPostProcessProjectile(component); } isOnScramblerCooldown = true; Invoke("resetFireCooldown", 5); } } //Century Greg Synergy if (Owner && base.transform && base.specRigidbody && base.gameObject && base.healthHaver && base.healthHaver.IsAlive && Owner.PlayerHasActiveSynergy("Century Greg")) { Chest chest = null; float num2 = float.MaxValue; for (int j = 0; j < StaticReferenceManager.AllChests.Count; j++) { Chest chest2 = StaticReferenceManager.AllChests[j]; if (chest2 && chest2.sprite && !chest2.IsOpen && !chest2.IsBroken && !chest2.IsSealed) { float num3 = Vector2.Distance(base.transform.position, chest2.sprite.WorldCenter); if (num3 < num2) { chest = chest2; num2 = num3; } } } if (num2 > 5f) { chest = null; } if (lastPredictedChest != chest) { if (lastPredictedChest) { //if (gregHologram == null) ETGModConsole.Log("base.m_hologram is null"); gregHologram.HideSprite(); } if (chest) { List <PickupObject> list = chest.PredictContents(Owner); if (list.Count > 0 && list[0].encounterTrackable) { tk2dSpriteCollectionData encounterIconCollection = AmmonomiconController.ForceInstance.EncounterIconCollection; gregHologram.ShowSprite(encounterIconCollection, encounterIconCollection.GetSpriteIdByName(list[0].encounterTrackable.journalData.AmmonomiconSprite)); } } lastPredictedChest = chest; } } else if (gregHologram.extantSprite) { gregHologram.HideSprite(); } base.Update(); }