public int tenetDirection = 1; //默认为1,当为0时表示是逆向的主角 //public bool attacking; //表示是否正在攻击,并传给sword // Start is called before the first fr ame update private void Awake() { //cController = CursorController.Instance; //获取单例变量 leftLeg2 = transform.Find("leftLeg1/leftLeg2"); rightLeg2 = transform.Find("rightLeg1/rightLeg2"); rigidbody = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); mController = GetComponent <MasterController>(); this.normalGravityScale = gravityScale; //rigidbody.gravityScale = this.gravityScale; //GameObject pfb = (GameObject)Resources.Load("Prefabs/sword"); //Debug.Log("123 "+pfb); sword = Instantiate(sword, weaponHand.transform.position, Quaternion.identity, weaponHand.transform); sword.father = this.gameObject; sword.transform.localEulerAngles = new Vector3(0, 0, -90); Master.bodyCollector.Add(this); //加入管理器中 //collider.GetComponent<BoxCollider2D>(); }
//public void AnimNormalize() //{ // anim.SetFloat("Recover", 0); //} public void EndAttack() { swordBody weapon = sword.GetComponent <swordBody>(); anim.SetInteger("Attack", 0); weapon.attacking = false; }
public void BeginAttack() { swordBody weapon = sword.GetComponent <swordBody>(); weapon.attacking = true; if (Master.status == 2) { anim.SetInteger("Attack", 0); //逆转状态时攻击状态也不能太久 weapon.attacking = false; } //todo //增加伤害计算 }