private void ShowRoadElement(RoadSettings element)
        {
            EditorGUILayout.BeginVertical("box");
            {
                RoadType saveKind = element.Type;
                element.Type = (RoadType)EditorGUILayout.EnumPopup("Type Road:", element.Type);

                if (GUI.changed && saveKind != element.Type)
                {
                    if (UsingType.Contains("rt_" + saveKind.ToString()))
                    {
                        UsingType.Remove("rt_" + saveKind.ToString());
                    }
                    UsingType.Add("rt_" + element.Type.ToString());
                }

                if (element.Type == RoadType.Rail)
                {
                    element.TypeRail = (RailwayType)EditorGUILayout.EnumPopup("Type Rail:", element.TypeRail);
                }
                element.Material = (Material)EditorGUILayout.ObjectField("Material", element.Material, typeof(Material));

                if (element.Material == null)
                {
                    DisplayErrorMEssage("Not setting material");
                }
                element.Width = EditorGUILayout.FloatField("Road Width", element.Width);
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #2
0
        public override string ToString()
        {
            string result = road.ToString() + " ";

            result += enemy.ToString() + " ";
            result += time.ToString() + " ";
            result += speed.ToString() + " ";
            result += count.ToString();
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Sets up environment based on given type, modifying
        /// the config, appending the new setup to the config string
        /// </summary>
        /// <param name="type"></param>
        /// <param name="config"></param>
        public string Setup(RoadType type)
        {
            string _config  = "";
            string typeName = type.ToString();

            _config += SetupFolliage(typeName);
            _config += SetupHouses(typeName);
            _config += SetupPavilion(typeName);

            return(_config);
        }
Beispiel #4
0
        public void SetType(RoadType type)
        {
            if (type != this.type)
            {
                this.type       = type;
                gameObject.name = type.ToString();

                WayPointContainer new_wpc = null;

                if (WPContainer != null)
                {
                    Destroy(WPContainer.gameObject);
                }

                switch (type)
                {
                case RoadType.Straight:
                    sprite  = straight;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_straight, transform);
                    break;

                case RoadType.End:
                    sprite  = end;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_end, transform);
                    break;

                case RoadType.Corner:
                    sprite  = corner;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_corner, transform);
                    break;

                case RoadType.Cross_T:
                    sprite  = cross_T;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_crossT, transform);
                    break;

                case RoadType.Cross_X:
                    sprite  = cross_X;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_crossX, transform);
                    break;

                case RoadType.Single:
                    sprite  = single;
                    new_wpc = Instantiate(Objects.GameObjects.wpc_single, transform);
                    break;
                }

                WPContainer = new_wpc;
            }
        }
        public void Initialize(string id, Tile tile, List <Vector3> verts, string halfWidth)
        {
            Id     = id;
            _tile  = tile;
            Type   = halfWidth.ToRoadType();
            _verts = verts;
            //GameObject roadLine = new GameObject();
            //var line = roadLine.AddComponent<LineRenderer>();

            //line.SetPositions(_verts.ToArray());
            //roadLine.transform.parent = tile.transform;
            for (int i = 1; i < _verts.Count; i++)
            {
                GameObject roadPlane = CreateMesh(5);
                roadPlane.GetComponent <Renderer>().material = Resources.Load("Asphalt") as Material;

                roadPlane.transform.position = tile.transform.position + ((verts[i] + verts[i - 1]) / 2);
                Vector3 scale = roadPlane.transform.localScale;
                scale.z = Vector3.Distance(verts[i], verts[i - 1]) / 9.5f;
                if (scale.z < 1.1f)
                {
                    scale.z = 1.35f * scale.z;
                }
                else if (scale.z < 1.5f)
                {
                    scale.z = 1.10f * scale.z;
                }
                scale.x = Type.ToWidthFloat() / 4f;
                roadPlane.transform.localScale = scale;
                roadPlane.transform.LookAt(tile.transform.position + verts[i - 1]);
                roadPlane.transform.parent = tile.transform;

                roadPlane.name = Type.ToString();
                roadPlane.tag  = "road";
            }
        }