public void SaveWorld() { Directory.CreateDirectory(Application.persistentDataPath + "/world"); string dataPath = Application.persistentDataPath + "/world/"; foreach (Room room in rooms) { if (room != null) { if (!(room.myRoomX == 500 && room.myRoomY == 500)) { byte[] file = SerializationUtility.SerializeValue(room.Save(), DataFormat.JSON); /*StreamWriter writer = new StreamWriter(dataPath + room.myRoomX + "_" + room.myRoomY + ".room"); * writer.Write(file); * writer.Dispose();*/ File.WriteAllBytes(dataPath + room.myRoomX + "_" + room.myRoomY + ".room", file); } } } byte[] winfofile = SerializationUtility.SerializeValue(WorldStatus.GetCurrentStatus(), DataFormat.JSON); /*StreamWriter winfowriter = new StreamWriter(dataPath + "world.info"); * winfowriter.Write(winfofile); * winfowriter.Dispose();*/ File.WriteAllBytes(dataPath + "world.info", winfofile); }
public World() { Rng.Seed(0); Status = WorldStatus.Created; TagManager = new TagManager <string>(); GroupManager = new GroupManager <string>(); EntityFactory = new EntityFactory(); EntityManager = new EntityManager(); Log = new GameLog(); EntityManager.EntityAdded += EntityManager_EntityAdded; EntityManager.EntityRemoved += EntityManager_EntityRemoved; ItemFactory.Init(EntityFactory); FeatureFactory.Init(EntityFactory); PersonFactory.Init(EntityFactory); TestEntityFactory.Init(EntityFactory); EntityFactory.Compile(); MapFactory = new MapFactory(this); Calendar = new Calendar(); CalendarEntity = EntityManager.Create(new List <Component> { new ControllerComponent(Calendar, new AP(World.OneSecondInSpeed / 2)) }); // ActionProcessed += World_ActionProcessed; }
void Start() { worldStatus = GameObject.FindWithTag("GameController").GetComponent <WorldStatus>(); prevIndex = worldStatus.worldColorIndex; GetComponent <Renderer>().material.color = worldStatus.worldColors[colorIndex]; boxCollider = GetComponent <BoxCollider2D>(); }
public void ChangeTexture(/*float sumPollution_*/ WorldStatus worldStatus) { if (/*sumPollution_ > 0.75*/ worldStatus == WorldStatus.DIRTY) { groundMat.mainTexture = groundTextures[2]; waterMat.mainTexture = waterTextures[2]; foreach (var mat in seaMats) { mat.mainTexture = waterTextures[2]; } } else if (/*sumPollution_ > 0.5*/ worldStatus == WorldStatus.STAGNANT) { groundMat.mainTexture = groundTextures[1]; waterMat.mainTexture = waterTextures[1]; foreach (var mat in seaMats) { mat.mainTexture = waterTextures[1]; } } else { groundMat.mainTexture = groundTextures[0]; waterMat.mainTexture = waterTextures[0]; foreach (var mat in seaMats) { mat.mainTexture = waterTextures[0]; } } }
void Start() { GameObject g = GameObject.FindWithTag("GameController"); worldStatus = g.GetComponent <WorldStatus>(); eventManager = g.GetComponent <EventManager>(); material = GetComponent <Renderer>().material; }
void Awake() { if (instance == null) { instance = this; } worldStatus = WorldStatus.CLEAR; oldWorldStatus = worldStatus; EventTextSetup(); }
/// <summary> /// Отдает планеты на рендер раз в какое-то время /// </summary> public IEnumerator PlanetReturning(float time) { status = WorldStatus.running; while (true) { yield return(new WaitForSeconds(time)); screenManager.GetPlanets(planetList.Values.ToList()); } }
// Start is called before the first frame update void Start() { worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); animator = GetComponent <Animator>(); if (worldStatus.ForestBackground) { animator.SetTrigger("Done"); activated = true; } }
// Start is called before the first frame update void Start() { worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); animator = GetComponent <Animator>(); if (worldStatus.GrandfatherClock == true) { activated = true; animator.SetTrigger("Done"); } }
// Start is called before the first frame update void Start() { worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); tempBlock = GameObject.Find("TempBlock"); cinemachine = GetComponent <CinemachineVirtualCamera>(); if (worldStatus.CaveBackground == true) { Destroy(tempBlock.gameObject); cinemachine.enabled = true; } }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); boxCollider = GetComponent <BoxCollider2D>(); worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); if (type == "ToyHouse" && worldStatus.CaveBackground == true) { Destroy(this.gameObject); worldStatus.collection++; } }
/// <summary> /// 一定時間毎にWorldStatusに変更があるか監視し、それに応じて世界の状態を変遷させる。 /// </summary> /// <returns>オーバーヘッド減少のため一定時間待つ</returns> IEnumerator UpdateWorld() { while (true) { UpdateWorldStatus(); if (worldStatus != oldWorldStatus) { EventStart(); oldWorldStatus = worldStatus; } yield return(new WaitForSeconds(0.3f)); } }
/// <summary> /// 汚染度に応じてworldStatusを更新する。 /// </summary> void UpdateWorldStatus() { if (IsClear()) { worldStatus = WorldStatus.CLEAR; } else if (IsStagnant()) { worldStatus = WorldStatus.STAGNANT; } else if (IsDirty()) { worldStatus = WorldStatus.DIRTY; } }
public void LoadWorld() { rooms[500, 500] = Room.starterRoom; string dataPath = Application.persistentDataPath + "/world/"; foreach (string path in Directory.GetFiles(dataPath, "*.room")) { string roomPosTitle = Path.GetFileNameWithoutExtension(path); int posX = int.Parse(roomPosTitle.Split('_')[0]); int posY = int.Parse(roomPosTitle.Split('_')[1]); Room genr = Instantiate(roomPrefab, new Vector3((posX * 52) - 26000, 0, 40000 - (posY * 40) - 20000), Quaternion.identity).GetComponent <Room>(); byte[] file = File.ReadAllBytes(path); Room.RoomInfo info = SerializationUtility.DeserializeValue <Room.RoomInfo>(file, DataFormat.JSON); WorldObject[] worldObjects = info.objs; genr.myRoomX = posX; genr.myRoomY = posY; genr.doors[0].physical.SetActive(info.doors[0]); genr.doors[1].physical.SetActive(info.doors[1]); genr.doors[2].physical.SetActive(info.doors[2]); genr.doors[3].physical.SetActive(info.doors[3]); rooms[posX, posY] = genr; foreach (WorldObject item in worldObjects) { GameObject g = Instantiate(dictionary[item.id], new Vector3(item.x, item.y, item.z), new Quaternion(item.rotX, item.rotY, item.rotZ, item.rotW)); genr.AddObjectToRegister(g); if (g.GetComponent <RandomRotation>() != null) { Destroy(g.GetComponent <RandomRotation>()); } } byte[] winfofile = File.ReadAllBytes(dataPath + "world.info"); WorldStatus status = SerializationUtility.DeserializeValue <WorldStatus>(winfofile, DataFormat.JSON); World.day = status.day; World.time = status.time; World.fuelInGenerator = status.fuel; } CameraController.instance.targetRoomPosition = Room.starterRoom.transform; CameraController.instance.roomPosition = Room.starterRoom.transform; }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); boxCollider = GetComponent <BoxCollider2D>(); playerInput = GameObject.Find("Player").GetComponent <UnityStandardAssets._2D.Platformer2DUserControl>(); worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); //Campfire Sit Collider disappears after the forest gets color if (type == "Campfire" && worldStatus.ForestBackground) { active = false; } if (type == "NightSky" && worldStatus.stars == true) { active = false; spriteRenderer.enabled = true; } }
public void Initialize() { _actionSystem = new ActionSystem(this); _visionSubsystem = new VisionSubsystem(this); Status = WorldStatus.Initialized; }
// Start is called before the first frame update void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); }
public void OnApplicationQuit() { status = WorldStatus.stop; }
public void SetGlobalAction(WorldStatus status) { foreach(BoidControl boid in this._boidList) { SetBoidAction(boid, _boidList, status); } foreach (var colony in _boidColonies) { foreach (var boid in colony.Boids) { SetBoidAction(boid, colony.Boids, status); } } }
void Start() { ws = GetComponent <WorldStatus>(); changeColor(0); }
public void SetBoidAction(BoidControl boid, IList<BoidControl> boidList, WorldStatus status) { if (status == WorldStatus.GlobalFollowPath) boid.Action = new BoidActionFollowPath(GlobalPath); else if (status == WorldStatus.GlobalFlee) boid.Action = new BoidActionFlee(); else if (status == WorldStatus.GlobalSeek) boid.Action = new BoidActionSeek(); else if (status == WorldStatus.GlobalWander || status == WorldLogic.WorldStatus.GlobalFCAS && boid.ID == 1) { boid.Action = new BoidActionWander(); boid.MaxSpeed = 2; } else if (status == WorldLogic.WorldStatus.LookForFood) boid.Action = new BoidActionLookFor(new WorldObjectFood(1), this); else if (status == WorldLogic.WorldStatus.GlobalCohesion) boid.Action = new BoidActionCohesion(boid, boidList, 100); else if (status == WorldStatus.GlobalArrive) boid.Action = new BoidActionArrive(); else if (status == WorldStatus.GlobalSeparate) boid.Action = new BoidActionSeparate(boid, boidList); else if (status == WorldStatus.GlobalAligment) boid.Action = new BoidActionAligment(boid, boidList); else if (status == WorldStatus.GlobalFCAS) boid.Action = new BoidCombinedActionFCAS(boid, boidList, _boidList, 100); }
public void SetStatus(WorldStatus status) { new SetStatusSendMessage(status) .SendIn(this.BotBits); }
private void Start() { worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>(); }
/// <summary> /// Initializes a new instance of the <see cref="SetStatusSendMessage" /> class. /// </summary> /// <param name="status">if set to <c>true</c>, spectating is allowed.</param> public SetStatusSendMessage(WorldStatus status) { this.Status = status; }
/// <summary> /// 引数から空の色を変更する。 /// </summary> /// <param name="skyStatus_">SkyStatus(enum)の値を設定</param> public void ChangeBackground(WorldStatus skyStatus_) { image.sprite = backgrounds[(int)skyStatus_]; }