public void DoChase(bool option, Color color, ITargeteable targetRecived) // Metodo candidato para el Action
    {
        chase = option;
        meshRenderer.material.color = color;

        target = targetRecived.GetMyTransform();
    }
예제 #2
0
    private void DetectTarget()
    {
        targetGameObject = null;
        _target          = null;
        Collider2D[] ray            = Physics2D.OverlapCircleAll(gameObject.transform.position, _data.detectRadius);
        ITargeteable targetSelected = null;
        float        minDistance    = 9999999999f;

        if (ray != null)
        {
            foreach (var var in ray)
            {
                ITargeteable targetAux = var.GetComponent <ITargeteable>();
                if (targetAux != null)
                {
                    float distance = Vector3.Distance(transform.position, targetAux.GetTarget().transform.position);
                    if (distance < minDistance)
                    {
                        minDistance    = distance;
                        targetSelected = targetAux;
                    }
                }
            }

            if (targetSelected != null)
            {
                targetSelected.SetTurret(this);
                targetGameObject = targetSelected.GetTarget();
                _target          = targetSelected;
            }
        }
    }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        ITargeteable target = other.gameObject.GetComponent <ITargeteable>();

        if (target != null)
        {
            OnTargetAppears(true, Color.yellow, target);  // Enemies
        }
        OnStayInTheTrigger(true);                         // Door
    }
        protected override Vector3 calculateDirectionVector(ITargeteable target)
        {
            Vector3 movementVector = target.Position - this.representation.Position;
           
            
            movementVector.Y = 0;
            movementVector.Normalize();

            
            return movementVector;
        }
 public bool isNear(ITargeteable target)
 {
     return this.isNear(target.Position);
 }
 public void setNoTarget()
 {
     this.target = null;
 }
 private void setTarget(ITargeteable _target)
 {
     this.target = _target;
     //marcamos hacia donde vamos
     marcaDePicking = TgcBox.fromSize(new Vector3(30, 10, 30), Color.Red);
     marcaDePicking.Position = this.target.Position;
     //iniciamos la animacion de movimiento
     this.representation.walk();
 }
        protected virtual Vector3 calculateDirectionVector(ITargeteable target)
        {
            Vector3 direction = target.Position - this.representation.Position;

            direction.Y = 0;
            direction.Normalize();

           
          
            return direction;
        }