Ejemplo n.º 1
0
    private void Awake()
    {
        manager = FindObjectOfType <GameManager>();

        monstersNumber = manager.roomCount * 2;

        List <GameObject> furnitures = Collect(furnituresSpawns, furnituresNumber);
        List <GameObject> monsters   = monsters = Collect(monstersSpawns, monstersNumber);

        int rnd = Random.Range(0, furnitures.Count);

        for (int index = 0; index < furnitures.Count; index++)
        {
            Material material = manager.standardMaterial;

            FurnitureManager furnitureManager = furnitures[index].GetComponent <FurnitureManager>();

            if (rnd == index)
            {
                material = manager.nextLevelMaterial;
            }

            furnitureManager.ChangeMaterial(material);
            furnitureManager.gameManager = manager;
            furnitureManager.isDoor      = rnd == index;
        }

        for (int index = 0; index < monsters.Count; index++)
        {
            monsters[index].GetComponent <Renderer>().material      = manager.currentLevelMaterial;
            monsters[index].GetComponent <MonsterManager>().manager = this;
        }

        hero = Instantiate(manager.heroPrefab, heroSpawn.position, heroSpawn.rotation);
    }
Ejemplo n.º 2
0
    public void ReadJson(JObject worldJson)
    {
        if (worldJson["Seed"] != null)
        {
            Seed = (int)worldJson["Seed"];
        }

        RandomStateFromJson(worldJson["RandomState"]);

        SetupWorld((int)worldJson["Width"], (int)worldJson["Height"], (int)worldJson["Depth"]);

        RoomManager.FromJson(worldJson["Rooms"]);
        TilesFromJson(worldJson["Tiles"]);
        InventoryManager.FromJson(worldJson["Inventories"]);
        FurnitureManager.FromJson(worldJson["Furnitures"]);
        UtilityManager.FromJson(worldJson["Utilities"]);
        RoomManager.BehaviorsFromJson(worldJson["RoomBehaviors"]);
        CharacterManager.FromJson(worldJson["Characters"]);
        CameraData.FromJson(worldJson["CameraData"]);
        LoadSkybox((string)worldJson["Skybox"]);
        Wallet.FromJson(worldJson["Wallet"]);
        TimeManager.Instance.FromJson(worldJson["Time"]);
        Scheduler.Scheduler.Current.FromJson(worldJson["Scheduler"]);

        tileGraph = new Path_TileGraph(this);
    }
Ejemplo n.º 3
0
    public void ReadJson(string filename)
    {
        StreamReader reader    = File.OpenText(filename);
        JObject      worldJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));

        Width  = (int)worldJson["Width"];
        Height = (int)worldJson["Height"];
        Depth  = (int)worldJson["Depth"];

        SetupWorld(Width, Height, Depth);

        RoomManager.FromJson(worldJson["Rooms"]);
        TilesFromJson(worldJson["Tiles"]);
        InventoryManager.FromJson(worldJson["Inventories"]);
        FurnitureManager.FromJson(worldJson["Furnitures"]);
        UtilityManager.FromJson(worldJson["Utilities"]);
        RoomManager.BehaviorsFromJson(worldJson["RoomBehaviors"]);
        CharacterManager.FromJson(worldJson["Characters"]);
        CameraData.FromJson(worldJson["CameraData"]);
        LoadSkybox((string)worldJson["Skybox"]);
        Wallet.FromJson(worldJson["Wallet"]);
        Scheduler.Scheduler.Current.FromJson(worldJson["Scheduler"]);

        tileGraph = new Path_TileGraph(this);
    }
Ejemplo n.º 4
0
    void LoadFurnitureType(object furnT)
    {
        FurnitureManager.FurnitureType furnType = (FurnitureManager.FurnitureType)furnT;
        FurnManager = GameObject.FindObjectOfType <FurnitureManager>();

        this.gameObject.transform.parent.gameObject.SetActive(true);

        NotAddedFurniture = new List <FurnitureManager.FurniturePairing>();
        foreach (FurnitureManager.FurniturePairing furn in FurnManager.myRegistry.myPairings)
        {
            bool alreadyUsed = false;
            //	Debug.Log ("Current is " + CurrentInfo);
            foreach (CustomerManager.FurniturePreference customerPref in CurrentInfo)
            {
                if (customerPref.FurnitureID == furn.id)
                {
                    alreadyUsed = true;
                    break;
                }
            }
            if (!alreadyUsed && (furnType == furn.myType || furnType == FurnitureManager.FurnitureType.Any))
            {
                NotAddedFurniture.Add(furn);
            }
        }

        LoadPage(0);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Calls update on characters.
 /// Also calls "OnFastUpdate" EventActions on visible furniture.
 /// </summary>
 /// <param name="deltaTime">Delta time.</param>
 private void TickEveryFrame(float deltaTime)
 {
     CharacterManager.Update(deltaTime);
     FurnitureManager.TickEveryFrame(deltaTime);
     GameEventManager.Update(deltaTime);
     ShipManager.Update(deltaTime);
 }
Ejemplo n.º 6
0
    private void SetupWorld(int width, int height)
    {
        // Set the current world to be this world.
        // TODO: Do we need to do any cleanup of the old world?
        Current = this;


        RoomManager           = new RoomManager();
        RoomManager.Adding   += (room) => roomGraph = null;
        RoomManager.Removing += (room) => roomGraph = null;

        FillTilesArray();

        FurnitureManager          = new FurnitureManager();
        FurnitureManager.Created += OnFurnitureCreated;

        UtilityManager   = new UtilityManager();
        CharacterManager = new CharacterManager();
        InventoryManager = new InventoryManager();
        jobQueue         = new JobQueue();
        GameEventManager = new GameEventManager();
        PowerNetwork     = new PowerNetwork();
        FluidNetwork     = new FluidNetwork();
        temperature      = new TemperatureDiffusion(this);
        Wallet           = new Wallet();
        CameraData       = new CameraData();

        LoadSkybox();
        AddEventListeners();

        holder.Start();
        biomes.RandomBiome();
        mapData.SetupWorld(width, height, biome.maxHeight);
    }
Ejemplo n.º 7
0
    public virtual void PlaceInWorld(FurnitureManager fm)
    {
        if (fm == null)
        {
            return;
        }

        bool worked = fm.PlaceFurniture(Prefab, X, Y);

        if (!worked)
        {
            Debug.LogError("Failed to place '" + Prefab + "'! Data may be lost!");
        }
        else
        {
            Furniture f = fm.GetFurnitureAt(X, Y);
            if (f != null)
            {
                ApplyData(f);
            }
            else
            {
                Debug.LogError("Placed furniture '" + Prefab + "' at " + X + ", " + Y + " but requesting the placed object failed! Might result in data loss for placed furniture.");
            }
        }
    }
Ejemplo n.º 8
0
    private void SetupWorld(int width, int height, int depth)
    {
        // Set the current world to be this world.
        // TODO: Do we need to do any cleanup of the old world?
        Current = this;

        Width  = width;
        Height = height;
        Depth  = depth;

        tiles = new Tile[Width, Height, Depth];

        RoomManager           = new RoomManager();
        RoomManager.Adding   += (room) => roomGraph = null;
        RoomManager.Removing += (room) => roomGraph = null;

        FillTilesArray();

        FurnitureManager          = new FurnitureManager();
        FurnitureManager.Created += OnFurnitureCreated;

        UtilityManager   = new UtilityManager();
        CharacterManager = new CharacterManager();
        InventoryManager = new InventoryManager();
        jobQueue         = new JobQueue();
        GameEventManager = new GameEventManager();
        PowerNetwork     = new PowerNetwork();
        temperature      = new Temperature();
        ShipManager      = new ShipManager();
        Wallet           = new Wallet();
        CameraData       = new CameraData();

        LoadSkybox();
        AddEventListeners();
    }
Ejemplo n.º 9
0
    public void OpenCatalog(List <CustomerManager.FurniturePreference> info)
    {
        FurnManager = GameObject.FindObjectOfType <FurnitureManager>();

        this.gameObject.transform.parent.gameObject.SetActive(true);
        CurrentInfo = info;

        NotAddedFurniture = new List <FurnitureManager.FurniturePairing>();
        foreach (FurnitureManager.FurniturePairing furn in FurnManager.myRegistry.myPairings)
        {
            bool alreadyUsed = false;
            foreach (CustomerManager.FurniturePreference customerPref in CurrentInfo)
            {
                if (customerPref.FurnitureID == furn.id)
                {
                    alreadyUsed = true;
                    break;
                }
            }
            if (!alreadyUsed)
            {
                NotAddedFurniture.Add(furn);
            }
        }
        LoadFurnitureType(currentType);
        LoadPage(0);
    }
Ejemplo n.º 10
0
        public void Get_AllFurnitureList()
        {
            var furrepo = new FurnitureManager(furniturecontextmock.Object);
            var furlist = furrepo.GetAllFurniture();

            Assert.AreEqual(2, furlist.Count());
        }
Ejemplo n.º 11
0
    /// <summary>
    /// Calls the update functions on the systems that are updated on a fixed frequency.
    /// </summary>
    /// <param name="deltaTime">Delta time.</param>
    private void TickFixedFrequency(float deltaTime)
    {
        FurnitureManager.TickFixedFrequency(deltaTime);

        // Progress temperature modelling
        temperature.Update();
        PowerNetwork.Update(deltaTime);
    }
Ejemplo n.º 12
0
    // Use this for initialization
    void Awake()
    {
        instance = this;
        if (saveOnStart)
        {
            //	SerializeFurniture ();
        }

        InitializeFurniture();
    }
    // public int Outwater = 0, OutSilver = 0, OutGas = 0;


    // Use this for initialization

    /*  void Start()
     * {
     *    Fur1 = GameObject.Find("FurnitureManager").GetComponent<FurnitureManager>();
     *    StartCoroutine("OKWaterButton");
     *    StartCoroutine("ReadyFlaskButton");
     *    MaterialButtonUpdate();
     * }*/

    public void DataAccess(DataVo dataVo)
    {
        MaterialWaterNumber   = int.Parse(dataVo.SaveBlue);
        MaterialQSilverNumber = int.Parse(dataVo.SaveRed);
        MaterialGasNumber     = int.Parse(dataVo.SaveGas);
        Fur1 = GameObject.Find("FurnitureManager").GetComponent <FurnitureManager>();
        StartCoroutine("OKWaterButton");
        StartCoroutine("ReadyFlaskButton");
        MaterialButtonUpdate();
    }
Ejemplo n.º 14
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
    void Awake()
    {
        StopWait     = false;
        EmotionCount = 0;
        animator     = GetComponent <Animator>();

        FurnitureEffect = GameObject.Find("FurnitureManager").GetComponent <FurnitureManager>();
        AddInFlu        = GameObject.Find("InfluenceManager").GetComponent <InfluenceManager>();
        Orderd          = GameObject.Find("SellingManager").GetComponent <SellingManager>();
        customerManager = GameObject.Find("CustomerManager").GetComponent <CustomerManager>();
        State           = GameObject.Find("StatusManager").GetComponent <StatusManager>();
    }
Ejemplo n.º 16
0
    private void ReadXml_Furnitures(XmlReader reader)
    {
        if (reader.ReadToDescendant("Furniture"))
        {
            do
            {
                int   x        = int.Parse(reader.GetAttribute("X"));
                int   y        = int.Parse(reader.GetAttribute("Y"));
                int   z        = int.Parse(reader.GetAttribute("Z"));
                float rotation = float.Parse(reader.GetAttribute("Rotation"));

                Furniture furniture = FurnitureManager.PlaceFurniture(reader.GetAttribute("type"), tiles[x, y, z], false, rotation);
                furniture.ReadXml(reader);
            }while (reader.ReadToNextSibling("Furniture"));
        }
    }
Ejemplo n.º 17
0
    private void SetupWorld(int width, int height, int depth)
    {
        // Set the current world to be this world.
        // TODO: Do we need to do any cleanup of the old world?
        Current = this;

        Width  = width;
        Height = height;
        Depth  = depth;

        tiles = new Tile[Width, Height, Depth];

        RoomManager           = new RoomManager();
        RoomManager.Adding   += (room) => roomGraph = null;
        RoomManager.Removing += (room) => roomGraph = null;

        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                for (int z = 0; z < Depth; z++)
                {
                    tiles[x, y, z]                  = new Tile(x, y, z);
                    tiles[x, y, z].TileChanged     += OnTileChangedCallback;
                    tiles[x, y, z].TileTypeChanged += OnTileTypeChangedCallback;
                    tiles[x, y, z].Room             = RoomManager.OutsideRoom; // Rooms 0 is always going to be outside, and that is our default room
                }
            }
        }

        FurnitureManager          = new FurnitureManager();
        FurnitureManager.Created += OnFurnitureCreated;

        UtilityManager   = new UtilityManager();
        CharacterManager = new CharacterManager();
        InventoryManager = new InventoryManager();
        jobQueue         = new JobQueue();
        GameEventManager = new GameEventManager();
        PowerNetwork     = new PowerNetwork();
        temperature      = new Temperature();
        ShipManager      = new ShipManager();
        Wallet           = new Wallet();
        CameraData       = new CameraData();

        LoadSkybox();
        AddEventListeners();
    }
Ejemplo n.º 18
0
    public void Awake()
    {
        RealityName = RealityName == null ? null : RealityName.Trim();
        if (string.IsNullOrEmpty(RealityName))
        {
            Debug.LogError("Reality name is null or empty! Invalid world for reality!");
            return;
        }

        Instance = this;

        TileMap       = GetComponent <TileMap>();
        TileMap.World = this;

        Furniture = GetComponent <FurnitureManager>();

        TileMap.Create();
    }
Ejemplo n.º 19
0
    //////////////////////////////////////////////////////////////////////////// AWAKE
    private void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (instance != null && instance != this)
        {
            //Destroy(this.gameObject);
            return;
        }
        instance = this;
        isOpen   = false;
        DontDestroyOnLoad(this.gameObject);
        GameManager.GetGameManager.OnReturnMenu += Destroy;
        netID = GetComponent <NetworkIdentity>();


        furnitures = InitFurnituresData(pathData);

        Inventory = new Inventory(10, 1);
    }
Ejemplo n.º 20
0
    public JObject ToJson()
    {
        JObject worldJson = new JObject();

        worldJson.Add("Width", Width.ToString());
        worldJson.Add("Height", Height.ToString());
        worldJson.Add("Depth", Depth.ToString());
        worldJson.Add("Rooms", RoomManager.ToJson());
        worldJson.Add("Tiles", TilesToJson());
        worldJson.Add("Inventories", InventoryManager.ToJson());
        worldJson.Add("Furnitures", FurnitureManager.ToJson());
        worldJson.Add("Utilities", UtilityManager.ToJson());
        worldJson.Add("RoomBehaviors", RoomManager.BehaviorsToJson());
        worldJson.Add("Characters", CharacterManager.ToJson());
        worldJson.Add("CameraData", CameraData.ToJson());
        worldJson.Add("Skybox", skybox.name);
        worldJson.Add("Wallet", Wallet.ToJson());
        worldJson.Add("Scheduler", Scheduler.Scheduler.Current.ToJson());
        return(worldJson);
    }
Ejemplo n.º 21
0
    public void ReadJson(JObject worldJson)
    {
        Width  = (int)worldJson["Width"];
        Height = (int)worldJson["Height"];
        Depth  = (int)worldJson["Depth"];

        SetupWorld(Width, Height, Depth);

        RoomManager.FromJson(worldJson["Rooms"]);
        TilesFromJson(worldJson["Tiles"]);
        InventoryManager.FromJson(worldJson["Inventories"]);
        FurnitureManager.FromJson(worldJson["Furnitures"]);
        UtilityManager.FromJson(worldJson["Utilities"]);
        RoomManager.BehaviorsFromJson(worldJson["RoomBehaviors"]);
        CharacterManager.FromJson(worldJson["Characters"]);
        CameraData.FromJson(worldJson["CameraData"]);
        LoadSkybox((string)worldJson["Skybox"]);
        Wallet.FromJson(worldJson["Wallet"]);
        Scheduler.Scheduler.Current.FromJson(worldJson["Scheduler"]);

        tileGraph = new Path_TileGraph(this);
    }
Ejemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        FurnManager = GameObject.FindObjectOfType <FurnitureManager> ();
        matManager  = GameObject.FindObjectOfType <MaterialManager> ();

        //string url = "https://s3-us-west-2.amazonaws.com/holoture/JSONfiles/customerRegistryA.json";
        string url = "http://mysterious-citadel-61929.herokuapp.com/api/customerRegistry";

        CustomerJson = new WWW(url);

        /* Harrison Commented Out
         * if (saveOnStart) {
         *      //SerializeCustomers ();
         * }
         */

        StartCoroutine(getCustRegistry());

        /* Harrison Commented Out
         * InitializeCustomers ();
         */
    }
Ejemplo n.º 23
0
 /// <summary>
 /// Notify world that the camera moved, so we can check which entities are visible to the camera.
 /// The invisible enities can be updated less frequent for better performance.
 /// </summary>
 public void OnCameraMoved(Bounds cameraBounds)
 {
     FurnitureManager.OnCameraMoved(cameraBounds);
 }
Ejemplo n.º 24
0
    public void WriteXml(XmlWriter writer)
    {
        // Save info here
        writer.WriteAttributeString("Width", Width.ToString());
        writer.WriteAttributeString("Height", Height.ToString());
        writer.WriteAttributeString("Depth", Depth.ToString());

        writer.WriteStartElement("Rooms");
        foreach (Room r in RoomManager)
        {
            if (RoomManager.OutsideRoom == r)
            {
                // Skip the outside room. Alternatively, should SetupWorld be changed to not create one?
                continue;
            }

            writer.WriteStartElement("Room");
            r.WriteXml(writer);
            writer.WriteEndElement();
        }

        writer.WriteEndElement();

        writer.WriteStartElement("Tiles");
        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                for (int z = 0; z < Depth; z++)
                {
                    if (tiles[x, y, z].Type != TileType.Empty)
                    {
                        writer.WriteStartElement("Tile");
                        tiles[x, y, z].WriteXml(writer);
                        writer.WriteEndElement();
                    }
                }
            }
        }

        writer.WriteEndElement();
        writer.WriteStartElement("Inventories");
        foreach (Inventory inventory in InventoryManager.Inventories.SelectMany(pair => pair.Value))
        {
            // If we don't have a tile, that means this is in a character's inventory (or some other non-tile location
            //      which means we shouldn't save that Inventory here, the character will take care of saving and loading
            //      the inventory properly.
            if (inventory.Tile != null)
            {
                writer.WriteStartElement("Inventory");
                inventory.WriteXml(writer);
                writer.WriteEndElement();
            }
        }

        writer.WriteEndElement();

        writer.WriteStartElement("Furnitures");
        FurnitureManager.WriteXml(writer);
        writer.WriteEndElement();

        writer.WriteStartElement("Utilities");
        UtilityManager.WriteXml(writer);
        writer.WriteEndElement();

        writer.WriteStartElement("Characters");
        CharacterManager.WriteXml(writer);
        writer.WriteEndElement();

        writer.WriteStartElement("CameraData");
        CameraData.WriteXml(writer);
        writer.WriteEndElement();

        writer.WriteElementString("Skybox", skybox.name);

        writer.WriteStartElement("Wallet");
        Wallet.WriteXml(writer);
        writer.WriteEndElement();

        Scheduler.Scheduler.Current.WriteXml(writer);
    }
Ejemplo n.º 25
0
 public override void Initialize(string extraData)
 {
     furnitureManager = FurnitureManager.instance;
 }
Ejemplo n.º 26
0
 private void Awake()
 {
     FurnManager = GameObject.FindObjectOfType <FurnitureManager>();
 }