コード例 #1
0
 public void SetTurretToBuild(StructureShopData turret)
 {
     turretToBuild          = turret;
     IsPlacing              = true;
     spriteRenderer.sprite  = turret.prefab.GetComponent <SpriteRenderer>().sprite;
     spriteRenderer.enabled = true;
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }