// Use this for initialization void Start() { _aniSp = GetComponent<tk2dAnimatedSprite>(); if (_aniSp == null) return; _aniSp.Play(0); StartCoroutine(accelerate()); }
public void animationCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { if(animationName_002 != "") { animatedSprite.Play(animationName_002); animatedSprite.animationCompleteDelegate -= animationCompleteDelegate; } }
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); }
// Use this for initialization void Start () { Screen.sleepTimeout = (int)SleepTimeout.NeverSleep; anim = GetComponent<tk2dAnimatedSprite>(); flipped = hasflipped = false; // set character skin if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.ANDY_GOOD.ItemId)) { anim.Play("Andy"); } if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.KELLY_GOOD.ItemId)) { anim.Play("Kelly"); } if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.NINJA_GOOD.ItemId)) { anim.Play("Ninja"); } if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIG_GOOD.ItemId)) { anim.Play("Pig"); } if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.PIRATE_GOOD.ItemId)) { anim.Play("Pirate"); } if (StoreInventory.IsVirtualGoodEquipped(AndysApplesAssets.WIZARD_GOOD.ItemId)) { anim.Play("Wizard"); } }
void Start() { mAnimSprite = GetComponent<tk2dAnimatedSprite>(); if(mAnimSprite != null && !mAnimSprite.playAutomatically) { mAnimSprite.Play(); } }
protected override void OnTouchDown() { if (instance == null && food == null) { instance = Instantiate(Resources.Load(PATH_OF_INSTANCE_PREFAB, typeof(GameObject))) as GameObject; instance.transform.position = instancePosition; instance.gameObject.name = GoodDataStore.FoodMenuList.Iced_greenTea.ToString(); baseScene.audioEffect.PlayOnecWithOutStop(baseScene.soundEffect_clips[2]); animatedInstance = instance.GetComponent<tk2dAnimatedSprite>(); animatedInstance.Play(); food = instance.GetComponent<GoodsBeh>(); food.offsetPos = Vector3.up * 4; food.costs = stageManager.goodDataStore.FoodDatabase_list[(int)GoodDataStore.FoodMenuList.Iced_greenTea].costs; food.GoodsBeh_putObjectOnTray_Event = Handle_putObjectOnTray_Event; food.ObjectsBeh_destroyObj_Event = Handle_destroyObj_Event; animatedInstance.animationCompleteDelegate = delegate(tk2dAnimatedSprite sprite, int clipId) { food._canDragaable = true; }; } base.OnTouchDown(); }
protected override void OnTouchDown() { if (soup_instance == null && soup == null) { soup_instance = Instantiate(Resources.Load(PATH_OF_SOUP_INSTANCE, typeof(GameObject))) as GameObject; soup_instance.transform.position = instancePosition; soup_instance.gameObject.name = GoodDataStore.FoodMenuList.Miso_soup.ToString(); animatedInstance = soup_instance.GetComponent<tk2dAnimatedSprite>(); animatedInstance.Play(); soup = soup_instance.GetComponent<GoodsBeh>(); soup.costs = stageManager.goodDataStore.FoodDatabase_list[(int)GoodDataStore.FoodMenuList.Miso_soup].costs; soup.offsetPos = Vector3.up * 4.5f; soup.GoodsBeh_putObjectOnTray_Event = Handle_putObjectOnTray_Event; soup.ObjectsBeh_destroyObj_Event = Handle_destroyObj_Event; animatedInstance.animationCompleteDelegate = delegate(tk2dAnimatedSprite sprite, int clipId) { soup._canDragaable = true; }; // Play sound effect. baseScene.audioEffect.PlayOnecWithOutStop(baseScene.soundEffect_clips[4]); } base.OnTouchDown(); }
public override void init() { base.init (); _renderer = GetComponent<Renderer>(); _animSprite = _sprite as tk2dAnimatedSprite; _type = GridPiece.WALL_TYPE | GridPiece.NPC_TYPE | GridPiece.PLAYER_TYPE; }
public void precacheAnimation(tk2dAnimatedSprite sprite, string animations) { if (!_spriteAnimations.ContainsKey(animations)) loadSpriteAnimation(animations); sprite.anim = _spriteAnimations[animations]; }
public void InstantiateCards(GameObject prefab) { cardOne = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; cardTwo = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; as1 = cardOne.GetComponent<tk2dAnimatedSprite>(); as2 = cardTwo.GetComponent<tk2dAnimatedSprite>(); }
void Start() { objSprite = GetComponent<tk2dAnimatedSprite>(); objSprite.animationCompleteDelegate = HitCompleteDelegate; objSprite.animationEventDelegate = FrameDeploymentTrigger; base.Start(); }
// plays the looping animation after the begin animation ends public void AnimationComplete(tk2dAnimatedSprite touchAnim, int clipId) { switch (clipId) { case 0: touchAnim.Play(touchAnimations[1]); break; } }
void FrameDeploymentTrigger(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { //Debug.Log("MinigunBoxController:FrameDeploymentTrigger()"); DeployGun(); }
// This is called once the hit animation has compelted playing // It returns to playing whatever animation was active before hit // was playing. void HitCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { if (walking) { anim.Play("walk"); } else { anim.Play("idle"); } }
// Use this for initialization protected void Awake () { if (mySprite == null) { mySprite = GetComponent<tk2dAnimatedSprite>(); } mySprite.Play(animationName); }
// Use this for initialization protected override void Start () { if (actionEffectAnimation == null) actionEffectAnimation = GetComponent<tk2dAnimatedSprite>(); actionEffectAnimation.animationCompleteDelegate = AnimationCompleteDelegate; base.Start(); }
protected override void Awake() { base.Awake(); mSprite = GetComponentInChildren<tk2dAnimatedSprite>(); mStats = GetComponentInChildren<StatBase>(); mActTarget = GetComponentInChildren<ActionTarget>(); //hook calls up }
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); } ); }
private void _getSprite() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } _sprite = go.GetComponent<tk2dAnimatedSprite>(); }
void Awake() { mSpriteBatcher = GetComponent<tk2dStaticSpriteBatcher>(); mSprite = GetComponent<tk2dBaseSprite>(); mSpriteAnim = mSprite != null ? mSprite as tk2dAnimatedSprite : null; if(mSpriteAnim != null) { mSpriteAnim.animationCompleteDelegate += OnSpriteAnimComplete; } }
protected virtual void Awake() { GameObject sceneObj = GameObject.FindGameObjectWithTag("GameController"); baseScene = sceneObj.GetComponent<Mz_BaseScene>(); try { sprite = this.gameObject.GetComponent<tk2dSprite>(); animatedSprite = this.gameObject.GetComponent<tk2dAnimatedSprite>(); } catch { } }
void findAnimations(Transform currentTransform) { foreach (Transform child in currentTransform) { if (child.gameObject.name == "anim_recycle") trashAnimation = (tk2dAnimatedSprite)child.gameObject.GetComponent(typeof(tk2dAnimatedSprite)); findAnimations(child); } }
void Start() { transform.localRotation = Quaternion.identity; sprite = GetComponent<tk2dAnimatedSprite>(); parent = transform.parent.GetComponent<Malisse>(); Walker = GetComponent<RoadWalker>(); Walker.RoadToWalk = GameUtils.FindAssociatedLevel(transform).transform.Find("Road").GetComponent<Spline>(); Walker.Stop(); }
public void Start() { if (Started) return; Started = true; Transform = transform; _growAnimationKey = color + "ShieldGrow"; var shrinkAnimationKey = color + "ShieldShrink"; _animation = GetComponent<tk2dAnimatedSprite>(); _growAnimationClipId = _animation.GetClipIdByName(_growAnimationKey); _shrinkAnimationClipId = _animation.GetClipIdByName(shrinkAnimationKey); _growDamageTaken = _growClipLength = _animation.anim.clips[_growAnimationClipId].frames.Length - 1; _shrinkClipLength = _animation.anim.clips[_shrinkAnimationClipId].frames.Length - 1; }
void Awake() { animatedSprite = GetComponent<tk2dAnimatedSprite>(); frameActions = new Dictionary<string, FrameActionHandler>(); clipMovementSpeeds = new Dictionary<string, float>(); GetComponent<tk2dAnimatedSprite>().animationEventDelegate += HandleAnimationEvent; frameActions["move"] = (s, f, i) => transform.position += transform.right * i; frameActions["lock"] = (s, f, i) => animLock = true; frameActions["unlock"] = (s, f, i) => animLock = false; foreach(var clip in GetComponent<tk2dAnimatedSprite>().anim.clips){ clipMovementSpeeds[clip.name] = CalculateClipMoveSpeed(clip); } }
void AttackNotChargeCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { isAttacking = false; hasReleased = false; attackState = AttackState.Idle; chargeStage = ChargeStage.NotCharge; weaponDegree = weaponStartingDegree; if (Input.GetKey ("/")) { Attack (); } // if (Input.touches.Length == 1) // Attack (); }
void JumpCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { if(dJump == DirectionJump.left && sJump == StateJump.launch){// && //!anim.IsPlaying("Jump_Left")){ anim.Play("Jump_Left"); anim.animationCompleteDelegate = null; sJump = StateJump.air; } else if(dJump == DirectionJump.right && sJump == StateJump.launch){// && //!anim.IsPlaying("Jump_Left")){ anim.Play("Jump_Right"); anim.animationCompleteDelegate = null; sJump = StateJump.air; } }
void LandCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { /* if(dJump == DirectionJump.left){ sJump = StateJump.none; anim.Play("Idle_Left"); anim.animationCompleteDelegate = null; charMovement.state = CharacterMovement.states.idleLeft; } else if(dJump == DirectionJump.right){ sJump = StateJump.none; anim.Play("Idle_Right"); anim.animationCompleteDelegate = null; charMovement.state = CharacterMovement.states.idleRight; } charMovement.landing = false; doneLanding = true; falling = false;*/ if(lastClip == "Idle_Left" || lastClip == "Walk_Left"){ dJump = DirectionJump.left; sJump = StateJump.none; anim.Play("Idle_Left"); anim.animationCompleteDelegate = null; charMovement.state = CharacterMovement.states.idleLeft; } else if(lastClip == "Idle_Right" || lastClip == "Walk_Right"){ dJump = DirectionJump.right; sJump = StateJump.none; anim.Play("Idle_Right"); anim.animationCompleteDelegate = null; charMovement.state = CharacterMovement.states.idleRight; } charMovement.landing = false; doneLanding = true; falling = false; throwingRock = false; charMovement.throwingRock = false; }
public void configure(CustomerDesc desc) { _desc = desc; _sprite = gameObject.AddComponent<tk2dAnimatedSprite>(); ContentManager.instance.configureObject(_sprite, _desc.spriteAtlas, _desc.spriteName); Debug.Log("Old animation atlas - "+_desc.animationAtlas); ContentManager.instance.precacheAnimation(_sprite, _desc.animationAtlas); _currentMood = 100; _moodDownSpeed = 60f/desc.moodDownTime; GameObject tableGO = (GameObject)Instantiate((GameObject)Resources.Load("Prefabs/OrderTable"), Vector3.zero, Quaternion.identity); _orderTable = tableGO.GetComponent<OrderTable>(); BoxCollider box = gameObject.AddComponent<BoxCollider>(); box.size = new Vector3(_sprite.GetBounds().size.x, _sprite.GetBounds().size.y, 1); _sprite.Play("hello"); setState(CustomerStateDeprecated.WAITING_STAND); }
void Start () { if (entityComponent == null) entityComponent = transform.parent.parent.GetComponent<EntityComponent>(); if (actionManager == null) actionManager = transform.parent.parent.FindChild("Attack").GetComponent<ActionManager>(); if (mySprite == null) mySprite = this.GetComponent<tk2dAnimatedSprite>(); //Attach ourselves to the relevant events entityComponent.onEntityDeath += HandleOnEntityDeath; entityComponent.onEntityDestroyed += HandleOnEntityDestroyed; if (actionManager != null) { actionManager.OnChargingActionEvent += HandleOnChargingActionEvent; actionManager.OnPerformingActionEvent += HandleOnActionEvent; actionManager.OnTargetHitEvent += HandleOnTargetHitEvent; } prevFacing = Facing.Right; playingIdleAnim = true; playingWalkAnim = false; playingEventAnim = false; mySprite.animationCompleteDelegate = OnAnimationComplete; mySprite.animationEventDelegate = OnAnimationEvent; //When the Entity moves we want to play the movement animation //When the Entity does a pre/during/post attack we want to play the pre/during/post attack animation //We'll have to check every once in a while to see if the entity is moving or not in Update and change the animation accordingly //while also keeping track of the fact that we don't want to co-opt other animations currently playing. }
public void onFxComplete(tk2dAnimatedSprite sprite, int clipId) { Destroy(sprite.gameObject); }
public override void OnInspectorGUI() { spriteUiVisible = EditorGUILayout.Foldout(spriteUiVisible, "Sprite"); if (spriteUiVisible) { base.OnInspectorGUI(); } Init(); if (animLibs == null) { GUILayout.Label("no libraries found"); if (GUILayout.Button("Refresh")) { initialized = false; Init(); } } else { tk2dAnimatedSprite sprite = (tk2dAnimatedSprite)target; EditorGUIUtility.LookLikeInspector(); EditorGUI.indentLevel = 1; if (sprite.anim == null) { sprite.anim = animLibs[0]; GUI.changed = true; } // Display animation library int selAnimLib = 0; for (int i = 0; i < animLibs.Length; ++i) { if (animLibs[i] == sprite.anim) { selAnimLib = i; break; } } int newAnimLib = EditorGUILayout.Popup("Anim Lib", selAnimLib, animLibNames); if (newAnimLib != selAnimLib) { sprite.anim = animLibs[newAnimLib]; sprite.clipId = 0; if (sprite.anim.clips.Length > 0) { // automatically switch to the first frame of the new clip sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection, sprite.anim.clips[sprite.clipId].frames[0].spriteId); } } // Everything else if (sprite.anim && sprite.anim.clips.Length > 0) { int clipId = sprite.clipId; // Sanity check clip id clipId = Mathf.Clamp(clipId, 0, sprite.anim.clips.Length - 1); if (clipId != sprite.clipId) { sprite.clipId = clipId; GUI.changed = true; } string[] clipNames = new string[sprite.anim.clips.Length]; // fill names (with ids if necessary) if (tk2dPreferences.inst.showIds) { for (int i = 0; i < sprite.anim.clips.Length; ++i) { if (sprite.anim.clips[i].name != null && sprite.anim.clips[i].name.Length > 0) { clipNames[i] = sprite.anim.clips[i].name + "\t[" + i.ToString() + "]"; } else { clipNames[i] = sprite.anim.clips[i].name; } } } else { for (int i = 0; i < sprite.anim.clips.Length; ++i) { clipNames[i] = sprite.anim.clips[i].name; } } int newClipId = EditorGUILayout.Popup("Clip", sprite.clipId, clipNames); if (newClipId != sprite.clipId) { sprite.clipId = newClipId; // automatically switch to the first frame of the new clip sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection, sprite.anim.clips[sprite.clipId].frames[0].spriteId); } } // Play automatically sprite.playAutomatically = EditorGUILayout.Toggle("Play automatically", sprite.playAutomatically); bool oldCreateCollider = sprite.createCollider; sprite.createCollider = EditorGUILayout.Toggle("Create collider", sprite.createCollider); if (oldCreateCollider != sprite.createCollider) { sprite.EditMode__CreateCollider(); } if (GUI.changed) { EditorUtility.SetDirty(sprite); } } }
// Use this for initialization void Start() { anim = GetComponent <tk2dAnimatedSprite>(); camera = FindObjectOfType(typeof(Camera)) as Camera; heart = FindObjectOfType(typeof(Heart)) as Heart; }
public override void OnInspectorGUI() { bool doConvert = false; base.OnInspectorGUI(); tk2dGuiUtility.InfoBox("The tk2dAnimatedSprite has been deprecated in favor of the new tk2dSpriteAnimator behaviour. " + "Using this new system will allow you to animate other kinds of sprites, etc. " + "The tk2dAnimatedSprite is now a wrapper to this system, but you can upgrade entirely to the new system " + "if you choose to", tk2dGuiUtility.WarningLevel.Warning); GUILayout.Space(8); GUI.backgroundColor = Color.red; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Convert to SpriteAnimator", GUILayout.Width(200)) && EditorUtility.DisplayDialog("Convert to SpriteAnimator", "Converting to the SpriteAnimator system will require you to manually fix " + "all references of this tk2dSpriteAnimation.\n\n" + "Are you sure you wish to proceed?", "Yes", "No")) { doConvert = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; GUILayout.Space(8); if (doConvert) { #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 Undo.RegisterSceneUndo("Convert animated sprite -> sprite animator"); #else int undoGroup = Undo.GetCurrentGroup(); #endif foreach (Object target in targets) { tk2dAnimatedSprite animSprite = target as tk2dAnimatedSprite; GameObject animSpriteGameObject = animSprite.gameObject; if (animSprite != null) { tk2dSprite sprite = animSprite.gameObject.AddComponent <tk2dSprite>(); #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) Undo.RegisterCreatedObjectUndo(sprite, "Create Sprite Animator"); #endif sprite.SetSprite(animSprite.Collection, animSprite.spriteId); sprite.color = animSprite.color; sprite.scale = animSprite.scale; // If this is not null, we assume it is already set up properly if (animSprite.GetComponent <tk2dSpriteAnimator>() == null) { tk2dSpriteAnimator spriteAnimator = animSprite.gameObject.AddComponent <tk2dSpriteAnimator>(); #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) Undo.RegisterCreatedObjectUndo(spriteAnimator, "Create Sprite Animator"); #endif spriteAnimator.Library = animSprite.Library; spriteAnimator.DefaultClipId = animSprite.DefaultClipId; spriteAnimator.playAutomatically = animSprite.playAutomatically; } #if (UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) GameObject.DestroyImmediate(animSprite, true); #else Undo.DestroyObjectImmediate(animSprite); #endif tk2dUtil.SetDirty(animSpriteGameObject); } } #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) Undo.CollapseUndoOperations(undoGroup); #endif } }
// This is called once the animation has compelted playing. public void AnimFinishedDelegate(tk2dAnimatedSprite sprite, int clipId) { sprite.gameObject.SetActive(false); }
static void DoCreateSpriteObject() { tk2dSpriteCollectionData sprColl = null; if (sprColl == null) { // try to inherit from other Sprites in scene tk2dSprite spr = GameObject.FindObjectOfType(typeof(tk2dSprite)) as tk2dSprite; if (spr) { sprColl = spr.Collection; } } if (sprColl == null) { tk2dSpriteCollectionIndex[] spriteCollections = tk2dEditorUtility.GetOrCreateIndex().GetSpriteCollectionIndex(); foreach (var v in spriteCollections) { GameObject scgo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(v.spriteCollectionDataGUID), typeof(GameObject)) as GameObject; var sc = scgo.GetComponent <tk2dSpriteCollectionData>(); if (sc != null && sc.spriteDefinitions != null && sc.spriteDefinitions.Length > 0) { sprColl = sc; break; } } if (sprColl == null) { EditorUtility.DisplayDialog("Create Sprite", "Unable to create sprite as no SpriteCollections have been found.", "Ok"); return; } } tk2dGenericIndexItem[] animIndex = tk2dEditorUtility.GetOrCreateIndex().GetSpriteAnimations(); tk2dSpriteAnimation anim = null; int clipId = -1; foreach (var animIndexItem in animIndex) { tk2dSpriteAnimation a = animIndexItem.GetAsset <tk2dSpriteAnimation>(); if (a != null && a.clips != null && a.clips.Length > 0) { for (int i = 0; i < a.clips.Length; ++i) { if (!a.clips[i].Empty && a.clips[i].frames[0].spriteCollection != null && a.clips[i].frames[0].spriteId >= 0) { clipId = i; break; } } if (clipId != -1) { anim = a; break; } } } if (anim == null || clipId == -1) { EditorUtility.DisplayDialog("Create Animated Sprite", "Unable to create animated sprite as no SpriteAnimations have been found.", "Ok"); return; } GameObject go = tk2dEditorUtility.CreateGameObjectInScene("AnimatedSprite"); tk2dAnimatedSprite sprite = go.AddComponent <tk2dAnimatedSprite>(); sprite.SwitchCollectionAndSprite(anim.clips[clipId].frames[0].spriteCollection, anim.clips[clipId].frames[0].spriteId); sprite.anim = anim; sprite.clipId = clipId; sprite.Build(); Selection.activeGameObject = go; Undo.RegisterCreatedObjectUndo(go, "Create AnimatedSprite"); }
//播放特效 public override bool Play(BattleCard target) { m_TargetCard = target; if (m_EffectLib == null || m_EffectLib.GetClipIdByName(m_EffectName) == -1) { Debug.LogError("Can't play effect! " + m_EffectName); if (EffectEnd != null) { EffectEnd(this, m_TargetCard, 0f); } return(false); } GameObject go = new GameObject(m_EffectName); go.transform.parent = m_StartPos.parent; Vector3 pos = new Vector3(0.0f, 0.0f, -30.0f); pos.x = m_StartPos.localPosition.x; pos.y = m_StartPos.localPosition.y; go.transform.localPosition = pos; Vector3 targetScale = m_StartPos.localScale; go.transform.localScale = targetScale / 0.63f; Vector3 direct = m_DirectionPoint - m_StartPos.transform.localPosition; if (direct.x != 0f || direct.y != 0f) { direct.z = 0f; go.transform.up = direct; } tk2dAnimatedSprite sprite = tk2dAnimatedSprite.AddComponent(go, m_EffectLib, m_EffectLib.GetClipIdByName(m_EffectName)); sprite.animationCompleteDelegate += AnimationCompleteHandler; sprite.animationEventDelegate += AnimationUpdateHandler; //如果速度不为0,则特效需要飞行,添加iTween事件 if (m_MoveSpeed > 0f) { go.AddComponent <iTweenHandler>().ProjectileFlyCompleteHandler = ProjectileFlyCompleteHandler; Hashtable args = new Hashtable(); args.Add("time", m_MoveSpeed); args.Add("x", m_EndPos.position.x); args.Add("y", m_EndPos.position.y); args.Add("looptype", iTween.LoopType.none); args.Add("easetype", iTween.EaseType.linear); args.Add("oncompletetarget", go); args.Add("oncompleteparams", go); args.Add("oncomplete", "OnProjectileFlyComplete"); iTween.MoveTo(go, args); } //播放 sprite.Play(m_EffectName); m_EffectObj = go; return(true); }
void Awake() { highlight = gameObject.transform.Find("highlight").GetComponent <tk2dAnimatedSprite>(); }
public void AnimationComplete(tk2dAnimatedSprite touchAnim, int clipId) { Destroy(gameObject); }
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; } } }
void WengziBgAnimationCompleteHandler(tk2dAnimatedSprite sprite, int clipId) { }
// Use this for initialization void Start() { anim = GetComponent <tk2dAnimatedSprite>(); }
public virtual void onEndAttack(tk2dAnimatedSprite sprite, int clipId) { onEndAttack(); }
void HitCompleteDelegate(tk2dAnimatedSprite sprite, int clipId) { //Debug.Log("MinigunBoxController:HitCompleteDelegate()"); Destroy(gameObject); }
public override void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { if (frame.eventInfo.ToLower() == "evaluateAttack".ToLower()) { if (currentTarget != null) { currentAttack.EvaluateAttack(); currentTargetHasBeenAttacked = true; attackChainIndex++; } } else if (frame.eventInfo.ToLower() == "endChainIfNeeded".ToLower()) { if (nextTarget != null && nextTarget.isAlive()) { attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentTarget = nextTarget; currentAttack.onEndAttack(); hasEndAttackChain = true; nextTarget = null; } else if (currentTarget == null || !currentTarget.isAlive()) { attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentTarget = null; currentAttack.onEndAttack(); hasEndAttackChain = true; } else if (abortAttackChain) { abortAttackChain = false; attackChainIndex = 0; currentTargetHasBeenAttacked = true; currentAttack.onEndAttack(); hasEndAttackChain = true; } } else if (frame.eventInfo.ToLower() == "endAttack".ToLower()) { attackChainIndex = 0; currentAttack.onEndAttack(); hasEndAttackChain = true; abortAttackChain = false; if (nextTarget != null && nextTarget.isAlive()) { currentTarget = nextTarget; nextTarget = null; } } else if (frame.eventInfo.ToLower() == "onSkillCompleted".ToLower()) { usingSkill = false; changeAnimation("idle"); } else if (frame.eventInfo.ToLower() == "startCharging".ToLower()) { SkCharge charge = GetComponent <SkCharge>(); if (charge != null) { charge.startCharging(); } } else if (frame.eventInfo.ToLower() == "stopCharging".ToLower()) { SkCharge charge = GetComponent <SkCharge>(); if (charge != null) { charge.stopCharging(); } } }
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 virtual void onEvent(tk2dAnimatedSprite sprite, tk2dSpriteAnimationClip clip, tk2dSpriteAnimationFrame frame, int frameNum) { }
static void DoCreateSpriteObject() { tk2dSpriteCollectionData sprColl = null; if (sprColl == null) { // try to inherit from other Sprites in scene tk2dSprite spr = GameObject.FindObjectOfType(typeof(tk2dSprite)) as tk2dSprite; if (spr) { sprColl = spr.collection; } } if (sprColl == null) { tk2dSpriteCollectionIndex[] spriteCollections = tk2dEditorUtility.GetOrCreateIndex().GetSpriteCollectionIndex(); foreach (var v in spriteCollections) { GameObject scgo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(v.spriteCollectionDataGUID), typeof(GameObject)) as GameObject; var sc = scgo.GetComponent <tk2dSpriteCollectionData>(); if (sc != null && sc.spriteDefinitions != null && sc.spriteDefinitions.Length > 0) { sprColl = sc; break; } } if (sprColl == null) { EditorUtility.DisplayDialog("Create Sprite", "Unable to create sprite as no SpriteCollections have been found.", "Ok"); return; } } tk2dSpriteAnimation[] anims = tk2dEditorUtility.GetOrCreateIndex().GetSpriteAnimations(); tk2dSpriteAnimation anim = null; foreach (var a in anims) { if (a != null && a.clips != null && a.clips.Length > 0) { anim = a; break; } } if (anim == null) { EditorUtility.DisplayDialog("Create Animated Sprite", "Unable to create animated sprite as no SpriteAnimations have been found.", "Ok"); return; } if (anim.clips[0].frames.Length == 0 || anim.clips[0].frames[0].spriteCollection == null) { EditorUtility.DisplayDialog("Create Animated Sprite", "Invalid SpriteAnimation has been found.", "Ok"); return; } GameObject go = tk2dEditorUtility.CreateGameObjectInScene("AnimatedSprite"); tk2dAnimatedSprite sprite = go.AddComponent <tk2dAnimatedSprite>(); sprite.collection = anim.clips[0].frames[0].spriteCollection; sprite.Build(); sprite.spriteId = anim.clips[0].frames[0].spriteId; sprite.anim = anim; Selection.activeGameObject = go; Undo.RegisterCreatedObjectUndo(go, "Create AnimatedSprite"); }
public void backToIdleAfterAttack(tk2dAnimatedSprite sprite, int clipId) { characterSprite.Play("idle"); characterSprite.animationCompleteDelegate = null; }
// Use this for initialization void Start() { // This script must be attached to the sprite to work. anim = GetComponent <tk2dAnimatedSprite>(); }
public virtual void onDie(tk2dAnimatedSprite sprite, int clipId) { onDie(); }
public override void onEnemySpawn(BasicEnemy enemy) { tk2dAnimatedSprite sprite = enemy.GetComponent <tk2dAnimatedSprite>(); sprite.localTimeScale = Game.game.getEnemiesTimeScale(); }
void Start() { tk2dAnimatedSprite ani = GetComponent <tk2dAnimatedSprite>(); ani.animationEventDelegate += Handle_AniSpriteFrameTrigger; }
void onAnimationComplete(tk2dAnimatedSprite sprite, int clipId) { playingAnimation = false; }
// Use this for initialization void Start() { animSprite = GetComponent <tk2dAnimatedSprite>(); setState(mInitState); }
protected virtual void Awake() { mSprite = GetComponent <tk2dBaseSprite>(); mSpriteAnim = mSprite as tk2dAnimatedSprite; }
void Awake() { _sprite = gameObject.AddComponent <tk2dAnimatedSprite>(); }