示例#1
0
    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);
    }
示例#2
0
        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;
        }
示例#3
0
 void Start()
 {
     worldStatus = GameObject.FindWithTag("GameController").GetComponent <WorldStatus>();
     prevIndex   = worldStatus.worldColorIndex;
     GetComponent <Renderer>().material.color = worldStatus.worldColors[colorIndex];
     boxCollider = GetComponent <BoxCollider2D>();
 }
示例#4
0
 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];
         }
     }
 }
示例#5
0
    void Start()
    {
        GameObject g = GameObject.FindWithTag("GameController");

        worldStatus  = g.GetComponent <WorldStatus>();
        eventManager = g.GetComponent <EventManager>();
        material     = GetComponent <Renderer>().material;
    }
示例#6
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     worldStatus    = WorldStatus.CLEAR;
     oldWorldStatus = worldStatus;
     EventTextSetup();
 }
示例#7
0
    /// <summary>
    /// Отдает планеты на рендер раз в какое-то время
    /// </summary>
    public IEnumerator PlanetReturning(float time)
    {
        status = WorldStatus.running;
        while (true)
        {
            yield return(new WaitForSeconds(time));

            screenManager.GetPlanets(planetList.Values.ToList());
        }
    }
示例#8
0
    // 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;
        }
    }
示例#9
0
    // 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");
        }
    }
示例#10
0
    // 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;
        }
    }
示例#11
0
    // 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++;
        }
    }
示例#12
0
    /// <summary>
    /// 一定時間毎にWorldStatusに変更があるか監視し、それに応じて世界の状態を変遷させる。
    /// </summary>
    /// <returns>オーバーヘッド減少のため一定時間待つ</returns>
    IEnumerator UpdateWorld()
    {
        while (true)
        {
            UpdateWorldStatus();

            if (worldStatus != oldWorldStatus)
            {
                EventStart();
                oldWorldStatus = worldStatus;
            }
            yield return(new WaitForSeconds(0.3f));
        }
    }
示例#13
0
 /// <summary>
 /// 汚染度に応じてworldStatusを更新する。
 /// </summary>
 void UpdateWorldStatus()
 {
     if (IsClear())
     {
         worldStatus = WorldStatus.CLEAR;
     }
     else if (IsStagnant())
     {
         worldStatus = WorldStatus.STAGNANT;
     }
     else if (IsDirty())
     {
         worldStatus = WorldStatus.DIRTY;
     }
 }
示例#14
0
    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;
    }
示例#15
0
    // 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;
        }
    }
示例#16
0
 public void Initialize()
 {
     _actionSystem    = new ActionSystem(this);
     _visionSubsystem = new VisionSubsystem(this);
     Status           = WorldStatus.Initialized;
 }
示例#17
0
 // Start is called before the first frame update
 void Start()
 {
     spriteRenderer = GetComponent <SpriteRenderer>();
     worldStatus    = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>();
 }
示例#18
0
 public void OnApplicationQuit()
 {
     status = WorldStatus.stop;
 }
示例#19
0
        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);
                }
            }
        }
示例#20
0
 void Start()
 {
     ws = GetComponent <WorldStatus>();
     changeColor(0);
 }
示例#21
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);
 }
示例#22
0
 public void SetStatus(WorldStatus status)
 {
     new SetStatusSendMessage(status)
     .SendIn(this.BotBits);
 }
示例#23
0
 private void Start()
 {
     worldStatus = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>();
 }
示例#24
0
 /// <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;
 }
示例#25
0
 /// <summary>
 /// 引数から空の色を変更する。
 /// </summary>
 /// <param name="skyStatus_">SkyStatus(enum)の値を設定</param>
 public void ChangeBackground(WorldStatus skyStatus_)
 {
     image.sprite = backgrounds[(int)skyStatus_];
 }