Example #1
0
        public static ICallbackObject CallWithIntervals(Action callback, int repeat = int.MaxValue, float waitTime = float.MinValue)
        {
            IntervalCallBackObject intervalCallBack = new GameObject("", typeof(IntervalCallBackObject)).GetComponent<IntervalCallBackObject>();
            intervalCallBack.Initialize(callback, repeat, waitTime);
            Instance.InitializeCallBack(intervalCallBack);

            return intervalCallBack;
        }
Example #2
0
        public GameObject CreateModel()
        {
            if (IsModelCreated)
                return null;

            var m = new GameObject().AddComponent<BuildingPolygon>();
            m.gameObject.transform.position = Center;
            m.Initialize(_verts);
            m.gameObject.GetComponent<Renderer>().material = Resources.Load("buildings01") as Material;

            IsModelCreated = true;
            return m.gameObject;
        }
        public static Vehicle Create(VehicleSpawner spawner)
        {
            var inst = new GameObject().AddComponent<Vehicle>();

            VehicleDef def;
            if (spawner.Info.CarId == -1) {
                def = GetRandomDef();
            } else {
                def = Item.GetDefinition<VehicleDef>(spawner.Info.CarId);
            }

            inst.Initialize(def, spawner.Info.Colors);

            inst.transform.position = spawner.transform.position - Vector3.up * inst.AverageWheelHeight;
            inst.transform.localRotation = spawner.transform.rotation;

            Networking.Server.Instance.GlobalGroup.Add(inst);

            return inst;
        }
 public static VehicleSpawner Create(ParkedVehicle info)
 {
     var vs = new GameObject().AddComponent<VehicleSpawner>();
     vs.Initialize(info);
     return vs;
 }
Example #5
0
        public static ICallbackObject ExecuteOnCondition(Action callBack, Func<bool> condition, float checkInterval = float.MinValue)
        {
            ConditionCallBackObject conditionCallback = new GameObject("", typeof(ConditionCallBackObject)).GetComponent<ConditionCallBackObject>();
            conditionCallback.Initialize(callBack, condition, checkInterval);
            Instance.InitializeCallBack(conditionCallback);

            return conditionCallback;
        }
Example #6
0
        public static ICallbackObject WaitThanCallback(Action callback, float waitTime)
        {
            WaitThanCallBackObject waitThanCallBackObject = new GameObject("", typeof(WaitThanCallBackObject)).GetComponent<WaitThanCallBackObject>();
            waitThanCallBackObject.Initialize(callback, waitTime);
            Instance.InitializeCallBack(waitThanCallBackObject);

            return waitThanCallBackObject;
        }
		private ContourSegment GenerateSection(Contour terrain, ContourSegmentConfig config) {
			ContourSegment section = new GameObject("Section", typeof(ContourSegment)).GetComponent<ContourSegment>();
			section.Initialize(terrain, config, attributes);
			return section;
		}
Example #8
0
        private void CreateRoads(JSONObject mapData)
        {
            foreach (var geo in mapData["features"].list)
            {
                var l = new List<Vector3>();

                for (int i = 0; i < geo["geometry"]["coordinates"].list.Count; i++)
                {
                    var c = geo["geometry"]["coordinates"][i];
                    var bm = GM.LatLonToMeters(c[1].f, c[0].f);
                    var pm = new Vector2(bm.x - Rect.center.x, bm.y - Rect.center.y);
                    l.Add(pm.ToVector3xz());
                }

                var m = new GameObject("road").AddComponent<RoadPolygon>();
                m.transform.parent = this.transform;
                try
                {
                    m.Initialize(geo["properties"]["id"].str, this, l, geo["properties"]["kind"].str);
                }
                catch (Exception ex)
                {
                    Debug.Log(ex);
                }
            }
        }