Esempio n. 1
0
    // Set new target for player
    void setTarget(coordinate tget)
    {
        Debug.Log("Now going to: X= " + tget.getX() + " Y= " + tget.getY());

        int startX = getCoord(this.transform.position).getX();
        int startY = getCoord(this.transform.position).getY();

        Debug.Log(startX + " / " + startY);
        int endX = tget.getX();
        int endY = tget.getY();

        int[] start = new int[2] {
            startY, startX
        };
        int[] end = new int[2] {
            endY, endX
        };
        List <Vector2> path = new Pathfinder(map, start, end, "").result;

        List <coordinate> coords = new List <coordinate>();

        foreach (Vector2 vec in path)
        {
            Debug.Log(vec.x + " " + vec.y);
            coords.Add(new coordinate((int)vec.y, (int)vec.x));
        }
        index      = 0;
        targetPath = coords.ToArray();
    }
Esempio n. 2
0
    // Get vector3 (transform.position) from coordinate
    public Vector3 decodeCoord(coordinate coord)
    {
        int rise = coord.getX();
        int run  = coord.getY();
        int x    = 5 + (10 * run);
        int y    = 195 - (10 * rise);

        return(new Vector3(x, 1.4f, y));
    }
Esempio n. 3
0
 public bool isEq(coordinate c)
 {
     if (c.getX() == x && c.getY() == y)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
    public static string coordinateTOstring(coordinate c)
    {
        string newstring = "";
        int    tempX     = c.getX();
        int    tempY     = c.getY();

        newstring += "blok(";
        newstring += IntToChar(tempX / 10);
        newstring += IntToChar(tempX % 10);
        newstring += ")(";
        newstring += IntToChar(tempY / 10);
        newstring += IntToChar(tempY % 10);
        newstring += ")";

        return(newstring);
    }
Esempio n. 5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetMouseButtonDown(0))
        {
            this.determine();
        }

        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform.name.Length > 5)
            {
                if (hit.transform.name.Substring(0, 5).Equals("blok("))
                {
                    // Debug.Log(hit.transform.name.Substring(0, 5));
                    if (StaticMethodLib.stringTOcoordinate(hit.transform.name).getX() == co.getX() &&
                        StaticMethodLib.stringTOcoordinate(hit.transform.name).getY() == co.getY())
                    {
                    }
                    else
                    {
                        for (int i = 0; i < 20; i++)
                        {
                            for (int j = 0; j < 20; j++)
                            {
                                if (!b[i, j].getFix())
                                {
                                    b[i, j].setShow(false);
                                }
                            }
                        }
                        co = StaticMethodLib.stringTOcoordinate(hit.transform.name);
                    }
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray2 = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit2;

            if (Physics.Raycast(ray2, out hit2))
            {
                // Debug.Log(hit.transform.name);
                dis = Main.ResetDisplayWay(hit2.transform.name);
                // blokAbstract.setblokName(hit.transform.name);
            }
        }

        coordinate[] coo = new coordinate[5];
        coo = findBlok(dis.getBlok(), dis.getSide(), dis.getAngle(), co);

        for (int i = 0; i < coo.Length; i++)
        {
            // Debug.Log(i + " is success");

            int x = coo[i].getX() - 1;
            int y = coo[i].getY() - 1;

            // Debug.Log("$ "+x+" "+y);

            if (x >= 20 || x < 0)
            {
            }
            else if (y >= 20 || y < 0)
            {
            }
            else
            {
                b[x, y].setShow(true);
            }
        }
    }
Esempio n. 6
0
 public static DisplayBlok findDisplayBlok(coordinate co)
 {
     return(b[co.getX() - 1, co.getY() - 1]);
 }
Esempio n. 7
0
 public static coordinate onlyDoOffset(coordinate co, int Xoffset, int Yoffset)
 {
     return(new coordinate(co.getX() + Xoffset, co.getY() + Yoffset));
 }