public void CopyFrom(tk2dSpriteAnimationFrame source, bool full)
	{
		spriteCollection = source.spriteCollection;
		spriteId = source.spriteId;
		
		if (full) CopyTriggerFrom(source);
	}
 public void CopyTriggerFrom(tk2dSpriteAnimationFrame source)
 {
     this.triggerEvent = source.triggerEvent;
     this.eventInfo = source.eventInfo;
     this.eventInt = source.eventInt;
     this.eventFloat = source.eventFloat;
 }
 void AnimationEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     Fsm.EventData.IntData = frame.eventInt;
     Fsm.EventData.StringData = frame.eventInfo;
     Fsm.EventData.FloatData = frame.eventFloat;
     Fsm.Event(animationTriggerEvent);
 }
Пример #4
0
    void FrameDeploymentTrigger(tk2dAnimatedSprite sprite, 
		tk2dSpriteAnimationClip clip, 
		tk2dSpriteAnimationFrame frame, 
		int frameNum)
    {
        //Debug.Log("MinigunBoxController:FrameDeploymentTrigger()");

        DeployGun();
    }
Пример #5
0
    public void CopyFrom(tk2dSpriteAnimationFrame source)
    {
        spriteCollection = source.spriteCollection;
        spriteId = source.spriteId;

        triggerEvent = source.triggerEvent;
        eventInfo = source.eventInfo;
        eventInt = source.eventInt;
        eventFloat = source.eventFloat;
    }
Пример #6
0
 void HandleAnimationEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     // Call FrameActionHandlers
     frame.eventInfo.Split(new []{","},System.StringSplitOptions.RemoveEmptyEntries).ToList()
         .ForEach(
             (x) => {
                 frameActions[x](x,frame.eventFloat,frame.eventInt);
             }
         );
 }
		public static ClipEditor.FrameGroup NewFrameGroup(List<ClipEditor.FrameGroup> frameGroups, int selectedFrameGroup)
		{
			ClipEditor.FrameGroup src = frameGroups[selectedFrameGroup];
			ClipEditor.FrameGroup fg = new ClipEditor.FrameGroup();
			fg.spriteCollection = src.spriteCollection;
			fg.spriteId = src.spriteId;
			tk2dSpriteAnimationFrame f = new tk2dSpriteAnimationFrame();
			f.spriteCollection = fg.spriteCollection;
			f.spriteId = fg.spriteId;
			fg.frames.Add(f);
			return fg;
		}
Пример #8
0
        private void AnimationEventDelegate(tk2dSpriteAnimator anim, tk2dSpriteAnimationClip clip, int frameNum)
        {
            if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Loop && clip.name != _storedClip ||
                clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection && clip.name != _storedClip ||
                clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Once)
            {
                _storedClip = clip.name;
                tk2dSpriteAnimationFrame frame = clip.GetFrame(frameNum);

                string clipName = frame.eventInfo;
                foreach (byte player in SessionManager.Instance.Players.Keys)
                {
                    ClientSend.EnemyAnimation(player, clipName, enemyId);
                }
            }
        }
    // Warps the current active frame to the local time (i.e. float frame number) specified.
    // Ensure that time doesn't exceed the number of frames. Will warp silently otherwise
    void WarpClipToLocalTime(tk2dSpriteAnimationClip clip, float time)
    {
        clipTime = time;
        int frameId = (int)clipTime % clip.frames.Length;
        tk2dSpriteAnimationFrame frame = clip.frames[frameId];

        SwitchCollectionAndSprite(frame.spriteCollection, frame.spriteId);
        if (frame.triggerEvent)
        {
            if (animationEventDelegate != null)
            {
                animationEventDelegate(this, clip, frame, frameId);
            }
        }
        previousFrame = frameId;
    }
        // Internal set clip, reset all
        void SetClip(tk2dSpriteAnimationClip clip)
        {
            if (this.clip != clip)
            {
                // reset stuff
                this.clip = clip;

                timelineEditor.Reset();

                if (!repeatPlayAnimation)
                {
                    playAnimation = false;
                }
                this.Sprite.Stop();

                // build frame groups
                if (clip != null)
                {
                    frameGroups.Clear();
                    tk2dSpriteCollectionData lastSc = null;
                    int        lastSpriteId         = -1;
                    FrameGroup frameGroup           = null;
                    for (int i = 0; i < clip.frames.Length; ++i)
                    {
                        tk2dSpriteAnimationFrame f = clip.frames[i];
                        if (f.spriteCollection != lastSc || f.spriteId != lastSpriteId)
                        {
                            if (frameGroup != null)
                            {
                                frameGroups.Add(frameGroup);
                            }
                            frameGroup = new FrameGroup();
                            frameGroup.spriteCollection = f.spriteCollection;
                            frameGroup.spriteId         = f.spriteId;
                        }
                        lastSc       = f.spriteCollection;
                        lastSpriteId = f.spriteId;
                        frameGroup.frames.Add(f);
                    }
                    if (frameGroup != null)
                    {
                        frameGroups.Add(frameGroup);
                    }
                }
            }
        }
Пример #11
0
        private void AnimationEventDelegate(tk2dSpriteAnimator anim, tk2dSpriteAnimationClip clip, int frameNum)
        {
            if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Loop && clip.name != _storedClip ||
                clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection && clip.name != _storedClip ||
                clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Once)
            {
                _storedClip = clip.name;
                tk2dSpriteAnimationFrame frame = clip.GetFrame(frameNum);

                string clipName = frame.eventInfo;
                //ServerSend.EnemyAnimation(clipName);
                foreach (byte player in playerIds)
                {
                    ServerSend.EnemyAnimation(player, clipName, enemyId);
                }
            }
        }
Пример #12
0
        private static tk2dSpriteAnimationFrame[] ConstructFrames(YAML.Animation mapping, GameObject go, YAML.Clip clip)
        {
            var frames = new List <tk2dSpriteAnimationFrame>();

            var collection = ConstructCollection(mapping, go, Resources.Load <Texture2D>(mapping.Spritesheet));

            for (int i = 0; i < clip.Frames.Count; i++)
            {
                var mframe = clip.Frames[i];

                var frame = new tk2dSpriteAnimationFrame {
                    spriteCollection = collection,
                    spriteId         = mframe.SpriteDefinitionId,
                };
            }

            return(frames.ToArray());
        }
Пример #13
0
 public void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     if (frame.eventInfo.ToLower() == "beginTravel".ToLower())
     {
         canTravel = true;
         tk2dSpriteAnimationClip travelClip = sprite.anim.clips[sprite.anim.GetClipIdByName("travel")];
         timer = (float)travelClip.frames.GetLength(0) / travelClip.fps;
         sprite.Play("travel");
     }
     else if (frame.eventInfo.ToLower() == "die".ToLower())
     {
         if (onDie != null)
         {
             onDie();
         }
         GameObject.Destroy(gameObject);
     }
 }
Пример #14
0
        private void OnAnimationEventTriggered(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex)
        {
            animator.AnimationEventTriggered -= OnAnimationEventTriggered;

            tk2dSpriteAnimationFrame frame = clip.GetFrame(frameIndex);

            if (frame.eventInfo == AnimationTriggerDefs.SkillApply.ToString())
            {
                skillUIElement.Apply(owner, data, targetPosition);
                skillUIElement.OnHit = () =>
                {
                    Cleaving(skillUIElement, 1);

                    skillUIElement = null;

                    Destroy(this);
                };
            }
        }
Пример #15
0
            public int startFrame = 0;             // this is a cache value used during the draw loop

            public bool SetFrameCount(int targetFrameCount)
            {
                bool changed = false;

                if (frames.Count > targetFrameCount)
                {
                    frames.RemoveRange(targetFrameCount, frames.Count - targetFrameCount);
                    changed = true;
                }
                while (frames.Count < targetFrameCount)
                {
                    tk2dSpriteAnimationFrame f = new tk2dSpriteAnimationFrame();
                    f.spriteCollection = spriteCollection;
                    f.spriteId         = spriteId;
                    frames.Add(f);
                    changed = true;
                }
                return(changed);
            }
Пример #16
0
        private void OnAnimationEventTriggered(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex)
        {
            animator.AnimationEventTriggered -= OnAnimationEventTriggered;

            tk2dSpriteAnimationFrame frame = clip.GetFrame(frameIndex);

            if (frame.eventInfo == AnimationTriggerDefs.SkillApply.ToString())
            {
                Vector3 startPoint = this.skillUIElement.transform.position;

                float degree = Mathf.Atan2(targetPosition.y - startPoint.y, targetPosition.x - startPoint.x) * Mathf.Rad2Deg;

                float angle = degree * Mathf.Deg2Rad;

                this.skillUIElement.Apply(owner, data, angle);

                for (int index = 0; index < shotAmount; index++)
                {
                    SkillUI skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID);
                    skillUIElement.transform.SetParent(owner.componentsHolder.transform);
                    skillUIElement.IgnoreCollisionMap(true);
                    skillUIElement.transform.position   = startPoint;
                    skillUIElement.transform.localScale = Vector2.one;
                    angle = (degree - shotDegree * (index + 1)) * Mathf.Deg2Rad;
                    skillUIElement.Apply(owner, data, angle);
                }

                for (int index = 0; index < shotAmount; index++)
                {
                    skillUIElement = ResourceUtils.AddAndGetComponent <SkillUI>(GlobalDefinitions.RESOURCE_PATH_SKILL + data.resourceID);
                    skillUIElement.transform.SetParent(owner.componentsHolder.transform);
                    skillUIElement.IgnoreCollisionMap(true);
                    skillUIElement.transform.position   = startPoint;
                    skillUIElement.transform.localScale = Vector2.one;
                    angle = (degree + shotDegree * (index + 1)) * Mathf.Deg2Rad;
                    skillUIElement.Apply(owner, data, angle);
                }

                Destroy(this);

                this.skillUIElement = null;
            }
        }
Пример #17
0
    private static tk2dSpriteAnimationClip[] CreateAnimationClip(tk2dSpriteCollectionData spriteCollectionData, string name, string action, string[] directionNames, tk2dSpriteAnimationClip.WrapMode wrapMode)
    {
        List <tk2dSpriteDefinition> frames = new List <tk2dSpriteDefinition>();

        foreach (var spriteDefine in spriteCollectionData.spriteDefinitions)
        {
            if (spriteDefine.name.Contains(name + "_" + action.ToLower()))
            {
                frames.Add(spriteDefine);
            }
        }
        frames = frames.OrderBy(o => o.name).ToList();
        var frameCount = frames.Count / directionNames.Length;

        tk2dSpriteAnimationClip[] clips = new tk2dSpriteAnimationClip[directionNames.Length];
        for (int i = 0; i < directionNames.Length; i++)
        {
            var clip = new tk2dSpriteAnimationClip();
            clips[i] = clip;
            clip.fps = 10;
            if (directionNames[i] == "")
            {
                clip.name = name + "_" + action;
            }
            else
            {
                clip.name = name + "_" + action + "_" + directionNames[i];
            }
            clip.frames   = new tk2dSpriteAnimationFrame[frameCount];
            clip.wrapMode = wrapMode;
            for (int j = 0; j < clip.frames.Length; ++j)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                frame.spriteCollection = spriteCollectionData;
                frame.spriteId         = frame.spriteCollection.GetSpriteIdByName(frames[i * frameCount + j].name);

                clip.frames[j] = frame;
            }
        }
        return(clips);
    }
Пример #18
0
 public static void CopyFrame(tk2dSpriteAnimationFrame source, tk2dSpriteAnimationFrame target)
 {
     target.eventAudio              = source.eventAudio;
     target.eventFloat              = source.eventFloat;
     target.eventInfo               = source.eventInfo;
     target.eventInt                = source.eventInt;
     target.eventLerpEmissive       = source.eventLerpEmissive;
     target.eventLerpEmissivePower  = source.eventLerpEmissivePower;
     target.eventLerpEmissiveTime   = source.eventLerpEmissiveTime;
     target.eventOutline            = source.eventOutline;
     target.eventStopVfx            = source.eventStopVfx;
     target.eventVfx                = source.eventVfx;
     target.finishedSpawning        = source.finishedSpawning;
     target.forceMaterialUpdate     = source.forceMaterialUpdate;
     target.groundedFrame           = source.groundedFrame;
     target.invulnerableFrame       = source.invulnerableFrame;
     target.requiresOffscreenUpdate = source.requiresOffscreenUpdate;
     target.spriteCollection        = source.spriteCollection;
     target.spriteId                = source.spriteId;
     target.triggerEvent            = source.triggerEvent;
 }
Пример #19
0
        private void ConfigWeaponAndSkill()
        {
            skillLauncher  = new SkillLauncher();
            weaponLauncher = new WeaponLauncher();

            componentsHolder.GetComponent(ComponentDefs.Body).animator.AnimationCompleted += delegate(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip)
            {
                componentsHolder.GetComponent(ComponentDefs.Body).Play(AnimationDefs.Idle.ToString().ToLower());

                weaponLauncher.Load(UserManager.GetInstance().user.GetActiveWeapon());
            };

            componentsHolder.GetComponent(ComponentDefs.Body).animator.AnimationEventTriggered += delegate(tk2dSpriteAnimator animator, tk2dSpriteAnimationClip clip, int frameIndex)
            {
                tk2dSpriteAnimationFrame frame = clip.GetFrame(frameIndex);

                if (frame.eventInfo == AnimationTriggerDefs.WeaponApply.ToString())
                {
                    weaponLauncher.LateApply();
                }
            };
        }
Пример #20
0
        public static GameObject CreateOverheadVFX(List <string> filepaths, string name, int fps)
        {
            //Setting up the Overhead Plague VFX
            GameObject overheadderVFX = SpriteBuilder.SpriteFromResource(filepaths[0], new GameObject(name));

            overheadderVFX.SetActive(false);
            tk2dBaseSprite plaguevfxSprite = overheadderVFX.GetComponent <tk2dBaseSprite>();

            plaguevfxSprite.GetCurrentSpriteDef().ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter, plaguevfxSprite.GetCurrentSpriteDef().position3);
            FakePrefab.MarkAsFakePrefab(overheadderVFX);
            UnityEngine.Object.DontDestroyOnLoad(overheadderVFX);

            //Animating the overhead
            tk2dSpriteAnimator plagueanimator = overheadderVFX.AddComponent <tk2dSpriteAnimator>();

            plagueanimator.Library       = overheadderVFX.AddComponent <tk2dSpriteAnimation>();
            plagueanimator.Library.clips = new tk2dSpriteAnimationClip[0];

            tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip {
                name = "NewOverheadVFX", fps = fps, frames = new tk2dSpriteAnimationFrame[0]
            };

            foreach (string path in filepaths)
            {
                int spriteId = SpriteBuilder.AddSpriteToCollection(path, overheadderVFX.GetComponent <tk2dBaseSprite>().Collection);

                overheadderVFX.GetComponent <tk2dBaseSprite>().Collection.spriteDefinitions[spriteId].ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.LowerCenter);

                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = spriteId, spriteCollection = overheadderVFX.GetComponent <tk2dBaseSprite>().Collection
                };
                clip.frames = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            plagueanimator.Library.clips     = plagueanimator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
            plagueanimator.playAutomatically = true;
            plagueanimator.DefaultClipId     = plagueanimator.GetClipIdByName("NewOverheadVFX");
            return(overheadderVFX);
        }
Пример #21
0
        private void Start()
        {
            if (_anim != null)
            {
                foreach (tk2dSpriteAnimationClip clip in _anim.Library.clips)
                {
                    if (clip.frames.Length > 0)
                    {
                        tk2dSpriteAnimationFrame frame0 = clip.frames[0];
                        frame0.triggerEvent = true;
                        frame0.eventInfo    = clip.name;
                        clip.frames[0]      = frame0;
                    }
                }

                _anim.AnimationEventTriggered = AnimationEventDelegate;
            }

            if (_hm != null)
            {
                _hm.hp *= 2;
            }
        }
Пример #22
0
    void AddFrame(tk2dSpriteAnimationClip clip)
    {
        System.Array.Resize(ref clip.frames, clip.frames.Length + 1);
        var newFrame = new tk2dSpriteAnimationFrame();

        newFrame.CopyFrom(clip.frames[clip.frames.Length - 2]);         // previous "last" entry
        if (tk2dPreferences.inst.groupAnimDisplay)
        {
            // make sure the spriteId is something different, so it ends up adding a new entry
            var defs = newFrame.spriteCollection.spriteDefinitions;
            for (int j = 0; j < defs.Length; ++j)
            {
                int i = (j + newFrame.spriteId + 1) % defs.Length;                 // start one after current frame, and work from there looping back
                if (i != newFrame.spriteId && defs[i].Valid)
                {
                    newFrame.spriteId = i;
                    break;
                }
            }
        }
        clip.frames[clip.frames.Length - 1] = newFrame;
        GUI.changed = true;
    }
Пример #23
0
        void DrawTriggerInspector()
        {
            GUILayout.Label("Trigger", EditorStyles.largeLabel, GUILayout.ExpandWidth(true));

            tk2dSpriteAnimationFrame frame = clip.frames[timelineEditor.CurrentState.selectedTrigger];

            EditorGUILayout.LabelField("Frame", timelineEditor.CurrentState.selectedTrigger.ToString());

            frame.eventInfo  = EditorGUILayout.TextField("Info", frame.eventInfo);
            frame.eventFloat = EditorGUILayout.FloatField("Float", frame.eventFloat);
            frame.eventInt   = EditorGUILayout.IntField("Int", frame.eventInt);
            //if (frame.playSoundClip = EditorGUILayout.Toggle("Sound", frame.playSoundClip))
            //{
            //    frame.soundID = (SoundList)EditorGUILayout.EnumPopup("ID", frame.soundID);
            //}
            //if (frame.hasSpawnEffect = EditorGUILayout.Toggle("Effect", frame.hasSpawnEffect))
            //{
            //    frame.spawnEffectID = (EffectId)EditorGUILayout.EnumPopup("ID", frame.spawnEffectID);
            //}


            GUILayout.Space(8);
            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            GUILayout.BeginVertical();


            if (GUILayout.Button("Delete", EditorStyles.miniButton))
            {
                clip.frames[timelineEditor.CurrentState.selectedTrigger].ClearTrigger();
                timelineEditor.CurrentState.Reset();
                Repaint();
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Пример #24
0
        // Token: 0x060002E1 RID: 737 RVA: 0x0001BB3C File Offset: 0x00019D3C
        public static void Initialise()
        {
            ShatterEffect.ShatterVFXObject = SpriteBuilder.SpriteFromResource("BunnyMod/Resources/EffectIcons/shattered_debuff_icon.png", new GameObject("ShatterIcon"), true);
            ShatterEffect.ShatterVFXObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(ShatterEffect.ShatterVFXObject);
            UnityEngine.Object.DontDestroyOnLoad(ShatterEffect.ShatterVFXObject);
            tk2dSpriteAnimator tk2dSpriteAnimator = ShatterEffect.ShatterVFXObject.AddComponent <tk2dSpriteAnimator>();

            tk2dSpriteAnimator.Library       = ShatterEffect.ShatterVFXObject.AddComponent <tk2dSpriteAnimation>();
            tk2dSpriteAnimator.Library.clips = new tk2dSpriteAnimationClip[0];
            tk2dSpriteAnimationClip tk2dSpriteAnimationClip = new tk2dSpriteAnimationClip
            {
                name   = "ShatterIcon",
                fps    = 1f,
                frames = new tk2dSpriteAnimationFrame[0]
            };

            foreach (string resourcePath in ShatterEffect.LockdownPaths)
            {
                int spriteId = SpriteBuilder.AddSpriteToCollection(resourcePath, ShatterEffect.ShatterVFXObject.GetComponent <tk2dBaseSprite>().Collection);
                tk2dSpriteAnimationFrame tk2dSpriteAnimationFrame = new tk2dSpriteAnimationFrame
                {
                    spriteId         = spriteId,
                    spriteCollection = ShatterEffect.ShatterVFXObject.GetComponent <tk2dBaseSprite>().Collection
                };
                tk2dSpriteAnimationClip.frames = tk2dSpriteAnimationClip.frames.Concat(new tk2dSpriteAnimationFrame[]
                {
                    tk2dSpriteAnimationFrame
                }).ToArray <tk2dSpriteAnimationFrame>();
            }
            tk2dSpriteAnimator.Library.clips = tk2dSpriteAnimator.Library.clips.Concat(new tk2dSpriteAnimationClip[]
            {
                tk2dSpriteAnimationClip
            }).ToArray <tk2dSpriteAnimationClip>();
            tk2dSpriteAnimator.playAutomatically = true;
            tk2dSpriteAnimator.DefaultClipId     = tk2dSpriteAnimator.GetClipIdByName("ShatterIcon");
        }
Пример #25
0
    void Handle_AniSpriteFrameTrigger(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
    {
        Color c = sprite.color;

        c.a          = frame.eventFloat;
        sprite.color = c;
    }
Пример #26
0
        private static void BuildWestBrosBossPrefab(AssetBundle assetBundle, out GameObject outObject, WestBros whichBro, bool isSmiley, tk2dSpriteCollectionData sourceSpriteCollection, tk2dSpriteAnimation sourceAnimations, bool keepIntroDoer = false)
        {
            GameObject prefab = ExpandCustomEnemyDatabase.GetOfficialEnemyByGuid(isSmiley
                ? "ea40fcc863d34b0088f490f4e57f8913"              // Smiley
                : "c00390483f394a849c36143eb878998f").gameObject; // Shades

            outObject = UnityEngine.Object.Instantiate(prefab, Vector3.zero, Quaternion.identity);

            try
            {
                string name = $"West Bros {whichBro}";

                outObject.SetActive(false);
                outObject.name = name;

                AIActor actor = outObject.GetComponent <AIActor>();

                actor.healthHaver.overrideBossName = "Western Bros";

                actor.EnemyId   = UnityEngine.Random.Range(100000, 999999);
                actor.ActorName = name;

                EncounterTrackable Encounterable = outObject.GetComponent <EncounterTrackable>();

                switch (whichBro)
                {
                case WestBros.Angel:
                    actor.EnemyGuid             = "275354563e244f558be87fcff4b07f9f";
                    Encounterable.EncounterGuid = "7d6e1faf682d4402b29535020313f383";
                    break;

                case WestBros.Nome:
                    actor.EnemyGuid             = "3a1a33a905bb4b669e7d798f20674c4c";
                    Encounterable.EncounterGuid = "78cb8889dc884dd9b3aafe64558d858e";
                    break;

                case WestBros.Tuc:
                    actor.EnemyGuid             = "d2e7ea9ea9a444cebadd3bafa0832cd1";
                    Encounterable.EncounterGuid = "1df53371ce084dafb46f6bcd5a6c1c5f";
                    break;
                }

                // TODO at some distant point in time
                Encounterable.journalData.PrimaryDisplayName           = name;
                Encounterable.journalData.NotificationPanelDescription = name;
                Encounterable.journalData.AmmonomiconFullEntry         = name;

                // x BroController
                // x BulletBroDeathController
                // x BulletBrosIntroDoer
                // x BulletBroSeekTargetBehavior // movement behaviour
                //   BulletBroRepositionBehavior // completely unused

                var oldBroController = outObject.GetComponent <BroController>();
                var newBroController = outObject.AddComponent <ExpandWesternBroController>();

                newBroController.enrageAnim          = oldBroController.enrageAnim;
                newBroController.enrageAnimTime      = oldBroController.enrageAnimTime;
                newBroController.enrageHealToPercent = oldBroController.enrageHealToPercent;
                newBroController.overheadVfx         = oldBroController.overheadVfx;
                newBroController.postEnrageMoveSpeed = oldBroController.postEnrageMoveSpeed;

                newBroController.whichBro = whichBro;
                newBroController.postSecondEnrageMoveSpeed = newBroController.postEnrageMoveSpeed;

                UnityEngine.Object.Destroy(oldBroController);

                UnityEngine.Object.Destroy(outObject.GetComponent <BulletBroDeathController>());
                outObject.AddComponent <ExpandWesternBroDeathController>();

                var newMovementBehavior = new ExpandWesternBroSeekTargetBehavior();
                var oldMovementBehavior = actor.behaviorSpeculator.MovementBehaviors.First() as BulletBroSeekTargetBehavior;

                newMovementBehavior.CustomRange     = oldMovementBehavior.CustomRange;
                newMovementBehavior.PathInterval    = oldMovementBehavior.PathInterval;
                newMovementBehavior.StopWhenInRange = oldMovementBehavior.StopWhenInRange;

                actor.behaviorSpeculator.MovementBehaviors = new List <MovementBehaviorBase>()
                {
                    newMovementBehavior
                };

                // only smiley has a bossIntroDoer, so the stuff after this would null reference if done with shade
                if (isSmiley)
                {
                    if (!keepIntroDoer)
                    {
                        UnityEngine.Object.Destroy(outObject.GetComponent <BulletBrosIntroDoer>());
                        UnityEngine.Object.Destroy(outObject.GetComponent <GenericIntroDoer>());
                    }
                    else
                    {
                        // BulletBrosIntroDoer is a SpecificIntroDoer; it does not inherent from GenericIntroDoer, it requires it to be present
                        BulletBrosIntroDoer bulletBrosIntroDoer = outObject.GetComponent <BulletBrosIntroDoer>();

                        // destroy it so we can add our own
                        UnityEngine.Object.Destroy(bulletBrosIntroDoer);

                        GenericIntroDoer genericIntroDoer = outObject.GetComponent <GenericIntroDoer>();

                        genericIntroDoer.portraitSlideSettings.bossNameString     = "Western Bros";
                        genericIntroDoer.portraitSlideSettings.bossSubtitleString = "Triple Tap";
                        genericIntroDoer.portraitSlideSettings.bossQuoteString    = string.Empty;

                        genericIntroDoer.portraitSlideSettings.bossArtSprite = assetBundle.LoadAsset <Texture2D>("WesternBrosBossCard");

                        genericIntroDoer.triggerType     = GenericIntroDoer.TriggerType.PlayerEnteredRoom;
                        genericIntroDoer.OnIntroFinished = () => { };

                        ExpandWesternBroIntroDoer specificIntroDoer = outObject.AddComponent <ExpandWesternBroIntroDoer>();
                    }
                }

                var animationsAsset = assetBundle.LoadAsset <GameObject>($"WestBrosAnimations_{whichBro}");

                List <tk2dSpriteAnimationClip> animationClips = new List <tk2dSpriteAnimationClip>();

                foreach (tk2dSpriteAnimationClip clip in sourceAnimations.clips)
                {
                    if (clip.name.StartsWith($"{whichBro.ToString().ToLower()}_"))
                    {
                        animationClips.Add(ExpandUtility.DuplicateAnimationClip(clip));
                    }
                }

                List <tk2dSpriteAnimationClip> clipsToAdd = new List <tk2dSpriteAnimationClip>();

                foreach (tk2dSpriteAnimationClip clip in animationClips)
                {
                    clip.name = clip.name.Replace($"{whichBro.ToString().ToLower()}_", string.Empty);

                    clip.name = clip.name.Replace("dash_front", "dash_forward");
                    clip.name = clip.name.Replace("move_front", "move_forward");

                    if (clip.name.EndsWith("_prime"))
                    {
                        clip.frames[5].eventAudio   = "Play_ENM_bullet_dash_01";
                        clip.frames[5].triggerEvent = true;
                    }
                    else if (clip.name.StartsWith("move_"))
                    {
                        clip.frames[2].eventAudio   = "PLay_FS_ENM";
                        clip.frames[2].triggerEvent = true;
                    }
                    else if (clip.name == "anger")
                    {
                        // we change the west bros anger animation from a loop to a loop section so the anger SFX only plays once.
                        // to do this we simply clone every frame once and make it loop at the first copied frame.

                        var angerFrames = clip.frames.ToList();

                        foreach (var frame in clip.frames)
                        {
                            tk2dSpriteAnimationFrame clonedFrame = new tk2dSpriteAnimationFrame();

                            ExpandUtility.ReflectionShallowCopyFields(clonedFrame, frame, BindingFlags.Public | BindingFlags.Instance);

                            angerFrames.Add(clonedFrame);
                        }

                        // it's important to do this before changing clip.frames
                        clip.loopStart              = clip.frames.Length;
                        clip.frames                 = angerFrames.ToArray();
                        clip.wrapMode               = tk2dSpriteAnimationClip.WrapMode.LoopSection;
                        clip.frames[0].eventAudio   = "Play_BOSS_bulletbros_anger_01";
                        clip.frames[0].triggerEvent = true;
                    }
                    else if (clip.name == "death_right")
                    {
                        clip.name = "die";

                        tk2dSpriteAnimationClip dieFrontRight = ExpandUtility.DuplicateAnimationClip(clip);
                        dieFrontRight.name = "die_front_right";
                        clipsToAdd.Add(dieFrontRight);
                    }
                    else if (clip.name == "death_left")
                    {
                        clip.name = "die_left";

                        tk2dSpriteAnimationClip dieFrontLeft = ExpandUtility.DuplicateAnimationClip(clip);
                        dieFrontLeft.name = "die_front_left";
                        clipsToAdd.Add(dieFrontLeft);
                    }
                    else if (clip.name == "idle_front")
                    {
                        clip.name = "idle";

                        tk2dSpriteAnimationClip bigShot = ExpandUtility.DuplicateAnimationClip(clip);
                        bigShot.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                        bigShot.name     = "big_shot";
                        clipsToAdd.Add(bigShot);

                        tk2dSpriteAnimationClip charge = ExpandUtility.DuplicateAnimationClip(clip);
                        charge.wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop;
                        charge.name     = "charge";
                        clipsToAdd.Add(charge);

                        // not really necessary since it's nuked from the animator further down
                        tk2dSpriteAnimationClip appear = ExpandUtility.DuplicateAnimationClip(clip);
                        appear.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                        appear.name     = "appear";
                        clipsToAdd.Add(appear);

                        tk2dSpriteAnimationClip introGunToggle = ExpandUtility.DuplicateAnimationClip(clip);
                        introGunToggle.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                        introGunToggle.name     = "intro2";
                        clipsToAdd.Add(introGunToggle);

                        introGunToggle.frames[0].eventInfo    = "guntoggle";
                        introGunToggle.frames[0].triggerEvent = true;
                    }
                    else if (clip.name == "summon")
                    {
                        clip.name     = "whistle";
                        clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                        // the summon vfx don't look right
                        // clip.frames[0].eventVfx = "summon_vfx";
                        // clip.frames[0].triggerEvent = true;
                    }
                    else if (clip.name == "pound")
                    {
                        clip.name = "jump_attack";
                        // Uses modified sound that plays faster on the first half to account for west bros having faster animation.
                        clip.frames[0].eventAudio   = "Play_EX_BOSS_westbros_slam_01";
                        clip.frames[0].triggerEvent = true;
                    }
                    else if (clip.name == "intro")
                    {
                        clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
                        // this is setup in case we want the intro to continue looping during the boss card instead of the idle animation
                        // requires to change the intro doer so it sets finished to true once it reaches the first loop

                        //if (whichBro == WestBros.Nome)
                        //{
                        //    // nome's intro animation wasn't looping at the end like the others
                        //    var list = clip.frames.ToList();

                        //    list.RemoveAt(20);
                        //    list.RemoveAt(20);

                        //    clip.frames = list.ToArray();

                        //    clip.loopStart = 23;

                        //    clip.frames[23] = clip.frames[0];
                        //    clip.frames[24] = clip.frames[1];
                        //    clip.frames[25] = clip.frames[2];
                        //    clip.frames[26] = clip.frames[3];
                        //}
                        //else if (whichBro == WestBros.Tuc)
                        //{
                        //    // tuc's intro animation was off by one frame compared to the others
                        //    var list = clip.frames.ToList();

                        //    list.RemoveAt(15);

                        //    clip.frames = list.ToArray();

                        //    clip.loopStart = 21;
                        //}
                    }
                }

                animationClips.AddRange(clipsToAdd);

                tk2dSpriteAnimation spriteAnimation = animationsAsset.AddComponent <tk2dSpriteAnimation>();

                spriteAnimation.clips = animationClips.ToArray();

                tk2dSpriteAnimator spriteAnimator = outObject.GetComponent <tk2dSpriteAnimator>();

                spriteAnimator.Library = spriteAnimation;

                tk2dSprite sprite = outObject.GetComponent <tk2dSprite>();
                sprite.SetSprite(sourceSpriteCollection, $"BB_{whichBro.ToString().ToLower()}_idle_front_001");
                sprite.PlaceAtPositionByAnchor(new Vector3(0f, 0f), tk2dBaseSprite.Anchor.LowerCenter);

                AIAnimator animator = outObject.GetComponent <AIAnimator>();
                // removes the 'appear' animation
                animator.OtherAnimations.RemoveAt(0);

                outObject.transform.Find("shadow").localPosition += new Vector3(1.52f, 0.02f, 0);

                var shooter = SetupAIShooter(outObject);
                shooter.handObject = WestBrosHandPrefab.GetComponent <PlayerHandController>();

                DebrisObject hatPrefab = null;

                switch (whichBro)
                {
                case WestBros.Angel:
                    shooter.gunAttachPoint.position = new Vector3(-1.05f, 0.5f);
                    WestBrosAngelGUID = actor.EnemyGuid;
                    hatPrefab         = WestBrosAngelHatPrefab.GetComponent <DebrisObject>();
                    break;

                case WestBros.Nome:
                    shooter.gunAttachPoint.position = new Vector3(-1.05f, 0.4f);
                    WestBrosNomeGUID = actor.EnemyGuid;
                    hatPrefab        = WestBrosNomeHatPrefab.GetComponent <DebrisObject>();
                    break;

                case WestBros.Tuc:
                    shooter.gunAttachPoint.position = new Vector3(-1.05f, 0.5f);
                    WestBrosTucGUID = actor.EnemyGuid;
                    hatPrefab       = WestBrosTucHatPrefab.GetComponent <DebrisObject>();
                    break;
                }

                shooter.equippedGunId = WestBrosRevolverGenerator.GetWestBrosRevolverID(whichBro);

                if (shooter.equippedGunId == -1)
                {
                    ETGModConsole.Log("The West Bros Gun ID should have been set at this point already, but it wasn't. Assigning fallback gun.");
                    shooter.equippedGunId = isSmiley ? 35 : 22;
                }

                var hatLauncher = outObject.GetComponentInChildren <ExplosionDebrisLauncher>();

                // basically changes smiley's debris launcher into shades'
                hatLauncher.specifyArcDegrees = false;
                hatLauncher.minShards         = 1;
                hatLauncher.maxShards         = 1;

                hatLauncher.debrisSources = new DebrisObject[] { hatPrefab };

                // move the ring of bullets spawned by jumping
                var shootPoint = outObject.transform.Find("shoot point");
                shootPoint.position += new Vector3(1.5f, 0);

                // move the actual pixel colliders
                var rigidbody = outObject.GetComponent <SpeculativeRigidbody>();

                foreach (var item in rigidbody.PixelColliders)
                {
                    item.ManualOffsetX = 32;
                    item.Regenerate(outObject.transform);
                }

                // TODO balance
                actor.healthHaver.ForceSetCurrentHealth(600);
                actor.healthHaver.SetHealthMaximum(600);

                actor.RegenerateCache();

                ExpandCustomEnemyDatabase.AddEnemyToDatabase(outObject, actor.EnemyGuid, true);
                FakePrefab.MarkAsFakePrefab(outObject);
                UnityEngine.Object.DontDestroyOnLoad(outObject);
            }
            catch (Exception e)
            {
                ETGModConsole.Log($"Error setting up the western bro {whichBro}: " + e.ToString());
            }
        }
    public override void OnInspectorGUI()
    {
		InitializeInspector();
		
		if (spriteCollectionIndex == null || allSpriteCollectionNames == null)
		{
			GUILayout.Label("data not found");
			if (GUILayout.Button("Refresh"))
			{
				initialized = false;
				InitializeInspector();
			}
			return;
		}

		
        tk2dSpriteAnimation anim = (tk2dSpriteAnimation)target;
        EditorGUILayout.BeginVertical();

		EditorGUI.indentLevel = 1;
		EditorGUILayout.BeginVertical();
		
		if (anim.clips.Length == 0)
		{
			if (GUILayout.Button("Add clip"))
			{
				anim.clips = new tk2dSpriteAnimationClip[1];
				anim.clips[0] = new tk2dSpriteAnimationClip();
				anim.clips[0].name = "New Clip 0";
				anim.clips[0].frames = new tk2dSpriteAnimationFrame[1];
				
				anim.clips[0].frames[0] = new tk2dSpriteAnimationFrame();
				anim.clips[0].frames[0].spriteCollection = GetSpriteCollection(0);
				anim.clips[0].frames[0].spriteId = 0;
			}
		}
		else // has anim clips
		{
			// All clips
			string[] allClipNames = new string[anim.clips.Length];
			for (int i = 0; i < anim.clips.Length; ++i)
				allClipNames[i] = anim.clips[i].name;
			currentClip = Mathf.Clamp(currentClip, 0, anim.clips.Length);
			
			#region AddAndDeleteClipButtons
			EditorGUILayout.BeginHorizontal();
			currentClip = EditorGUILayout.Popup("Clips", currentClip, allClipNames);
			
			// Add new clip
			if (GUILayout.Button("+", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)))
			{
				int previousClipId = currentClip;
				
				// try to find an empty slot
				currentClip = -1;
				for (int i = 0; i < anim.clips.Length; ++i)
				{
					if (anim.clips[i].name.Length == 0)
					{
						currentClip = i;
						break;
					}
				}
				
				if (currentClip == -1)
				{
					tk2dSpriteAnimationClip[] clips = new tk2dSpriteAnimationClip[anim.clips.Length + 1];
					for (int i = 0; i < anim.clips.Length; ++i)
						clips[i] = anim.clips[i];
					currentClip = anim.clips.Length;
					clips[currentClip] = new tk2dSpriteAnimationClip();
					anim.clips = clips;
				}
				
				string uniqueName = "New Clip ";
				int uniqueId = 0;
				for (int i = 0; i < anim.clips.Length; ++i)
				{
					string uname = uniqueName + uniqueId.ToString();
					if (anim.clips[i].name == uname)
					{
						uniqueId++;
						i = -1;
						continue;
					}
				}
				
				anim.clips[currentClip] = new tk2dSpriteAnimationClip();
				anim.clips[currentClip].name = uniqueName + uniqueId.ToString();
				anim.clips[currentClip].fps = 15;
				anim.clips[currentClip].wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop;
				anim.clips[currentClip].frames = new tk2dSpriteAnimationFrame[1];
				tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
				if (previousClipId < anim.clips.Length
				    && anim.clips[previousClipId] != null 
				    && anim.clips[previousClipId].frames != null
				    && anim.clips[previousClipId].frames.Length != 0
				    && anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1] != null
				    && anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1].spriteCollection != null)
				{
					var previousClip = anim.clips[previousClipId];
					var lastFrame = previousClip.frames[previousClip.frames.Length - 1];
					frame.spriteCollection = lastFrame.spriteCollection;
					frame.spriteId = lastFrame.spriteId;
				}
				else
				{
					frame.spriteCollection = GetSpriteCollection(0);
					frame.spriteId = 0;
				}
				anim.clips[currentClip].frames[0] = frame;
				
				GUI.changed = true;
			}
			
			// Delete clip
			if (GUILayout.Button("-", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)))
			{
				anim.clips[currentClip].name = "";
				anim.clips[currentClip].frames = new tk2dSpriteAnimationFrame[0];
				
				currentClip = 0;
				// find first non zero clip
				for (int i = 0; i < anim.clips.Length; ++i)
				{
					if (anim.clips[i].name != "")
					{
						currentClip = i;
						break;
					}
				}
				
				GUI.changed = true;
			}
			EditorGUILayout.EndHorizontal();
			#endregion
			
			#region PruneClipList
			// Prune clip list
			int lastActiveClip = 0;
			for (int i = 0; i < anim.clips.Length; ++i)
			{
				if ( !(anim.clips[i].name == "" && anim.clips[i].frames != null && anim.clips[i].frames.Length == 0) ) lastActiveClip = i;
			}
			if (lastActiveClip != anim.clips.Length - 1)
			{
				System.Array.Resize<tk2dSpriteAnimationClip>(ref anim.clips, lastActiveClip + 1);
				GUI.changed = true;
			}
			#endregion
			
			// If anything has changed up to now, redraw
			if (GUI.changed)
			{
				EditorUtility.SetDirty(anim);
				Repaint();
				return;
			}
			
			EditorGUI.indentLevel = 2;
			tk2dSpriteAnimationClip clip = anim.clips[currentClip];

			// Clip properties
			
			// Name
			clip.name = EditorGUILayout.TextField("Name", clip.name);
			
			#region NumberOfFrames
			// Number of frames
			int clipNumFrames = (clip.frames != null)?clip.frames.Length:0;
			int newFrameCount = 0;
			if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Single)
			{
				newFrameCount = 1; // only one frame, no need to display
			}
			else
			{
				int maxFrameCount = 100;
				string[] numFrameStr = new string[maxFrameCount];
				for (int i = 1; i < maxFrameCount; ++i)
					numFrameStr[i] = i.ToString();
				
				newFrameCount = EditorGUILayout.Popup("Num Frames", clipNumFrames, numFrameStr);
				if (newFrameCount == 0) newFrameCount = 1; // minimum = 1
			}
			
			if (newFrameCount != clipNumFrames)
			{
				tk2dSpriteAnimationFrame[] frames = new tk2dSpriteAnimationFrame[newFrameCount];
				
				int c1 = Mathf.Min(clipNumFrames, frames.Length);
				for (int i = 0; i < c1; ++i)
				{
					frames[i] = new tk2dSpriteAnimationFrame();
					frames[i].spriteCollection = clip.frames[i].spriteCollection;
					frames[i].spriteId = clip.frames[i].spriteId;
				}
				if (c1 > 0)
				{
					for (int i = c1; i < frames.Length; ++i)
					{
						frames[i] = new tk2dSpriteAnimationFrame();
						frames[i].spriteCollection = clip.frames[c1-1].spriteCollection;
						frames[i].spriteId = clip.frames[c1-1].spriteId;
					}
				}
				else
				{
					for (int i = 0; i < frames.Length; ++i)
					{
						frames[i] = new tk2dSpriteAnimationFrame();
						frames[i].spriteCollection = GetSpriteCollection(0);
						frames[i].spriteId = 0;
					}
				}
				
				clip.frames = frames;
				clipNumFrames = newFrameCount;
			}
			#endregion
			
			// Frame rate
			if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single)
				clip.fps = EditorGUILayout.FloatField("Frame rate", clip.fps);
			
			// Wrap mode
			clip.wrapMode = (tk2dSpriteAnimationClip.WrapMode)EditorGUILayout.EnumPopup("Wrap mode", clip.wrapMode);
			if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection)
			{
				clip.loopStart = EditorGUILayout.IntField("Loop start", clip.loopStart);
				clip.loopStart = Mathf.Clamp(clip.loopStart, 0, clip.frames.Length - 1);
			}
			
			#region DrawFrames
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.PrefixLabel("Frames");
			GUILayout.FlexibleSpace();
			
			// Reverse
			if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single &&
			    GUILayout.Button("Reverse"))
			{
				System.Array.Reverse(clip.frames);
				GUI.changed = true;
			}
			
			// Auto fill
			if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single && clip.frames.Length >= 1)
			{
				AutoFill(clip);
			}
			
			if (GUILayout.Button(tk2dPreferences.inst.horizontalAnimDisplay?"H":"V", GUILayout.MaxWidth(24)))
			{
				tk2dPreferences.inst.horizontalAnimDisplay = !tk2dPreferences.inst.horizontalAnimDisplay;
				Repaint();
			}
			EditorGUILayout.EndHorizontal();

			// Sanitize frame data
			for (int i = 0; i < clip.frames.Length; ++i)
			{
				if (clip.frames[i].spriteCollection == null || clip.frames[i].spriteCollection.spriteDefinitions.Length == 0)
				{
					EditorUtility.DisplayDialog("Warning", "Invalid sprite collection found.\nThis clip will now be deleted", "Ok");

					clip.name = "";
					clip.frames = new tk2dSpriteAnimationFrame[0];
					Repaint();
					return;
				}
				
				if (clip.frames[i].spriteId < 0 || clip.frames[i].spriteId >= clip.frames[i].spriteCollection.Count)
				{
					EditorUtility.DisplayDialog("Warning", "Invalid frame found, resetting to frame 0", "Ok");
					clip.frames[i].spriteId = 0;
				}
			}
			
			// Warning when one of the frames has different poly count
			if (clipNumFrames > 0)
			{
				bool differentPolyCount = false;
				int polyCount = clip.frames[0].spriteCollection.spriteDefinitions[clip.frames[0].spriteId].positions.Length;
				for (int i = 1; i < clipNumFrames; ++i)
				{
					int thisPolyCount = clip.frames[i].spriteCollection.spriteDefinitions[clip.frames[i].spriteId].positions.Length;
					if (thisPolyCount != polyCount)
					{
						differentPolyCount = true;
						break;
					}
				}
				
				if (differentPolyCount)
				{
					Color bg = GUI.backgroundColor;
					GUI.backgroundColor = Color.red;
					GUILayout.TextArea("Sprites have different poly counts. Performance will be affected");
					GUI.backgroundColor = bg;
				}
			}
			
			// Draw frames
			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space();
			if (tk2dPreferences.inst.horizontalAnimDisplay)
			{
				scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(144.0f));
				EditorGUILayout.BeginHorizontal();

				for (int i = 0; i < clipNumFrames; ++i)
				{
					int currSpriteCollectionId = GetSpriteCollectionId(clip.frames[i].spriteCollection);
					EditorGUILayout.BeginHorizontal();
						
					GUILayout.Label(i.ToString());
					DrawSpritePreview(currSpriteCollectionId, clip.frames[i].spriteId);
					
					EditorGUILayout.BeginVertical();
					{
						int newSpriteCollectionId = EditorGUILayout.Popup(currSpriteCollectionId, allSpriteCollectionNames);
						if (newSpriteCollectionId != currSpriteCollectionId)
						{
							clip.frames[i].spriteCollection = GetSpriteCollection(newSpriteCollectionId);
							clip.frames[i].spriteId = 0;
						}
						
						clip.frames[i].spriteId = tk2dEditorUtility.SpriteSelectorPopup(null, clip.frames[i].spriteId, clip.frames[i].spriteCollection);
						
						clip.frames[i].triggerEvent = EditorGUILayout.Toggle("Trigger", clip.frames[i].triggerEvent);
						if (clip.frames[i].triggerEvent)
						{
							clip.frames[i].eventInfo = EditorGUILayout.TextField("Trigger info", clip.frames[i].eventInfo);
							clip.frames[i].eventFloat = EditorGUILayout.FloatField("Trigger float", clip.frames[i].eventFloat);
							clip.frames[i].eventInt = EditorGUILayout.IntField("Trigger int", clip.frames[i].eventInt);
						}
					}					
					EditorGUILayout.EndVertical();
					
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.Space();
					EditorGUILayout.Space();
				}
			
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.EndScrollView();
			}
			else
			{
				scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
				EditorGUILayout.BeginVertical();
				
				for (int i = 0; i < clipNumFrames; ++i)
				{
					EditorGUILayout.BeginHorizontal();
					
					GUILayout.Label(i.ToString());
					
					int currSpriteCollectionId = GetSpriteCollectionId(clip.frames[i].spriteCollection);
					
					EditorGUILayout.BeginVertical();
					{
						int newSpriteCollectionId = EditorGUILayout.Popup(currSpriteCollectionId, allSpriteCollectionNames);
						if (newSpriteCollectionId != currSpriteCollectionId)
						{
							clip.frames[i].spriteCollection = GetSpriteCollection(newSpriteCollectionId);
							clip.frames[i].spriteId = 0;
						}
						
						clip.frames[i].spriteId = tk2dEditorUtility.SpriteSelectorPopup(null, clip.frames[i].spriteId, clip.frames[i].spriteCollection);
						
						clip.frames[i].triggerEvent = EditorGUILayout.Toggle("Trigger", clip.frames[i].triggerEvent);
						if (clip.frames[i].triggerEvent)
						{
							clip.frames[i].eventInfo = EditorGUILayout.TextField("Trigger info", clip.frames[i].eventInfo);
							clip.frames[i].eventFloat = EditorGUILayout.FloatField("Trigger float", clip.frames[i].eventFloat);
							clip.frames[i].eventInt = EditorGUILayout.IntField("Trigger int", clip.frames[i].eventInt);
						}
					}
					EditorGUILayout.EndVertical();
					
					DrawSpritePreview(currSpriteCollectionId, clip.frames[i].spriteId);
					
					EditorGUILayout.EndHorizontal();
				}				
				
				EditorGUILayout.EndVertical();
				EditorGUILayout.EndScrollView();
			}
			
			EditorGUILayout.EndHorizontal();
			#endregion
		}
		
		EditorGUILayout.EndVertical();
		
		if (GUI.changed)
			EditorUtility.SetDirty(anim);
	}
Пример #28
0
 public virtual void Launch(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     currentAmmo.LaunchAt(foundTarget);
     currentAmmo = null;
 }
Пример #29
0
        /// <summary>
        /// Creates a custom chest.
        /// </summary>
        /// <param name="idleSprite">The pathway to the idle sprite. Setup like how you would do an item. Do not put an idle inside of the spritePaths list!</param>
        /// <param name="gameObjectName">The name of the chest's game object</param>
        /// <param name="hitboxOffset">The offset of the hitbox. Idk what this does but you can tinker with it if you need to.</param>
        /// <param name="hitboxDimensions">Start at the size of the chest's idle dimensions and tinker with the values until they feel right</param>
        /// <param name="spritePaths">A list of the chest's sprite paths.</param>
        /// <param name="lootTableIdsAndWeights">Uses a custom class I made called ItemAndWeight that allows me to have a list with mutliple types per item in it. Just make a list of ItemAndWeights like this: new ItemAndWeight {itemID = "the gun/passive/active's id", itemWeight = "x" (Best left at 1), itemCanHaveDupes = false/true (idk what this really means but I would add it.)}; </param>
        /// <param name="sTierChance">The chance to get an S tier item from the chest's loot pool.</param>
        /// <param name="aTierChance">The chance to get an A tier item from the chest's loot pool.</param>
        /// <param name="bTierChance">The chance to get a B tier item from the chest's loot pool.</param>
        /// <param name="cTierChance">The chance to get a C tier item from the chest's loot pool.</param>
        /// <param name="dTierChance">The chance to get a D tier item from the chest's loot pool.</param>
        /// <param name="isLocked">If the chest is locked.</param>
        /// <param name="type">If the chest is a Passive/Active chest, a Gun chest, or unspecified.</param>
        /// <param name="potentialPrefab">If you are using a RealPrefab, put it here. If you don't know what this means or aren't using one, leave this null.</param>
        public static Chest CreateChest(string idleSprite, string gameObjectName, IntVector2 hitboxOffset, IntVector2 hitboxDimensions, List <string> spritePaths, List <ItemAndWeight> lootTableIdsAndWeights, float sTierChance, float aTierChance, float bTierChance, float cTierChance, float dTierChance, ChestType type = ChestType.Unspecified, bool isLocked = true, GameObject potentialPrefab = null)
        {
            try
            {
                GameObject obj = SpriteBuilder.SpriteFromResource(idleSprite, potentialPrefab == null ? new GameObject(gameObjectName) : potentialPrefab);
                obj.SetActive(false);
                FakePrefab.MarkAsFakePrefab(obj);
                UnityEngine.Object.DontDestroyOnLoad(obj);
                tk2dSprite           sprite = obj.GetComponent <tk2dSprite>();
                SpeculativeRigidbody body   = sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitboxDimensions);
                body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.HighObstacle;
                tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>();
                animator.Library         = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
                animator.Library.clips   = new tk2dSpriteAnimationClip[0];
                animator.Library.enabled = true;
                List <int> appearIds  = new List <int>();
                List <int> breakIds   = new List <int>();
                List <int> openIds    = new List <int>();
                string     zeroHpName = "";
                foreach (string text in spritePaths)
                {
                    if (text.Contains("appear"))
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else if (text.Contains("break"))
                    {
                        if (text.EndsWith("001"))
                        {
                            int id = SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection);
                            zeroHpName = obj.GetComponent <tk2dBaseSprite>().Collection.inst.spriteDefinitions[id].name;
                        }
                        else
                        {
                            breakIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                        }
                    }
                    else if (text.Contains("open"))
                    {
                        openIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                    else
                    {
                        appearIds.Add(SpriteBuilder.AddSpriteToCollection(text, obj.GetComponent <tk2dBaseSprite>().Collection));
                    }
                }
                appearIds.Add(sprite.spriteId);
                tk2dSpriteAnimationClip openClip = new tk2dSpriteAnimationClip {
                    name = "open", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in openIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    openClip.frames = openClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                openClip.wrapMode      = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { openClip }).ToArray();
                tk2dSpriteAnimationClip appearClip = new tk2dSpriteAnimationClip {
                    name = "appear", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in appearIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    appearClip.frames = appearClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                appearClip.wrapMode    = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { appearClip }).ToArray();
                tk2dSpriteAnimationClip breakClip = new tk2dSpriteAnimationClip {
                    name = "break", fps = 10, frames = new tk2dSpriteAnimationFrame[0]
                };
                foreach (int id in breakIds)
                {
                    tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame
                    {
                        spriteId         = id,
                        spriteCollection = obj.GetComponent <tk2dBaseSprite>().Collection
                    };
                    breakClip.frames = breakClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
                }
                breakClip.wrapMode     = tk2dSpriteAnimationClip.WrapMode.Once;
                animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { breakClip }).ToArray();
                Chest chestController = obj.AddComponent <Chest>();
                chestController.spawnCurve = new AnimationCurve
                {
                    keys = new Keyframe[] { new Keyframe {
                                                time = 0f, value = 0f, inTangent = 3.562501f, outTangent = 3.562501f
                                            }, new Keyframe {
                                                time       = 1f, value = 1.0125f, inTangent = 0.09380959f,
                                                outTangent = 0.09380959f
                                            } }
                };

                GenericLootTable Table;
                Table = UnityEngine.Object.Instantiate <GenericLootTable>(GameManager.Instance.RewardManager.ItemsLootTable);
                Table.defaultItemDrops          = new WeightedGameObjectCollection();
                Table.defaultItemDrops.elements = new List <WeightedGameObject>();
                foreach (ItemAndWeight itemAndWeight in lootTableIdsAndWeights)
                {
                    Table.defaultItemDrops.elements.Add(new WeightedGameObject()
                    {
                        pickupId = itemAndWeight.itemID,
                        weight   = itemAndWeight.itemWeight,
                        forceDuplicatesPossible = itemAndWeight.itemCanHaveDupes,
                        additionalPrerequisites = new DungeonPrerequisite[0]
                    });
                }
                chestController.openAnimName   = "open";
                chestController.spawnAnimName  = "appear";
                chestController.majorBreakable = obj.AddComponent <MajorBreakable>();
                chestController.majorBreakable.spriteNameToUseAtZeroHP         = zeroHpName;
                chestController.majorBreakable.usesTemporaryZeroHitPointsState = true;
                chestController.breakAnimName = "break";
                chestController.VFX_GroundHit = new GameObject("example thingy");
                chestController.VFX_GroundHit.transform.parent = chestController.transform;
                chestController.VFX_GroundHit.SetActive(false);
                chestController.groundHitDelay      = 5f;
                chestController.overrideMimicChance = 0f;
                chestController.lootTable           = new LootData();
                chestController.lootTable.lootTable = Table;
                chestController.lootTable.S_Chance  = sTierChance;
                chestController.lootTable.A_Chance  = aTierChance;
                chestController.lootTable.B_Chance  = bTierChance;
                chestController.lootTable.C_Chance  = cTierChance;
                chestController.lootTable.D_Chance  = dTierChance;
                switch (type)
                {
                case ChestType.Unspecified:
                    chestController.ChestType = Chest.GeneralChestType.UNSPECIFIED;
                    break;

                case ChestType.PassiveActive:
                    chestController.ChestType = Chest.GeneralChestType.ITEM;
                    break;

                case ChestType.Gun:
                    chestController.ChestType = Chest.GeneralChestType.WEAPON;
                    break;
                }
                chestController.IsLocked = isLocked;
                return(chestController);
            }
            catch (Exception e)
            {
                ETGModConsole.Log("Something BROKE when making a chestController! Error is: " + e.ToString());
                return(null);
            }
        }
Пример #30
0
        public static void Init()
        {
            Gun gun = ETGMod.Databases.Items.NewGun("High-Quality Gun", "hd");

            Game.Items.Rename("outdated_gun_mods:high-quality_gun", "spapi:high_quality_gun");
            gun.gameObject.AddComponent <HDGun>();
            GunExt.SetShortDescription(gun, "HD!");
            GunExt.SetLongDescription(gun, "Bullets charm enemies.\n\nThis gun is just magnum, but but has 4 times more pixels. Because of that, it seems very weird among all other guns, but at the same time looks kinda cool!");
            GunExt.SetupSprite(gun, null, "hd_idle_001", 8);
            GunExt.SetAnimationFPS(gun, gun.shootAnimation, 13);
            GunExt.SetAnimationFPS(gun, gun.reloadAnimation, 12);
            GunExt.AddProjectileModuleFrom(gun, Toolbox.GetGunById(38), true, false);
            gun.gunSwitchGroup = "Magnum";
            VFXPool pool = new VFXPool();

            pool.type = VFXPoolType.All;
            VFXComplex complex = new VFXComplex();
            VFXObject  vfObj   = new VFXObject();
            GameObject obj     = new GameObject("hd_smoke");

            obj.SetActive(false);
            FakePrefab.MarkAsFakePrefab(obj);
            UnityEngine.Object.DontDestroyOnLoad(obj);
            tk2dSprite              sprite     = obj.AddComponent <tk2dSprite>();
            tk2dSpriteAnimator      animator   = obj.AddComponent <tk2dSpriteAnimator>();
            tk2dSpriteAnimationClip clip       = new tk2dSpriteAnimationClip();
            GameObject              origEffect = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[0].effect;
            VFXObject origVfEffect             = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[0];

            clip.fps    = origEffect.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.fps;
            clip.frames = new tk2dSpriteAnimationFrame[0];
            for (int i = 1; i < 4; i++)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                frame.spriteId = Toolbox.VFXCollection.GetSpriteIdByName("hd_smoke_00" + i);
                Toolbox.VFXCollection.inst.spriteDefinitions[frame.spriteId] = Toolbox.VFXCollection.inst.spriteDefinitions[origEffect.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.frames[i - 1].spriteId].CopyDefinitionFrom();
                frame.spriteCollection = Toolbox.VFXCollection;
                clip.frames            = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
            clip.name     = "start";
            animator.spriteAnimator.Library       = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
            animator.spriteAnimator.Library.clips = new tk2dSpriteAnimationClip[] { clip };
            animator.playAutomatically            = true;
            animator.DefaultClipId = animator.GetClipIdByName("start");
            SpriteAnimatorKiller kill = animator.gameObject.AddComponent <SpriteAnimatorKiller>();

            kill.fadeTime             = -1f;
            kill.animator             = animator;
            kill.delayDestructionTime = -1f;
            obj.gameObject.SetLayerRecursively(LayerMask.NameToLayer("Unpixelated"));
            vfObj.orphaned        = origVfEffect.orphaned;
            vfObj.attached        = origVfEffect.attached;
            vfObj.persistsOnDeath = origVfEffect.persistsOnDeath;
            vfObj.usesZHeight     = origVfEffect.usesZHeight;
            vfObj.zHeight         = origVfEffect.zHeight;
            vfObj.alignment       = origVfEffect.alignment;
            vfObj.destructible    = origVfEffect.destructible;
            vfObj.effect          = obj;
            VFXObject  vfObj2 = new VFXObject();
            GameObject obj2   = new GameObject("hd_flare");

            obj2.SetActive(false);
            FakePrefab.MarkAsFakePrefab(obj2);
            UnityEngine.Object.DontDestroyOnLoad(obj2);
            tk2dSprite              sprite2     = obj2.AddComponent <tk2dSprite>();
            tk2dSpriteAnimator      animator2   = obj2.AddComponent <tk2dSpriteAnimator>();
            tk2dSpriteAnimationClip clip2       = new tk2dSpriteAnimationClip();
            GameObject              origEffect2 = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[1].effect;
            VFXObject origVfEffect2             = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[1];

            clip2.fps    = origEffect2.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.fps;
            clip2.frames = new tk2dSpriteAnimationFrame[0];
            for (int i = 1; i < 6; i++)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                frame.spriteId = Toolbox.VFXCollection.GetSpriteIdByName("hd_flare_00" + i);
                Toolbox.VFXCollection.inst.spriteDefinitions[frame.spriteId] = Toolbox.VFXCollection.inst.spriteDefinitions[origEffect2.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.frames[i - 1].spriteId].CopyDefinitionFrom();
                frame.spriteCollection = Toolbox.VFXCollection;
                clip2.frames           = clip2.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            clip2.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once;
            clip2.name     = "start";
            animator2.spriteAnimator.Library       = animator2.gameObject.AddComponent <tk2dSpriteAnimation>();
            animator2.spriteAnimator.Library.clips = new tk2dSpriteAnimationClip[] { clip2 };
            animator2.playAutomatically            = true;
            animator2.DefaultClipId = animator2.GetClipIdByName("start");
            SpriteAnimatorKiller kill2 = animator2.gameObject.AddComponent <SpriteAnimatorKiller>();

            kill2.fadeTime             = -1f;
            kill2.animator             = animator2;
            kill2.delayDestructionTime = -1f;
            obj2.gameObject.SetLayerRecursively(LayerMask.NameToLayer("Unpixelated"));
            vfObj2.orphaned        = origVfEffect2.orphaned;
            vfObj2.attached        = origVfEffect2.attached;
            vfObj2.persistsOnDeath = origVfEffect2.persistsOnDeath;
            vfObj2.usesZHeight     = origVfEffect2.usesZHeight;
            vfObj2.zHeight         = origVfEffect2.zHeight;
            vfObj2.alignment       = origVfEffect2.alignment;
            vfObj2.destructible    = origVfEffect2.destructible;
            vfObj2.effect          = obj2;
            complex.effects        = new VFXObject[] { vfObj, vfObj2 };
            pool.effects           = new VFXComplex[] { complex };
            gun.muzzleFlashEffects = pool;
            Projectile projectile = UnityEngine.Object.Instantiate <Projectile>((PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0]);

            projectile.gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(projectile.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(projectile);
            gun.DefaultModule.projectiles[0] = projectile;
            gun.OverrideAngleSnap            = null;
            projectile.transform.parent      = gun.barrelOffset;
            projectile.AppliesCharm          = true;
            projectile.CharmApplyChance      = 100f;
            projectile.baseData.damage       = 20f;
            projectile.charmEffect           = (PickupObjectDatabase.GetById(527) as BulletStatusEffectItem).CharmModifierEffect;
            projectile.GetAnySprite().spriteId = ETGMod.Databases.Items.ProjectileCollection.inst.GetSpriteIdByName("hd_bullet_001");
            ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[projectile.GetAnySprite().spriteId] =
                ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[(PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0].GetAnySprite().spriteId].CopyDefinitionFrom();
            gun.DefaultModule.numberOfShotsInClip = 8;
            projectile.name = "Charmingly_HD_Projectile";
            gun.reloadTime  = 1.0f;
            gun.SetBaseMaxAmmo(280);
            gun.quality = PickupObject.ItemQuality.S;
            gun.encounterTrackable.EncounterGuid = "hd";
            gun.gunClass = GunClass.PISTOL;
            GameObject shellCasing = UnityEngine.Object.Instantiate(Toolbox.GetGunById(38).shellCasing);

            shellCasing.SetActive(false);
            FakePrefab.MarkAsFakePrefab(shellCasing);
            tk2dSpriteAnimator      gunAnim    = gun.GetComponent <tk2dSpriteAnimator>();
            tk2dSpriteAnimationClip reloadClip = gunAnim.GetClipByName(gun.reloadAnimation);

            reloadClip.frames = new tk2dSpriteAnimationFrame[0];
            foreach (string text in reloadFrames)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text)
                };
                reloadClip.frames = reloadClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            UnityEngine.Object.DontDestroyOnLoad(shellCasing);
            shellCasing.GetAnyComponent <tk2dBaseSprite>().SetSprite(Toolbox.VFXCollection, Toolbox.VFXCollection.GetSpriteIdByName("hd_shell_001"));
            Toolbox.VFXCollection.spriteDefinitions[shellCasing.GetAnyComponent <tk2dBaseSprite>().spriteId] =
                Toolbox.GetGunById(38).shellCasing.GetAnyComponent <tk2dBaseSprite>().Collection.spriteDefinitions[Toolbox.GetGunById(38).shellCasing.GetAnyComponent <tk2dBaseSprite>().spriteId].CopyDefinitionFrom();
            shellCasing.AddComponent <AlwaysUnpixeledBehaviour>();
            gun.shellCasing            = shellCasing;
            gun.shellsToLaunchOnFire   = 0;
            gun.shellsToLaunchOnReload = 6;
            gun.reloadShellLaunchFrame = 2;
            gun.barrelOffset.transform.localPosition = new Vector3(1.0625f, 0.5625f, 0f);
            ETGMod.Databases.Items.Add(gun, null, "ANY");
            gun.AddToCursulaShop();
            gun.AddToBlacksmithShop();
            gun.RemovePeskyQuestionmark();
            gun.PlaceItemInAmmonomiconAfterItemById(38);
            ItemBuilder.AddPassiveStatModifier(gun, PlayerStats.StatType.Coolness, 3, StatModifier.ModifyMethod.ADDITIVE);
            tk2dSpriteDefinition ammonomiconDef = AmmonomiconController.ForceInstance.EncounterIconCollection.spriteDefinitions[AmmonomiconController.ForceInstance.EncounterIconCollection.GetSpriteIdByName("hd_idle_001")];

            ammonomiconDef.position1                  = new Vector3(ammonomiconDef.position1.x / 2, ammonomiconDef.position1.y / 2, ammonomiconDef.position1.z / 2);
            ammonomiconDef.position2                  = new Vector3(ammonomiconDef.position2.x / 2, ammonomiconDef.position2.y / 2, ammonomiconDef.position2.z / 2);
            ammonomiconDef.position3                  = new Vector3(ammonomiconDef.position3.x / 2, ammonomiconDef.position3.y / 2, ammonomiconDef.position3.z / 2);
            ammonomiconDef.boundsDataCenter           = new Vector3(ammonomiconDef.boundsDataCenter.x / 2, ammonomiconDef.boundsDataCenter.y / 2, ammonomiconDef.boundsDataCenter.z / 2);
            ammonomiconDef.boundsDataExtents          = new Vector3(ammonomiconDef.boundsDataExtents.x / 2, ammonomiconDef.boundsDataExtents.y / 2, ammonomiconDef.boundsDataExtents.z / 2);
            ammonomiconDef.untrimmedBoundsDataCenter  = new Vector3(ammonomiconDef.untrimmedBoundsDataCenter.x / 2, ammonomiconDef.untrimmedBoundsDataCenter.y / 2, ammonomiconDef.untrimmedBoundsDataCenter.z / 2);
            ammonomiconDef.untrimmedBoundsDataExtents = new Vector3(ammonomiconDef.untrimmedBoundsDataExtents.x / 2, ammonomiconDef.untrimmedBoundsDataExtents.y / 2, ammonomiconDef.untrimmedBoundsDataExtents.z / 2);
            List <tk2dSpriteDefinition> affected = new List <tk2dSpriteDefinition>();

            foreach (tk2dSpriteAnimationClip clip3 in gun.GetGunAnimationClips())
            {
                if (clip3.frames != null)
                {
                    foreach (tk2dSpriteAnimationFrame frame in clip3.frames)
                    {
                        if (frame != null && frame.spriteCollection != null)
                        {
                            tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId];
                            if (def != null && !affected.Contains(def))
                            {
                                def.position1                  = new Vector3(def.position1.x / 2, def.position1.y / 2, def.position1.z / 2);
                                def.position2                  = new Vector3(def.position2.x / 2, def.position2.y / 2, def.position2.z / 2);
                                def.position3                  = new Vector3(def.position3.x / 2, def.position3.y / 2, def.position3.z / 2);
                                def.boundsDataCenter           = new Vector3(def.boundsDataCenter.x / 2, def.boundsDataCenter.y / 2, def.boundsDataCenter.z / 2);
                                def.boundsDataExtents          = new Vector3(def.boundsDataExtents.x / 2, def.boundsDataExtents.y / 2, def.boundsDataExtents.z / 2);
                                def.untrimmedBoundsDataCenter  = new Vector3(def.untrimmedBoundsDataCenter.x / 2, def.untrimmedBoundsDataCenter.y / 2, def.untrimmedBoundsDataCenter.z / 2);
                                def.untrimmedBoundsDataExtents = new Vector3(def.untrimmedBoundsDataExtents.x / 2, def.untrimmedBoundsDataExtents.y / 2, def.untrimmedBoundsDataExtents.z / 2);
                                def.RemoveOffset();
                                affected.Add(def);
                            }
                        }
                    }
                }
            }
            affected.Clear();
            int index = 0;

            foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.idleAnimation).frames)
            {
                tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId];
                if (def != null && !affected.Contains(def))
                {
                    def.MakeOffset(offsets[0][index]);
                    affected.Add(def);
                }
                index++;
            }
            index = 0;
            foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames)
            {
                tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId];
                if (def != null && !affected.Contains(def))
                {
                    def.MakeOffset(offsets[1][index]);
                    affected.Add(def);
                }
                index++;
            }
            index = 0;
            foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames)
            {
                tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId];
                if (def != null && !affected.Contains(def))
                {
                    def.MakeOffset(offsets[2][index]);
                    affected.Add(def);
                }
                index++;
            }
            AdvancedHoveringGunSynergyProcessor processor = gun.gameObject.AddComponent <AdvancedHoveringGunSynergyProcessor>();

            processor.RequiredSynergy              = "#LOW-QUALITY_HELP";
            processor.TargetGunID                  = 38;
            processor.UsesMultipleGuns             = false;
            processor.PositionType                 = HoveringGunController.HoverPosition.CIRCULATE;
            processor.AimType                      = HoveringGunController.AimType.PLAYER_AIM;
            processor.FireType                     = HoveringGunController.FireType.ON_RELOAD;
            processor.FireCooldown                 = 0.2f;
            processor.FireDuration                 = 0f;
            processor.OnlyOnEmptyReload            = false;
            processor.ShootAudioEvent              = "";
            processor.OnEveryShotAudioEvent        = "";
            processor.FinishedShootingAudioEvent   = "";
            processor.Trigger                      = AdvancedHoveringGunSynergyProcessor.TriggerStyle.CONSTANT;
            processor.NumToTrigger                 = 1;
            processor.TriggerDuration              = 0f;
            processor.ConsumesTargetGunAmmo        = false;
            processor.ChanceToConsumeTargetGunAmmo = 0f;
        }
    void WalkingEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
    {
        if(frame.eventInfo == "step1"){
            if(audioState == AudioState.grass)
                audio.playGrassWalkingS1();

            else if(audioState == AudioState.dry)
                audio.playDryWalkingS1();

            else if(audioState == AudioState.wet)
                audio.playWetWalkingS1();
        }

        else if(frame.eventInfo == "step2"){
            if(audioState == AudioState.grass)
                audio.playGrassWalkingS2();

            else if(audioState == AudioState.dry)
                audio.playDryWalkingS2();

            else if(audioState == AudioState.wet)
                audio.playWetWalkingS2();
        }
    }
			public List<tk2dSpriteAnimationFrame> DuplicateFrames(List<tk2dSpriteAnimationFrame> source)
			{
				List<tk2dSpriteAnimationFrame> dest = new List<tk2dSpriteAnimationFrame>();
				foreach (tk2dSpriteAnimationFrame f in source)
				{
					tk2dSpriteAnimationFrame q = new tk2dSpriteAnimationFrame();
					q.CopyFrom(f);
					dest.Add(q);
				}
				return dest;
			}
Пример #33
0
 public void CopyFrom(tk2dSpriteAnimationClip source)
 {
     name = source.name;
     if (source.frames == null)
     {
         frames = null;
     }
     else
     {
         frames = new tk2dSpriteAnimationFrame[source.frames.Length];
         for (int i = 0; i < frames.Length; ++i)
         {
             if (source.frames[i] == null)
             {
                 frames[i] = null;
             }
             else
             {
                 frames[i] = new tk2dSpriteAnimationFrame();
                 frames[i].CopyFrom(source.frames[i]);
             }
         }
     }
     fps = source.fps;
     loopStart = source.loopStart;
     wrapMode = source.wrapMode;
     if (wrapMode == tk2dSpriteAnimationClip.WrapMode.Single && frames.Length > 1)
     {
         frames = new tk2dSpriteAnimationFrame[] { frames[0] };
         Debug.LogError(string.Format("Clip: '{0}' Fixed up frames for WrapMode.Single", name));
     }
 }
 void OnSpriteAnimFrameEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     if(stateEventCallback != null) {
         stateEventCallback(mCurState, mCurDir, new EventData(frame.eventInt, frame.eventFloat, frame.eventInfo));
     }
 }
Пример #35
0
 public override void Launch(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     base.Reload(null);
     base.Launch(sprite, clip, frame, frameNum);
 }
Пример #36
0
        public static void Init()
        {
            string     itemName     = "Green Chamber";
            string     resourceName = "SpecialItemPack/Resources/GreenChamberItem/GreenChamber";
            GameObject obj          = new GameObject(itemName);
            var        item         = obj.AddComponent <GreenChamberItem>();

            ItemBuilder.AddSpriteToObject(itemName, resourceName, obj);
            string shortDesc = "\"the world burning\"";
            string longDesc  = "Etched into its chambers is a single worn glyph.\n\nBurn everything.";

            ItemBuilder.SetupItem(item, shortDesc, longDesc, "spapi");
            ItemBuilder.SetCooldownType(item, ItemBuilder.CooldownType.Damage, 300f);
            ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Curse, 2f);
            ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.RateOfFire, 0.15f);
            ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Health, 2f);
            item.consumable = false;
            item.quality    = ItemQuality.S;
            item.PlaceItemInAmmonomiconAfterItemById(209);
            List <int> spriteIds = new List <int>
            {
                item.sprite.spriteId,
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_001", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_002", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_003", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_004", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_005", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_006", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_007", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_008", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_009", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_010", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_011", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_012", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_013", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_014", item.sprite.Collection),
                SpriteBuilder.AddSpriteToCollection("SpecialItemPack/Resources/GreenChamberItem/GreenChamber_melt_015", item.sprite.Collection),
            };
            tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>();

            animator.Library       = animator.gameObject.AddComponent <tk2dSpriteAnimation>();
            animator.Library.clips = new tk2dSpriteAnimationClip[0];
            tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip {
                fps = 15, frames = new tk2dSpriteAnimationFrame[0], name = "melt", wrapMode = tk2dSpriteAnimationClip.WrapMode.Once
            };

            for (int i = 0; i < spriteIds.Count; i++)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = spriteIds[i], spriteCollection = item.sprite.Collection
                };
                clip.frames = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray();
            tk2dSpriteAnimationClip clip1 = new tk2dSpriteAnimationClip {
                fps = 15, frames = new tk2dSpriteAnimationFrame[0], name = "unmelt", wrapMode = tk2dSpriteAnimationClip.WrapMode.Once
            };

            for (int i = spriteIds.Count - 1; i > -1; i--)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = spriteIds[i], spriteCollection = item.sprite.Collection
                };
                clip1.frames = clip1.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            animator.Library.clips = animator.Library.clips.Concat(new tk2dSpriteAnimationClip[] { clip1 }).ToArray();
            item.SetupUnlockOnCustomFlag(CustomDungeonFlags.ITEMSPECIFIC_GREEN_CHAMBER, true);
            SpecialItemIds.GreenChamber = item.PickupObjectId;
        }
Пример #37
0
    public override void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
    {
        if (loopToMove && frame.eventInfo.ToLower() == "loop".ToLower())
        {
            isLooping = true;
        }

        base.onEvent(sprite, clip, frame, frameNum);
    }
Пример #38
0
        public SpriteAnimData(string name, Texture2D texture, float width, float height, ScaleType scaleType, int frames, bool loop, float duration)
        {
            this.name   = name;
            this.frames = frames;

            float textureWidth  = texture.width / frames;
            float textureHeight = texture.height;

            switch (scaleType)
            {
            case ScaleType.NONE:
                this.width  = textureWidth;
                this.height = textureHeight;
                break;

            case ScaleType.SCALED_WIDTH:
                this.width  = width;
                this.height = width * textureHeight / textureWidth;
                break;

            case ScaleType.SCALED_HEIGHT:
                this.width  = height * textureWidth / textureHeight;
                this.height = height;
                break;

            case ScaleType.SCALED:
            default:
                this.width  = width;
                this.height = height;
                break;
            }
            this.regionWidth  = textureWidth;
            this.regionHeight =
                texture.wrapMode == TextureWrapMode.Repeat ?
                this.height * textureWidth / this.width :
                textureHeight
            ;

            string[]  names   = new string[frames];
            Rect[]    regions = new Rect[frames];
            Vector2[] anchors = new Vector2[frames];
            for (int i = 0; i < frames; i++)
            {
                names[i]   = String.Format("{0}_frame{1}", name, i);
                regions[i] = new Rect(this.regionWidth * i, 0f, this.regionWidth, this.regionHeight);
                anchors[i] = new Vector2(this.regionWidth / 2, this.regionHeight / 2);
            }

            tk2dRuntime.SpriteCollectionSize size = tk2dRuntime.SpriteCollectionSize.ForTk2dCamera();
            this.data = tk2dRuntime.SpriteCollectionGenerator.CreateFromTexture(texture, size, names, regions, anchors);
            this.data.gameObject.name = String.Format("DataSpriteAnim{0}", name);

            tk2dSpriteAnimationFrame[] animationFrames = new tk2dSpriteAnimationFrame[frames];
            for (int i = 0; i < frames; i++)
            {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                frame.spriteCollection = this.data;
                frame.spriteId         = i;
                animationFrames[i]     = frame;
            }
            tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip();

            clip.fps      = frames / duration;
            clip.name     = name;
            clip.wrapMode = loop ? tk2dSpriteAnimationClip.WrapMode.Loop : tk2dSpriteAnimationClip.WrapMode.Once;
            clip.frames   = animationFrames;

            this.anim       = this.data.gameObject.AddComponent <tk2dSpriteAnimation>();
            this.anim.clips = new tk2dSpriteAnimationClip[] { clip };
        }
 void RockDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     if(frame.eventInfo == "Rock")
         charMovement.throwRock();
 }
	void OnAnimationEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
	{
		SendMessageUpwards(frame.eventInfo);
	}
Пример #41
0
    public virtual void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
    {
        if (frame.eventInfo.ToLower() == "loop".ToLower())
        {
            playAnim("loop");
        }
        else if (frame.eventInfo.ToLower() == "die".ToLower())
        {
            if (ammoDeathCb != null)
            {
                ammoDeathCb(this);
            }

            GameObject.Destroy(this.gameObject);
        }
    }
Пример #42
0
    void AnimationEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
    {
        string str = sprite.name + "\n" + clip.name + "\n" + "INFO: " + frame.eventInfo;

        StartCoroutine(PopupText(str));
    }
Пример #43
0
        public static void InitButterflyPrefab()
        {
            AIActor       aiactor  = SetupAIActorDummy("Butterfly", new IntVector2(0, 0), new IntVector2(10, 10));
            List <string> leftAnim = new List <string>
            {
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_001",
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_002",
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_003"
            };
            List <string> rightAnim = new List <string>
            {
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_001",
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_002",
                "SpecialItemPack/Resources/Butterfly/butterfly_idle_left_003"
            };

            GenerateSpriteAnimator(aiactor.gameObject, null, 0, 0, playAutomatically: true, clipTime: 0, ClipFps: 0);
            tk2dSpriteAnimator spriteAnim = aiactor.gameObject.GetComponent <tk2dSpriteAnimator>();

            spriteAnim.playAutomatically = true;
            spriteAnim.Library           = aiactor.gameObject.AddComponent <tk2dSpriteAnimation>();
            spriteAnim.Library.clips     = new tk2dSpriteAnimationClip[0];
            spriteAnim.DefaultClipId     = 0;
            tk2dSpriteAnimationClip leftClip = new tk2dSpriteAnimationClip {
                fps = 5, frames = new tk2dSpriteAnimationFrame[0], name = "idle_left"
            };

            foreach (string path in leftAnim)
            {
                int id = SpriteBuilder.AddSpriteToCollection(path, SpriteBuilder.itemCollection);
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = id, spriteCollection = SpriteBuilder.itemCollection
                };
                leftClip.frames = leftClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            aiactor.sprite.SetSprite(leftClip.frames[0].spriteCollection, leftClip.frames[0].spriteId);
            spriteAnim.Library.clips = spriteAnim.Library.clips.Concat(new tk2dSpriteAnimationClip[] { leftClip }).ToArray();
            tk2dSpriteAnimationClip rightClip = new tk2dSpriteAnimationClip {
                fps = 5, frames = new tk2dSpriteAnimationFrame[0], name = "idle_right"
            };

            foreach (string path in rightAnim)
            {
                int id = SpriteBuilder.AddSpriteToCollection(path, SpriteBuilder.itemCollection);
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame {
                    spriteId = id, spriteCollection = SpriteBuilder.itemCollection
                };
                rightClip.frames = rightClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray();
            }
            spriteAnim.Library.clips = spriteAnim.Library.clips.Concat(new tk2dSpriteAnimationClip[] { rightClip }).ToArray();
            AIAnimator aiAnim = GenerateBlankAIAnimator(aiactor.gameObject);

            aiAnim.aiAnimator.facingType            = AIAnimator.FacingType.Default;
            aiAnim.aiAnimator.faceSouthWhenStopped  = false;
            aiAnim.aiAnimator.faceTargetWhenStopped = false;
            aiAnim.aiAnimator.HitType = AIAnimator.HitStateType.Basic;
            aiAnim.IdleAnimation      = new DirectionalAnimation
            {
                Type      = DirectionalAnimation.DirectionType.TwoWayHorizontal,
                Flipped   = new DirectionalAnimation.FlipType[2],
                AnimNames = new string[]
                {
                    "idle_right",
                    "idle_left"
                }
            };
            aiAnim.IdleAnimation = aiAnim.MoveAnimation;
            BehaviorSpeculator   chickSpec = EnemyDatabase.GetOrLoadByGuid("76bc43539fc24648bff4568c75c686d1").behaviorSpeculator;
            SpeculativeRigidbody body      = aiactor.specRigidbody;

            body.PixelColliders.RemoveAt(1);
            body.PrimaryPixelCollider.CollisionLayer = CollisionLayer.BulletBlocker;
            BehaviorSpeculator spec = aiactor.behaviorSpeculator;

            spec.OverrideBehaviors               = chickSpec.OverrideBehaviors;
            spec.OtherBehaviors                  = chickSpec.OtherBehaviors;
            spec.TargetBehaviors                 = chickSpec.TargetBehaviors;
            spec.AttackBehaviors                 = chickSpec.AttackBehaviors;
            spec.MovementBehaviors               = chickSpec.MovementBehaviors;
            spec.InstantFirstTick                = chickSpec.InstantFirstTick;
            spec.TickInterval                    = chickSpec.TickInterval;
            spec.PostAwakenDelay                 = chickSpec.PostAwakenDelay;
            spec.RemoveDelayOnReinforce          = chickSpec.RemoveDelayOnReinforce;
            spec.OverrideStartingFacingDirection = chickSpec.OverrideStartingFacingDirection;
            spec.StartingFacingDirection         = chickSpec.StartingFacingDirection;
            spec.SkipTimingDifferentiator        = chickSpec.SkipTimingDifferentiator;
            aiactor.SetIsFlying(true, "butter fly", true, true);
            Game.Enemies.Add("spapi:butterfly", aiactor);
        }
 void AddFrame(tk2dSpriteAnimationClip clip)
 {
     System.Array.Resize(ref clip.frames, clip.frames.Length + 1);
     var newFrame = new tk2dSpriteAnimationFrame();
     newFrame.CopyFrom(clip.frames[clip.frames.Length - 2]); // previous "last" entry
     if (tk2dPreferences.inst.groupAnimDisplay)
     {
         // make sure the spriteId is something different, so it ends up adding a new entry
         var defs = newFrame.spriteCollection.spriteDefinitions;
         for (int j = 0; j < defs.Length; ++j)
         {
             int i = (j + newFrame.spriteId + 1) % defs.Length; // start one after current frame, and work from there looping back
             if (i != newFrame.spriteId && defs[i].Valid)
             {
                 newFrame.spriteId = i;
                 break;
             }
         }
     }
     clip.frames[clip.frames.Length - 1] = newFrame;
     GUI.changed = true;
 }
Пример #45
0
 void Handle_AniSpriteFrameTrigger(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     Color c = sprite.color;
     c.a = frame.eventFloat;
     sprite.color = c;
 }
    void DrawFrameEditor(tk2dSpriteAnimationClip clip, int frameId, int frameCount)
    {
        var frame = clip.frames[frameId];

        tk2dGuiUtility.BeginChangeCheck();
        frame.spriteCollection = tk2dSpriteGuiUtility.SpriteCollectionPopup(frame.spriteCollection);
        if (tk2dGuiUtility.EndChangeCheck())
        {
            frame.spriteId = tk2dSpriteGuiUtility.GetValidSpriteId(frame.spriteCollection, frame.spriteId);
            PropogateFrameChange(clip, frameId, frameCount,
            (dest, src) => { dest.spriteCollection = src.spriteCollection; dest.spriteId = src.spriteId; } );
        }

        tk2dGuiUtility.BeginChangeCheck();
        frame.spriteId = tk2dSpriteGuiUtility.SpriteSelectorPopup(null, frame.spriteId, frame.spriteCollection);
        if (tk2dGuiUtility.EndChangeCheck()) PropogateFrameChange(clip, frameId, frameCount, (dest, src) => dest.spriteId = src.spriteId );

        if (tk2dPreferences.inst.groupAnimDisplay)
        {
            int newFrameCount = EditorGUILayout.Popup(frameCount, GetDurationTableForClip(clip));
            if (newFrameCount != frameCount)
            {
                if (newFrameCount == 0)
                {
                    deferredFrameOp = delegate(tk2dSpriteAnimationClip target)
                    {
                        if (frameCount == target.frames.Length) frameCount--; // don't delete last sprite
                        if (frameCount > 0)
                        {
                            List<tk2dSpriteAnimationFrame> frames = new List<tk2dSpriteAnimationFrame>(target.frames);
                            frames.RemoveRange(frameId, frameCount);
                            target.frames = frames.ToArray();
                        }
                    };
                }
                else if (newFrameCount < frameCount)
                {
                    deferredFrameOp = delegate(tk2dSpriteAnimationClip target)
                    {
                        int toRemove = frameCount - newFrameCount;
                        List<tk2dSpriteAnimationFrame> frames = new List<tk2dSpriteAnimationFrame>(target.frames);
                        frames.RemoveRange(frameId + frameCount - 1 - toRemove, toRemove);
                        target.frames = frames.ToArray();
                    };
                }
                else if (newFrameCount > frameCount)
                {
                    deferredFrameOp = delegate(tk2dSpriteAnimationClip target)
                    {
                        int toAdd = newFrameCount - frameCount;
                        List<tk2dSpriteAnimationFrame> frames = new List<tk2dSpriteAnimationFrame>(target.frames);
                        var source = target.frames[frameId + frameCount - 1]; // last valid one
                        var framesToInsert = new List<tk2dSpriteAnimationFrame>(toAdd);
                        for (int j = 0; j < toAdd; ++j)
                        {
                            tk2dSpriteAnimationFrame f = new tk2dSpriteAnimationFrame();
                            f.CopyFrom(source, false);
                            framesToInsert.Add(f);
                        }
                        frames.InsertRange(frameId + frameCount, framesToInsert);
                        target.frames = frames.ToArray();
                    };
                }
            }
            GUILayout.Space(8);
        }

        tk2dGuiUtility.BeginChangeCheck();
        frame.triggerEvent = EditorGUILayout.Toggle("Trigger", frame.triggerEvent);
        if (tk2dGuiUtility.EndChangeCheck()) PropogateFrameChange(clip, frameId, frameCount, (dest, src) => dest.triggerEvent = src.triggerEvent );
        if (frame.triggerEvent)
        {
            EditorGUI.indentLevel++;

            tk2dGuiUtility.BeginChangeCheck();
            frame.eventInfo = EditorGUILayout.TextField("Info", frame.eventInfo);
            if (tk2dGuiUtility.EndChangeCheck()) PropogateFrameChange(clip, frameId, frameCount, (dest, src) => dest.eventInfo = src.eventInfo );

            tk2dGuiUtility.BeginChangeCheck();
            frame.eventFloat = EditorGUILayout.FloatField("Float", frame.eventFloat);
            if (tk2dGuiUtility.EndChangeCheck()) PropogateFrameChange(clip, frameId, frameCount, (dest, src) => dest.eventFloat = src.eventFloat );

            tk2dGuiUtility.BeginChangeCheck();
            frame.eventInt = EditorGUILayout.IntField("Int", frame.eventInt);
            if (tk2dGuiUtility.EndChangeCheck()) PropogateFrameChange(clip, frameId, frameCount, (dest, src) => dest.eventInt = src.eventInt );

            GUILayout.Space(8);
            EditorGUI.indentLevel--;
        }
    }
    public override void OnInspectorGUI()
    {
        InitializeInspector();

        if (spriteCollectionIndex == null || allSpriteCollectionNames == null)
        {
            GUILayout.Label("data not found");
            if (GUILayout.Button("Refresh"))
            {
                initialized = false;
                InitializeInspector();
            }
            return;
        }


        tk2dSpriteAnimation anim = (tk2dSpriteAnimation)target;

        EditorGUILayout.BeginVertical();

        EditorGUI.indentLevel = 1;
        EditorGUILayout.BeginVertical();

        if (anim.clips.Length == 0)
        {
            if (GUILayout.Button("Add clip"))
            {
                anim.clips           = new tk2dSpriteAnimationClip[1];
                anim.clips[0]        = new tk2dSpriteAnimationClip();
                anim.clips[0].name   = "New Clip 0";
                anim.clips[0].frames = new tk2dSpriteAnimationFrame[1];

                anim.clips[0].frames[0] = new tk2dSpriteAnimationFrame();
                anim.clips[0].frames[0].spriteCollection = GetSpriteCollection(0);
                anim.clips[0].frames[0].spriteId         = 0;
            }
        }
        else         // has anim clips
        {
            // All clips
            string[] allClipNames = new string[anim.clips.Length];
            for (int i = 0; i < anim.clips.Length; ++i)
            {
                allClipNames[i] = anim.clips[i].name;
            }
            currentClip = Mathf.Clamp(currentClip, 0, anim.clips.Length);

            #region AddAndDeleteClipButtons
            EditorGUILayout.BeginHorizontal();
            currentClip = EditorGUILayout.Popup("Clips", currentClip, allClipNames);

            // Add new clip
            if (GUILayout.Button("+", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)))
            {
                int previousClipId = currentClip;

                // try to find an empty slot
                currentClip = -1;
                for (int i = 0; i < anim.clips.Length; ++i)
                {
                    if (anim.clips[i].name.Length == 0)
                    {
                        currentClip = i;
                        break;
                    }
                }

                if (currentClip == -1)
                {
                    tk2dSpriteAnimationClip[] clips = new tk2dSpriteAnimationClip[anim.clips.Length + 1];
                    for (int i = 0; i < anim.clips.Length; ++i)
                    {
                        clips[i] = anim.clips[i];
                    }
                    currentClip        = anim.clips.Length;
                    clips[currentClip] = new tk2dSpriteAnimationClip();
                    anim.clips         = clips;
                }

                string uniqueName = "New Clip ";
                int    uniqueId   = 0;
                for (int i = 0; i < anim.clips.Length; ++i)
                {
                    string uname = uniqueName + uniqueId.ToString();
                    if (anim.clips[i].name == uname)
                    {
                        uniqueId++;
                        i = -1;
                        continue;
                    }
                }

                anim.clips[currentClip]          = new tk2dSpriteAnimationClip();
                anim.clips[currentClip].name     = uniqueName + uniqueId.ToString();
                anim.clips[currentClip].fps      = 15;
                anim.clips[currentClip].wrapMode = tk2dSpriteAnimationClip.WrapMode.Loop;
                anim.clips[currentClip].frames   = new tk2dSpriteAnimationFrame[1];
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                if (previousClipId < anim.clips.Length &&
                    anim.clips[previousClipId] != null &&
                    anim.clips[previousClipId].frames != null &&
                    anim.clips[previousClipId].frames.Length != 0 &&
                    anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1] != null &&
                    anim.clips[previousClipId].frames[anim.clips[previousClipId].frames.Length - 1].spriteCollection != null)
                {
                    var previousClip = anim.clips[previousClipId];
                    var lastFrame    = previousClip.frames[previousClip.frames.Length - 1];
                    frame.spriteCollection = lastFrame.spriteCollection;
                    frame.spriteId         = lastFrame.spriteId;
                }
                else
                {
                    frame.spriteCollection = GetSpriteCollection(0);
                    frame.spriteId         = 0;
                }
                anim.clips[currentClip].frames[0] = frame;

                GUI.changed = true;
            }

            // Delete clip
            if (GUILayout.Button("-", GUILayout.MaxWidth(28), GUILayout.MaxHeight(14)))
            {
                anim.clips[currentClip].name   = "";
                anim.clips[currentClip].frames = new tk2dSpriteAnimationFrame[0];

                currentClip = 0;
                // find first non zero clip
                for (int i = 0; i < anim.clips.Length; ++i)
                {
                    if (anim.clips[i].name != "")
                    {
                        currentClip = i;
                        break;
                    }
                }

                GUI.changed = true;
            }
            EditorGUILayout.EndHorizontal();
            #endregion

            #region PruneClipList
            // Prune clip list
            int lastActiveClip = 0;
            for (int i = 0; i < anim.clips.Length; ++i)
            {
                if (!(anim.clips[i].name == "" && anim.clips[i].frames != null && anim.clips[i].frames.Length == 0))
                {
                    lastActiveClip = i;
                }
            }
            if (lastActiveClip != anim.clips.Length - 1)
            {
                System.Array.Resize <tk2dSpriteAnimationClip>(ref anim.clips, lastActiveClip + 1);
                GUI.changed = true;
            }
            #endregion

            // If anything has changed up to now, redraw
            if (GUI.changed)
            {
                EditorUtility.SetDirty(anim);
                Repaint();
                return;
            }

            EditorGUI.indentLevel = 2;
            tk2dSpriteAnimationClip clip = anim.clips[currentClip];

            // Clip properties

            // Name
            clip.name = EditorGUILayout.TextField("Name", clip.name);

            #region NumberOfFrames
            // Number of frames
            int clipNumFrames = (clip.frames != null)?clip.frames.Length:0;
            int newFrameCount = 0;
            if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.Single)
            {
                newFrameCount = 1;                 // only one frame, no need to display
            }
            else
            {
                int      maxFrameCount = 100;
                string[] numFrameStr   = new string[maxFrameCount];
                for (int i = 1; i < maxFrameCount; ++i)
                {
                    numFrameStr[i] = i.ToString();
                }

                newFrameCount = EditorGUILayout.Popup("Num Frames", clipNumFrames, numFrameStr);
                if (newFrameCount == 0)
                {
                    newFrameCount = 1;                                     // minimum = 1
                }
            }

            if (newFrameCount != clipNumFrames)
            {
                tk2dSpriteAnimationFrame[] frames = new tk2dSpriteAnimationFrame[newFrameCount];

                int c1 = Mathf.Min(clipNumFrames, frames.Length);
                for (int i = 0; i < c1; ++i)
                {
                    frames[i] = new tk2dSpriteAnimationFrame();
                    frames[i].spriteCollection = clip.frames[i].spriteCollection;
                    frames[i].spriteId         = clip.frames[i].spriteId;
                }
                if (c1 > 0)
                {
                    for (int i = c1; i < frames.Length; ++i)
                    {
                        frames[i] = new tk2dSpriteAnimationFrame();
                        frames[i].spriteCollection = clip.frames[c1 - 1].spriteCollection;
                        frames[i].spriteId         = clip.frames[c1 - 1].spriteId;
                    }
                }
                else
                {
                    for (int i = 0; i < frames.Length; ++i)
                    {
                        frames[i] = new tk2dSpriteAnimationFrame();
                        frames[i].spriteCollection = GetSpriteCollection(0);
                        frames[i].spriteId         = 0;
                    }
                }

                clip.frames   = frames;
                clipNumFrames = newFrameCount;
            }
            #endregion

            // Frame rate
            if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single)
            {
                clip.fps = EditorGUILayout.FloatField("Frame rate", clip.fps);
            }

            // Wrap mode
            clip.wrapMode = (tk2dSpriteAnimationClip.WrapMode)EditorGUILayout.EnumPopup("Wrap mode", clip.wrapMode);
            if (clip.wrapMode == tk2dSpriteAnimationClip.WrapMode.LoopSection)
            {
                clip.loopStart = EditorGUILayout.IntField("Loop start", clip.loopStart);
                clip.loopStart = Mathf.Clamp(clip.loopStart, 0, clip.frames.Length - 1);
            }

            #region DrawFrames
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Frames");
            GUILayout.FlexibleSpace();

            // Reverse
            if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single &&
                GUILayout.Button("Reverse"))
            {
                System.Array.Reverse(clip.frames);
                GUI.changed = true;
            }

            // Auto fill
            if (clip.wrapMode != tk2dSpriteAnimationClip.WrapMode.Single && clip.frames.Length >= 1)
            {
                AutoFill(clip);
            }

            if (GUILayout.Button(tk2dPreferences.inst.horizontalAnimDisplay?"H":"V", GUILayout.MaxWidth(24)))
            {
                tk2dPreferences.inst.horizontalAnimDisplay = !tk2dPreferences.inst.horizontalAnimDisplay;
                Repaint();
            }
            EditorGUILayout.EndHorizontal();

            // Sanitize frame data
            for (int i = 0; i < clip.frames.Length; ++i)
            {
                if (clip.frames[i].spriteCollection == null || clip.frames[i].spriteCollection.spriteDefinitions.Length == 0)
                {
                    EditorUtility.DisplayDialog("Warning", "Invalid sprite collection found.\nThis clip will now be deleted", "Ok");

                    clip.name   = "";
                    clip.frames = new tk2dSpriteAnimationFrame[0];
                    Repaint();
                    return;
                }

                if (clip.frames[i].spriteId < 0 || clip.frames[i].spriteId >= clip.frames[i].spriteCollection.Count)
                {
                    EditorUtility.DisplayDialog("Warning", "Invalid frame found, resetting to frame 0", "Ok");
                    clip.frames[i].spriteId = 0;
                }
            }

            // Warning when one of the frames has different poly count
            if (clipNumFrames > 0)
            {
                bool differentPolyCount = false;
                int  polyCount          = clip.frames[0].spriteCollection.spriteDefinitions[clip.frames[0].spriteId].positions.Length;
                for (int i = 1; i < clipNumFrames; ++i)
                {
                    int thisPolyCount = clip.frames[i].spriteCollection.spriteDefinitions[clip.frames[i].spriteId].positions.Length;
                    if (thisPolyCount != polyCount)
                    {
                        differentPolyCount = true;
                        break;
                    }
                }

                if (differentPolyCount)
                {
                    Color bg = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;
                    GUILayout.TextArea("Sprites have different poly counts. Performance will be affected");
                    GUI.backgroundColor = bg;
                }
            }

            // Draw frames
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space();
            if (tk2dPreferences.inst.horizontalAnimDisplay)
            {
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(144.0f));
                EditorGUILayout.BeginHorizontal();

                for (int i = 0; i < clipNumFrames; ++i)
                {
                    int currSpriteCollectionId = GetSpriteCollectionId(clip.frames[i].spriteCollection);
                    EditorGUILayout.BeginHorizontal();

                    GUILayout.Label(i.ToString());
                    DrawSpritePreview(currSpriteCollectionId, clip.frames[i].spriteId);

                    EditorGUILayout.BeginVertical();
                    {
                        int newSpriteCollectionId = EditorGUILayout.Popup(currSpriteCollectionId, allSpriteCollectionNames);
                        if (newSpriteCollectionId != currSpriteCollectionId)
                        {
                            clip.frames[i].spriteCollection = GetSpriteCollection(newSpriteCollectionId);
                            clip.frames[i].spriteId         = 0;
                        }

                        clip.frames[i].spriteId = tk2dEditorUtility.SpriteSelectorPopup(null, clip.frames[i].spriteId, clip.frames[i].spriteCollection);

                        clip.frames[i].triggerEvent = EditorGUILayout.Toggle("Trigger", clip.frames[i].triggerEvent);
                        if (clip.frames[i].triggerEvent)
                        {
                            clip.frames[i].eventInfo  = EditorGUILayout.TextField("Trigger info", clip.frames[i].eventInfo);
                            clip.frames[i].eventFloat = EditorGUILayout.FloatField("Trigger float", clip.frames[i].eventFloat);
                            clip.frames[i].eventInt   = EditorGUILayout.IntField("Trigger int", clip.frames[i].eventInt);
                        }
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndScrollView();
            }
            else
            {
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
                EditorGUILayout.BeginVertical();

                for (int i = 0; i < clipNumFrames; ++i)
                {
                    EditorGUILayout.BeginHorizontal();

                    GUILayout.Label(i.ToString());

                    int currSpriteCollectionId = GetSpriteCollectionId(clip.frames[i].spriteCollection);

                    EditorGUILayout.BeginVertical();
                    {
                        int newSpriteCollectionId = EditorGUILayout.Popup(currSpriteCollectionId, allSpriteCollectionNames);
                        if (newSpriteCollectionId != currSpriteCollectionId)
                        {
                            clip.frames[i].spriteCollection = GetSpriteCollection(newSpriteCollectionId);
                            clip.frames[i].spriteId         = 0;
                        }

                        clip.frames[i].spriteId = tk2dEditorUtility.SpriteSelectorPopup(null, clip.frames[i].spriteId, clip.frames[i].spriteCollection);

                        clip.frames[i].triggerEvent = EditorGUILayout.Toggle("Trigger", clip.frames[i].triggerEvent);
                        if (clip.frames[i].triggerEvent)
                        {
                            clip.frames[i].eventInfo  = EditorGUILayout.TextField("Trigger info", clip.frames[i].eventInfo);
                            clip.frames[i].eventFloat = EditorGUILayout.FloatField("Trigger float", clip.frames[i].eventFloat);
                            clip.frames[i].eventInt   = EditorGUILayout.IntField("Trigger int", clip.frames[i].eventInt);
                        }
                    }
                    EditorGUILayout.EndVertical();

                    DrawSpritePreview(currSpriteCollectionId, clip.frames[i].spriteId);

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                EditorGUILayout.EndScrollView();
            }

            EditorGUILayout.EndHorizontal();
            #endregion
        }

        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(anim);
        }
    }
Пример #48
0
 public static void SetCollection(this tk2dSpriteAnimationFrame frame, tk2dSpriteCollectionData collection)
 {
     frame.spriteCollection = collection;
 }
Пример #49
0
 public void CopyFrom(tk2dSpriteAnimationFrame source)
 {
     CopyFrom(source, true);
 }
Пример #50
0
 void AnimationEventDelegate(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     string str = sprite.name + "\n" + clip.name + "\n" + "INFO: " + frame.eventInfo;
     StartCoroutine( PopupText( str ) );
 }
			public int startFrame = 0; // this is a cache value used during the draw loop

			public bool SetFrameCount(int targetFrameCount)
			{
				bool changed = false;
				if (frames.Count > targetFrameCount)
				{
					frames.RemoveRange(targetFrameCount, frames.Count - targetFrameCount);
					changed = true;
				}
				while (frames.Count < targetFrameCount)
				{
					tk2dSpriteAnimationFrame f = new tk2dSpriteAnimationFrame();
					f.spriteCollection = spriteCollection;
					f.spriteId = spriteId;
					frames.Add(f);
					changed = true;
				}
				return changed;
			}
Пример #52
0
        public SpriteAnimData(string name, Texture2D texture, float width, float height, ScaleType scaleType, int frames, bool loop, float duration)
        {
            this.name = name;
            this.frames = frames;

            float textureWidth = texture.width / frames;
            float textureHeight = texture.height;
            switch (scaleType) {
                case ScaleType.NONE:
                    this.width = textureWidth;
                    this.height = textureHeight;
                    break;
                case ScaleType.SCALED_WIDTH:
                    this.width = width;
                    this.height = width * textureHeight / textureWidth;
                    break;
                case ScaleType.SCALED_HEIGHT:
                    this.width = height * textureWidth / textureHeight;
                    this.height = height;
                    break;
                case ScaleType.SCALED:
                default:
                    this.width = width;
                    this.height = height;
                    break;
            }
            this.regionWidth = textureWidth;
            this.regionHeight =
                texture.wrapMode == TextureWrapMode.Repeat ?
                this.height * textureWidth / this.width :
                textureHeight
            ;

            string[] names = new string[frames];
            Rect[] regions = new Rect[frames];
            Vector2[] anchors = new Vector2[frames];
            for (int i = 0; i < frames; i++) {
                names[i] = String.Format("{0}_frame{1}", name, i);
                regions[i] = new Rect(this.regionWidth * i, 0f, this.regionWidth, this.regionHeight);
                anchors[i] = new Vector2(this.regionWidth / 2, this.regionHeight / 2);
            }

            tk2dRuntime.SpriteCollectionSize size = tk2dRuntime.SpriteCollectionSize.ForTk2dCamera();
            this.data = tk2dRuntime.SpriteCollectionGenerator.CreateFromTexture(texture, size, names, regions, anchors);
            this.data.gameObject.name = String.Format("DataSpriteAnim{0}", name);

            tk2dSpriteAnimationFrame[] animationFrames = new tk2dSpriteAnimationFrame[frames];
            for (int i = 0; i < frames; i++) {
                tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame();
                frame.spriteCollection = this.data;
                frame.spriteId = i;
                animationFrames[i] = frame;
            }
            tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip();
            clip.fps = frames / duration;
            clip.name = name;
            clip.wrapMode = loop ? tk2dSpriteAnimationClip.WrapMode.Loop : tk2dSpriteAnimationClip.WrapMode.Once;
            clip.frames = animationFrames;

            this.anim = this.data.gameObject.AddComponent<tk2dSpriteAnimation>();
            this.anim.clips = new tk2dSpriteAnimationClip[] { clip };
        }
Пример #53
0
 public void CopyFrom(tk2dSpriteAnimationFrame source)
 {
     CopyFrom(source, true);
 }
Пример #54
0
 void PlayerAnim(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum)
 {
     if(frame.eventInt == 2){
         SpecialAttack();
     }
     if(frame.eventFloat != 0f){
         if(frame.eventFloat == 5f){
             grabbedHitCount++;
             if(grabbedHitCount==3){
                 hitBoxes[(int)(frame.eventFloat-1f)].GetComponent<mirrorCol>().collisionType = CollisionType.strong;
             }
         }
         hitBoxes[(int)(frame.eventFloat-1f)].GetComponent<mirrorCol>().Attack();
     }
     if(frame.eventInfo == "continue" && isPlayer){
         if(frame.eventInt==1){
             if(nextAttack){
                 nextAttack=false;
             }
             else{
                 states = PlayerStates.idle;
                 player.Play("Idle");
             }
         }
     }
     if(frame.eventInfo == "returngrab"){
         if(grabbedHitCount==3){
             grabbedHitCount=0;
             player.Play("Idle");
             states = PlayerStates.idle;
         }
         else{
             player.Play("grab");
             states = PlayerStates.grab;
         }
     }
     if(frame.eventInfo == "returngrabbed"){
         if(transform.parent != null){
             player.Play("grabbed");
             states = PlayerStates.grabbed;
         }
         else{
             player.Play("Idle");
             states = PlayerStates.idle;
         }
     }
     if(frame.eventInfo == "preparethrow"){
         PrepareToThrow();
     }
     if(frame.eventInfo == "throw"){
         Throw();
     }
     if(frame.eventInfo == "return"){
         nextAttack=false;
         states = PlayerStates.idle;
         player.Play("Idle");
     }
     if(frame.eventInfo == "isdead?"){
         if(life==0){
             player.Play("knocked");
             states = PlayerStates.dead;
         }
     }
 }