public BuildingStats(BuildingDefinition bd, int x, int y) { this.def = bd; this.x = x; this.y = y; hpLeft = bd.hpMax; // upgrades = TODO }
public BuildingStats(BuildingDefinition bd, int x, int y) { this.def = bd; this.x = x; this.y = y; hpLeft = bd.hpMax; // upgrades = TODO }
public void Init(BuildingDefinition bd, UIController uiCtrl) { nameText.text = bd.name; priceText.text = "$" + bd.buildPrice; powerText.text = "¤" + bd.powerUse; buildingType = bd.type; this.uiCtrl = uiCtrl; }
public void Init(BuildingDefinition bd, UIController uiCtrl) { nameText.text = bd.name; priceText.text = "$" + bd.buildPrice; powerText.text = "¤" + bd.powerUse; buildingType = bd.type; this.uiCtrl = uiCtrl; }
// invokes ob touch public void CheckTarget() { _buildingDefinition = null; var hitInfo = Physics2D.OverlapPoint(_csGlobal.g_mousePosition); if (hitInfo != null) { _buildingDefinition = hitInfo.GetComponent <BuildingDefinition>(); } }
public void Init() { //Initialize build panel foreach (BuildingType bt in Enum.GetValues(typeof(BuildingType))) { BuildingDefinition bd = BuildingLibrary.I.GetDefinition(bt); GameObject buildPanelElement = Instantiate(buildPanelElementPrefab); buildPanelElement.transform.SetParent(layoutBuildPanel.transform); buildPanelElement.transform.localScale = Vector3.one; buildPanelElement.GetComponent <Toggle>().group = layoutBuildPanel.GetComponent <ToggleGroup>(); buildPanelElement.GetComponent <BuildElement>().Init(bd, this); } waveInfoPanel.Init(this); }
public void BuildBuilding(int x, int y, BuildingType type) { //Calc world pos float posX = -4f + x * 1f; float posY = gameCtrl.camCtrl.GetBottomY() + gameCtrl.buildingFieldYAboveBottom - 1f + y * 1f; Vector2 pos = new Vector2(posX, posY); //Get building def BuildingDefinition bd = BuildingLibrary.I.GetDefinition(type); //Hide selector if (buildingSelector != null) { buildingSelector.gameObject.SetActive(false); } //Create building GameObject buildingGO = (GameObject)Instantiate(buildingPrefab, pos, Quaternion.identity); Building building = buildingGO.GetComponent <Building>(); building.Init(type, bd, x, y); //Initialise cannon if (bd.isTurret) { Turret turret = buildingGO.GetComponent <Turret>(); turret.Init(bd.turretDef); turrets.Add(turret); } //Set sprite buildingGO.GetComponent <SpriteRenderer>().sprite = SpriteLibrary.I.GetBuildingSprite(type); //Destroy scaffold // if (selectedBuilding != null) GameObject.Destroy(selectedBuilding.gameObject); // selectedBuilding = null; //Set values buildingSlots[x, y] = building; buildings.Add(building); gameCtrl.UpdateAmmoAndPower(); HideBuildingGhosts(); }
public void UpdateAmmoAndPower() { foreach (ProjectileType typ in System.Enum.GetValues(typeof(ProjectileType))) { turretAmmo[typ] = -1; } powerUse = 0; powerMax = 0; foreach (Building building in buildingCtrl.buildings) { if (building == null || building.stats == null) { continue; } BuildingDefinition bd = BuildingLibrary.I.GetDefinition(building.stats.def.type); if (building.stats.def.type == BuildingType.TURRET_ROCKET || building.stats.def.type == BuildingType.TURRET_MINIGUN) { Turret turret = building.GetComponent <Turret>(); if (turretAmmo[turret.Stats.def.type] == -1) { turretAmmo[turret.Stats.def.type] = 0; } turretAmmo[turret.Stats.def.type] += turret.Stats.def.maxAmmo; } if (bd.powerUse > 0) { powerMax += bd.powerUse; } else { powerUse += -bd.powerUse; } } UpdateInfoPanel(); }
public void Init(BuildingType type, BuildingDefinition bd, int x, int y) { stats = new BuildingStats(bd, x, y); }
public void Init(BuildingType type, BuildingDefinition bd, int x, int y) { stats = new BuildingStats(bd, x, y); }