// Inits variables used throughout the onClick chain
        void Start()
        {
            spriteRenderer = gameObject.GetComponent <SpriteRenderer>();
            libs           = GameManager.libs;
            GameObject go = GameObject.Find("GameManager");

            gm = go.GetComponent <GameManager>();
        }
Exemple #2
0
        /// <summary>
        /// Generates a placementmap out of a real map containing all available placements, as
        /// well as placement possibillities for special cases, like mines.
        /// </summary>
        /// <param name="map">Real map</param>
        /// <returns>A 2D array containing all available placements.</returns>
        private int[,] generatePlacementMap(int[,] map)
        {
            int debug_numAvailable     = 0;
            int debug_numNotAvailable  = 0;
            int debug_numMineAvailable = 0;


            int[,] tempMap = new int[map.GetLength(0), map.GetLength(1)];
            for (int y = 0; y < map.GetLength(1); y++)
            {
                for (int x = 0; x < map.GetLength(0); x++)
                {
                    int tile = map[x, y];

                    if ((IngameObjectLibrary.GetCategory(tile) == IngameObjectLibrary.Category.Ground) &&
                        (tile != MapMaker.WATER_SPRITEID))
                    {
                        if (testForMine(new Point(x, y), map))
                        {
                            map[x, y] = MINE_AVAILABLE;
                            debug_numMineAvailable++;
                        }
                        else
                        {
                            tempMap[x, y] = AVAILABLE;
                            debug_numAvailable++;
                        }
                    }
                    else
                    {
                        tempMap[x, y] = NOT_AVAILABLE;
                        debug_numNotAvailable++;
                    }
                }
            }
            return(tempMap);
        }
Exemple #3
0
 /// <summary>
 /// Virtual method to return a buildings blueprint id
 /// </summary>
 /// <returns></returns>
 public virtual int GetSpriteBlueprintID()
 {
     return(local_sprite_blueprint + IngameObjectLibrary.GetOffset(CATEGORY));
 }
Exemple #4
0
 /// <summary>
 /// Gets the unique global sprite id of this object.
 /// </summary>
 /// <returns>Sprite ID to be used with the IngameObjectLibrary</returns>
 public int GetSpriteID()
 {
     return(LocalSpriteID + IngameObjectLibrary.GetOffset(SpriteCategory));
 }
Exemple #5
0
 /// <summary>
 /// Gets a random spriteID out of the available sprites.
 /// </summary>
 /// <returns>Valid Sprite ID</returns>
 public new int GetSpriteID()
 {
     return(localIDs[UnityEngine.Random.Range(0, localIDs.Length - 1)] + IngameObjectLibrary.GetOffset(category));
 }
Exemple #6
0
 public int GetPortraitID()
 {
     return(portraitID + IngameObjectLibrary.GetOffset(SPRITEPORTRAITCATEGORY));
 }
Exemple #7
0
 public int GetSpriteID()
 {
     return(LocalSpriteID + IngameObjectLibrary.GetOffset(SPRITECATEGORY));
 }