Наследование: System.Web.UI.Page
Пример #1
0
 void Start()
 {
     moveCamera    = FindObjectOfType <MoveCamera>();
     player        = FindObjectOfType <PlayerController>();
     betweenBattle = FindObjectOfType <BetweenBattle>();
     showMap       = FindObjectOfType <ShowMap>();
     rooms         = player.rooms;
 }
Пример #2
0
 // Start is called before the first frame update
 void Start()
 {
     //Adds a listener to the main slider and invokes a method when the value changes.
     slider = gameObject.GetComponent <Slider>();
     slider.onValueChanged.AddListener(delegate { ValueChangeCheck(); });
     label = GameObject.Find("TxtTimeLine").GetComponent <Text>();
     other = GameObject.Find("Mapbox").GetComponent <ShowMap>();
 }
Пример #3
0
 public void InitializeRuntime()
 {
     showMaps  = new ShowMap[] { new ShowMap(), new ShowMap(), new ShowMap(), new ShowMap() };
     instances = new UIBaseMap[] {
         UIMainMap.instance.baseMapParameters,
         UIMiniMap.instance.baseMapParameters,
         UICompass.instance.baseMapParameters,
         UIScreenMap.instance.baseMapParameters
     };
     iconNames = new string[] { mainMapIconName, miniMapIconName, compassIconName, screenMapIconName };
 }
Пример #4
0
 void Start()
 {
     showMap = FindObjectOfType <ShowMap>();
     Generate();
     showMap.GenerateMap();
 }
Пример #5
0
 void Start()
 {
     player      = FindObjectOfType <PlayerController>();
     showMap     = FindObjectOfType <ShowMap>();
     gameSession = GameSession.Instance;
 }
Пример #6
0
    void Awake()
    {
        S = this;

        SSF = (float) ss;
        float texScale = 1.0f / SSF;
        TEX_SCALE = Vector2.one * texScale;

        SPRITE_SHEET_W = mapSprites.width / ss;
    }
Пример #7
0
        // draw map from a timer every interval
        private void DrawMapWhenReady_Tick(object sender, EventArgs e)
        {
            // create the tiles map
            int width  = 100;
            int height = 100;

            float[,] tilesmap = new float[width, height];

            // create random map
            System.Random _rand = new Random();
            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j)
                {
                    tilesmap[i, j] = (float)_rand.NextDouble();
                }
            }

            // create a grid
            PathFind.Grid grid = new PathFind.Grid(tilesmap);

            // create source and target points
            PathFind.Point _from = new PathFind.Point(1, 1);
            PathFind.Point _to   = new PathFind.Point(90, 90);

            // get path
            // path will either be a list of Points (x, y), or an empty list if no path is found.
            List <PathFind.Point> path1 = PathFind.Pathfinding.FindPath(grid, _from, _to);

            // for Manhattan distance
            List <PathFind.Point> path2 = PathFind.Pathfinding.FindPath(grid, _from, _to, Pathfinding.DistanceType.Manhattan);

            // get graphics context
            Graphics g = ShowMap.CreateGraphics();

            // draw map background
            var tileSize = 4;

            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j)
                {
                    var   colVal = (int)(tilesmap[i, j] * 255);
                    Brush aBrush = new SolidBrush(Color.FromArgb(colVal, colVal, colVal));
                    g.FillRectangle(aBrush, i * tileSize, j * tileSize, tileSize, tileSize);
                }
            }

            // draw paths
            Brush p1Brush = new SolidBrush(Color.Red);

            foreach (var n in path1)
            {
                g.FillRectangle(p1Brush, n.x * tileSize, n.y * tileSize, tileSize, tileSize);
            }
            Brush p2Brush = new SolidBrush(Color.Blue);

            foreach (var n in path2)
            {
                g.FillRectangle(p2Brush, n.x * tileSize, n.y * tileSize, tileSize, tileSize);
            }

            // set interval until next calculation
            DrawMapWhenReady.Interval = 500;
        }
Пример #8
0
 // Start is called before the first frame update
 void Start()
 {
     other       = GameObject.Find("Mapbox").GetComponent <ShowMap>();
     bars_script = GameObject.Find("Mapbox").GetComponent <BarsVis>();
 }
Пример #9
0
    void Start()
    {
        //float minW = GameObject.Find("Map").GetComponent<points_Scene1>().minW;//points
        //float maxW = GameObject.Find("Map").GetComponent<points_Scene1>().maxW;//points
        float minW = GameObject.Find("Mapbox").GetComponent <ShowMap>().minW; //points
        float maxW = GameObject.Find("Mapbox").GetComponent <ShowMap>().maxW; //points

        // Build 0012
        sm = GameObject.Find("Mapbox").GetComponent <ShowMap>();
        //

        if (Neighbors.Count != 0)
        {
            for (int i = 0; i < Neighbors.Count; i++)
            {
                Color   Nclr;
                Vector3 offset = new Vector3(0, 0, 0);
                int     flag   = 0;

                if (!currentNode.visited.Contains(Neighbors[i].name))
                {
                    if (dist <= Neighbors[i].LeastCost)
                    {
                        offset = new Vector3(0, 0, 0.5f);
                        flag   = 1;
                    }
                    else
                    {
                        if (!Neighbors[i].NeighborNames.Contains(gameObject.name))
                        {
                            offset = new Vector3(0, 0, 0.5f);
                            flag   = 1;
                        }
                        else
                        {
                            offset = new Vector3(0, 0, -0.5f);
                            flag   = 2;
                        }
                    }
                }
                else
                {
                    offset = new Vector3(0, 0, -0.5f);
                    flag   = 2;
                }

                // Build 0022, node merge by image mapping
                if (sm.dropdown_graphop.value >= 4)
                {
                    offset = new Vector3(0, 0, 0);
                }

                float sWidth = 1 - (dist - minW) / (maxW - minW);
                float eWidth = 1 - (Neighbors[i].LeastCost - minW) / (maxW - minW);

                // Build 0034, bug fixed for line (C, B), can not have correct offset value
                if (dist == Neighbors[i].LeastCost)
                {
                    Neighbors[i].visited.Add(currentNode.name);
                    eWidth = sWidth;
                }

                Nclr    = nColor;
                newline = Instantiate(line);
                l       = newline.GetComponent <LineRenderer>();
                newline.transform.parent = GameObject.Find("Edges").transform;
                Graph.LinesNum           = Graph.LinesNum + 1;
                newline.transform.name   = "Line" + Graph.LinesNum.ToString() + "(" + currentNode.name + "," + Neighbors[i].name + ")";

                List <Vector3> pos = new List <Vector3>();
                pos.Add(currentNode.vec + offset); // Build 0021, transform.position
                pos.Add(Neighbors[i].vec + offset);

                // Build 0013, alesund graph
                if (sm.dropdown_graphop.value < 6)
                {
                    l.startWidth = sWidth;
                    l.endWidth   = eWidth;

                    if (flag == 2)
                    {
                        if (nColor != Neighbors[i].clr)
                        {
                            l.startWidth = eWidth;
                            l.endWidth   = sWidth;
                        }
                    }
                    l.startColor = Nclr;
                    l.endColor   = Nclr;
                }
                else
                {
                    l.startWidth = 0.1f;
                    l.endWidth   = 0.1f;

                    l.startColor = Color.red;
                    l.endColor   = Color.red;
                }
                //


                l.SetPositions(pos.ToArray());
                //Build 0012, more nodes for edges, search LinesNum
                if (sm.dropdown_graphop.value >= 3)
                {
                    foreach (AuxLine x in sm.AuxLines.FindAll(element => element.LineName == (currentNode.index + "_" + Neighbors[i].index)))
                    {
                        var posv = new Vector3[x.AuxNodes.Count + 2];
                        posv[0] = currentNode.vec + offset; // Build 0021, transform.position
                        //Debug.Log("Find nodes by index[" + nodeIndex.ToString() + "]: " + x.name);
                        for (int j = 0; j < x.AuxNodes.Count; j++)
                        {
                            posv[j + 1] = x.AuxNodes[j] + offset; // Build 0036
                        }
                        posv[x.AuxNodes.Count + 1] = Neighbors[i].vec + offset;
                        l.positionCount            = posv.Length;
                        l.SetPositions(posv);
                    }
                }
                //l.useWorldSpace = true;
            }
        }
    }