bool OnDamage(int d, int type) { if (state == State.Dead || state == State.Magic) { return(false); } bool flag = true; if (type == 0) { int difference = 0; if (side == WarSceneController.WhichSide.Left) { difference = Informations.Instance.GetGeneralInfo(WarSceneController.rightGeneralIdx).strength - Informations.Instance.GetGeneralInfo(WarSceneController.leftGeneralIdx).strength; } else { difference = Informations.Instance.GetGeneralInfo(WarSceneController.leftGeneralIdx).strength - Informations.Instance.GetGeneralInfo(WarSceneController.rightGeneralIdx).strength; } difference = Mathf.Clamp(difference, -20, 20); if (Random.Range(0, 100) > 60 + difference) { flag = false; } } else if (type == 1) { if (Random.Range(0, 100) > 70 - gInfo.strength / 5) { flag = false; } } else if (type == -1) { flag = true; } if (!flag) { if (!isFighting) { isParrying = true; timeParry = 0.2f; head.Stop(); body.Stop(); horse.Stop(); head.SetFrame("Misc", 2); body.SetFrame("Misc", 2); horse.SetFrame("Idle", 0); SoundController.Instance.PlaySound3D("00035", transform.position); } return(false); } SoundController.Instance.PlaySound3D("00036", transform.position); gInfo.healthCur -= d; if (gInfo.healthCur <= 0) { gInfo.healthCur = 0; if (state == State.Escape) { transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } horse.transform.localScale = new Vector3(-horse.transform.localScale.x, horse.transform.localScale.y, horse.transform.localScale.z); horse.transform.parent = transform.parent; horse.Play("Run"); head.Stop(); body.Stop(); head.SetFrame("Dead", 0); body.SetFrame("Dead", 0); head.transform.localPosition += deadBodyOffset; body.transform.localPosition += deadBodyOffset; weapon.gameObject.SetActive(true); weapon.transform.localPosition += weaponOffset; weapon.PlayDefault(); state = State.Dead; timeTick = 0; warCtrl.OnGeneralDead(side); } else { if (!isFighting) { isHited = true; head.Play("Hit"); body.Play("Hit"); horse.Stop(); horse.SetFrame("Idle", 0); } } return(true); }