Example #1
0
 // funcion que controla el ataque
 public void Attack()
 {
     if (enlace.GetComponent<Player>().objetivos.Count > 0) {
         targetlocal = (RTSObject)enlace.GetComponent<Player>().objetivos[0];
         if (targetlocal != null) {
             transform.LookAt(targetlocal.transform);
             GetComponent<MovimientoAleatorioCivil>().enabled = false; // desactivo el movimiento aleatorio
             dist = Vector3.Distance(transform.position, targetlocal.transform.position);
             if (targetlocal.GetComponent<RTSObject>().hitPoints == 0)
             {
                 enlace.GetComponent<Player>().objetivos.Remove(targetlocal);
             }
             if (dist > 2)
             {
                 transform.Translate(0, 0, 1 * speed * Time.deltaTime);
                 anim.SetBool("IsWalking", true);
             }
             else
             {
                 transform.Translate(0, 0, 0);
                 anim.SetBool("IsWalking", false);
                 GetComponent<RTSObject>().AttackObject(targetlocal);
             }
         }
     }
 }
Example #2
0
    protected override void OnFinished()
    {
        //Once we're finished give the calling object it's path
        m_ObjectCalling.GetComponent <LandMovement>().SetPath(m_Result);

        if (m_CallBackFunction != null)
        {
            m_CallBackFunction();
        }
    }