Esempio n. 1
0
    // Activates This Window
    public void ActivateWindow(Building building)
    {
        // Set the linked building and its timer
        linkedBuilding      = building;
        linkedBuildingTimer = linkedBuilding.GetBuildingTimer();

        // Get the on-screen building position and place the window above it
        Vector3 screenPosition = Camera.main.WorldToScreenPoint(linkedBuilding.v3GetWorldPosition());

        SetPosition(screenPosition.x, screenPosition.y + 80);

        iBuildingID = linkedBuilding.iGetObjectID();

        // Set Window Activated to true
        bWindowActivated = true;
    }
    // Initialize Values
    public void Init(int tileX, int tileY, int width, int height,
                     int id, Vector3 worldPosition, DateTime startTime, bool ready, bool inactive)
    {
        iTileX    = tileX;
        iTileY    = tileY;
        iWidth    = width;
        iHeight   = height;
        iObjectID = id;

        v3WorldPosition = worldPosition;

        gameObject.GetComponent <SpriteRenderer>().sprite = aSpriteTextures[iObjectID];

        timerScript = gameObject.GetComponent <BuildingTimer>();
        timerScript.SetResourceID(iObjectID);
        timerScript.SetStartTime(startTime);
        timerScript.bInActive = inactive;

        av2CoveredTiles = new Vector2[width * height];
        aTileScripts    = new Tile[width * height];

        SetCoveredTiles();
    }
Esempio n. 3
0
    // Creates a building
    void CreateBuilding(int tileX, int tileY, int width, int height,
                        int id, DateTime startTime, bool ready, bool inactive)
    {
        if (lBuildingList == null)
        {
            lBuildingList = new List <Building>();
        }

        // Tile Position
        Vector3 buildingPosition;

        buildingPosition.x = tTileStartPoint.position.x
                             + (tileX * (fTileWidth / 2))
                             - (tileY * (fTileWidth / 2));

        buildingPosition.y = tTileStartPoint.position.y
                             - ((tileX + tileY) * (fTileHeight / 4))
                             + fBuildingOffset;

        buildingPosition.z = tTileStartPoint.position.z - ((tileX + width - 1) + (tileY + height - 1)) - 0.01f;

        // Create the tile
        GameObject building = (GameObject)Instantiate(oBuildingPrefab, buildingPosition, Quaternion.identity);

        // Find the Building Component on the Building Object
        Building      buildingScript = building.GetComponent <Building>();
        BuildingTimer timerScript    = building.GetComponent <BuildingTimer>();

        // Add the tile to the Tile Object array
        lBuildingList.Add(buildingScript);

        buildingScript.Init(tileX, tileY, width, height, id, buildingPosition, startTime, ready, inactive);
        Debug.Log("Instantiate: " + startTime.ToString());

        timerScript.SetTimeInterval(BuildingTypeData.aBuildingTypes[id].resourceTime);
    }
Esempio n. 4
0
 private void Awake()
 {
     _resourceManager        = FindObjectOfType <ResourceManager>();
     _buildingTimer          = GetComponent <BuildingTimer>();
     _buildingTimer.Builded += OnBuilded;
 }