예제 #1
0
    public void PurchaseWell()
    {
        _statusUi.SetActive(false);
        oilWellCost *= 2;
        _purchasableOilWell.SetPrice(oilWellCost);
        var oilWell = Instantiate <GameObject>(_oilWellPrefab, transform.Find("Container"));

        oilWell.GetComponent <OilWell>().triedToFindOil.AddListener(FindingOil);
        // Disable until placed;
        var placer = oilWell.AddComponent <Placer>();

        placer.DisabledComponentsUntilPlaced = new List <Behaviour> {
            oilWell.GetComponent <OilWell>()
        };
        var bounds = transform.GetComponent <BoxCollider2D>().bounds;

        bounds.extents = new Vector3(bounds.extents.x - 0.25f, bounds.extents.y - 0.25f, bounds.extents.z);
        placer.Bounds  = bounds;
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        _playerStatus = GameObject.FindObjectOfType <PlayerStatus>();
        _statusUi     = transform.Find("StatusUI").gameObject;
        _statusUi.SetActive(false);
        _statusPanel   = _statusUi.transform.Find("StatusPanel").gameObject;
        _oilWellPrefab = (GameObject)Resources.Load("Prefabs/Oil Well");
        var name = _statusPanel.transform.Find("Header/Name").GetComponent <Text>();

        name.text = _regionName;

        _purchasableOilWell = transform.Find("PurchasableOilWell").GetComponent <Purchasable>();
        _purchasableOilWell.activated.AddListener(PurchaseWell);
        _purchasableOilWell.SetPrice(oilWellCost);

        _prospect = transform.Find("Prospect").GetComponent <Purchasable>();
        _prospect.activated.AddListener(Prospect);
        _prospect.SetPrice(prospectingCost);

        _normal      = (Material)Resources.Load("Materials/Normal");
        _highlighted = (Material)Resources.Load("Materials/Highlighted");
        _renderer    = transform.Find("Sprite").GetComponent <SpriteRenderer>();
    }