//lo mismo pero ahora solo mira entre los que esten en el ultimo waypoint
    //Con mas waypoints deberia ir mejor
    //Hace where y solo usa el maxMy para coger el mayor
    protected GameObject Mejor5Punto1()
    {
        GameObject nearestEnemy = null;
        int        maxWaypoint  = enemiesNearTower.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        nearestEnemy = OrderAux.MaxByGameObject(enemiesNearTower.Where(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex == maxWaypoint), x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude);
        return(nearestEnemy);
    }
 private void OnAddCategory()
 {
     SelectedOrder = new OrderAux()
     {
         Date = DateTime.Now.Date
     };
     OnPropertyChanged("SelectedOrder");
 }
Exemplo n.º 3
0
    protected GameObject ChooseLastEnemy()
    {
        Collider[] collidersInRange = Physics.OverlapSphere(transform.position, range, layerMask);
        if (collidersInRange.Length == 0)
        {
            return(null);
        }
        int minWaypoint = collidersInRange.Min(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        return(OrderAux.MaxElement(collidersInRange.Where(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex == minWaypoint), x => (Waypoints.waypoints[minWaypoint] - x.transform.position).sqrMagnitude).gameObject);
    }
 public OrderViewModel()
 {
     SelectedOrder = new OrderAux()
     {
         OrderID = 0, Date = DateTime.Now.Date
     };
     AddOrderCommand    = new MyICommand(OnAddCategory, CanAddCategory);
     UpdateOrderCommand = new MyICommand(OnUpdateOrder, CanUpdateOrder);
     DeleteOrderCommand = new MyICommand(OnDeleteOrder, CanDeleteOrder);
     LoadOrder();
 }
        private void DataGridOrders_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            OrderAux order = DataGridOrders.SelectedItem as OrderAux;

            if (order != null)
            {
                OrderDetailView orderDetailView = new OrderDetailView();
                orderDetailView.OrderId.Text = Convert.ToString(order.OrderID);
                orderDetailView.ShowDialog();
            }
        }
    /*Ademas ahora usa int para filtrar a ver si es mas rapido que con floats, la pega es que deja mas numeros en la lista*/
    protected GameObject ChooseNearestEnemyNew3()
    {
        GameObject nearestEnemy = null;
        int        minX         = (int)(transform.position.x - range);
        int        minZ         = (int)(transform.position.z - range);
        int        maxX         = (int)(transform.position.x + range);
        int        maxZ         = (int)(transform.position.z + range);

        nearestEnemy = OrderAux.MaxByGameObject(enemiesSpawned.Where(x => x.transform.position.x > minX && x.transform.position.z > minZ &&
                                                                     x.transform.position.x < maxX && x.transform.position.z < maxZ), x => (transform.position - x.transform.position).sqrMagnitude);
        return(nearestEnemy);
    }
Exemplo n.º 7
0
    protected GameObject ChooseNearestEnemy()
    {
        Collider hitCollider = OrderAux.MinElement(Physics.OverlapSphere(transform.position, range, layerMask), x => (transform.position - x.transform.position).sqrMagnitude);

        if (hitCollider)
        {
            return(hitCollider.gameObject);
        }
        else
        {
            return(null);
        }
    }
    protected GameObject BestColliderChooseNearestEnemy(float range, int layer)
    {
        int      layerMask   = 1 << layer;
        Collider hitCollider = OrderAux.MinElement(Physics.OverlapSphere(transform.position, range, layerMask).Where(x => x.CompareTag("enemy")), x => (transform.position - x.transform.position).sqrMagnitude);

        if (hitCollider)
        {
            return(hitCollider.gameObject);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 9
0
    protected GameObject ChooseWeakestEnemy()
    {
        IEnumerable <Collider> collidersInRange = Physics.OverlapSphere(transform.position, range, layerMask);

        if (collidersInRange.Count() == 0)
        {
            return(null);
        }
        float maxHpEnemy = collidersInRange.Min(x => x.gameObject.GetComponent <EnemyFather>().maxHp);

        collidersInRange = collidersInRange.Where(x => x.gameObject.GetComponent <EnemyFather>().maxHp == maxHpEnemy);
        int maxWaypoint = collidersInRange.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        return(OrderAux.MinElement(collidersInRange.Where(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex == maxWaypoint), x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude).gameObject);
    }
Exemplo n.º 10
0
    //TriggerCollider por cada torre en la que se guardan los que entran y los que van saliendo
    //Al atacar buscar en esa lista el mas cercano al nexo
    protected GameObject Mejor4()
    {
        GameObject nearestEnemy = null;
        int        maxWaypoint  = enemiesNearTower.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        nearestEnemy = OrderAux.MaxByGameObject(enemiesNearTower, x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude);
        if (nearestEnemy)
        {
            return(nearestEnemy.gameObject);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 11
0
    protected GameObject Mejor2()
    {
        int      layerMask    = 1 << layer;
        int      maxWaypoint  = enemiesNearTower.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);
        Collider nearestEnemy = OrderAux.MinElement(Physics.OverlapSphere(transform.position, range, layerMask).Where(x => x.CompareTag("enemy")), x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude);

        if (nearestEnemy)
        {
            return(nearestEnemy.gameObject);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 12
0
    //Lo mismo pero sin hacer el cuadrado antes para sacar distancia de solo los que estan dentro
    protected GameObject ChooseNearestEnemyNew6()
    {
        GameObject nearestEnemy = null;
        float      rangePow     = range * range;
        int        maxWaypoint  = enemiesNearTower.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        nearestEnemy = OrderAux.MaxByGameObject(enemiesSpawned.Where(x => maxWaypoint == x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex&& (transform.position - x.transform.position).sqrMagnitude < rangePow), x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude);
        if (nearestEnemy)
        {
            return(nearestEnemy.gameObject);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 13
0
    /*Ahora coge los que vayan por el waypoint mas lejano y saca la distancia con el siguiente waypoint */
    protected GameObject Mejor1()
    {
        GameObject nearestEnemy = null;
        int        minX         = (int)(transform.position.x - range);
        int        minZ         = (int)(transform.position.z - range);
        int        maxX         = (int)(transform.position.x + range);
        int        maxZ         = (int)(transform.position.z + range);
        float      rangePow     = range * range;
        int        maxWaypoint  = enemiesNearTower.Max(x => x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex);

        nearestEnemy = OrderAux.MaxByGameObject(enemiesSpawned.Where(x => maxWaypoint == x.gameObject.GetComponent <EnemyFather>().nextWayPointIndex&& x.transform.position.x > minX && x.transform.position.z > minZ &&
                                                                     x.transform.position.x < maxX && x.transform.position.z < maxZ && (transform.position - x.transform.position).sqrMagnitude < rangePow), x => (Waypoints.waypoints[maxWaypoint] - x.transform.position).sqrMagnitude);
        if (nearestEnemy)
        {
            return(nearestEnemy.gameObject);
        }
        else
        {
            return(null);
        }
    }
        public void LoadOrder()
        {
            ObservableCollection <OrderAux> orders = new ObservableCollection <OrderAux>();

            using (MFSContext context = new MFSContext())
            {
                var data = from o in context.Orders
                           //join c in context.Categories on p.Category.CategoryId equals c.CategoryId
                           join s in context.Supliers on o.Suplier.SuplierId equals s.SuplierId
                           join u in context.Users on o.User.UserId equals u.UserId
                           select new
                {
                    Id          = o.OrderId,
                    UserId      = u.UserId,
                    UserName    = u.Name,
                    SuplierId   = s.SuplierId,
                    SuplierName = s.Name,
                    Date        = o.Date,
                    CodOrder    = o.CodOrder
                };


                foreach (var or in data)
                {
                    OrderAux order = new OrderAux();
                    order.OrderID     = or.Id;
                    order.UserId      = or.UserId;
                    order.UserName    = or.UserName;
                    order.SuplierId   = or.SuplierId;
                    order.SuplierName = or.SuplierName;
                    order.Date        = or.Date;
                    order.CodOrder    = or.CodOrder;

                    orders.Add(order);
                }
            }
            Orders = orders;
        }