Esempio n. 1
0
 public List<Vector2> Ruta_a(Punt2d origen, Punt2d final)
 {
     var jpParam = new JumpPointParam(mapa_pa_sala, false, false, false, HeuristicMode.MANHATTAN);
     //jpParam.Reset(new GridPos(0,14), new GridPos(0,12));
     jpParam.Reset(new GridPos(origen.X, origen.Y), new GridPos(final.X, final.Y));
     //Debug.Log(Vector_Grid(origen).x+" "+Vector_Grid(origen).y+"origen");
     var ruta_a = JumpPointFinder.FindPath(jpParam);
     var ruta_a_tra = new List<Vector2>();
     foreach (var cosa in ruta_a)
     {
         //Debug.Log(cosa.x+" "+cosa.y);
         ruta_a_tra.Add(Grid_Vector(cosa));
     }
     //Debug.Log(ruta_a_tra.Count + " Hola");
     return ruta_a_tra;
 }  
Esempio n. 2
0
 public Quadrant(int topX, int topY, int bottX, int bottY)
 {
     TopLeftCorner = new Punt2d(topX, topY);
     BottomRightCorner = new Punt2d(bottX, bottY);
     Center = new Punt2d((bottX + topX) / 2, (bottY + topY) / 2);
 }
Esempio n. 3
0
    List<int> Test_dir_blo(Punt2d punt)
    {
        int tempCont;
        var direccionsDis = new List<int>();

        for (var i = 0; i < 4; i++)
        {
            switch (i)
            {
                //nord
                case 0:
                    tempCont = _map[punt.X, punt.Y + 1];
                    if (tempCont == 0 || tempCont == 666) direccionsDis.Add(0);
                    break;
                //sud
                case 1:
                    tempCont = _map[punt.X, punt.Y - 1];
                    if (tempCont == 0 || tempCont == 666) direccionsDis.Add(1);
                    break;
                //est
                case 2:
                    tempCont = _map[punt.X + 1, punt.Y];
                    if (tempCont == 0 || tempCont == 666) direccionsDis.Add(2);
                    break;
                //oest
                case 3:
                    tempCont = _map[punt.X - 1, punt.Y];
                    if (tempCont == 0 || tempCont == 666) direccionsDis.Add(3);
                    break;
            }
        }
        return direccionsDis;
    }
Esempio n. 4
0
 private void InstantiateTrigger(GameObject trigger, Transform parent, Punt2d position)
 {
     var temptrigger = Instantiate(trigger, ToRealWorldPosition(position.X, position.Y), Quaternion.identity) as GameObject;
     temptrigger.GetComponent<Trigg_ele>().coor = position;
     temptrigger.transform.SetParent(parent, true);
 }
Esempio n. 5
0
    private void PopulateWith(int elementType, Punt2d dir)
    {
        if (elementType < 4 || elementType == 1111)
        {
            if (elementType == Constants.RandomGeneration.EmptyRoomId || elementType == Constants.RandomGeneration.InitalRoomId) _map.RoomCount++;
            _map.Pointer.X += dir.X;
            _map.Pointer.Y += dir.Y;
            if (elementType == Constants.RandomGeneration.CorridorId)
            {
                elementType = dir.Y != 0 ? Constants.RandomGeneration.VerticalCorridorId : Constants.RandomGeneration.HorizontalCorridorId;
            }
        }
        else
        {
            _map.Pointer.X = dir.X;
            _map.Pointer.Y = dir.Y;
        }

        _map[_map.Pointer.X, _map.Pointer.Y] = elementType;
    }
Esempio n. 6
0
    Punt2d Super_mino(Punt2d punt)
    {
        var direccionsDis = new List<int>();

        for (var i = 0; i < 4; i++)
        {
            switch (i)
            {
                //nord
                case 0:
                    if (_map[punt.X, punt.Y + 2] == Constants.RandomGeneration.EmptyRoomId) direccionsDis.Add(0);
                    break;
                //sud
                case 1:
                    if (_map[punt.X, punt.Y - 2] == Constants.RandomGeneration.EmptyRoomId) direccionsDis.Add(1);
                    break;
                //est
                case 2:
                    if (_map[punt.X + 2, punt.Y] == Constants.RandomGeneration.EmptyRoomId) direccionsDis.Add(2);
                    break;
                //oest
                case 3:
                    if (_map[punt.X - 2, punt.Y] == Constants.RandomGeneration.EmptyRoomId) direccionsDis.Add(3);
                    break;
            }
        }

        //        Debug.Log(direccionsDis.Count);
        var dir = direccionsDis[Random.Range(0, direccionsDis.Count)];
        switch (dir)
        {
            //nord
            case 0:
                return new Punt2d(punt.X, punt.Y + 2);
            //sud
            case 1:
                return new Punt2d(punt.X, punt.Y - 2);
            //est
            case 2:
                return new Punt2d(punt.X + 2, punt.Y);
            //oest
            case 3:
                return new Punt2d(punt.X - 2, punt.Y);
        }
        return new Punt2d(55555, 55555);
    }
Esempio n. 7
0
    //checks if all 4 directions 2 positions away from the pointer are empty, if they aren't, they are removed 
    private List<Punt2d> testDirections(List<Punt2d> directionsCheck)
    {
        var tempFarDirections = Enumerable.ToList(directionsCheck.Select(t => new Punt2d(t.X * 2, t.Y * 2)));

        var tempList = new List<Punt2d>(directionsCheck);

        for (var dir = 0; dir < directionsCheck.Count; dir++)
        {
            var positionValue = _map[_map.Pointer.X + tempFarDirections[dir].X, _map.Pointer.Y + tempFarDirections[dir].Y];
            if (positionValue == 666) tempList.Remove(directionsCheck[dir]);
            else if (positionValue != 0)
            {
                var point = new Punt2d(_map.Pointer.X + tempFarDirections[dir].X, _map.Pointer.Y + tempFarDirections[dir].Y);
                if (TestDirectionsFrom(point).Count >= 3) continue;
                if (!Utils.ChanceTrue(Constants.RandomGeneration.ChanceAcceptBuild))
                {
                    tempList.Remove(directionsCheck[dir]);
                }
            }
        }
        return tempList;
    }
Esempio n. 8
0
 //test if and specific direction from the pointer is empty
 private bool testDirections(Punt2d dir)
 {
     return _map[_map.Pointer.X + dir.X, _map.Pointer.Y + dir.Y] == 0;
 }
Esempio n. 9
0
    //test if all 4 directions from the point provided are empty
    private List<Punt2d> TestDirectionsFrom(Punt2d point)
    {
        var direccionsDis = new List<Punt2d>();

        for (var dir = 0; dir < 4; dir++)
        {
            if (_map[point.X + Constants.RandomGeneration.CloseDirections[dir].X, point.Y + Constants.RandomGeneration.CloseDirections[dir].Y] == 0) direccionsDis.Add(Constants.RandomGeneration.CloseDirections[dir]);
        }
        return direccionsDis;
    }
Esempio n. 10
0
 int Quin_Quadrant(Punt2d puntQua)
 {
     if (puntQua.X > (_map.Width / 2))
     {
         return puntQua.Y > (_map.Height / 2) ? 3 : 1;
     }
     return puntQua.Y < (_map.Height / 2) ? 0 : 2;
 }
Esempio n. 11
0
 public EnterAreaMessage(Punt2d coor)
 {
     Coor = coor;
 }