Example #1
0
        /* FIXME: currently cardinal directions are assumed as follows
         * North is x - 1
         * East is y - 1
         * South is x + 1
         * West is y + 1
         * other directions are a combination of the above
         * handling edge cases x = 0, x = level.width - 1, y = 0, and y = level.height - 1?
         * sends an int where a 1 in the following positions indicates a neightbor of the same type
         */

        public string CheckForStructureConnections(int x, int y, Models.Structures.StructureType type)
        {
            //Return this when done
            //Keeps track of directions in which the current tile has neighbors;
            string direction = "";

            //North
            if (x < this.width - 1 && this.GetSurfaceAt(x + 1, y).Structure != null && this.GetSurfaceAt(x + 1, y).Structure.Type == type)
            {
                direction += "N";
            }
            //East
            if (y > 0 && this.GetSurfaceAt(x, y - 1).Structure != null && this.GetSurfaceAt(x, y - 1).Structure.Type == type)
            {
                direction += "E";
            }
            //South
            if (x > 0 && this.GetSurfaceAt(x - 1, y).Structure != null && this.GetSurfaceAt(x - 1, y).Structure.Type == type)
            {
                direction += "S";
            }
            //West
            if (y < this.height - 1 && this.GetSurfaceAt(x, y + 1).Structure != null && this.GetSurfaceAt(x, y + 1).Structure.Type == type)
            {
                direction += "W";
            }

            //Temp Check for final direction of Structure
            Debug.Log("this structure has same structures in directions " + direction);

//			this.GetSurfaceAt (x, y).Structure = flag;
            //FIXME: Place holder, currently return the structure's direction as is.
            return(direction);
        }
Example #2
0
 /// <summary>
 /// Builds the structure.
 /// </summary>
 /// <param name="type">Type.</param>
 /// <param name="surfaceModel">Surface model.</param>
 protected void BuildStructure(Models.Structures.StructureType type, Models.Surfaces surfaceModel)
 {
     Debug.Log("Controllers.Mouse -> BuildStructure : building " + type);
     //TODO: currently it only checks if there is a structure,
     // in the future it should check for null values? or create a different system to remove structures
     levelModel.PlaceStructure(type, surfaceModel);
 }
Example #3
0
        /// <description>
        /// This subsection includes all functions related to surfaces listed as follows
        /// PlaceStructure(Models.Structure.StructureType, Models.Surfaces):
        ///         creates and places a structure of type structuretype on surface.
        /// CheckForStructureConnections(int, int, Models.Structure.StructureType):
        ///         chedk if the given structure type has connectable neighbors
        /// </description>
        public void PlaceStructure(Models.Structures.StructureType type, Models.Surfaces surfaceModel)
        {
            Debug.Log("Models.Levels -> placeStructure : trying to place structure of type : " + type);
            if (structurePrototypes.ContainsKey(type) == false)
            {
                Debug.Log("Models.Levels -> placeStructure : Cannot create structure of type " + type);
                return;
            }

            Models.Structures structureModel = Models.Structures.PlaceStructureOnSurface(structurePrototypes [type], surfaceModel);

            //either there are no callbacks or
            //structureModel returns null as there is already a structure on the surface
            if (StructurePlacedCallBacks != null && structureModel != null)
            {
                Debug.Log("Models.Levels -> placeStructure : callback for showing on screen");
                StructurePlacedCallBacks(structureModel);
            }
        }