Пример #1
0
 public Structure(uint structureId,
                  IStructureStats stats,
                  uint x,
                  uint y,
                  string theme,
                  ITechnologyManager technologyManager,
                  StructureProperties structureProperties,
                  IDbManager dbManager) : base(structureId, x, y)
 {
     Theme          = theme;
     this.stats     = stats;
     this.dbManager = dbManager;
     techmanager    = technologyManager;
     properties     = structureProperties;
 }
 public void addStructure(Vector3 position, IStructureBehavior attackBehavior, IStructureStats structureStats)
 {
     GameObject tileGO = _mapInstance.getTile(new Vector2(position.x, position.z));
     if(!tileGO){
         return;
     }
     Tile tile = tileGO.GetComponent<Tile>();
     if(tile.isEmpty()){
         tile.tileEmpty = false;
         GameObject newStruct = Object.Instantiate(Resources.Load(structureStats.Prefab)) as GameObject;
         newStruct.name = structureStats.Name;
         GameObject gObject = new GameObject();
         gObject.name = structureStats.Name+Time.realtimeSinceStartup;
         gObject.transform.parent = this.transform;
         newStruct.transform.parent = gObject.transform;
         Structure structureScript = newStruct.GetComponent("Structure") as Structure;
         newStruct.transform.position = new Vector3(tileGO.transform.localPosition.x , tileGO.transform.localPosition.y, tileGO.transform.localPosition.z);
         structureScript.structureBehavior = attackBehavior;
         structureScript.structureStats = structureStats;
         structureScript.init();
     }
 }
 public void addStructure(Vector2 position, IStructureBehavior attackBehavior, IStructureStats structureStats)
 {
     if(structures == null){
         structures = new ArrayList();
     }
     Tile tile = mapInstance.getTile(position);
     if(tile.isEmpty()){
         tile.TileEmpty = false;
         GameObject newStruct = Object.Instantiate(Resources.Load(structureStats.Prefab)) as GameObject;
         newStruct.name = structureStats.Name;
         GameObject gObject = new GameObject();
         gObject.name = structureStats.Name+structuresID;
         gObject.transform.parent = this.transform;
         newStruct.transform.parent = gObject.transform;
         Structure structureScript = newStruct.GetComponent("Structure") as Structure;
         structureScript.Position = position;
         structureScript.structureBehavior = attackBehavior;
         structureScript.structureStats = structureStats;
         structureScript.init();
         structures.Add(newStruct);
         structuresCount++;
         structuresID++;
     }
 }
 public AttackingUnit(IStructureBehavior behavior, IStructureStats stats)
 {
     _structureBehavior = behavior;
     _structureStats = stats;
 }