示例#1
0
    public Queue <Clickable> GetWayToClickable(Clickable currentClickable, Clickable finalClickable)
    {
        Vector2 currentPosInMatrix = Lee.GetPosInMatrix(currentClickable.num, currentClickable.GetFloor());
        Vector2 finalPosInMatrix   = Lee.GetPosInMatrix(finalClickable.num, finalClickable.GetFloor());

        Vector2[] vectArr = Lee.GetRecoveryWay((int)currentPosInMatrix.x, (int)currentPosInMatrix.y, (int)finalPosInMatrix.x, (int)finalPosInMatrix.y);

        Queue <Clickable> tempQueue = new Queue <Clickable>();

        for (int i = 0; i < vectArr.Length; i++)
        {
            // Debug.Log(vectArr[i]);
            if (i == vectArr.Length - 1)
            {
                tempQueue.Enqueue(GetClickableByPosInMatrix(vectArr[i]));
                break;
            }

            if (IsJumping(GetClickableByPosInMatrix(vectArr[i])) && GetClickableByPosInMatrix(vectArr[i + 1]) == null)
            {
                tempQueue.Enqueue(GetClickableByPosInMatrix(vectArr[i]));
                i += 2;
            }
        }
        //Debug.Log(" ");

        return(tempQueue);
    }
示例#2
0
    int GetLenToPos(Clickable firstClickable, Clickable secondClickable)
    {
        Vector2 aVector = Lee.GetPosInMatrix(firstClickable.num, firstClickable.GetFloor());
        Vector2 bVector = Lee.GetPosInMatrix(secondClickable.num, secondClickable.GetFloor());

        return(Lee.GetLength((int)aVector.x, (int)aVector.y, (int)bVector.x, (int)bVector.y));
    }
示例#3
0
    void AlienMoveTo(Alien alien)
    {
        List <Clickable> tempClickable = null;

        /*
         * if (alien.GetCurrentClickable().GetBuildingType().Equals(Clickable.BuildingType.Wall))
         * {
         *  tempClickable = library.map.GetAcceptableClickedWithWall(alien);
         * }*/
        // на основе алгоритма ли надо найти ближайшие точки

        //        library.map.GetClickableInArea();

        /*Изменить grid в lee*/
        Vector2 pos = new Vector2(-1, -1);

        if (alien.GetIgnoreWallClickable() != null)
        {
            pos = Lee.GetPosInMatrix(alien.GetIgnoreWallClickable().num, alien.GetIgnoreWallClickable().GetFloor());
            Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.WALL;
        }

        /*
         * for (int j = Lee.startGrid.GetLength(0) - 1; j >= 0; j--)
         * {
         *  string str = "";
         *  for (int i = 0; i < Lee.startGrid.GetLength(1); i++)
         *  {
         *      string qwe = " ";
         *      if (Lee.startGrid[j, i] >= 0 && Lee.startGrid[j, i] < 10)
         *      {
         *          qwe = "  ";
         *      }
         *      str += Lee.startGrid[j, i] + qwe;
         *  }
         *  Debug.Log(str);
         * }
         * Debug.Log(" ");*/
        Clickable clickable = library.map.GetRandomFreeCellToMove(alien.GetCurrentClickable(), tempClickable);

        //      if (alien.GetIgnoreWallClickable() != null)
        //       {
        //           Debug.Log(clickable.num);
        //     }

        Queue <Clickable> wayToClickable = library.map.GetWayToClickable(alien.GetCurrentClickable(), clickable);


        if (pos != new Vector2(-1, -1))
        {
            Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK;
        }
        /*Вернуть обратно*/

        //  foreach (Clickable cl in wayToClickable)
        //  Debug.Log(cl.num);
        //alien.SetTarget(clickable);

        alien.SetWayQueue(wayToClickable);
    }
示例#4
0
    public List <Clickable> GetClickableInArea(Clickable currentClickable, int min, int length)
    {
        Vector2 currentPosInMatrix = Lee.GetPosInMatrix(currentClickable.num, currentClickable.GetFloor());

        Vector2[] vectArr = Lee.GetPositionInArea((int)currentPosInMatrix.x, (int)currentPosInMatrix.y, min, length);

        List <Clickable> listClickable = new List <Clickable>();

        foreach (Vector2 vect in vectArr)
        {
            Clickable clickable = GetClickableByPosInMatrix(vect);

            if (clickable != null)
            {
                listClickable.Add(clickable);
            }
        }

        return(listClickable);
    }
示例#5
0
    public bool AlienFindFountain(Alien alien)
    {
        List <Clickable> tempClickable = null;

        /*if (alien.GetCurrentClickable().GetBuildingType().Equals(Clickable.BuildingType.Wall))
         * {
         *  tempClickable = library.map.GetAcceptableClickedWithWall(alien);
         * }*/
        Vector2 pos = new Vector2(-1, -1);

        if (alien.GetIgnoreWallClickable() != null)
        {
            pos = Lee.GetPosInMatrix(alien.GetIgnoreWallClickable().num, alien.GetIgnoreWallClickable().GetFloor());
            Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.WALL;
        }
        Clickable clickable = library.map.FindNearestFountain(alien, tempClickable);


        if (clickable != null /*&& !alien.IsFountainTimeOut()*/)
        {
            Queue <Clickable> wayToClickable = library.map.GetWayToClickable(alien.GetCurrentClickable(), clickable);

            if (pos != new Vector2(-1, -1))
            {
                Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK;
            }

            alien.SetFountainWayQueue(wayToClickable);
            //  alien.SetTarget(library.map.FindNearestFountain(alien.GetCurrentClickable()));
            // alien.SetFoundFountain(true);
            return(true);
        }
        else
        {
            if (pos != new Vector2(-1, -1))
            {
                Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK;
            }
            return(false);
        }
    }