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 void Move() { if (!_isMovable) { return; } float speed = GetMoveSpeed(); Vector2 pos = _curPos; bool isIdle = true; OperationController op = OperationController.GetInstance(); if (op.IsDirKeyAvailable(eSTGKey.KeyLeft)) { pos.x -= speed; isIdle = false; _aniChar.Play(AniActionType.Move, Consts.DIR_LEFT); } else if (op.IsDirKeyAvailable(eSTGKey.KeyRight)) { pos.x += speed; isIdle = false; _aniChar.Play(AniActionType.Move, Consts.DIR_RIGHT); } if (op.IsDirKeyAvailable(eSTGKey.KeyDown)) { pos.y -= speed; } else if (op.IsDirKeyAvailable(eSTGKey.KeyUp)) { pos.y += speed; } // 计算额外运动参数 pos.x += _extraVelocityX + _extraAcceX; pos.y += _extraVelocityY + _extraAcceY; // 检测是否越界 if (pos.x < Global.PlayerLBBorderPos.x) { pos.x = Global.PlayerLBBorderPos.x; } if (pos.y < Global.PlayerLBBorderPos.y) { pos.y = Global.PlayerLBBorderPos.y; } if (pos.x > Global.PlayerRTBorderPos.x) { pos.x = Global.PlayerRTBorderPos.x; } if (pos.y > Global.PlayerRTBorderPos.y) { pos.y = Global.PlayerRTBorderPos.y; } _curPos = pos; if (isIdle) { _aniChar.Play(AniActionType.Idle, Consts.DIR_NULL); } }
public override void SetEnemyAni(string aniId) { if (_enemyAni == null) { _enemyAni = AnimationManager.GetInstance().CreateAnimation <AnimationCharacter>(LayerId.Enemy); _enemyGo = _enemyAni.GetAniParent(); _tf = _enemyGo.transform; } _enemyAni.Play(aniId, AniActionType.Idle, Consts.DIR_NULL); }
public void SetAni(string aniId) { if (_enemyGo == null) { _enemyGo = ResourceManager.GetInstance().GetPrefab("Prefab/Boss", "Boss"); } _enemyTf = _enemyGo.transform; _bossAni = AnimationManager.GetInstance().CreateAnimation <AnimationCharacter>(_enemyGo, "Animation", LayerId.Enemy); _bloodBarLayerTf = _enemyTf.Find("BloodBarLayer"); _bloodBarLayerTf.gameObject.SetActive(false); _isShowBloodBar = false; _bloodBarSp = _bloodBarLayerTf.Find("BloodBar").GetComponent <SpriteRenderer>(); // 魔法阵 _isShowAura = false; _auraTf = _enemyTf.Find("MagicSquare"); // 符卡血条 _scLifeGo = _enemyTf.Find("SpellCardLife").gameObject; _scLifeBorderTf = _enemyTf.Find("SpellCardLife/Border"); _scLifeBorderMesh = _scLifeBorderTf.GetComponent <MeshFilter>().mesh; _scLifeTf = _enemyTf.Find("SpellCardLife/Life"); _scLifeMesh = _scLifeTf.GetComponent <MeshFilter>().mesh; PopulateMesh(_scLifeBorderMesh, 128, 16, 5); PopulateMesh(_scLifeMesh, 112, 16, 3); _isShowAura = false; _isShowSCHpAura = false; // 默认动作 _bossAni.Play(aniId, AniActionType.Idle, Consts.DIR_NULL); }