void OnEscapeHandle() { if (isStopped) { if (head.IsPlaying("Run")) { head.Play("Idle"); body.Play("Idle"); horse.Play("Idle"); } return; } if (!head.IsPlaying("Run")) { head.Play("Run"); body.Play("Run"); horse.Play("Run"); } SoundController.Instance.PlaySound3D("00021", transform.position); if (side == WarSceneController.WhichSide.Left) { transform.localPosition = new Vector3(transform.localPosition.x - runSpeed * Time.deltaTime * 0.6f, transform.localPosition.y, transform.localPosition.z); if (transform.localPosition.x <= -WarSceneController.manPosMaxX + WarSceneController.locationStepX) { Destroy(gameObject); warCtrl.OnWarResult(WarSceneController.WhichSide.Left, true); } else if (transform.localPosition.x <= -WarSceneController.manPosMaxX + 100) { float transparent = (transform.localPosition.x + WarSceneController.manPosMaxX) / 100f; head.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); body.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); horse.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); } } else { transform.localPosition = new Vector3(transform.localPosition.x + runSpeed * Time.deltaTime * 0.6f, transform.localPosition.y, transform.localPosition.z); if (transform.localPosition.x >= WarSceneController.manPosMaxX - WarSceneController.locationStepX) { Destroy(gameObject); warCtrl.OnWarResult(WarSceneController.WhichSide.Right, true); } else if (transform.localPosition.x >= WarSceneController.manPosMaxX - 100) { float transparent = (WarSceneController.manPosMaxX - transform.localPosition.x) / 100f; head.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); body.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); horse.GetComponent <exSprite>().color = new Color(1, 1, 1, transparent); } } }