/// <summary> /// 播放敌机动画 /// <para>enemy</para> /// <para>参数可选</para> /// <para>[Optional]AniActionType at</para> /// <para>[Optional]int dir</para> /// <para>[Optional]int duration</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int PlayEnemyAni(ILuaState luaState) { int top = luaState.GetTop(); EnemyBase enemy = luaState.ToUserData(-top) as EnemyBase; if (top == 2) { AniActionType at = (AniActionType)luaState.ToInteger(-1); enemy.PlayAni(at); } else if (top == 3) { AniActionType at = (AniActionType)luaState.ToInteger(-2); int dir = luaState.ToInteger(-1); enemy.PlayAni(at, dir); } else if (top == 4) { AniActionType at = (AniActionType)luaState.ToInteger(-3); int dir = luaState.ToInteger(-2); int duration = luaState.ToInteger(-1); enemy.PlayAni(at, dir, duration); } return(0); }
public override void PlayAni(AniActionType at, int dir = Consts.DIR_NULL, int duration = int.MaxValue) { if (_bossAni.Play(at, dir)) { _isPlayAni = true; _playAniTime = 0; _playAniDuration = duration; } }
//public override bool Play(string aniName, AniActionType type, int dir, int interval, bool isLoop = true, int loopCount = int.MaxValue) //{ // _curAction = type; // _curDir = dir; // base.Play(aniName,type) // _cache = AnimationManager.GetInstance().GetAnimationCache(aniName); // _isPlaying = true; // _curFrame = 0; // _spList = _cache.GetSprites(get); // _totalFrame = _spList.Length; // _isLoop = isLoop; // _curLoopCount = 1; // _totalLoopCount = loopCount; // return true; //} public virtual bool Play(string aniId, AniActionType type, int dir) { _cfg = AnimationManager.GetInstance().GetUnitAniCfgById(aniId); if (_cfg == null) { return(false); } _cache = AnimationManager.GetInstance().GetAnimationCache(_cfg.aniName); return(Play(type, dir)); }
/// <summary> 播放BOSS动画 /// <para>boss</para> /// <para>at Enum AniAcitonType</para> /// <para>dir 动作方向</para> /// <para>duration 持续时间,单位 帧</para> /// </summary> /// <param name="luaState"></param> /// <returns></returns> public static int PlayBossAni(ILuaState luaState) { Boss boss = luaState.ToUserData(-4) as Boss; AniActionType at = (AniActionType)luaState.ToInteger(-3); int dir = luaState.ToInteger(-2); int duration = luaState.ToInteger(-1); luaState.Pop(4); boss.PlayAni(at, dir, duration); return(0); }
public override void DoAction(AniActionType actType, int dir, int duration = Consts.MaxDuration) { if (_enemyAni.Play(actType, dir)) { if (actType == AniActionType.Move) { _isMoving = true; _moveTime = 0; _moveDuration = duration; } } }
public virtual bool Play(AniActionType type, int dir, int loopCount = int.MaxValue) { if (_cfg == null) { return(false); } if (type == AniActionType.Idle || type == AniActionType.Cast) { dir = Consts.DIR_NULL; } if (type == _curAction && dir == _curDir) { return(false); } string key; int interval; Vector3 lScale; if (_cfg.isFlapX && dir == Consts.DIR_LEFT) { lScale = _aniTf.localScale; lScale.x = -Mathf.Abs(lScale.x); _aniTf.localScale = lScale; } else { lScale = _aniTf.localScale; lScale.x = Mathf.Abs(lScale.x); _aniTf.localScale = lScale; } if (type == AniActionType.Move && _curAction != AniActionType.FadeToMove) { key = GetPlayString(AniActionType.FadeToMove, dir); _cfg.aniIntervalMap.TryGetValue(key, out interval); if (Play(AniActionType.FadeToMove, dir, interval, false, 1)) { SetPlayCompleteCallBack(FadeCompleteCBFunc, dir); return(true); } else { return(Play(AniActionType.Move, dir, interval, true)); } //Logger.Log("AnimationPlay FadeToMove dir = " + dir); } key = GetPlayString(type, dir); _cfg.aniIntervalMap.TryGetValue(key, out interval); return(Play(type, dir, interval, true, int.MaxValue)); }
public Sprite[] GetSprites(AniActionType type, int dir) { Sprite[] sp; string key = "Idle"; if (type == AniActionType.Move) { key = "Right"; } if (_actionSpsMap.TryGetValue(key, out sp)) { return(sp); } return(null); }
/// <summary> /// 根据参数获得对应动画数组的key /// </summary> /// <param name="type"></param> /// <param name="dir"></param> /// <returns></returns> protected override string GetPlayString(AniActionType type, int dir) { string key = ""; if (type == AniActionType.Idle) { key = "Idle"; } else if (type == AniActionType.Cast) { key = "Cast"; } else { // action switch (type) { case AniActionType.Move: key = ""; break; case AniActionType.FadeToMove: key = "FadeTo"; break; } // dir string dirStr = ""; if (dir == Consts.DIR_RIGHT) { dirStr = "Right"; } else if (dir == Consts.DIR_LEFT) { if (!_cfg.isFlapX) { dirStr = "Left"; } else { dirStr = "Right"; } } key = key + dirStr; } return(key); }
protected bool Play(AniActionType type, int dir, int interval, bool isLoop = true, int loopCount = int.MaxValue) { Sprite[] aniSpList = _cache.GetSprites(GetPlayString(type, dir)); if (aniSpList.Length == 0) { return(false); } _curAction = type; _curDir = dir; _frameInterval = interval; _isPlaying = true; _curFrame = 0; _spList = aniSpList; _totalFrame = _spList.Length; _isLoop = isLoop; _curLoopCount = 0; _totalLoopCount = loopCount; return(true); }
public virtual void DoAction(AniActionType actType, int dir = Consts.DIR_NULL, int duration = Consts.MaxDuration) { }
public virtual bool Play(string aniName, AniActionType type, int dir, int interval, bool isLoop = true, int loopCount = int.MaxValue) { _cache = AnimationManager.GetInstance().GetAnimationCache(aniName); return(Play(type, dir, interval, isLoop, loopCount)); }
public virtual void PlayAni(AniActionType actionType, int dir = Consts.DIR_NULL, int duration = int.MaxValue) { throw new System.NotImplementedException(); }
public override void PlayAni(AniActionType actionType, int dir = Consts.DIR_NULL, int duration = int.MaxValue) { _enemyObj.DoAction(actionType, dir, duration); }