public bool OnDamage(int t, WarSceneController.Direction dir) { if (state == State.Dead) { return(false); } bool flag = true; int block = 50; switch (t) { case -1: block = 0; break; case 1000: block = 50; break; case 0: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 20; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 70; } break; case 1: if (soliderType == 0 || soliderType == 6 || soliderType == 10) { block = 30; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 70; } break; case 2: if (soliderType == 0 || soliderType == 7 || soliderType == 10) { block = 30; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 70; } break; case 3: case 4: case 5: if (soliderType == 1 || soliderType == 2 || soliderType == 6 || soliderType == 8 || soliderType == 10) { block = 30; } else if (soliderType == 0 || soliderType == 7 || soliderType == 9) { block = 80; } break; case 6: if (soliderType == 2 || soliderType == 8 || soliderType == 10) { block = 30; } else if (soliderType == 1 || soliderType == 3 || soliderType == 9) { block = 70; } break; case 7: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 25; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 65; } break; case 8: if (soliderType == 0 || soliderType == 7 || soliderType == 10) { block = 25; } else if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 65; } break; case 9: if (soliderType == 3 || soliderType == 4 || soliderType == 5) { block = 25; } else if (soliderType == 1 || soliderType == 2 || soliderType == 8) { block = 65; } break; case 10: block = 60; break; } int rand = Random.Range(0, 100); if (block > rand) { flag = false; } if (!flag) { if (!isFighting) { isParrying = true; timeTick = 0; anim.Stop(); anim.SetFrame("Parry", 0); } return(false); } if (isKnight) { if (t != -1 && life > 1) { life--; return(false); } } SoundController.Instance.PlaySound3D("00036", transform.position); state = State.Dead; timeTick = 0; anim.Stop(); anim.SetFrame("Dead", 0); if ((dir == WarSceneController.Direction.Left && transform.localScale.x > 0) || (dir == WarSceneController.Direction.Right && transform.localScale.x < 0)) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } if (isKnight && soliderType != 6) { Transform horse = transform.GetChild(0); horse.gameObject.SetActive(true); horse.parent = transform.parent; horse.GetComponent <SolidersHorse>().SetHorseRun(); warCtrl.AddSoliderHorse(horse.GetComponent <SolidersHorse>()); } Vector3 pos = transform.localPosition; pos += deadBodyOffset; transform.localPosition = pos; warCtrl.RemoveSolider(index); Destroy(mapPoint.gameObject); return(true); }