Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        frameCounter++;
        if (frameCounter % tick == 0)
        {
            if (arrowFlying)
            {
                vel = myRbd.velocity;
                this.transform.rotation = Quaternion.Euler(new Vector3(0, 0, Mathf.Atan2(vel.y, vel.x) * Mathf.Rad2Deg));
                RaycastHit2D hit = Physics2D.Raycast(arrowHead.position, vel.normalized, ArrowCheckDistance, checkLayers);

                if (hit.collider != null)
                {
                    FreezeArrow();
                    Debug.Log("ARROW HIT :" + hit.transform.gameObject.name);
                    if (hit.collider.gameObject.tag == "WalkerUnit")
                    {
                        IDamagableInterface target = UtilityScript.RecursevlyLookForInterface(hit.transform);
                        //GenericTrackWalker walkerScript = RecursevlyLookForScriptInParents(hit.collider.gameObject.transform);
                        this.transform.SetParent(hit.transform);

                        if (target != null)
                        {
                            target.ArrowHit(arrowDamage, hit.collider);
                        }
                    }
                }
            }
        }
    }
 protected virtual void DoAttack()
 {
     genericWalkerAnimator.SetTrigger("Attack");
     if (hitList != null)
     {
         if (hitList.Length > 0)
         {
             foreach (RaycastHit2D hit in hitList)
             {
                 UtilityScript.RecursevlyLookForInterface(hit.transform).NormalHit(startingDamage, hit.collider);
                 //hit.collider.gameObject.GetComponent<IDamagableInterface>().ReceiveDamage(startingDamage);
             }
         }
     }
     previousAttackTime = Time.time;
 }