void Start() { this.bloodBar = ScriptEF.CreateBloodBar(gameObject); gameObject.animation.wrapMode = WrapMode.Once; cameraCtrl = Camera.main.GetComponent <CameraCtrl>(); myController = GetComponent <CharacterController>(); initObj(); }
private void OnHit(int damage, Vector3 attackdir, Character attacker, bool isCrit, bool isDodge) { // 反击 if (this.currentState != RUN && (this.atkTarget == null || this.atkTarget.ai.IsDied())) { this.atkTarget = attacker; this.currentState = ATK; } ScriptEF.CreateDamageNum(this.transform.position, 2, damage, attackdir, isCrit, isDodge); this.bloodBar.Damaged(character.maxHp, character.hp); if (isDodge) { return; } if (!IsDied()) { if (animation.IsPlaying("idle") || animation.IsPlaying("run")) { PlayClip("hit"); } } else { PlayClip("die1"); this.bloodBar.gameObject.SetActive(false); Vector3[] path = new Vector3[2]; Ray ray = new Ray(); ray.origin = attacker.gameObject.transform.position; ray.direction = this.transform.position - attacker.gameObject.transform.position; path[0] = ray.GetPoint(3); path[0].y = 1.5f; path[1] = ray.GetPoint(4);; iTween.MoveTo(this.gameObject, iTween.Hash("path", path, "time", 1.5f)); myController.enabled = false; } }