コード例 #1
0
 // method for creating the Warrior Class
 public Warrior()
 {
     Name           = "Warrior";
     Strength       = 13;
     Health         = 14;
     FightBehaviour = new SwordBehaviour();
 }
コード例 #2
0
 // method for creating the Warrior Class
 public Warrior()
 {
     Name = "Warrior";
     Strength = 13;
     Health = 14;
     FightBehaviour = new SwordBehaviour();
 }
コード例 #3
0
    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;
    }
コード例 #4
0
    // 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();
            }
        }
    }
コード例 #5
0
    // 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();
            }
        }
    }
コード例 #6
0
 public King()
 {
     weapon = new SwordBehaviour();
 }
コード例 #7
0
 public Knight()
 {
     Weapon = new SwordBehaviour();
 }
コード例 #8
0
 // Start is called before the first frame update
 void Start()
 {
     swordBehaviour = sword.GetComponent <SwordBehaviour>();
     state          = State.Nothing;
     GoToNextState();
 }
コード例 #9
0
 private void Start()
 {
     swordBehaviour = GetComponent <SwordBehaviour>();
     UpdateManager.Instance.toUpdate += HandleUpdate;
 }