예제 #1
0
 public bool SetTarget(Vector3 dirVector)
 {
     if (!move && Vector.Multiplicity(transform.position + dirVector))
     {
         Vector3        nextPos = transform.position + dirVector;
         RaycastHit2D[] hits    = Physics2D.RaycastAll(nextPos, new Vector3(0, 0, 10));
         floor = null;
         BlockMove bm     = null;
         bool      player = false;
         foreach (RaycastHit2D hit in hits)
         {
             if (floor == null)
             {
                 floor = hit.transform.GetComponent <Floor>();
             }
             if (hit.transform.GetComponent <BlockMove>() != null && hit.transform.GetComponent <BlockMove>().enabled)
             {
                 bm = hit.transform.GetComponent <BlockMove>();
             }
             if (hit.transform.GetComponent <PlayerMove>() != null)
             {
                 player = true;
             }
         }
         if (floor != null && floor.Available(gameObject))
         {
             if (at != null && condititon == Condititon.underPit && player)
             {
                 StartMove(dirVector);
                 condititon = Condititon.normal;
                 return(true);
             }
             if (at != null && condititon == Condititon.underPit && !player)
             {
                 return(false);
             }
             if (at != null && player && at.condititon == Attachment.Condititon.attached && moveFromPlayer)
             {
                 moveFromPlayer = false;
                 StartMove(dirVector);
                 return(true);
             }
             if (bm != null && bm.enabled)
             {
                 if (bm.SetTarget(dirVector))
                 {
                     StartMove(dirVector);
                     return(true);
                 }
             }
             else
             {
                 StartMove(dirVector);
                 return(true);
             }
         }
     }
     return(false);
 }