Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        timer       = Camera.main.GetComponent <Timer>();
        dm          = GetComponent <DataManager>();
        dm.savefile = savefile;

        ColorUtility.TryParseHtmlString("#0182FF", out maxColor);
        ColorUtility.TryParseHtmlString("#9A9A9A", out minColor);
        sim = new SimProfile();

        grid.addTiles(resourceMap, sizeX, sizeY, sim);

        foreach (GameObject harbor in harbors)
        {
            harbor.GetComponent <HarborMaster>().grid = grid;
            harbor.GetComponent <HarborMaster>().sim  = sim;
            //  harbor.GetComponent<HarborMaster>().resourceMap = resourceMap;
            harbor.GetComponent <HarborMaster>().setStartValues(sim);
        }

        //InvokeRepeating("colorResourceGrid", 1f, 1f);
        StartCoroutine(colorResourceGrid(grid));


        timer.startTimer(sim);
        // resourceMap.RefreshAllTiles();
        //InvokeRepeating("colorTest", 0f, 1f);
    }
Esempio n. 2
0
 public void startTimer(SimProfile sim)
 {
     daytime        = sim.weektime;
     monthText.text = "M: 1";
     //InvokeRepeating("restart", 0.5f, daytime + 0.01f);
     Invoke("restart", 0f);
 }
Esempio n. 3
0
    void init()
    {
        sim = new SimProfile();

        resource.setResourceTileColors();

        // resource.makeTiles(resourceMap, sizeX, sizeY, sim);

        setupHarbors();
    }
Esempio n. 4
0
    public void setStartValues(SimProfile sim)
    {
        GameObject boat;

        boatNumber = 20;
        for (int i = 0; i < boatNumber; i++)
        {
            this.sim = new SimProfile();
            boat     = Instantiate(boatPrefab);
            boat.transform.position = transform.position;
            boat.transform.parent   = transform;
        }

        foreach (Transform child in transform)
        {
            child.gameObject.GetComponent <BoatTileMovement>().resourceMap = resourceMap;
            child.gameObject.GetComponent <BoatTileMovement>().grid        = grid;
            child.gameObject.GetComponent <BoatTileMovement>().sim         = sim;
            child.GetComponent <BoatTileMovement>().capacity = Random.Range(sim.minBoatCapacity, sim.maxBoatCapacity);
            child.GetComponent <BoatTileMovement>().sim      = sim;
            child.gameObject.GetComponent <BoatTileMovement>().startBoat();
        }
    }
Esempio n. 5
0
        public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
        {
            //default method set up to act as ogs user server
            SimProfile SimInfo = new SimProfile();

            //get siminfo from grid server
            SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
            Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]);

            theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
            response["home"]     = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
            response["sim_ip"]   = SimInfo.sim_ip;
            response["sim_port"] = (Int32)SimInfo.sim_port;
            response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
            response["region_x"] = (Int32)SimInfo.RegionLocX * 256;

            //default is ogs user server, so let the sim know about the user via a XmlRpcRequest
            Console.WriteLine(SimInfo.caps_url);
            Hashtable SimParams = new Hashtable();

            SimParams["session_id"]        = theUser.CurrentSessionID.ToString();
            SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
            SimParams["firstname"]         = theUser.firstname;
            SimParams["lastname"]          = theUser.lastname;
            SimParams["agent_id"]          = theUser.UUID.ToString();
            SimParams["circuit_code"]      = (Int32)circode;
            SimParams["startpos_x"]        = theUser.homepos.X.ToString();
            SimParams["startpos_y"]        = theUser.homepos.Y.ToString();
            SimParams["startpos_z"]        = theUser.homepos.Z.ToString();
            ArrayList SendParams = new ArrayList();

            SendParams.Add(SimParams);

            XmlRpcRequest  GridReq  = new XmlRpcRequest("expect_user", SendParams);
            XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
        }
Esempio n. 6
0
    public void addTiles(Tilemap map, int x, int y, SimProfile sim)
    {
        sizeX = x;
        sizeY = y;

        maxCarry = sim.getMaxCarry();

        for (int i = 0; i < sizeX; i++)
        {
            for (int j = 0; j < sizeY; j++)
            {
                if (map.GetTile(new Vector3Int(i, j, 0)) != null)
                {
                    ResourceTile tile = new ResourceTile();

                    float randX = Random.Range(0f, 200f);
                    float randY = randX;//Random.Range(0f, 200f);

                    tile.carryCapacity   = Mathf.PerlinNoise((i + randX) / (randX + sizeX), (j + randX) / (randX + sizeY)) * maxCarry * 2;
                    tile.currentResource = tile.carryCapacity * startingResourcePercentage;
                    tile.updatedResource = tile.currentResource;
                    tile.growthRate      = sim.growthRate;

                    tile.x = i;
                    tile.y = j;

                    resourceTiles.Add(new Vector3Int(i, j, 0), tile);
                    index++;
                }
            }
        }

        addNeighbors();

        Debug.Log("Cells added to resource grid: " + index);
    }
 public void makeTiles(Tilemap resourceMap, int sizeX, int sizeY, SimProfile sim)
 {
     this.sim = sim;
     grid.addTiles(resourceMap, sizeX, sizeY, sim);
     colorResource();
 }