void Hanging() { if (CheckMovement()) { var centerPosition = transform.position + (currentDirection * -.25f) + (Vector3.down * .25f); if (targetDirection == currentDirection) { if ((CubeManager.Instance.getCube(centerPosition + targetDirection + Vector3.up) == null) && (CubeManager.Instance.getCube(centerPosition + Vector3.up) == null)) { targetPosition = centerPosition + targetDirection + Vector3.up; knightState = KnightState.ClimbingUp; } } else if (targetDirection != (currentDirection * -1)) { if (CubeManager.Instance.getCube(centerPosition + targetDirection) != null) { targetPosition = transform.position + (currentDirection * -.25f) + (targetDirection * .25f); currentDirection = targetDirection; knightState = KnightState.ClimbingDiagonal; } else if (CubeManager.Instance.getCube(centerPosition + targetDirection + currentDirection) != null) { targetPosition = transform.position + targetDirection; knightState = KnightState.ClimbingAcross; } else { targetPosition = transform.position + (currentDirection * .75f) + (targetDirection * .75f); currentDirection = -targetDirection; knightState = KnightState.ClimbingCorner; } } } }
void ClimbingDiagonal() { Vector3 compareVector1 = Vector3.Scale(targetPosition, targetDirection); Vector3 compareVector2 = Vector3.Scale(transform.position, targetDirection); if (Vector3.Distance(compareVector1, compareVector2) > 0.01f) { transform.position += targetDirection * .05f; } else { transform.position -= compareVector2; transform.position += compareVector1; float diff = Vector3.Distance(targetPosition, transform.position); if (Vector3.Distance(targetPosition, transform.position) > 0.01f) { Vector3 compareVector3 = Vector3.Normalize(targetPosition - transform.position); transform.position += compareVector3 * .05f; } else { transform.position = targetPosition; knightState = KnightState.Hanging; } } }
void JumpingDown() { Vector3 verticalVector1 = Vector3.Scale(targetDirection, transform.position); verticalVector1.y = targetPosition.y; Vector3 verticalVector2 = Vector3.Scale(targetDirection, targetPosition); verticalVector2.y = targetPosition.y; if (Vector3.Distance(verticalVector1, verticalVector2) >= .5f) { transform.position += (Vector3.up * .05f); transform.position += (targetDirection * .1f); } else if (Vector3.Distance(verticalVector1, verticalVector2) > .01f) { transform.position += (Vector3.down * .2f); transform.position += (targetDirection * .1f); } else { transform.position = targetPosition; knightState = KnightState.Idle; } }
void HoldingBlock() { if (Input.GetKeyUp(KeyCode.Space)) { heldCube = null; transform.position -= currentDirection * .25f; knightState = KnightState.Idle; } else if (CheckMovement()) { if (currentDirection == targetDirection) { heldCube.SendMessage("SetHeldCube", targetDirection); targetPosition = targetDirection + transform.position; knightState = KnightState.Pulling; } else if (currentDirection == -targetDirection) { if (CubeManager.Instance.getCube(heldCube.transform.position + (targetDirection * 2)) == null) { heldCube.SendMessage("SetTargetPosition", heldCube.transform.position + targetDirection); targetPosition = targetDirection + transform.position; knightState = KnightState.Pulling; } } } }
void Pausing() { if (Time.time >= timeToUnpause) { knightState = KnightState.Idle; } }
// Start is called before the first frame update void Start() { hitPoint = MaxHitPoint; instantSkillEffect = null; //myState = KnightState.AutoAttacking; //skill = KnightSkill.RangeSmash; myState = KnightState.SkillChaging; skill = KnightSkill.Dunut; }
public void ChangeState(KnightState state) { if (currentState != KnightState.None) { stateMachine[currentState].Quit(); } stateMachine[state].Setup(); currentState = state; }
//BattleCon - MonsterSetting()에서 호출됨. public void SetData(KnightState _ks, int n) { ks = _ks; skin.SetData(ks.k); isKnight = true; UpdateText(); TurnEnd(); index = n; }
void ClimbingAcross() { transform.position += (targetDirection * .1f); if (Vector3.Distance(transform.position, targetPosition) <= 0.01f) { transform.position = targetPosition; knightState = KnightState.Hanging; } }
void Falling() { transform.position += Vector3.down * .1f; Vector3 checkVector = transform.position + (currentDirection * .75f) + (Vector3.down * .25f); if (CubeManager.Instance.getCube(checkVector) != null) { knightState = KnightState.Hanging; } }
//XML LOAD에서 사용됨. public void Load() { knightStates = new KnightState[k.Length]; for (int i = 0; i < k.Length; i++) { Knight knight = UnitData.Instance.knights[k[i]]; knight.teaming = true; knightStates[i] = new KnightState(knight); } }
public void SetData(Form _form, KnightState _ks, SkillInfo _skillInfo) { form = _form; //기본정보 ks = _ks; //스킬정보 skillInfo = _skillInfo; skillIconImg.sprite = skillInfo.img; nameText.text = skillInfo.name; }
void Moving() { transform.position += (targetDirection * .1f); if (Vector3.Distance(transform.position, targetPosition) <= 0.01f) { transform.position = targetPosition; knightState = KnightState.Idle; ContinueDirectionMove(); } }
void SkillPlace() { if (skillPlaced) { bool attacked = skillPlaceComponent.DangerSkillAttacked("SkillChaging", "Skill"); if (attacked) { myState = KnightState.AutoAttacking; Destroy(instantSkillEffect.gameObject); instantSkillEffect = null; skillPlaced = false; } } else { skillPlaced = true; Quaternion effectQua = new Quaternion(); effectQua = Quaternion.Euler(new Vector3(-90, 0, 0)); instantSkillEffect = Instantiate(chagingSkillEffect, transform.position, effectQua); instantSkillEffect.transform.parent = transform; GameObject ShotSkill = null; Vector3 targetPosition = new Vector3(0, 0, 0); Quaternion targetQua = new Quaternion(); switch (skill) { case (KnightSkill.RangeSmash): ShotSkill = tripleSphereSkill; targetPosition = new Vector3(3.5f, 0, -12.0f); break; case (KnightSkill.Slash): ShotSkill = crossSkill; targetPosition = transform.position; break; case (KnightSkill.Dunut): ShotSkill = donut; targetPosition = transform.position; break; default: ShotSkill = tripleSphereSkill; targetPosition = new Vector3(3.5f, 0, -12.0f); break; } skillPlaceComponent.SkillPlace(ShotSkill, targetPosition, "SkillChaging"); } }
public void SetData(KnightState ks) { hp = ks.k.hp; maxHp = ks.k.maxHp; Power = ks.k.power; Speed = ks.k.speed; stress = ks.k.stress; uni = ks.k.uni; LifeType = LifeType.K; powerMultiple = 1; speedMultiple = 1; }
void Idle() { if (Input.GetKey(KeyCode.Space)) { heldCube = CubeManager.Instance.getCube(transform.position + currentDirection); if (heldCube != null) { transform.position += currentDirection * .25f; knightState = KnightState.HoldingBlock; } } else if (CheckMovement()) { targetPosition = targetDirection + transform.position; if (CubeManager.Instance.getCube(targetPosition) == null) { currentDirection = targetDirection; if (CubeManager.Instance.getCube(targetPosition + Vector3.down) == null) { if (CubeManager.Instance.getCube(targetPosition + (Vector3.down * 2)) != null) { targetPosition += Vector3.down; knightState = KnightState.JumpingDown; } else { currentDirection = -targetDirection; targetPosition = transform.position + (targetDirection * .75f) + (Vector3.down * .75f); knightState = KnightState.ClimbingDown; } } else { knightState = KnightState.Moving; } } else if (targetDirection != currentDirection) { currentDirection = targetDirection; knightState = KnightState.Pausing; timeToUnpause = Time.time + 0.1f; } else if (CubeManager.Instance.getCube(targetPosition + Vector3.up) == null) { targetPosition = transform.position + targetDirection + Vector3.up; knightState = KnightState.JumpingUp; } } }
private void LoadBattleData() { //1-1 . 데이타 로드. // - 몬스터 위치 지정은 그냥 순서대로 4명 씩 Load함. // - 모든 기사와 몬스터의 요소를 Thing(ArrayList)에 집어넣음 dp = EventData.Instance.battle_dp; knightCount = dp.p.k.Length; int cnt = dp.p.k.Length; thing.Clear(); for (int i = 0; i < cnt; i++) { KnightState ks = dp.p.knightStates[i]; if (ks.s.Hp > 0) { thing.Add(ks.s); kps[i].SetData(ks, i); ks.s.SetBKP(kps[i]); thingTarget.Add(i); } } for (int i = cnt; i < 4; i++) { kps[i].gameObject.SetActive(false); } //1-1-2 스킬 폼을 세팅해줌. ColController.Instance.SetForm(); //1-1-3 dp(Battle)에서 m은 int로 저장되있다. monsterArr를 생성해 직접 Monster를 삽입한다. int size = dp.m.Length; Monster[] monsterArr = new Monster[size]; for (int i = 0; i < size; i++) { monsterArr[i] = MonsterData.Instance.monsters[dp.m[i]]; } foreach (Monster m in monsterArr) { monsterList.Add(m); } //1-2 . 던전에 따른 세팅 (데코part) //---------- 필드 세팅 완료 ----------- //1-3. 전투 턴, 페이즈 초기화 및 전투개시. State = BattleState.로드; }
void ContinueDirectionMove() { if (CheckMovement()) { targetPosition = targetDirection + transform.position; if ((CubeManager.Instance.getCube(targetPosition) == null) && (CubeManager.Instance.getCube(targetPosition + Vector3.down) != null)) { knightState = KnightState.Moving; } else if (CubeManager.Instance.getCube(targetPosition) != null) { currentDirection = targetDirection; knightState = KnightState.Pausing; timeToUnpause = Time.time + 0.1f; } } }
public Party(int _d, int[] _kNum, int _day, int _dayIndex) { dungeonNum = _d; int size = _kNum.Length; this.k = new int[size]; knightStates = new KnightState[size]; for (int i = 0; i < size; i++) { this.k[i] = _kNum[i]; Knight k = UnitData.Instance.knights[_kNum[i]]; k.teaming = true; knightStates[i] = new KnightState(k); } dayIndex = _dayIndex; day = DungeonData.Instance.day_Array[dayIndex]; PrefaceDay = 0; }
void SkillChange() { timeLine++; if (timeLine == 1) { myState = KnightState.SkillChaging; skill = KnightSkill.RangeSmash; } else if (timeLine == 1000) { myState = KnightState.SkillChaging; skill = KnightSkill.Slash; } else if (timeLine == 1400) { myState = KnightState.SkillChaging; skill = KnightSkill.Dunut; } else if (timeLine > 1800) { timeLine = 0; } }
void Pulling() { transform.position += (targetDirection * .1f); heldCube.SendMessage("UpdatePosition", targetDirection); if (Vector3.Distance(transform.position, targetPosition) <= 0.01f) { heldCube.SendMessage("SetEndPosition"); transform.position = targetPosition; if (CubeManager.Instance.getCube(transform.position - (currentDirection * .25f) + Vector3.down) == null) { heldCube = null; transform.position += (Vector3.up * .25f) - (currentDirection * .25f) - (targetDirection * .25f); currentDirection = -targetDirection; knightState = KnightState.Falling; } else { knightState = KnightState.HoldingBlock; } } }
void ClimbingUp() { Vector3 halfwayVector = transform.position; halfwayVector.y = targetPosition.y; if (Vector3.Distance(halfwayVector, transform.position) > 0.1f) { transform.position += (Vector3.up * .15f); } else { transform.position = halfwayVector; if (Vector3.Distance(targetPosition, transform.position) > 0.1f) { transform.position += (targetDirection * .15f); } else { transform.position = targetPosition; knightState = KnightState.Idle; } } }
//3-2 [전투] 상태임. private void Battle() { //3-2-0 마지막 사람 종료시 // who는 sequence의 pivot임. if (who == sequence.Count) { //스피드 변경이 감지되면 순서 다시 정해줌. //아닐경우 해당 순서로 다시 진행. if (isSpeed) { SettingTurn(); } else { Turn++; who = 0; State = BattleState.전투; } return; } //전투 실행.(Player 행동결정) Debug.Log(" Battle() 실행"); //알맞는 thing을 위해 몬스터의 경우, 부족한 기사 수만큼 피봇 수를 빼줌. int n = sequence[who]; if (n >= 4) { n -= (4 - knightCount); } //3-2-1 기사 혹은 몬스터의 공격 // 해당 턴이 기사일 경우, (사용자에게 입력받는) 해당 기사의 Skill셋으로 변경해줌. try { if (thing[n].LifeType == LifeType.K) { int num = thingTarget[sequence[who]]; KnightState ks = kps[num].ks; kps[num].TurnStart(); //스킬을 세팅해줌 ColController.Instance.TurnStart(num); } else//일단 임시(테스트용) { if (mps[n - knightCount].s.alive == AliveType.죽음) { StartCoroutine("NextTurn"); return; } int num = thingTarget[sequence[who]]; mps[n - knightCount].MyTurn(); } } catch (ArgumentOutOfRangeException ex) { Debug.Log("오류가 발생햇지만 넘어간당"); } }
public void CheckDamage(Player p) { if (this.State == KnightState.INVULNERABLE || this.State == KnightState.DYING) return; if (p.shouldDamage && (p.State == Player.PlayerState.SWORD || p.State == Player.PlayerState.SWORD_TWO)) { if (isColliding(p.swordCollision)) { TakeDamage(p.GetPosition()); } } else { if (p.invulnCount > 0)// || (p.StateCount > .01f && p.State == Player.PlayerState.JUMP)) return; if (isColliding(p)) { p.TakeDamage(this.GetPosition()); } } switch (State) { case KnightState.IDLE: case KnightState.MOVING: switch (_direction) { case Direction.RIGHT: case Direction.LEFT: if (this.y - attackSideDist < p.y && this.y + attackSideDist > p.y) if (_direction == Direction.LEFT && this.x > p.x && this.x - attackDist < p.x) { FSoundManager.PlaySound("knightAttack"); State = KnightState.ATTACK_START; PlayAnim(true); attackTarget = p; } else if (_direction == Direction.RIGHT && this.x < p.x && this.x + attackDist > p.x) { FSoundManager.PlaySound("knightAttack"); State = KnightState.ATTACK_START; PlayAnim(true); attackTarget = p; } break; case Direction.UP: case Direction.DOWN: if (this.x - attackSideDist < p.x && this.x + attackSideDist > p.x) if (_direction == Direction.DOWN && this.y > p.y && this.y - attackDist < p.y) { FSoundManager.PlaySound("knightAttack"); State = KnightState.ATTACK_START; PlayAnim(true); attackTarget = p; } else if (_direction == Direction.UP && this.y < p.y && this.y + attackDist > p.y) { FSoundManager.PlaySound("knightAttack"); State = KnightState.ATTACK_START; PlayAnim(true); attackTarget = p; } break; } break; case KnightState.ATTACKING: if (RXRandom.Float() < .3f) SpawnTrailParticles(_direction, 1); break; } }
public override void OnFixedUpdate() { if (C.isTransitioning) return; switch (State) { case KnightState.IDLE: case KnightState.MOVING: if (stateCount > minState) { if (RXRandom.Float() < .3f) { switch (State) { case KnightState.IDLE: if (RXRandom.Float() < .5f) { //left or right if (RXRandom.Float() < .5f) xAcc = moveSpeed; else xAcc = -moveSpeed; } else { //up or down if (RXRandom.Float() < .5f) yAcc = moveSpeed; else yAcc = -moveSpeed; } State = KnightState.MOVING; break; case KnightState.MOVING: if (RXRandom.Float() < .3f) { //stop State = KnightState.IDLE; PlayAnim(true); xAcc = 0; yAcc = 0; } else { //Just turn if (RXRandom.Float() < .5f) { if (RXRandom.Float() < .5f) xAcc = moveSpeed; else xAcc = -moveSpeed; yAcc = 0; } else { if (RXRandom.Float() < .5f) yAcc = moveSpeed; else yAcc = -moveSpeed; xAcc = 0; } stateCount = 0; } break; } } } if (xAcc == 0) xVel *= .8f; if (yAcc == 0) yVel *= .8f; break; case KnightState.ATTACK_START: xAcc = 0; yAcc = 0; xVel = 0; yVel = 0; if (stateCount > attackDelay) { State = KnightState.ATTACKING; Vector2 diff = (attackTarget.GetPosition() - this.GetPosition()).normalized; maxXVel = 100; maxYVel = 100; minYVel = -100; xVel = diff.x * 6; yVel = diff.y * 6; } break; case KnightState.ATTACKING: if (stateCount > attackTime * 1.4f) { State = KnightState.IDLE; if (changeDirAfterAttack) { switch (CurrentDirection) { case Direction.UP: xAcc = RXRandom.Bool() ? moveSpeed : -moveSpeed; yAcc = 0; break; case Direction.RIGHT: xAcc = 0; yAcc = RXRandom.Bool() ? moveSpeed : -moveSpeed; break; case Direction.DOWN: xAcc = RXRandom.Bool() ? moveSpeed : -moveSpeed; yAcc = 0; break; case Direction.LEFT: changeDirAfterAttack = true; xAcc = 0; yAcc = RXRandom.Bool() ? moveSpeed : -moveSpeed; break; } State = KnightState.MOVING; } changeDirAfterAttack = false; resetMax(); } this.xVel *= .9f; this.yVel *= .9f; switch (CurrentDirection) { case Direction.UP: if (hitUp) changeDirAfterAttack = true; break; case Direction.RIGHT: if (hitRight) changeDirAfterAttack = true; break; case Direction.DOWN: if (hitDown) changeDirAfterAttack = true; break; case Direction.LEFT: if (hitLeft) changeDirAfterAttack = true; break; } break; case KnightState.INVULNERABLE: if (RXRandom.Float() < .2f) SpawnParticles(Direction.UP, 1); this.isVisible = stateCount * 100 % 10 < 5; if (stateCount > invulnerableCount) { State = KnightState.IDLE; resetMax(); this.isVisible = true; } this.xVel *= .9f; this.yVel *= .9f; break; case KnightState.DYING: if (RXRandom.Float() < .4f + .4f * stateCount) SpawnParticles(Direction.UP, 1 + (int)stateCount); this.isVisible = stateCount * 100 % 10 < 5; if (stateCount > invulnerableCount) { if (!String.IsNullOrEmpty(name)) C.Save.requiredEnemyKills.Add(this.name); FSoundManager.PlaySound("enemyDie"); if (RXRandom.Float() < Knight.HEART_DROP_CHANCE) world.addObject(new Heart(world, this.GetPosition())); SpawnParticles(Direction.UP, 25); world.removeObject(this); } this.xVel *= .9f; this.yVel *= .9f; break; } base.OnFixedUpdate(); PlayAnim(); }
public void TakeDamage(Vector2 pos) { FSoundManager.PlaySound("enemyHurt"); Go.killAllTweensWithTarget(this); this.health--; if (health > 0) State = KnightState.INVULNERABLE; else State = KnightState.DYING; Vector2 dist = (this.GetPosition() - pos).normalized * 4; maxXVel = 50f; maxYVel = 50f; minYVel = -50f; xVel = dist.x; yVel = dist.y; xAcc = 0; yAcc = 0; }