public void SetTurretToBuild(StructureShopData turret) { turretToBuild = turret; IsPlacing = true; spriteRenderer.sprite = turret.prefab.GetComponent <SpriteRenderer>().sprite; spriteRenderer.enabled = true; }
private void BuildLocation(int location, StructureShopData structure) { if (CheckLocation(location)) { (Structure newStructure, int response) = bm.BuildStructureOpp(buildLocations[location].position, structure); Debug.Log("Build: " + location + structure); if (response == 0) { SetLocation(location); structures[location] = newStructure; SetReward(1f); } } else { //SetReward(-0.1f); } }
public (Structure, int) BuildStructureOpp(Vector3 position, StructureShopData structure) { if (StatManager.OpponentGold < structure.cost) { return(null, 1); } else if (StatManager.OpponentDefenseUnit + structure.defenseUnit > StatManager.DefenseUnitMax) { return(null, 2); } else { StatManager.OpponentGold -= structure.cost; StatManager.OpponentScore += structure.cost; StatManager.OpponentDefenseUnit += structure.defenseUnit; Structure newStructure = Instantiate(structure.prefab, position, Quaternion.identity).GetComponent <Structure>(); newStructure.PlayerOwned = false; return(newStructure, 0); } }