Ejemplo n.º 1
0
        void RenderNetwork(World world)
        {
            for (int i = 0; i < World.WIDTH; i++)
            {
                for (int j = 0; j < World.HEIGHT; j++)
                {
                    var c      = new Coord(i, j);
                    var cAbove = new Coord(i, j + 1);
                    var cRight = new Coord(i + 1, j);

                    Tile tile, tileAbove, tileRight;
                    if (world.tiles.TryGetValue(c, out tile) && !tile.Impassable)
                    {
                        if (world.tiles.TryGetValue(cAbove, out tileAbove) && !tileAbove.Impassable)
                        {
                            var r = ShapeGOFactory.InstantiateRect(RectPropertyForLink(tile, tileAbove));
                            r.transform.parent = transform;
                        }
                        if (world.tiles.TryGetValue(cRight, out tileRight) && !tileRight.Impassable)
                        {
                            var r = ShapeGOFactory.InstantiateRect(RectPropertyForLink(tile, tileRight));
                            r.transform.parent = transform;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void RenderWorld(World world)
        {
            // render tiles
            foreach (var pair in world.tiles)
            {
                var coord = pair.Key;
                var tile  = pair.Value;
                if (!tileRendererDict.ContainsKey(coord))
                {
                    var renderer = ShapeGOFactory.InstantiateRect(RectPropertyFromTile(tile));
                    renderer.transform.parent = transform;
                    tileRendererDict[coord]   = renderer;

                    var caption = Instantiate <TextMesh>(captionPrefab);
                    caption.transform.parent        = renderer.transform;
                    caption.transform.localPosition = new Vector3(tileSideLength / 2f, -tileSideLength / 2f, -5);
                    caption.text = tile.type.ToString();
                    if (!tile.Rendered)
                    {
                        caption.color = new Color32(0, 0, 0, 0);
                    }
                    captionDict[coord] = caption;
                }
                else
                {
                    tileRendererDict[coord].property = RectPropertyFromTile(tile);
                }
            }

            // render artifacts
            // TODO reuse renderer
            foreach (var renderer in artifactRendererDict.Values)
            {
                Destroy(renderer.gameObject);
            }
            artifactRendererDict.Clear();

            foreach (var artifact in world.visibleArtifacts)
            {
                var renderer = ShapeGOFactory.InstantiateRect(RectPropertyFromArtifact(artifact));
                artifactRendererDict[artifact] = renderer;
            }

            if (!rendered)
            {
                RenderNetwork(world);
            }

            rendered = true;
        }
Ejemplo n.º 3
0
        void Start()
        {
            var color  = Color.black;
            var width  = 0.1f;
            var height = 0.1f;
            var angle  = 0f;

            /*
             * if (unit is Player) {
             *  //color = Color.green;
             *  height = 0.3f;
             *  //angle = 22.5f;
             * }
             */

            shapeRenderer = ShapeGOFactory.InstantiateRect(new RectProperty(width: width, height: height, color: color, angle: angle, layer: -2));
        }
Ejemplo n.º 4
0
        public void RenderGraph(GraphMatrix mat)
        {
            if (edgeRendererDict != null)
            {
                foreach (var pair in mat.edgeToPath)
                {
                    edgeRendererDict[pair.Key].property = RectPropertyFromPath(pair.Value);
                }

                return;
            }
            edgeRendererDict = new Dictionary <Edge, RectRenderer>();
            foreach (var pair in mat.edgeToPath)
            {
                // draw edge
                var edge = pair.Key;
                var path = pair.Value;

                var rectRend = ShapeGOFactory.InstantiateRect(RectPropertyFromPath(path));

                edgeRendererDict.Add(edge, rectRend);
            }
        }
Ejemplo n.º 5
0
    public static Animatable2 CreateCircle(CircleProperty cp)
    {
        var p = ShapeGOFactory.InstantiateCircle(cp);

        return(p.gameObject.AddComponent <Animatable2>());
    }