// Token: 0x06000061 RID: 97 RVA: 0x00005358 File Offset: 0x00003558 public static void BuildPrefab() { bool flag = Skelebot.PenguinPrefab != null || CompanionBuilder.companionDictionary.ContainsKey(Skelebot.guid); bool flag2 = flag; if (!flag2) { Skelebot.PenguinPrefab = CompanionBuilder.BuildPrefab("Baby Good Chamber", Skelebot.guid, Skelebot.spritePaths[0], new IntVector2(1, 0), new IntVector2(7, 12)); Skelebot.PenguinBehavior penguinBehavior = Skelebot.PenguinPrefab.AddComponent <Skelebot.PenguinBehavior>(); AIAnimator aiAnimator = penguinBehavior.aiAnimator; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "run_right", "run_left" } }; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle_right", "idle_left" } }; bool flag3 = Skelebot.beeCollection == null; if (flag3) { Skelebot.beeCollection = SpriteBuilder.ConstructCollection(Skelebot.PenguinPrefab, "Ice_Collection"); UnityEngine.Object.DontDestroyOnLoad(Skelebot.beeCollection); for (int i = 0; i < Skelebot.spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(Skelebot.spritePaths[i], Skelebot.beeCollection); } SpriteBuilder.AddAnimation(penguinBehavior.spriteAnimator, Skelebot.beeCollection, new List <int> { 0, 1 }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(penguinBehavior.spriteAnimator, Skelebot.beeCollection, new List <int> { 2, 3 }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(penguinBehavior.spriteAnimator, Skelebot.beeCollection, new List <int> { 0, 1 }, "run_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(penguinBehavior.spriteAnimator, Skelebot.beeCollection, new List <int> { 2, 3 }, "run_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; } penguinBehavior.aiActor.MovementSpeed = 7f; penguinBehavior.specRigidbody.Reinitialize(); penguinBehavior.specRigidbody.CollideWithTileMap = false; penguinBehavior.aiActor.CanTargetEnemies = true; penguinBehavior.aiActor.HasShadow = false; penguinBehavior.aiActor.CollisionDamage = 1f; penguinBehavior.aiActor.HitByEnemyBullets = true; penguinBehavior.CanInterceptBullets = true; penguinBehavior.aiActor.healthHaver.PreventAllDamage = false; penguinBehavior.aiActor.specRigidbody.CollideWithOthers = true; penguinBehavior.aiActor.specRigidbody.CollideWithTileMap = true; penguinBehavior.aiActor.specRigidbody.CollidedX = true; penguinBehavior.aiActor.specRigidbody.CollidedY = true; penguinBehavior.aiActor.IsWorthShootingAt = true; penguinBehavior.aiActor.CollisionDamage = 0f; penguinBehavior.aiActor.HitByEnemyBullets = true; penguinBehavior.aiActor.PreventAutoKillOnBossDeath = true; penguinBehavior.aiActor.healthHaver.ForceSetCurrentHealth(50f); penguinBehavior.aiActor.healthHaver.SetHealthMaximum(50f, null, false); penguinBehavior.aiActor.healthHaver.PreventAllDamage = false; penguinBehavior.aiActor.healthHaver.OnPreDeath += Skelebot.YourMother; BehaviorSpeculator behaviorSpeculator = penguinBehavior.behaviorSpeculator; behaviorSpeculator.MovementBehaviors.Add(new CompanionFollowPlayerBehavior { IdleAnimations = new string[] { "idle" } }); UnityEngine.Object.DontDestroyOnLoad(Skelebot.PenguinPrefab); FakePrefab.MarkAsFakePrefab(Skelebot.PenguinPrefab); Skelebot.PenguinPrefab.SetActive(false); } }
public static void BuildPrefab() { // bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = EnemyBuilder.BuildPrefab("Inflamed_Eye", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false); var companion = prefab.AddComponent <EnemyBehavior>(); companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true); companion.aiActor.EffectResistances = new ActorEffectResistance[] { new ActorEffectResistance() { resistAmount = 1, resistType = EffectResistanceType.Fire }, }; companion.aiActor.knockbackDoer.weight = 5; companion.aiActor.MovementSpeed = 5f; companion.aiActor.name = "Inflamed Eye"; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = false; companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false); AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle" } }; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "die", anim = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "die", } } } }; bool flag3 = OphaimCollection == null; if (flag3) { OphaimCollection = SpriteBuilder.ConstructCollection(prefab, "Inflamed_Eye_Collection"); UnityEngine.Object.DontDestroyOnLoad(OphaimCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], OphaimCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, OphaimCollection, new List <int> { 0, 1, }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, OphaimCollection, new List <int> { 2, 3, 4, 5, 6, 7 }, "die", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f; } var bs = prefab.GetComponent <BehaviorSpeculator>(); float[] angles = { 45, 135, 225, 135 }; prefab.GetComponent <ObjectVisibilityManager>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; shootpoint = new GameObject("f**k"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = companion.sprite.WorldCenter; GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f, } }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootBehavior() { ShootPoint = m_CachedGunAttachPoint, BulletScript = new CustomBulletScriptSelector(typeof(FlameShooter)), LeadAmount = 0f, AttackCooldown = 3f, RequiresLineOfSight = false, Uninterruptible = true } }; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; Game.Enemies.Add("cak:inflamed_eye", companion.aiActor); } }
public static void BuildPrefab() { // bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { //float AttackAnimationThingAMaWhatIts = 0.5f; prefab = EnemyBuilder.BuildPrefab("turret_cak", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false); var companion = prefab.AddComponent <EnemyBehavior>(); companion.aiActor.knockbackDoer.weight = 10000; companion.aiActor.MovementSpeed = 2.5f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 50f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = true; companion.aiActor.aiAnimator.HitReactChance = 0f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = false; companion.aiActor.PreventFallingInPitsEver = true; companion.aiActor.healthHaver.ForceSetCurrentHealth(20f); companion.aiActor.CollisionKnockbackStrength = 1f; companion.aiActor.procedurallyOutlined = false; companion.aiActor.CanTargetPlayers = false; companion.aiActor.healthHaver.SetHealthMaximum(20f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true); companion.aiActor.healthHaver.PreventAllDamage = true; companion.aiActor.healthHaver.PreventCooldownGainFromDamage = true; companion.aiActor.CollisionDamage = 0f; companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 19, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 19, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.PlayerCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 19, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("2d4f8b5404614e7d8b235006acde427a").CorpseObject; companion.aiActor.PreventBlackPhantom = true; AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "die", anim = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "die_left", "die_right" } } } }; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle_left", "idle_right" } }; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "run_left", "run_right" } }; bool flag3 = BatCollection == null; if (flag3) { BatCollection = SpriteBuilder.ConstructCollection(prefab, "Bat_Collection"); UnityEngine.Object.DontDestroyOnLoad(BatCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], BatCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 0, 0 }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 0 }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 0 }, "run_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 0 }, "run_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 1 }, "die_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BatCollection, new List <int> { 1 }, "die_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 8f; //companion.aiActor.gameObject.AddComponent<ColliderComponent>(); var bs = prefab.GetComponent <BehaviorSpeculator>(); prefab.GetComponent <ObjectVisibilityManager>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("9b4fb8a2a60a457f90dcf285d34143ac").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; shootpoint = new GameObject("turretshoot"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = companion.sprite.WorldCenter; GameObject m_CachedGunAttachPoint = companion.transform.Find("turretshoot").gameObject; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; Game.Enemies.Add("cak:turret", companion.aiActor); ItemsMod.Strings.Enemies.Set("#TURRET", "Turret"); companion.aiActor.OverrideDisplayName = "#TURRET"; companion.aiActor.ActorName = "#TURRET"; companion.aiActor.name = "#TURRET"; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootBehavior() { ShootPoint = m_CachedGunAttachPoint, BulletScript = new CustomBulletScriptSelector(typeof(SkellScript)), LeadAmount = 0f, AttackCooldown = 5f, InitialCooldown = 1f, RequiresLineOfSight = true, StopDuring = ShootBehavior.StopType.Attack, Uninterruptible = true, } }; } } }
/// <summary> /// Used to create new VFX. Place sprites inside of Mods/YourModFolder/sprites/VFX Collection, inside the EtG directory. Each parameter that is a list must have an entry for each sprite of the animation /// </summary> /// <param name="name">The name of the VFX</param> /// <param name="spriteNames">The name of the sprites for the VFX, like VFX_001, VFX_002, etc.</param> /// <param name="fps">The frame rate the animation will play at</param> /// <param name="spriteSizes">The size of each sprite in the animation. Must have an IntVector2 entry for each sprite in the animation</param> /// <param name="anchors">I don't know what exactly this does</param> /// <param name="manualOffsets">I don't know what exactly this does</param> /// <param name="orphaned">I don't know what exactly this does</param> /// <param name="attached">I don't know what exactly this does</param> /// <param name="persistsOnDeath">Best left false</param> /// <param name="usesZHeight">Change if needed</param> /// <param name="zHeight">Change if needed, but usually left at 0</param> /// <param name="alignment">Leave at Fixed</param> /// <param name="destructible">Always set to true</param> /// <param name="emissivePowers">Doesn't seem to work, set all entries at 0. Might cause bugs if tinkered with</param> /// <param name="emissiveColors">Does't seem to work, set all entries to VFXLibrary.emptyColor. Might cause bugs if tinkered with</param> /// <returns></returns> /// public static GameObject CreateVFX(string name, List <string> spritePaths, int fps, IntVector2 Dimensions, tk2dBaseSprite.Anchor anchor, bool usesZHeight, float zHeightOffset, float emissivePower = -1, Color?emissiveColour = null) { GameObject Obj = new GameObject(name); VFXObject vfObj = new VFXObject(); Obj.SetActive(false); FakePrefab.MarkAsFakePrefab(Obj); UnityEngine.Object.DontDestroyOnLoad(Obj); tk2dSpriteCollectionData VFXSpriteCollection = SpriteBuilder.ConstructCollection(Obj, (name + "_Collection")); int spriteID = SpriteBuilder.AddSpriteToCollection(spritePaths[0], VFXSpriteCollection); tk2dSprite sprite = Obj.GetOrAddComponent <tk2dSprite>(); sprite.SetSprite(VFXSpriteCollection, spriteID); tk2dSpriteDefinition defaultDef = sprite.GetCurrentSpriteDef(); defaultDef.colliderVertices = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3((Dimensions.x / 16), (Dimensions.y / 16), 0f) }; tk2dSpriteAnimator animator = Obj.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimation animation = Obj.GetOrAddComponent <tk2dSpriteAnimation>(); animation.clips = new tk2dSpriteAnimationClip[0]; animator.Library = animation; tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "start", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); for (int i = 0; i < spritePaths.Count; i++) { tk2dSpriteCollectionData collection = VFXSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(spritePaths[i], collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.ConstructOffsetsFromAnchor(anchor); frameDef.colliderVertices = defaultDef.colliderVertices; if (emissivePower > 0) { frameDef.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { frameDef.material.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { frameDef.material.SetColor("_EmissiveColor", (Color)emissiveColour); } if (emissivePower > 0) { frameDef.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { frameDef.materialInst.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { frameDef.materialInst.SetColor("_EmissiveColor", (Color)emissiveColour); } frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } if (emissivePower > 0) { sprite.renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { sprite.renderer.material.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { sprite.renderer.material.SetColor("_EmissiveColor", (Color)emissiveColour); } clip.frames = frames.ToArray(); clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); SpriteAnimatorKiller kill = animator.gameObject.AddComponent <SpriteAnimatorKiller>(); kill.fadeTime = -1f; kill.animator = animator; kill.delayDestructionTime = -1f; animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("start"); vfObj.attached = true; vfObj.persistsOnDeath = false; vfObj.usesZHeight = usesZHeight; vfObj.zHeight = zHeightOffset; vfObj.alignment = VFXAlignment.NormalAligned; vfObj.destructible = false; vfObj.effect = Obj; return(Obj); }
private static GameObject SetupTackShooter() { //Make Tack Projectile projectile = UnityEngine.Object.Instantiate <Projectile>((PickupObjectDatabase.GetById(26) as Gun).DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); projectile.baseData.damage = 8f; projectile.baseData.range = 5f; projectile.hitEffects.overrideMidairDeathVFX = (PickupObjectDatabase.GetById(28) as Gun).DefaultModule.projectiles[0].hitEffects.tileMapVertical.effects[0].effects[0].effect; //Setup the Tack Shooter Object GameObject prefab = CompanionBuilder.BuildPrefab("Tack Shooter", "Tack_Shooter_GUID", TackShooter.RegTackShooterSprites[0], new IntVector2(6, 2), new IntVector2(7, 14));//SpriteBuilder.SpriteFromResource("Planetside/Resources2/testturret/testturret_idle_001"); prefab.name = "Tack Shooter"; var body = prefab.GetComponent <tk2dSprite>().SetUpSpeculativeRigidbody(new IntVector2(6, 2), new IntVector2(7, 14)); TackShooterBehaviour shooter = prefab.AddComponent <TackShooterBehaviour>(); shooter.ProjectileToShoot = projectile; AIAnimator aiAnimator = prefab.GetOrAddComponent <AIAnimator>(); aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.Single, Flipped = new DirectionalAnimation.FlipType[1], Prefix = "idle", AnimNames = new string[] { "idle" } }; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { //Spawn new AIAnimator.NamedDirectionalAnimation { name = "appear", anim = new DirectionalAnimation { Prefix = "appear", Type = DirectionalAnimation.DirectionType.Single, Flipped = new DirectionalAnimation.FlipType[1], AnimNames = new string[] { "appear" } } }, //Shoot new AIAnimator.NamedDirectionalAnimation { name = "shoot", anim = new DirectionalAnimation { Prefix = "shoot", Type = DirectionalAnimation.DirectionType.Single, Flipped = new DirectionalAnimation.FlipType[1], AnimNames = new string[] { "shoot" } } }, }; tk2dSpriteAnimator spriteAnimator = prefab.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteCollectionData tackShooterCollection = SpriteBuilder.ConstructCollection(prefab, "TackShooterCollection"); UnityEngine.Object.DontDestroyOnLoad(tackShooterCollection); for (int i = 0; i < RegTackShooterSprites.Length; i++) { SpriteBuilder.AddSpriteToCollection(RegTackShooterSprites[i], tackShooterCollection); } SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> { 0 }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 12; SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> { 1, 2 }, "shoot", tk2dSpriteAnimationClip.WrapMode.Once).fps = 12; SpriteBuilder.AddAnimation(spriteAnimator, tackShooterCollection, new List <int> { 3, 4, 5, 6, 7 }, "appear", tk2dSpriteAnimationClip.WrapMode.Once).fps = 12; body.PixelColliders.Clear(); body.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.PlayerHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 6, ManualOffsetY = 2, ManualWidth = 7, ManualHeight = 14, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); body.CollideWithOthers = false; prefab.SetActive(false); FakePrefab.MarkAsFakePrefab(prefab); UnityEngine.Object.DontDestroyOnLoad(prefab); return(prefab); }
public static void BuildPrefab() { // source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93"); bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = EnemyBuilder.BuildPrefab("RoyalJesterlet", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false); var companion = prefab.AddComponent <EnemyBehavior>(); companion.aiActor.knockbackDoer.weight = 200; companion.aiActor.MovementSpeed = 2f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = true; companion.aiActor.healthHaver.ForceSetCurrentHealth(25f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.CanTargetPlayers = true; companion.aiActor.healthHaver.SetHealthMaximum(25f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 12, ManualHeight = 26, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 12, ManualHeight = 26, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle", "idle_two" } }; bool flag3 = RoyalJesterletCollection == null; if (flag3) { RoyalJesterletCollection = SpriteBuilder.ConstructCollection(prefab, "RoyalJesterlet_Collection"); UnityEngine.Object.DontDestroyOnLoad(RoyalJesterletCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], RoyalJesterletCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, RoyalJesterletCollection, new List <int> { 0, 1, }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, RoyalJesterletCollection, new List <int> { 2, 3 }, "idle_two", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f; } var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; shootpoint = new GameObject("f**k"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = companion.sprite.WorldCenter; GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; Game.Enemies.Add("cak:royal_jestlet", companion.aiActor); } }
public static GameObject BuildPrefab() { var bomb = SpriteBuilder.SpriteFromResource("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_001.png", new GameObject("DiceBomb")); bomb.SetActive(false); FakePrefab.MarkAsFakePrefab(bomb); var animator = bomb.AddComponent <tk2dSpriteAnimator>(); var collection = (PickupObjectDatabase.GetById(108) as SpawnObjectPlayerItem).objectToSpawn.GetComponent <tk2dSpriteAnimator>().Library.clips[0].frames[0].spriteCollection; //DEPLOYMENT var deployAnimation = SpriteBuilder.AddAnimation(animator, collection, new List <int> { SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_001.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_002.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_003.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_004.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_005.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_006.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_007.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_008.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_009.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_throw_010.png", collection), }, "dicebomb_thrown", tk2dSpriteAnimationClip.WrapMode.Once); deployAnimation.fps = 20; //Dice bomb takes 1 second to explode, so I set this to double the amount of frames in the animation to make sure this animation takes half the time to play. foreach (var frame in deployAnimation.frames) { frame.eventLerpEmissiveTime = 0.5f; frame.eventLerpEmissivePower = 30f; } var explodeAnimation = SpriteBuilder.AddAnimation(animator, collection, new List <int> { SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_explode_001.png", collection), }, "dicebomb_explode", tk2dSpriteAnimationClip.WrapMode.Once); explodeAnimation.fps = 16; foreach (var frame in explodeAnimation.frames) { frame.eventLerpEmissiveTime = 0.5f; frame.eventLerpEmissivePower = 30f; } var armedAnimation = SpriteBuilder.AddAnimation(animator, collection, new List <int> { SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_001.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_002.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_003.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_004.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_005.png", collection), SpriteBuilder.AddSpriteToCollection("NevernamedsItems/Resources/ThrowableActives/dicegrenade_primed_006.png", collection), }, "dicebomb_primed", tk2dSpriteAnimationClip.WrapMode.LoopSection); armedAnimation.fps = 12f; armedAnimation.loopStart = 4; foreach (var frame in armedAnimation.frames) { frame.eventLerpEmissiveTime = 0.5f; frame.eventLerpEmissivePower = 30f; } CustomThrowableObject throwable = new CustomThrowableObject { OnThrownAnimation = "dicebomb_thrown", DefaultAnim = "dicebomb_primed", OnEffectAnim = "dicebomb_explode", thrownSoundEffect = "Play_OBJ_item_throw_01", destroyOnHitGround = false, doEffectOnHitGround = false, doEffectAfterTime = true, timeTillEffect = 1f }; bomb.AddComponent <CustomThrowableObject>(throwable); bomb.AddComponent <DiceGrenadeEffect>(); return(bomb); }
public static void BuildPrefab() { if (!(prefab != null || AdvEnemyBuilder.Dictionary.ContainsKey(guid))) { prefab = AdvEnemyBuilder.BuildPrefab("Test Enemy", guid, spritePaths[0], new IntVector2(14, 5), new IntVector2(5, 5), false); var companion = prefab.AddComponent <EnemyBehavior>(); //Actor Variables companion.aiActor.MovementSpeed = 7f; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = true; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.CanTargetPlayers = true; companion.aiActor.CanTargetEnemies = false; companion.aiActor.PreventFallingInPitsEver = false; companion.aiActor.CollisionKnockbackStrength = 10f; companion.aiActor.procedurallyOutlined = true; companion.aiActor.PreventBlackPhantom = false; //Body Variables companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; //Health Variables companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.healthHaver.SetHealthMaximum(15f, null, false); companion.aiActor.healthHaver.ForceSetCurrentHealth(15f); //Other Variables companion.aiActor.knockbackDoer.weight = 10f; //AnimatorVariables companion.aiAnimator.HitReactChance = 1f; companion.aiAnimator.faceSouthWhenStopped = false; companion.aiAnimator.faceTargetWhenStopped = true; companion.aiActor.SetIsFlying(true, "Flying Entity"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_NAME_SMALL", "Test Enemy"); companion.aiActor.OverrideDisplayName = "#TEST_ENEMY_NAME_SMALL"; companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.gameObject.AddComponent <tk2dSpriteAttachPoint>(); companion.aiActor.gameObject.AddComponent <ObjectVisibilityManager>(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 14, ManualOffsetY = 5, ManualWidth = 5, ManualHeight = 5, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 14, ManualOffsetY = 5, ManualWidth = 5, ManualHeight = 5, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "idle_right", "idle_left", } }; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "move_right", "move_left", } }; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "sex", anim = new DirectionalAnimation { Prefix = "sex", Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[0], AnimNames = new string[] { "sex_right", "sex_left", } } }, }; if (TestEnemyCollection == null) { TestEnemyCollection = SpriteBuilder.ConstructCollection(prefab, "TestEnemyCollection"); UnityEngine.Object.DontDestroyOnLoad(TestEnemyCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], TestEnemyCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 0, 1, 2, 3, }, "idle_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15 ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 4, 5, 6, 7, }, "idle_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15 ; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 8, 9, 10, 11, }, "move_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 12, 13, 14, 15, }, "move_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 15; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 16, 17, 18, }, "sex_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20; SpriteBuilder.AddAnimation(companion.spriteAnimator, TestEnemyCollection, new List <int> { 19, 20, 21, }, "sex_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 20; } var bs = prefab.GetComponent <BehaviorSpeculator>(); prefab.GetComponent <ObjectVisibilityManager>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; //ATTACK BEHAVIOUR SETUP (Must be done BY HAND) shootpoint = new GameObject("f**k"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = (companion.sprite.WorldCenter + new Vector2(0, 0)); GameObject m_CachedGunAttachPoint = companion.transform.Find("f**k").gameObject; bs.TargetBehaviors = new List <TargetBehaviorBase> { //Add your target behaviours here! new TargetPlayerBehavior { Radius = 1000, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f, }, }; bs.MovementBehaviors = new List <MovementBehaviorBase>() //Add your movement behaviours here! { new SeekTargetBehavior() { StopWhenInRange = true, CustomRange = 5, LineOfSight = false, ReturnToSpawn = true, SpawnTetherDistance = -1, PathInterval = 0.25f, SpecifyRange = false, MinActiveRange = 0, MaxActiveRange = 0 }, }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { //Attack behaviours must be added here MANUALLY }; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; if (companion.GetComponent <EncounterTrackable>() != null) { UnityEngine.Object.Destroy(companion.GetComponent <EncounterTrackable>()); } Game.Enemies.Add("nn:Test_Enemy".ToLower(), companion.aiActor); SpriteBuilder.AddSpriteToCollection("AmmonomiconSprite", AdvEnemyBuilder.ammonomiconCollection); companion.encounterTrackable = companion.gameObject.AddComponent <EncounterTrackable>(); companion.encounterTrackable.journalData = new JournalEntry(); companion.encounterTrackable.EncounterGuid = "nn:Test Enemy".ToLower(); companion.encounterTrackable.prerequisites = new DungeonPrerequisite[0]; companion.encounterTrackable.journalData.SuppressKnownState = false; companion.encounterTrackable.journalData.IsEnemy = true; companion.encounterTrackable.journalData.SuppressInAmmonomicon = false; companion.encounterTrackable.ProxyEncounterGuid = ""; companion.encounterTrackable.journalData.AmmonomiconSprite = "Bingly Bungly Boo"; companion.encounterTrackable.journalData.enemyPortraitSprite = ItemAPI.ResourceExtractor.GetTextureFromResource("Bungle Bish bash bosh"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY", "Test Enemy"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_SHORTDESC", "Quote"); AdvEnemyBuilder.Strings.Enemies.Set("#TEST_ENEMY_LONGDESC", "Description"); companion.encounterTrackable.journalData.PrimaryDisplayName = "#TEST_ENEMY"; companion.encounterTrackable.journalData.NotificationPanelDescription = "#TEST_ENEMY_SHORTDESC"; companion.encounterTrackable.journalData.AmmonomiconFullEntry = "#TEST_ENEMY_LONGDESC"; AdvEnemyBuilder.AddEnemyToDatabase(companion.gameObject, "nn:Test_Enemy".ToLower()); EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).ForcedPositionInAmmonomicon = 15; EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isInBossTab = false; EnemyDatabase.GetEntry("nn:Test_Enemy".ToLower()).isNormalEnemy = true; } }
public static void BuildPrefab() { bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); prefab = EnemyBuilder.BuildPrefab("fancykin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true); var companion = prefab.AddComponent <EnemyBehavior>();; companion.aiActor.knockbackDoer.weight = 800; companion.aiActor.MovementSpeed = 2f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = false; companion.aiActor.healthHaver.ForceSetCurrentHealth(30f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.CanTargetPlayers = true; companion.aiActor.healthHaver.SetHealthMaximum(55f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "die", anim = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "die_right", "die_left" } } } }; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle_front_right", "idle_front_left", "idle_back_right", "idle_back_left" } }; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.FourWay, Flipped = new DirectionalAnimation.FlipType[4], AnimNames = new string[] { "run_back_right", "run_front_right", "run_front_left", "run_back_left", } }; bool flag3 = fancykinCollection == null; if (flag3) { fancykinCollection = SpriteBuilder.ConstructCollection(prefab, "fancykin_Collection"); UnityEngine.Object.DontDestroyOnLoad(fancykinCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], fancykinCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 0, }, "idle_back_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 1, }, "idle_back_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 2, }, "idle_front_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 3, }, "idle_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 4, 5, 6, 7, 8, 9 }, "run_back_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 10, 11, 12, 13, 14, 15 }, "run_back_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 16, 17, 18, 19, 20, 21 }, "run_front_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f; SpriteBuilder.AddAnimation(companion.spriteAnimator, fancykinCollection, new List <int> { 22, 23, 24, 25, 26, 27 }, "run_front_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f; } var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(fancykinScript)), FixTargetDuringAttack = true, StopDuringAttack = true, LeadAmount = 0, LeadChance = 1, RespectReload = true, MagazineCapacity = 3, ReloadSpeed = 5f, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = -1, PreventTargetSwitching = true, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.6f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = true, MaxUsages = 0, } }; bs.MovementBehaviors = new List <MovementBehaviorBase> { new SeekTargetBehavior { StopWhenInRange = true, CustomRange = 7f, LineOfSight = false, ReturnToSpawn = false, SpawnTetherDistance = 0f, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 0f, MaxActiveRange = 0f } }; BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("206405acad4d4c33aac6717d184dc8d4").behaviorSpeculator; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject; Vector2 offset = new Vector2(1.5f, -0.50f); m_CachedGunAttachPoint.transform.position = companion.sprite.WorldCenter + offset; EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), 476, m_CachedGunAttachPoint.transform); Game.Enemies.Add("cak:fancykin", companion.aiActor); } }
/// <summary> /// Adds a tiled trail to the Projectile /// </summary> /// <param name="timeTillAnimStart">How long after spawning until the trail will begin to play it's animation, if it has one.</param> public static void AddTrailToProjectile(this Projectile target, string spritePath, Vector2 colliderDimensions, Vector2 colliderOffsets, List <string> animPaths = null, int animFPS = -1, List <string> startAnimPaths = null, int startAnimFPS = -1, float timeTillAnimStart = -1, float cascadeTimer = -1, float softMaxLength = -1, bool destroyOnEmpty = false) { try { GameObject newTrailObject = new GameObject(); newTrailObject.InstantiateAndFakeprefab(); newTrailObject.transform.parent = target.transform; float convertedColliderX = colliderDimensions.x / 16f; float convertedColliderY = colliderDimensions.y / 16f; float convertedOffsetX = colliderOffsets.x / 16f; float convertedOffsetY = colliderOffsets.y / 16f; int spriteID = SpriteBuilder.AddSpriteToCollection(spritePath, ETGMod.Databases.Items.ProjectileCollection); tk2dTiledSprite tiledSprite = newTrailObject.GetOrAddComponent <tk2dTiledSprite>(); tiledSprite.SetSprite(ETGMod.Databases.Items.ProjectileCollection, spriteID); tk2dSpriteDefinition def = tiledSprite.GetCurrentSpriteDef(); def.colliderVertices = new Vector3[] { new Vector3(convertedOffsetX, convertedOffsetY, 0f), new Vector3(convertedColliderX, convertedColliderY, 0f) }; def.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.MiddleLeft); tk2dSpriteAnimator animator = newTrailObject.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimation animation = newTrailObject.GetOrAddComponent <tk2dSpriteAnimation>(); animation.clips = new tk2dSpriteAnimationClip[0]; animator.Library = animation; TrailController trail = newTrailObject.AddComponent <TrailController>(); //---------------- Sets up the animation for the main part of the trail if (animPaths != null) { BeamToolbox.SetupBeamPart(animation, animPaths, "trail_mid", animFPS, null, null, def.colliderVertices); trail.animation = "trail_mid"; trail.usesAnimation = true; } else { trail.usesAnimation = false; } if (startAnimPaths != null) { BeamToolbox.SetupBeamPart(animation, startAnimPaths, "trail_start", startAnimFPS, null, null, def.colliderVertices); trail.startAnimation = "trail_start"; trail.usesStartAnimation = true; } else { trail.usesStartAnimation = false; } //Trail Variables if (softMaxLength > 0) { trail.usesSoftMaxLength = true; trail.softMaxLength = softMaxLength; } if (cascadeTimer > 0) { trail.usesCascadeTimer = true; trail.cascadeTimer = cascadeTimer; } if (timeTillAnimStart > 0) { trail.usesGlobalTimer = true; trail.globalTimer = timeTillAnimStart; } trail.destroyOnEmpty = destroyOnEmpty; } catch (Exception e) { ETGModConsole.Log(e.ToString()); } }
public static void BuildPrefab() { // source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93"); bool flag = prefab != null || BossBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = BossBuilder.BuildPrefab("Kill Shrine", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), false, true); var companion = prefab.AddComponent <EnemyBehavior23>(); companion.aiActor.knockbackDoer.weight = 200; companion.aiActor.MovementSpeed = 6f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = true; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0.05f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = true; companion.aiActor.healthHaver.ForceSetCurrentHealth(500f); companion.aiActor.healthHaver.SetHealthMaximum(500f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.procedurallyOutlined = true; companion.aiActor.CanTargetPlayers = true; ItemsMod.Strings.Enemies.Set("#KILLSHRINE", "Sepulchergiest"); ItemsMod.Strings.Enemies.Set("#????", "???"); ItemsMod.Strings.Enemies.Set("#KILLSHRINESUBTITLE", "KILL SHRINE"); ItemsMod.Strings.Enemies.Set("#KILLSHRINEQUOTE", "THE SHRINING"); companion.aiActor.healthHaver.overrideBossName = "#KILLSHRINE"; companion.aiActor.OverrideDisplayName = "#KILLSHRINE"; companion.aiActor.ActorName = "#KILLSHRINE"; companion.aiActor.name = "#KILLSHRINE"; companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true); prefab.name = companion.aiActor.OverrideDisplayName; GenericIntroDoer miniBossIntroDoer = prefab.AddComponent <GenericIntroDoer>(); miniBossIntroDoer.triggerType = GenericIntroDoer.TriggerType.PlayerEnteredRoom; miniBossIntroDoer.initialDelay = 0.15f; miniBossIntroDoer.cameraMoveSpeed = 14; miniBossIntroDoer.specifyIntroAiAnimator = null; miniBossIntroDoer.BossMusicEvent = "Play_MUS_Boss_Theme_Beholster"; companion.aiActor.ShadowObject = EnemyDatabase.GetOrLoadByGuid("c00390483f394a849c36143eb878998f").ShadowObject; companion.aiActor.HasShadow = true; miniBossIntroDoer.PreventBossMusic = false; miniBossIntroDoer.InvisibleBeforeIntroAnim = false; miniBossIntroDoer.preIntroAnim = string.Empty; miniBossIntroDoer.preIntroDirectionalAnim = string.Empty; miniBossIntroDoer.introAnim = "intro"; miniBossIntroDoer.introDirectionalAnim = string.Empty; miniBossIntroDoer.continueAnimDuringOutro = false; miniBossIntroDoer.cameraFocus = null; miniBossIntroDoer.roomPositionCameraFocus = Vector2.zero; miniBossIntroDoer.restrictPlayerMotionToRoom = false; miniBossIntroDoer.fusebombLock = false; miniBossIntroDoer.AdditionalHeightOffset = 0; miniBossIntroDoer.portraitSlideSettings = new PortraitSlideSettings() { bossNameString = "#KILLSHRINE", bossSubtitleString = "#KILLSHRINESUBTITLE", bossQuoteString = "#KILLSHRINEQUOTE", bossSpritePxOffset = IntVector2.Zero, topLeftTextPxOffset = IntVector2.Zero, bottomRightTextPxOffset = IntVector2.Zero, bgColor = Color.cyan }; miniBossIntroDoer.SkipBossCard = false; miniBossIntroDoer.portraitSlideSettings.bossArtSprite = BossCardTexture; companion.aiActor.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar; miniBossIntroDoer.SkipFinalizeAnimation = true; miniBossIntroDoer.RegenerateCache(); //BehaviorSpeculator aIActor = EnemyDatabase.GetOrLoadByGuid("465da2bb086a4a88a803f79fe3a27677").behaviorSpeculator; //Tools.DebugInformation(aIActor); ///// companion.aiActor.healthHaver.SetHealthMaximum(500f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 15, ManualOffsetY = 10, ManualWidth = 60, ManualHeight = 80, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 15, ManualOffsetY = 10, ManualWidth = 60, ManualHeight = 80, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("c0ff3744760c4a2eb0bb52ac162056e6").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.Single, Prefix = "idle", AnimNames = new string[1], Flipped = new DirectionalAnimation.FlipType[1] }; DirectionalAnimation almostdone = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.Single, Prefix = "intro", AnimNames = new string[1], Flipped = new DirectionalAnimation.FlipType[1] }; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "intro", anim = almostdone } }; bool flag3 = BishopCollection == null; if (flag3) { BishopCollection = SpriteBuilder.ConstructCollection(prefab, "FlameChamber_Collection"); UnityEngine.Object.DontDestroyOnLoad(BishopCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], BishopCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, BishopCollection, new List <int> { 0, 1 }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 7f; SpriteBuilder.AddAnimation(companion.spriteAnimator, BishopCollection, new List <int> { 2, 3, 4, 5, 6, 7, 8 }, "intro", tk2dSpriteAnimationClip.WrapMode.Once).fps = 7f; } var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; shootpoint = new GameObject("attach"); shootpoint.transform.parent = companion.transform; shootpoint.transform.position = companion.sprite.WorldCenter; GameObject m_CachedGunAttachPoint = companion.transform.Find("attach").gameObject; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; float[] angles = { 45, 135, 225, 135 }; bs.MovementBehaviors = new List <MovementBehaviorBase> { }; bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem> { }; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; Game.Enemies.Add("cak:killshrine", companion.aiActor); } }
private static void BuildLibrary(LichsBookItem targetBook) { List <string> spriteNames = new List <string>(); string[] resources = ResourceExtractor.GetResourceNames(); string spriteDirectory = "LichItems/Resources/InfinilichTransformation"; for (int i = 0; i < resources.Length; i++) { if (resources[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase)) { spriteNames.Add(resources[i]); } } List <Texture2D> sprites = new List <Texture2D>(); foreach (string name in spriteNames) { sprites.Add(ResourceExtractor.GetTextureFromResource(name)); } tk2dSpriteAnimation library = Instantiate((PickupObjectDatabase.GetById(163) as BulletArmorItem).knightLibrary); DontDestroyOnLoad(library); var orig = library.clips[0].frames[0].spriteCollection; var copyCollection = Instantiate(orig); tk2dSpriteDefinition copydef = CopyDefinitionFrom((PickupObjectDatabase.GetById(607) as BankMaskItem).OverrideHandSprite.GetCurrentSpriteDef()); copydef.name = "knight_hand_001"; int handId = SpriteBuilder.AddSpriteToCollection(copydef, copyCollection); DontDestroyOnLoad(copyCollection); RuntimeAtlasPage page = new RuntimeAtlasPage(); for (int i = 0; i < sprites.Count; i++) { var tex = sprites[i]; var def = copyCollection.GetSpriteDefinition(tex.name); if (def != null) { def.ReplaceTexture(tex); def.name = def.name.Replace("knight", "inflich"); MakeOffset(def, new Vector2(-0.0625f, 0f), false); } } page.Apply(); foreach (var clip in library.clips) { for (int i = 0; i < clip.frames.Length; i++) { clip.frames[i].spriteCollection = copyCollection; } } foreach (tk2dSpriteAnimationClip clip in library.clips) { foreach (tk2dSpriteAnimationFrame frame in clip.frames) { if (!string.IsNullOrEmpty(frame.eventAudio) && (frame.eventAudio == "Play_FS" || frame.eventAudio == "Play_CHR_boot_stairs_01")) { frame.eventAudio = ""; } } } GameObject spriteObj = new GameObject("OverrideHandSprite"); spriteObj.SetActive(false); DontDestroyOnLoad(spriteObj); tk2dSprite sprite = spriteObj.AddComponent <tk2dSprite>(); sprite.SetSprite(copyCollection, handId); targetBook.replacementHandSprite = sprite; targetBook.replacementLibrary = library; }
public static void SetupHatSprites(List <string> spritePaths, GameObject hatObj, int fps, Vector2 hatSize) { Hat hatness = hatObj.GetComponent <Hat>(); if (hatness) { string collectionName = hatness.hatName; collectionName = collectionName.Replace(" ", "_"); tk2dSpriteCollectionData HatSpriteCollection = SpriteBuilder.ConstructCollection(hatObj, (collectionName + "_Collection")); int spriteID = SpriteBuilder.AddSpriteToCollection(spritePaths[0], HatSpriteCollection); tk2dSprite hatBaseSprite = hatObj.GetOrAddComponent <tk2dSprite>(); hatBaseSprite.SetSprite(HatSpriteCollection, spriteID); tk2dSpriteDefinition def = hatBaseSprite.GetCurrentSpriteDef(); def.colliderVertices = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3((hatSize.x / 16), (hatSize.y / 16), 0f) }; hatBaseSprite.PlaceAtPositionByAnchor(hatObj.transform.position, tk2dBaseSprite.Anchor.LowerCenter); hatBaseSprite.depthUsesTrimmedBounds = true; hatBaseSprite.IsPerpendicular = true; hatBaseSprite.UpdateZDepth(); hatBaseSprite.HeightOffGround = 0.2f; List <string> SouthAnimation = new List <string>(); List <string> NorthAnimation = new List <string>(); List <string> EastAnimation = new List <string>(); List <string> WestAnimation = new List <string>(); List <string> NorthWestAnimation = new List <string>(); List <string> NorthEastAnimation = new List <string>(); List <string> SouthEastAnimation = new List <string>(); List <string> SouthWestAnimation = new List <string>(); switch (hatness.hatDirectionality) { case Hat.HatDirectionality.EIGHTWAY: foreach (string path in spritePaths) { if (path.ToLower().Contains("_north_")) { NorthAnimation.Add(path); } if (path.ToLower().Contains("_south_")) { SouthAnimation.Add(path); } if (path.ToLower().Contains("_west_")) { WestAnimation.Add(path); } if (path.ToLower().Contains("_east_")) { EastAnimation.Add(path); } if (path.ToLower().Contains("_northwest_")) { NorthWestAnimation.Add(path); } if (path.ToLower().Contains("_northeast_")) { NorthEastAnimation.Add(path); } if (path.ToLower().Contains("_southwest_")) { SouthWestAnimation.Add(path); } if (path.ToLower().Contains("_southeast_")) { SouthEastAnimation.Add(path); } } break; case Hat.HatDirectionality.SIXWAY: foreach (string path in spritePaths) { if (path.ToLower().Contains("_north_")) { NorthAnimation.Add(path); } if (path.ToLower().Contains("_south_")) { SouthAnimation.Add(path); } if (path.ToLower().Contains("_west_")) { WestAnimation.Add(path); } if (path.ToLower().Contains("_east_")) { EastAnimation.Add(path); } if (path.ToLower().Contains("_northwest_")) { NorthWestAnimation.Add(path); } if (path.ToLower().Contains("_northeast_")) { NorthEastAnimation.Add(path); } } break; case Hat.HatDirectionality.FOURWAY: foreach (string path in spritePaths) { if (path.ToLower().Contains("_west_")) { WestAnimation.Add(path); } if (path.ToLower().Contains("_east_")) { EastAnimation.Add(path); } if (path.ToLower().Contains("_north_")) { NorthAnimation.Add(path); } if (path.ToLower().Contains("_south_")) { SouthAnimation.Add(path); } } break; case Hat.HatDirectionality.TWOWAYHORIZONTAL: foreach (string path in spritePaths) { if (path.ToLower().Contains("_west_")) { WestAnimation.Add(path); } if (path.ToLower().Contains("_east_")) { EastAnimation.Add(path); } } break; case Hat.HatDirectionality.TWOWAYVERTICAL: foreach (string path in spritePaths) { if (path.ToLower().Contains("_north_")) { NorthAnimation.Add(path); } if (path.ToLower().Contains("_south_")) { SouthAnimation.Add(path); } } break; case Hat.HatDirectionality.NONE: foreach (string path in spritePaths) { if (path.ToLower().Contains("_south_")) { SouthAnimation.Add(path); } } break; } //SET UP THE ANIMATOR AND THE ANIMATION tk2dSpriteAnimator animator = hatObj.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimation animation = hatObj.GetOrAddComponent <tk2dSpriteAnimation>(); animation.clips = new tk2dSpriteAnimationClip[0]; animator.Library = animation; //SOUTH ANIMATION if (SouthAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_south", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in SouthAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //NORTH ANIMATIONS if (NorthAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_north", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in NorthAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //WEST ANIMATIONS if (WestAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_west", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in WestAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //EAST ANIMATIONS if (EastAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_east", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in EastAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //NORTHEAST if (NorthEastAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_northeast", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in NorthEastAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //NORTHWEST ANIMATION if (NorthWestAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_northwest", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in NorthWestAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //SOUTHWEST ANIMATION if (SouthWestAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_southwest", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in SouthWestAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } //SOUTHEAST ANIMATION if (SouthEastAnimation != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "hat_southeast", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in SouthEastAnimation) { tk2dSpriteCollectionData collection = HatSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.colliderVertices = def.colliderVertices; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter); frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); } } }