/// <summary> /// 禁锢,暂用于怪物,被调用时将调用物体的速度设为0,且无法移动 /// </summary> public void Encompass(float time) { MovementEnemies movement = gameObject.GetComponent <MovementEnemies>(); movement.SetSpeedNull(); movement.RequestChangeControlStatus(time, MovementEnemies.EnemyStatus.Encompass); }
/// <summary> /// 被击退函数 击退方向由攻击者和被击者的位置决定,力的大小由参数parameter决定 /// </summary> /// <param name="attackerPos">攻击者</param> /// <param name="interruptTime">击退时间</param> /// <param name="parameter">力大小参数</param> public void BeatBack(Transform attackerPos, float interruptTime, float parameter) { Vector2 fighterPos = attackerPos.transform.position; Vector2 beFightedPos = transform.position; Vector2 interruptVector = (beFightedPos - fighterPos).normalized * parameter; //获取移动组件 //如果被打的是player if (gameObject.name == "Player") { MovementPlayer movement = gameObject.GetComponent <MovementPlayer>(); if (movement.RequestChangeControlStatus(interruptTime, MovementPlayer.PlayerControlStatus.Interrupt)) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } } else { MovementEnemies movement = gameObject.GetComponent <MovementEnemies>(); if (movement.RequestChangeControlStatus(interruptTime, MovementEnemies.EnemyStatus.Stun)) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } } }
//public SharedFloat lastAttackedTime; public override void OnStart() { base.OnStart(); //slimerAnim = GetComponent<Animator>(); defenceComponent = GetComponent <DefenceEnemies>(); movementComponent = GetComponent <MovementEnemies>(); }
/// <summary> /// 被击退函数 自定击退方向 /// </summary> /// <param name="attackerPos">攻击者</param> /// <param name="interruptTime">打断时间</param> /// <param name="interruptVector">击退力的方向</param> public void BeatBack(Transform attackerPos, float interruptTime, Vector2 interruptVector) { if (!isImmune) { //获取移动组件 //如果被打的是player if (gameObject.name == "Player") { MovementPlayer movement = gameObject.GetComponent <MovementPlayer>(); if (movement.RequestChangeControlStatus(interruptTime, MovementPlayer.PlayerControlStatus.Stun)) { if (transform.position.x > attackerPos.position.x) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } else { movement.RequestMoveByTime(-interruptVector, interruptTime, MovementPlayer.MovementMode.Attacked); } } } else { MovementEnemies movement = gameObject.GetComponent <MovementEnemies>(); if (movement.RequestChangeControlStatus(interruptTime, MovementEnemies.EnemyStatus.Stun)) { if (transform.position.x > attackerPos.position.x) { movement.RequestMoveByTime(interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } else { movement.RequestMoveByTime(-interruptVector, interruptTime, MovementEnemies.MovementMode.Attacked); } } } } }
private void Start() { movement = enemy.GetComponent <MovementEnemies>(); }
public override void OnStart() { base.OnStart(); movementComponent = GetComponent <MovementEnemies>(); }
public override void OnStart() { base.OnStart(); movementComponent = GetComponent <MovementWitcher>(); }