Beispiel #1
0
 public Resources(Models.Levels level, ResourceType type, int x, int y, int z = 0)
 {
     this.level = level;
     this.x     = x;
     this.y     = y;
     this.z     = z;
     this.type  = type;
 }
Beispiel #2
0
        public Surfaces(Models.Levels level, int x, int y, int z = 0)
        {
            this.level = level;
            this.x     = x;
            this.y     = y;
            this.z     = z;

            //TODO: assign basic values to terrain-type, structure, and resource
        }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     levelModel = Models.Levels.Instance;
 }
Beispiel #4
0
        public static Models.Structures PlaceStructureOnSurface(Models.Structures structureModel, Models.Surfaces surfaceModel)
        {
            if (structureModel.PositionValidationFunctions(surfaceModel) == false)
            {
                Debug.Log("Models.Structures --> place structure on surface : cannot place the structure here");
                return(null);
            }

            Models.Structures structure = new Models.Structures();

            structure.type            = structureModel.type;
            structure.movemenCost     = structureModel.movemenCost;
            structure.width           = structureModel.width;
            structure.height          = structureModel.height;
            structure.linksToNeighbor = structureModel.linksToNeighbor;

            structure.SurfaceModel = surfaceModel;

            if (surfaceModel.hasStructure())
            {
                Console.Write("Models.Structure -> placeStructureOnSurface : surface has pre-existing structure on it");
                return(null);
            }
            else
            {
                Debug.Log("Models.Structure -> placeStructureOnSurface : structure added to surface");
                surfaceModel.PlaceStructure(structure);
            }


            int x = structure.SurfaceModel.X;
            int y = structure.SurfaceModel.Y;

            Models.Levels levelModel = Models.Levels.Instance;

            if (structure.linksToNeighbor == true)
            {
                //North
                if (x < levelModel.Width - 1 && levelModel.GetSurfaceAt(x + 1, y).Structure != null && levelModel.GetSurfaceAt(x + 1, y).Structure.Type == structure.type)
                {
                    levelModel.GetSurfaceAt(x + 1, y).Structure.StructureCallBacks(levelModel.GetSurfaceAt(x + 1, y).Structure);
                }
                //East
                if (y > 0 && levelModel.GetSurfaceAt(x, y - 1).Structure != null && levelModel.GetSurfaceAt(x, y - 1).Structure.Type == structure.type)
                {
                    levelModel.GetSurfaceAt(x, y - 1).Structure.StructureCallBacks(levelModel.GetSurfaceAt(x, y - 1).Structure);
                }
                //South
                if (x > 0 && levelModel.GetSurfaceAt(x - 1, y).Structure != null && levelModel.GetSurfaceAt(x - 1, y).Structure.Type == structure.type)
                {
                    levelModel.GetSurfaceAt(x - 1, y).Structure.StructureCallBacks(levelModel.GetSurfaceAt(x - 1, y).Structure);
                }
                //West
                if (y < levelModel.Height - 1 && levelModel.GetSurfaceAt(x, y + 1).Structure != null && levelModel.GetSurfaceAt(x, y + 1).Structure.Type == structure.type)
                {
                    levelModel.GetSurfaceAt(x, y + 1).Structure.StructureCallBacks(levelModel.GetSurfaceAt(x, y + 1).Structure);
                }
            }

            return(structure);
        }