IEnumerator Attack() { //enter while (state == CharacterState.Attack) { yield return(null); //stay MoveUtil.RotateBurst(transform, attackPoint.transform); if (Vector3.Distance(transform.position, attackPoint.transform.position) > attackRange && RemainTime(0.7f)) { SetState(CharacterState.AttackRun); break; } if (monsterFSM.state == CharacterState.Dead && (a.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f) > 0.7) { attackPoint.SetActive(false); SetState(CharacterState.Idle); break; } } //exit }
IEnumerator Attack() { //enter while (state == CharacterState.Attack) { yield return(null); //stay MoveUtil.RotateBurst(transform, player); if (Vector3.Distance(transform.position, player.position) > attackRange) { SetState(CharacterState.Run); break; } if (playerFSM.IsDead()) { SetState(CharacterState.Idle); break; } } //exit }
IEnumerator Patrol() { //Debug.Log("Patrol " + isNewState); //Debug.Log("Moving Enemy"); while (isNewState == false) { yield return(null); //float dist = Vector3.Distance(target.transform.position, transform.position); //Debug.Log("InPatrol" + Mathf.Round(dist)); if (MoveUtil.Move(target.transform.position, cc, patrolPoint, moveSpeed, rotationSpeed)) { //Debug.Log(Vector3.Distance(target.transform.position, transform.position)); if (MoveUtil.DetectPlayer(player.transform, transform, sightRange)) { SetState(State.AttackRun); } if (Vector3.Distance(target.transform.position, transform.position) < 1f) { SetState(State.Idle); } //if (MoveUtil.DetectPlayer(target.transform, gameObject.transform, sightRange)) //{ // SetState(State.AttackRun); //} } } }
public static int GetSeeCaptureScore(ChessBoard cb, int move) { if (EngineConstants.Assert) { if (MoveUtil.GetAttackedPieceIndex(move) == 0) { Assert.IsTrue(MoveUtil.GetMoveType(move) != 0); } } var index = MoveUtil.GetToIndex(move); var allPieces = cb.AllPieces & ~Util.PowerLookup[MoveUtil.GetFromIndex(move)]; var slidingMask = MagicUtil.GetQueenMovesEmptyBoard(index) & allPieces; // add score when promotion if (MoveUtil.IsPromotion(move)) { return(EvalConstants.PromotionScore[MoveUtil.GetMoveType(move)] + EvalConstants.Material[MoveUtil.GetAttackedPieceIndex(move)] - GetSeeScore(cb, cb.ColorToMoveInverse, index, MoveUtil.GetMoveType(move), allPieces, slidingMask)); } return(EvalConstants.Material[MoveUtil.GetAttackedPieceIndex(move)] - GetSeeScore(cb, cb.ColorToMoveInverse, index, MoveUtil.GetSourcePieceIndex(move), allPieces, slidingMask)); }
public void SetHhScores(int colorToMove) { for (var j = _nextToMove[_ply]; j < _nextToGenerate[_ply]; j++) { _moveScores[j] = GetHhScore(colorToMove, MoveUtil.GetFromToIndex(_moves[j])); } }
public bool IsRepetition(int move) { if (!EngineConstants.EnableRepetitionTable) { return(false); } // if move was an attacking-move or pawn move, no repetition if (!MoveUtil.IsQuiet(move) || MoveUtil.GetSourcePieceIndex(move) == Pawn) { return(false); } var moveCountMin = Math.Max(0, MoveCounter - 50); for (var i = MoveCounter - 2; i >= moveCountMin; i -= 2) { if (ZobristKey != ZobristKeyHistory[i]) { continue; } if (Statistics.Enabled) { Statistics.Repetitions++; } return(true); } return(false); }
protected virtual IEnumerator MS_Attack() { MoveUtil.RotateToDirBurst(transform, player.transform); do { yield return(null); if (IsDead()) { break; } if (CompareDist(transform.position, player.transform.position, State.AttackRange) && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.7f) { SetState(CH_STATE.MS_AttackRun); break; } else if (!CompareDist(transform.position, player.transform.position, State.AttackRange) && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.7f) { SetState(CH_STATE.MS_Wait); break; } if (player.IsDead()) { SetState(CH_STATE.MS_Wait); break; } } while (!isNewState); }
protected virtual IEnumerator Whirlwind() { float angle = 0; do { yield return(null); Mana.ConsumeMP(5.0f * Time.deltaTime); if (m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.9f && m_Anim.GetCurrentAnimatorStateInfo(0).IsName("Whirlwind")) { WhirlwindFX.SetActive(false); WhirlwindFX.SetActive(true); SoundManager.Instance.PlaySFX("Whirlwind_Loop", 1.0f, true); } if (m_Anim.GetCurrentAnimatorStateInfo(0).IsName("WhirlwindShot")) { MoveUtil.MoveFrame(m_CC, Point, State.WalkSpeed, State.TurnSpeed); angle -= Time.deltaTime * State.TurnSpeed; WhirlwindFX.transform.localPosition = new Vector3(0, 0, 0); WhirlwindFX.transform.localRotation = Quaternion.Euler(90, 0, angle); } } while (!isNewState); }
public override IEnumerator NpcExit() { //transform.position = LevelManager.Instance.orderPosition.position; yield return(MoveUtil.MoveOverSeconds(transform.gameObject, LevelManager.Instance.startPosition.position, secondsToMove)); Destroy(gameObject.gameObject); }
protected override IEnumerator Idle() { int i = Random.Range(0, movePoints.Length); target = movePoints[i]; float time = 0f; Debug.Log("Idle Enemy"); while (isNewState == false) { yield return(null); time += Time.deltaTime; if (MoveUtil.DetectPlayer(player.transform, transform, sightRange)) { SetState(State.AttackRun); } else { if (time >= 1f) { SetState(State.Patrol); } } } }
private MoveBreakdown CreateBreakdown() { int newRow = _move.Piece.Row; int newCol = _move.Piece.Col; var removedPieces = new List <CheckerPiece>(); foreach (MoveDirection direction in _move.Direction) { newRow += MoveUtil.GetRowMoveAmountByColor(_move.Piece.Owner, direction); newCol += MoveUtil.GetColMoveAmount(direction); // adjust for jump CheckerPiece pieceAtPosition = _board.GetPiece(newRow, newCol); if (pieceAtPosition != null && pieceAtPosition.Owner != _move.Piece.Owner) { removedPieces.Add(pieceAtPosition); newRow += MoveUtil.GetRowMoveAmountByColor(_move.Piece.Owner, direction); newCol += MoveUtil.GetColMoveAmount(direction); } } return(new MoveBreakdown { FinalRow = newRow, FinalCol = newCol, RemovedPieces = removedPieces }); }
public void AddCounterMove(int color, int parentMove, int counterMove) { if (EngineConstants.EnableCounterMoves) { _counterMoves[color][MoveUtil.GetSourcePieceIndex(parentMove)][MoveUtil.GetToIndex(parentMove)] = counterMove; } }
public void AddBfValue(int color, int move, int depth) { _bfMoves[color][MoveUtil.GetFromToIndex(move)] += depth * depth; if (EngineConstants.Assert) { Assert.IsTrue(_bfMoves[color][MoveUtil.GetFromToIndex(move)] >= 0); } }
protected virtual IEnumerator MS_Attack2() { do { yield return(null); if (IsDead()) { break; } StopCoroutine(AttackDelay()); MoveUtil.RotateToDirBurst(transform, player.transform); NavMesh.isStopped = true; if (Vector3.Distance(transform.position, player.transform.position) > State.AttackRange && m_Anim.GetCurrentAnimatorStateInfo(0).IsName("chargeAttack") && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.8f) { NavMesh.isStopped = false; IsAttacked = true; StartCoroutine(AttackDelay()); SetState(CH_STATE.MS_AttackRun); break; } else if (Vector3.Distance(transform.position, player.transform.position) <= State.AttackRange / 2 && m_Anim.GetCurrentAnimatorStateInfo(0).IsName("chargeAttack") && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.7f) { NavMesh.isStopped = false; IsAttacked = true; StartCoroutine(AttackDelay()); SetState(CH_STATE.MS_Avoid); break; } else if (Vector3.Distance(transform.position, player.transform.position) <= State.AttackRange && m_Anim.GetCurrentAnimatorStateInfo(0).IsName("chargeAttack") && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.8f) { NavMesh.isStopped = false; IsAttacked = true; StartCoroutine(AttackDelay()); SetState(CH_STATE.MS_Wait); break; } if (player.IsDead()) { NavMesh.isStopped = false; SetState(CH_STATE.MS_Wait); break; } } while (!isNewState); }
private static void AssertBackwardRightMoveIsCorrect(CheckerBoard board, int originalRow, int originalColumn, PieceColor color) { Assert.IsNull(board.GetPiece(originalRow, originalColumn)); int newRow = originalRow + MoveUtil.GetRowMoveAmountByColor(color, MoveDirection.BackwardRight); int newCol = originalColumn + MoveUtil.GetColMoveAmount(MoveDirection.BackwardRight); AssertPieceExists(board, newRow, newCol, color); }
public void Avoid() { if (CommonSkill(4, true)) { MoveUtil.RotateToDirBurst(transform, player.Point); player.SetState(CH_STATE.Avoid); } }
public static bool IsExistCodeFront(Pos pos, char code) { int dis; EFaceDirection face; bool rs = MoveUtil.GetFaceDirection(out dis, out face, pos, MapCode.NPC_DARK_PRINCE, (int)(Camera.main.transform.eulerAngles.z / 90)); return(rs && dis == 1 && face == EFaceDirection.Forward); }
public static void ShowDangerTip(Pos pos) { // 如果孙女反叛就不显示危险提示 if (GameData._isGrandDaughterRebel || !Singleton._npcManager.Contains(ERole.GrandDaughter) || !GameData._isGrandDaughterInQueue) { return; } int dis; EFaceDirection face; bool rs = MoveUtil.GetFaceDirection(out dis, out face, pos, MapCode.NPC_DARK_PRINCE, (int)(Camera.main.transform.eulerAngles.z / 90)); if (rs) { string label = ""; switch (face) { case EFaceDirection.Forward: label = "前"; break; case EFaceDirection.Backward: label = "后"; break; case EFaceDirection.LeftForward: label = "左前"; break; case EFaceDirection.RightForward: label = "右前"; break; case EFaceDirection.LeftBackward: label = "左后"; break; case EFaceDirection.RightBackward: label = "右后"; break; case EFaceDirection.Left: label = "左"; break; case EFaceDirection.Right: label = "右"; break; } label += "方"; label += (dis == 1 ? "一" : "两") + "米"; UIManager._Instance.SetTipInfo(string.Format(TipMessage._dirTip, label)); } }
public void ThrowAxe() { if (CommonSkill(3, true)) { player.Mana.ConsumeMP(15); MoveUtil.RotateToDirBurst(transform, player.Point); player.SetState(CH_STATE.ThrowAxe); } }
/// <summary> /// 输入偏移量 /// </summary> public void Move(int x, int y) { if (_anim != null) { _anim.SetFloat("h", x); _anim.SetFloat("v", y); } var pos = _transform.localPosition.ToPos(); MoveUtil.Move(pos, x, y, _transform); }
public void SetMvvlvaScores() { for (var j = _nextToMove[_ply]; j < _nextToGenerate[_ply]; j++) { _moveScores[j] = MoveUtil.GetAttackedPieceIndex(_moves[j]) * 6 - MoveUtil.GetSourcePieceIndex(_moves[j]); if (MoveUtil.GetMoveType(_moves[j]) == MoveUtil.TypePromotionQ) { _moveScores[j] += Queen * 6; } } }
//공격 protected override IEnumerator MS_Attack() { do { yield return null; if (IsDead()) break; //죽었을 때는 공격을 못함 //플레이어에게 바로 회전 MoveUtil.RotateToDirBurst(transform, player.transform); NavMesh.isStopped = true; //공격하는중에는 이동을 멈추자 //공격 후 거리가 벌어졌다면 쫓아가자 if (Vector3.Distance(transform.position, player.transform.position) > State.AttackRange && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.8f) { NavMesh.isStopped = false; SetState(CH_STATE.MS_AttackRun); break; } //공격 후 거리가 가까워졌다면 피하자 else if (Vector3.Distance(transform.position, player.transform.position) <= State.AttackRange / 2 && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.8f) { NavMesh.isStopped = false; SetState(CH_STATE.MS_Avoid); break; } // 공격 후 공격범위 안에 있다면 다시 대기 상태에서 공격 준비 else if (Vector3.Distance(transform.position, player.transform.position) <= State.AttackRange && m_Anim.GetCurrentAnimatorStateInfo(0).normalizedTime % 1.0f > 0.8f) { NavMesh.isStopped = false; SetState(CH_STATE.MS_Wait); break; } //플레이어가 죽었다면? 다시 순찰상태로 돌아가자 if (player.IsDead()) { NavMesh.isStopped = false; SetState(CH_STATE.MS_Wait); break; } } while (!isNewState); }
// Update public void Update() { if (_isGrabbed) { MoveUtil.AccelerateClampedToward( _rigidbody, Camera.main.transform.TransformPoint(_offset), _acceleration, _maxAcceleration, _maxVelocity, _timeToReach); } }
void zombie_forward() { if ((r = MoveUtil.MoveByFrame(transform, nextPosition, moveSpeed)) == 0.0f) { transform.position = nextPosition; zombie_movement = Zombie_Movement.zombie_forward_idle; _animator.SetInteger("zombie_movement", (int)zombie_movement); isMoving = false; //ManagerGame.zombieMove = false; isCalcued = false; return; } }
protected virtual IEnumerator AttackRun() { do { yield return(null); //거리가 공격범위 안에 들어오면 공격 상태로 전환 if (MoveUtil.MoveFrame(m_CC, Point, State.WalkSpeed, State.TurnSpeed) <= State.AttackRange) { SetState(CH_STATE.Attack); } } while (!isNewState); }
protected virtual IEnumerator Dash() { do { yield return(null); if (MoveUtil.MoveFrame(m_CC, Point, State.RunSpeed, State.TurnSpeed) < 1.0f) { DashTrail.SetActive(false); SetState(CH_STATE.Wait); break; } } while (!isNewState); }
IEnumerator RUN() { do { yield return(null); effect.SetActive(false); if (MoveUtil.MoveFrame(cc, movePoint.transform, moveSpeed, 1000) == 0) // 2의 movespeed 1000의 turnspeed로 movepoint까지 이동되면 { SetState(CharacterState.REFLESH); // 도착 후 REFLESH 상태로 movePoint.SetActive(false); } } while(state == CharacterState.RUN); }
public void ProcessDamage(float damage) { currentHP -= (int)damage; if (currentHP <= 0) { SetState(CharacterState.Dead); currentHP = 0; } else { SetState(CharacterState.Run); MoveUtil.RotateBurst(transform, player); } }
protected virtual IEnumerator Run() { do { yield return(null); //거리가 1미만으로 줄어들면 달리기를 멈춤 if (MoveUtil.MoveFrame(m_CC, Point, State.WalkSpeed, State.TurnSpeed) < 1.0f) { SetState(CH_STATE.Wait); break; } } while (!isNewState); }
public void Bash() { if (CommonSkill(1, true)) { if (player.Point.transform.position.y - player.transform.position.y > 3) { return; } player.Mana.ConsumeMP(20); MoveUtil.RotateToDirBurst(transform, player.Point); player.SetState(CH_STATE.Bash); } }