// method for creating the Warrior Class public Warrior() { Name = "Warrior"; Strength = 13; Health = 14; FightBehaviour = new SwordBehaviour(); }
void Awake() { // Set up the references. behaviours = new List <GenericBehaviour> (); overridingBehaviours = new List <GenericBehaviour>(); anim = GetComponent <Animator> (); hFloat = Animator.StringToHash("H"); vFloat = Animator.StringToHash("V"); camScript = playerCamera.GetComponent <ThirdPersonOrbitCamBasic> (); rBody = GetComponent <Rigidbody> (); swordBehaviour = GetComponent <SwordBehaviour>(); // Grounded verification variables. groundedBool = Animator.StringToHash("Grounded"); colExtents = GetComponent <Collider>().bounds.extents; }
// Update is called once per frame void OnTriggerEnter2D(Collider2D other) { float dir = Mathf.Sign(other.transform.root.localScale.x); Vector2 impactPoint = other.bounds.ClosestPoint(transform.position); SwordBehaviour sword = other.gameObject.GetComponent <SwordBehaviour>(); if (animator) { isVunerable = !animator.GetBool("Hurt"); } if (other.gameObject.tag == "sword" && sword.activated && isVunerable) { if (impactEffect) { Instantiate(impactEffect, impactPoint, Quaternion.identity); } if (knockback && rig != null) { rig.velocity = new Vector2(-dir * 20, rig.velocity.y); } if (animator) { animator.SetBool("Hurt", true); } if (animator && !animator.GetBool("Death")) { if (manager) { manager.addScore(10); manager.addMult(); } } if (cam && !cam.getShaking()) { StartCoroutine(cam.shakeScreen()); } if (hurtEvent != null) { hurtEvent.Invoke(); } } }
// Update is called once per frame void OnTriggerEnter2D(Collider2D other) { float dir = Mathf.Sign(other.transform.root.localScale.x); Vector2 impactPoint = other.bounds.ClosestPoint(transform.position); SwordBehaviour sword = other.gameObject.GetComponent <SwordBehaviour>(); if (animator) { isVunerable = !animator.GetBool("Hurt"); } if (other.gameObject.tag == "sword" && sword.activated && isVunerable) { int vert = 0; if (verticalKnockback) { vert = 10; } if (produceOrbs && Random.Range(1, 3) == 1) { Instantiate(memOrbs, transform.position, transform.rotation); } if (impactEffect) { Instantiate(impactEffect, impactPoint, Quaternion.identity); } if (knockback && rig != null) { rig.velocity = new Vector2(-dir * 20, rig.velocity.y + vert); } if (verticalKnockback) { rig.AddTorque(90 * Mathf.Sign(rig.velocity.x)); } //Vector2 impactDir = new Vector2(transform.position.x, transform.position.y) - impactPoint; //if (knockback && rig != null) rig.velocity = impactDir.normalized * 20; if (animator) { animator.SetBool("Hurt", true); } if (animator && !animator.GetBool("Death")) { if (manager) { //manager.addScore(10); //manager.addMult(); } } if (cam && !cam.getShaking()) { StartCoroutine(cam.shakeScreen()); } if (hurtEvent != null) { hurtEvent.Invoke(); } } }
public King() { weapon = new SwordBehaviour(); }
public Knight() { Weapon = new SwordBehaviour(); }
// Start is called before the first frame update void Start() { swordBehaviour = sword.GetComponent <SwordBehaviour>(); state = State.Nothing; GoToNextState(); }
private void Start() { swordBehaviour = GetComponent <SwordBehaviour>(); UpdateManager.Instance.toUpdate += HandleUpdate; }