Ejemplo n.º 1
0
 public Tile(string assetname = "", TileType tp = TileType.Background, int layer = 0, string id = "")
     : base(assetname, layer, id)
 {
     type = tp;
     hot = false;
     ice = false;
 }
Ejemplo n.º 2
0
		private Material GetMaterial(TileType type, TileDir dir)
		{
			string path = "Material/TileGrass";
			switch (type)
			{
				case TileType.DeapWater:
					path = "Material/Tile/DeapWater";
					break;
				case TileType.ShallowWater:
					path = "Material/Tile/ShallowWater";
					break;
				case TileType.Sandbeach:
					path = "Material/Tile/Sand";
					break;
				case TileType.Grassland:
					path = "Material/Tile/Grass";
					break;
				case TileType.Forest:
					path = "Material/Tile/Forest";
					break;
				case TileType.Snow:
					path = "Material/Tile/Snow";
					break;
				default:
					Log.LogError("Tile.GetMaterial: failed");
					break;
			}
			Material mat = Resources.Load(path) as Material;
			return mat;
		}
Ejemplo n.º 3
0
        public BillboardPrimitive(Core core, TileType tileType)
            : base(core)
        {
            this.tileType = tileType;

              BuildPrimitive();
        }
Ejemplo n.º 4
0
        private void CreateTile(TileType type, Vector2 position)
        {
            //sets tile with given position to given type

            if (position.X > mapSize
                || position.Y > mapSize)
            {
                return;
            }

            Tile til;
            switch (type)
            {
                case TileType.Grass:
                    til = new TileGrass(position);
                    break;
                case TileType.Rock:
                    til = new TileRock(position);
                    break;
                case TileType.Gravel:
                    til = new TileGravel(position);
                    break;
                case TileType.Water:
                    til = new TileWater(position);
                    break;
                default:
                    til = new TileGrass(position);
                    break;
            }

            int X = (int)position.X;
            int Y = (int)position.Y;

            TilesArray[X, Y] = til;
        }
Ejemplo n.º 5
0
 public Tile(TileType type, Point loc, int code)
 {
     MapLocation = loc;
     Type = type;
     DistanceFromStart = 0;
     TileCode = code;
 }
Ejemplo n.º 6
0
        private int propertyPrice = 0; // Cost to initially purchase property

        #endregion Fields

        #region Constructors

        public PropertyTile(
            TileType t,
            string n,
            Color c,
            int bR,
            int h1R,
            int h2R,
            int h3R,
            int h4R,
            int hR,
            int mV,
            int hC,
            int hotelC,
            int pP)
            : base(n, t)
        {
            // Set all the property values
            // These are meant to be static, so they shouldn't change

            houseRent = new int[4];

            color = c;
            baseRent = bR;
            houseRent[0] = h1R;
            houseRent[1] = h2R;
            houseRent[2] = h3R;
            houseRent[3] = h4R;
            hotelRent = hR;
            mortgageValue = mV;
            houseCost = hC;
            hotelCost = hotelC;
            propertyPrice = pP;

            currentRentCost = baseRent;
        }
Ejemplo n.º 7
0
 public Game(GameConfiguration configuration)
 {
     this.firstCapture = TileType.none;
     this.turnOrder.Add(TileType.yellow);
     this.currentTurn = 0;
     this.Configuration = configuration;
 }
Ejemplo n.º 8
0
 public Tile(TileType type, int tileID, Texture2D texture)
 {
     _tileType = type;
     _texture = texture;
     _tileName = String.Empty;
     _tileID = tileID;
 }
Ejemplo n.º 9
0
        public void CreateTile(TileType tileType, bool supportsWideTile)
        {
            ShellTile shellTile = _FindTile(tileType);
            ShellTileData shellTileData=null;
            switch(tileType)
            {
                case TileType.Standard:

                    shellTileData = _CreateStandardTileData();
                    supportsWideTile = false;
                    break;
                case TileType.Flip:
                    shellTileData = _CreateFlipTileData();
                    break;
                case TileType.Cycle:
                    shellTileData = _CreateCycleTileData();
                    break;
                case TileType.Iconic:
                    shellTileData = _CreateIconicTileData();
                    break;
            }
            if (shellTile != null)
            {
                shellTile.Update(shellTileData);
                //shellTile.Delete();
            }
            else
            {

                ShellTile.Create(new Uri("/Page1.xaml?TileType=" + tileType, UriKind.Relative), shellTileData, supportsWideTile);
            }

        }
Ejemplo n.º 10
0
        public bool IsTileAngle()
        {
            var mid = Elevations[4];

            if (Elevations[0] < mid)
            {
                this.Type = TileType.TopLeftAngle;
                return true;
            }

            if (Elevations[2] < mid)
            {
                this.Type = TileType.TopRightAngle;
                return true;
            }

            if (Elevations[6] < mid)
            {
                this.Type = TileType.BottomLeftAngle;
                return true;
            }

            if (Elevations[8] < mid)
            {
                this.Type = TileType.BottomRightAngle;
                return true;
            }

            return false;
        }
Ejemplo n.º 11
0
        public Tile(int id, Vector3 position, Vector2 size, TileType tileType)
        {
            //this.rand = new Random(DateTime.Now.Millisecond);
            this.ID = id;
            this.Position = position;
            this.Size = size;
            this.TileType = tileType;
            //this.Paths = new List<List<Tile>>();
            this.PathsInts = new List<List<int>>();
            this.UnSafePaths = new List<List<int>>();
            //this.units = new List<Unit>();
            //this.unitsInTile = new List<bool>();
            //this.unitIndexes = new List<int>();
            //this.unitsCount = 0;
            this.tileNeighbors = new List<Tile>();

            for (int i = 0/*Paths.Count*/; i < TileMap.TileCount; i++)
            {
                //Paths.Add(new List<Tile>());
                PathsInts.Add(new List<int>());
                UnSafePaths.Add(new List<int>());
            }

            /*for (int i = 0; i < UnitCollection.TotalPossibleUnitCount(); i++)
            {
                //unitsInTile.Add(false);
                unitIndexes.Add(0);
            }*/
            SetTileType(tileType);
        }
Ejemplo n.º 12
0
 private Tile LoadBasicTile(string name, TileType tileType, bool hot = false, bool ice = false)
 {
     Tile t = new Tile("Tiles/" + name, tileType);
     t.Hot = hot;
     t.Ice = ice;
     return t;
 }
Ejemplo n.º 13
0
 public Tile(Vector2 pos, Vector2 size, TileType type, Color color)
 {
     position = pos;
     this.size = size;
     Color = color;
     this.type = type;
 }
Ejemplo n.º 14
0
        // Create a new tile for this row using common base
        public MetroTile AddTile(TileType type, TileWidth width, TileHeight height, string bgColor, string title, string onClick = "", string navUrl = "")
        {
            // Get the last tile added to this row
            MetroTile lastTileAdded = this.Tiles.LastOrDefault();
            int nextLeftMargin = 0;

            // If this is the first tile in the row, margin is column margin
            if (lastTileAdded == null)
            {
                nextLeftMargin = this.Column.LeftMargin;
            }
            else
            {
                // Calculate left margin based on the previous tile in the row
                nextLeftMargin = lastTileAdded.LeftMargin + lastTileAdded.Width + Column.SpacingBetweenTiles;
            }

            // Now create the actual tile based on our calculations
            MetroTile newTile = new MetroTile(this.Column.Position, type, TopMargin, nextLeftMargin, width, height, bgColor, title, onClick, navUrl);

            // Add the new tile to the list of tiles for this row
            this.Tiles.Add(newTile);

            // Recalculate the width and height of this row
            this.Width = this.Width == 0 ? newTile.Width : this.Width + Column.SpacingBetweenTiles + newTile.Width;
            this.Height = this.Height < newTile.Height ? newTile.Height : this.Height;

            // Return the new tile so it can be further worked with
            return newTile;
        }
Ejemplo n.º 15
0
 public LevelTile(Point twoDimPoint, TileType type, Bitmap texture)
 {
     dimensions = new Size(40, 38);
     this.type = type;
     this.twoDimPoint = twoDimPoint;
     this.texture = texture;
 }
Ejemplo n.º 16
0
        public override bool Do()
        {
            if (Layer.IsTileEmpty(TilePosition))
            {
                //architect.AddTile(Layer, TileWorldPosition, TilePosition, DoTileType, DoRotationFlip);
                Layer.AddTile(TilePosition, DoTileType, DoRotationFlip);
                return true;
            }
            else if (Layer[TilePosition].TileType != DoTileType)
            //else if (Layer[TilePosition].TileType != architect.SelectedTileType)
            {
                OldTileType = Layer[TilePosition].TileType;
                OldRotationFlip = ArchitectRotationFlip.FromTransform(Layer[TilePosition].Transform);
                Layer.EmptyTile(TilePosition);
                //architect.AddSelectedTileType(Layer, TileWorldPosition, TilePosition);
                Layer.AddTile(TilePosition, DoTileType, DoRotationFlip);
                OldRotationFlip.ApplyTo(Layer[TilePosition].Transform);
                return true;
            }
            else if (!DoRotationFlip.Equals(Layer[TilePosition].Transform))
            //else if (!architect.RotationFlip.Equals(Layer[TilePosition].Transform))
            {
                //PDebug.Log(Layer[TilePosition].Transform.localScale, Layer[TilePosition].Transform.localRotation.eulerAngles.z, architect.RotationFlip);
                OldTileType = Layer[TilePosition].TileType;

                OldRotationFlip = ArchitectRotationFlip.FromTransform(Layer[TilePosition].Transform);
                DoRotationFlip.ApplyTo(Layer[TilePosition].Transform);
                //architect.RotationFlip.ApplyTo(Layer[TilePosition].Transform);
                return true;
            }
            else
                return false;
        }
 public Entity ReplaceTileType(TileType newType) {
     var componentPool = GetComponentPool(ComponentIds.TileType);
     var component = (TileTypeComponent)(componentPool.Count > 0 ? componentPool.Pop() : new TileTypeComponent());
     component.type = newType;
     ReplaceComponent(ComponentIds.TileType, component);
     return this;
 }
Ejemplo n.º 18
0
 public Tile(bool blocksMovement, TileType type)
     : base(DrawTag.Tile_Ground_1, "")
 {
     this.blocksMovement = blocksMovement;
     setDrawTag(type);
     discovered = true;
 }
Ejemplo n.º 19
0
 public override void MatchedTilesAsBonus(GameDriver driver, TileType matchedType)
 {
     if (Random.Range(0, 100) <= bonusChance) {
         driver.AddStats(matchedType, 3, matchedType);
         driver.AddBonus(type);
     }
 }
Ejemplo n.º 20
0
 public Tool(TileType type, Texture2D texture, bool isObstacle, int cost)
 {
     this.type = type;
     this.texture = texture;
     this.isObstacle = isObstacle;
     this.cost = cost;
 }
Ejemplo n.º 21
0
        public int[] FillMap(int size)
        {
            TileType[] tiles = null;
            int nbTiles=0;
            int[] res = null;
            switch (size)
            {
                case 0:
                    nbTiles = 36;
                    tiles = new TileType[nbTiles];
                    res = new int[nbTiles];
                    break;
                case 1:
                    nbTiles = 100;
                    tiles = new TileType[nbTiles];
                    res = new int[nbTiles];
                    break;
                case 2:
                    nbTiles = 196;
                    tiles = new TileType[nbTiles];
                    res = new int[nbTiles];
                    break;
                default:
                    System.Console.WriteLine("CE MODE N4EXISTE PAS GROS BATARD.");
                    break;
            }

            Algo_fillMap(nativeAlgo, tiles, nbTiles);
            for(int i=0;i<res.Length;i++)
            {
                res[i] = (int)tiles[i];
            }
            return res;
        }
Ejemplo n.º 22
0
        public Tile(String title, Color c, String path, bool pinned)
        {
            InitializeComponent();

            TileTitle = title;
            l_LabelTile.Content = TileTitle;

            SolidColorBrush scb = new SolidColorBrush(c);
            r_TileRect.Fill = scb;
            r_Fx.Color = c;

            s_AppPath = path;

            //Pinned state
            b_isPinned = pinned;
            if (b_isPinned == true)
                cm_Pin.Header = "Unpin";

            tt_Type = TileType.Application;
            this.DataContext = this;

            api_Email = new APIGmHelper("", "");
            //"\\Images\\Icons\\"

            String exeName = path;
            int start = exeName.LastIndexOf("\\");
            exeName = exeName.Substring(start + 1, exeName.Length - start - 5);
            exeName = exeName.ToLower();
            BitmapImage img = new BitmapImage(new Uri("..\\Images\\AppIcons\\" + exeName + ".png", UriKind.Relative));
            i_Icon.Source = img;
                //(BitmapSource)Helpers.GetIcon(s_AppPath, false, false);

            InitAnimations();
        }
Ejemplo n.º 23
0
    // TODO Make reading of types from file
    void FillTileTypes()
    {
        tileTypes = new TileType[7];
        TileType grass = new TileType(Types.Grassland, true, 1);
        
        TileType road = new TileType(Types.Road, true, 2);
        
        TileType mountain = new TileType(Types.Mountain, false, 1);
        
        TileType water = new TileType(Types.Water, false, 1);

        TileType swamp = new TileType(Types.Swamp, true, 0.5f);

        TileType unknown = new TileType(Types.Unknown, true, 1);

        TileType house = new TileType(Types.House, false, 1);

        tileTypes[0] = grass;
        tileTypes[1] = road;
        tileTypes[2] = mountain;
        tileTypes[3] = water;
        tileTypes[4] = swamp;
        tileTypes[5] = unknown;
        tileTypes[6] = house;
    }
Ejemplo n.º 24
0
 public TileStruct(int x, int y, TileType type, TerrainType terrainType)
 {
     SetBoth(terrainType);
     this.X = x;
     this.Y = y;
     this.Type = type;
 }
Ejemplo n.º 25
0
	/// <summary>
	/// Grows the minerals on the map.
	/// </summary>
	/// <param name="map">The map where the minerals spawn</param>
	/// <param name="biomeMap">The biome map attached to the previous map.</param>
	public void GrowAll (TileType[, ] map, BiomeType[, ] biomeMap) {

		NoiseGenerator gen = new NoiseGenerator ();

		while (availableMinerals.Count > 0) {

			MineralInfo mineral = availableMinerals.Dequeue();

			gen.Reset();

			for (int x = 0; x < map.GetLength(0); x ++) {

				int y = (mineral.minHeight > 0 ? mineral.minHeight : 0);
				int maxY = (mineral.maxHeight < map.GetLength(1) ? mineral.maxHeight : map.GetLength(1));

				for (; y < maxY; y ++) {

					if (IsTileCompatible(biomeMap, x, y, mineral.compatibleBiomes) && (mineral.rarity < (int) gen.PerlinNoise(x, y, 10, 100, 1)))
						PlaceMinerals(map, x, y, mineral.minerals);

				}
			}
		
		}

	}
Ejemplo n.º 26
0
 public void init(float height)
 {
     this.height = height;
     this.heatIndex = 0;
     this.type = TerrainTile.TileType.none;
     this.maxHeat = 10;
 }
 public HexagonTileSerializable(HexagonTile source)
 {
     //this.Active = source.Active;
     this.X = source.Visual.X;
     this.Y = source.Visual.Y;
     this.TileType = source.TileType;
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Create an invisible tile. Useful for the spawn tile or waypoint tiles
 /// </summary>
 /// <param name="position">The tile's world coordinates</param>
 /// <param name="type">The tile type, determined when it is initially read in</param>
 public Tile(Vector2 position, TileType type, float depth)
 {
     texture = null;
     BoundingRectangle = new BoundingBox(new Vector3(position.X, position.Y, depth), new Vector3(position.X + 60, position.Y + 40, depth));
     tileType = type;
     setCollisions();
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Draws the preview.
 /// </summary>
 void DrawPreview()
 {
     GUILayout.Label("Preview", EditorStyles.boldLabel);
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
     EditorGUILayout.Separator();
     EditorGUILayout.TextField(AssetDatabase.GetAssetPath(selected));
     TileType tempType = ttype;
     ttype = (TileType) EditorGUILayout.EnumPopup("Base Frame", ttype);
     if (ttype != tempType)
         OnSelectionChange();
     int tempInt = pivotX;
     pivotX = EditorGUILayout.IntField("Pivot X", pivotX);
     if (pivotX != tempInt)
         OnSelectionChange();
     tempInt = pivotY;
     pivotY = EditorGUILayout.IntField("Pivot Y", pivotY);
     if (pivotY != tempInt)
         OnSelectionChange();
     EditorGUILayout.Popup(0, new string[] {"New Category", "Brick"});
     categoryName = EditorGUILayout.TextField("Category Name", categoryName);
     if (GUILayout.Button("add to library")) {
         OnClickAdd();
     }
     GUILayout.EndVertical();
     GUILayout.Box(mixed);
     GUILayout.EndHorizontal();
 }
Ejemplo n.º 30
0
 //Activates the tile's fruit.
 public void SetFruit()
 {
     fruitObject.SetActive(true);
     type = TileType.Fruit;
 }
Ejemplo n.º 31
0
 public static BoardTile FindTile(TileType Type, int TileID)
 {
     return(AllTiles.First(i => i.Type == Type && i.boardID == TileID));
 }
Ejemplo n.º 32
0
 public Tile(TileType type, int idx, Vector3 pos) : this((int)type, idx, pos)
 {
 }
Ejemplo n.º 33
0
 public void SetTile(TileType tileType)
 {
     Type = tileType;
     SetTexture(Type);
 }
Ejemplo n.º 34
0
 public Tile(TileType new_tile_type)
 {
     this.mType = new_tile_type;
 }
Ejemplo n.º 35
0
 public TilePosTuple(Point pos, TileType type)
 {
     this.Pos      = pos;
     this.TileType = type;
 }
Ejemplo n.º 36
0
 public TileProperties(TileType tileProp)
 {
     this.tileIdentity = tileProp;
 }
Ejemplo n.º 37
0
 public GridTile(Room pRoom, int pX, int pY, TileType pType) : base(pRoom, pX, pY, pType)
 {
 }
Ejemplo n.º 38
0
 public void SetMode_Bulldoze()
 {
     buildModeIsObjects = false;
     buildModeTile      = TileType.Empty;
 }
Ejemplo n.º 39
0
 public void SetTile(int x, int y, TileType type)
 {
     _cells[x + y * Width] = type;
 }
Ejemplo n.º 40
0
 public void SetMode_BuildRock()
 {
     buildModeIsObjects = false;
     buildModeTile      = TileType.Rock;
 }
Ejemplo n.º 41
0
 public TileClass(Vector3Int _pos, TileType _type = TileType.None, bool _enabled = true)
 {
     position = _pos;
     type     = _type;
     enabled  = _enabled;
 }
Ejemplo n.º 42
0
 public static LayerTile GetTile(TileType tileType, string key)
 {
     return(tiles[tileType, key]);
 }
Ejemplo n.º 43
0
 public void SetMode_BuildFloor()
 {
     buildModeIsObjects = false;
     buildModeTile      = TileType.Floor;
 }
Ejemplo n.º 44
0
    public void Start()
    {
        //Adds special tiles
        SpecialTiles.Add(0);
        SpecialTiles.Add(5);
        //Adds Accepted tiles
        for (int TileCount = 0; TileCount < 6; TileCount++)
        {
            AcceptedTiles.Add(TileCount, new List <int>());
            AcceptedTiles[TileCount].Add(TileCount);
        }
        AcceptedTiles[3].Add(2);
        AcceptedTiles[3].Add(5);
        //Creates list of blank tile infomation then adds it all.
        for (int i = 0; i < TileInfo.Length; i++)
        {
            TileInfo[i] = new TileType();
        }
        TileInfo[0].Name         = "Grass";
        TileInfo[0].FertilityMax = 1f;
        TileInfo[0].FertilityMin = 0.2f;
        TileInfo[0].MetalMax     = 0.6f;
        TileInfo[0].MetalMin     = 0.1f;
        TileInfo[0].StoneMax     = 0.6f;
        TileInfo[0].StoneMin     = 0.1f;
        TileInfo[0].WaterMax     = 0.6f;
        TileInfo[0].WaterMin     = 0.1f;
        TileInfo[0].WoodMax      = 0.4f;
        TileInfo[0].WoodMin      = 0.0f;

        TileInfo[1].Name         = "Stone";
        TileInfo[1].FertilityMax = 0.2f;
        TileInfo[1].FertilityMin = 0.0f;
        TileInfo[1].MetalMax     = 1f;
        TileInfo[1].MetalMin     = 0.6f;
        TileInfo[1].StoneMax     = 1f;
        TileInfo[1].StoneMin     = 0.8f;
        TileInfo[1].WaterMax     = 0.3f;
        TileInfo[1].WaterMin     = 0.0f;
        TileInfo[1].WoodMax      = 0.2f;
        TileInfo[1].WoodMin      = 0.0f;

        TileInfo[2].Name         = "Water";
        TileInfo[2].FertilityMax = 0.1f;
        TileInfo[2].FertilityMin = 0.0f;
        TileInfo[2].MetalMax     = 0.2f;
        TileInfo[2].MetalMin     = 0.0f;
        TileInfo[2].StoneMax     = 0.0f;
        TileInfo[2].StoneMin     = 0.0f;
        TileInfo[2].WaterMax     = 1f;
        TileInfo[2].WaterMin     = 1f;
        TileInfo[2].WoodMax      = 0.2f;
        TileInfo[2].WoodMin      = 0.0f;

        TileInfo[3].Name         = "Sand";
        TileInfo[3].FertilityMax = 0.1f;
        TileInfo[3].FertilityMin = 0.0f;
        TileInfo[3].MetalMax     = 0.2f;
        TileInfo[3].MetalMin     = 0.0f;
        TileInfo[3].StoneMax     = 0.6f;
        TileInfo[3].StoneMin     = 0.0f;
        TileInfo[3].WaterMax     = 0.7f;
        TileInfo[3].WaterMin     = 0.5f;
        TileInfo[3].WoodMax      = 0.2f;
        TileInfo[3].WoodMin      = 0.0f;

        TileInfo[4].Name         = "Woodland";
        TileInfo[4].FertilityMax = 1f;
        TileInfo[4].FertilityMin = 0.5f;
        TileInfo[4].MetalMax     = 0.4f;
        TileInfo[4].MetalMin     = 0.2f;
        TileInfo[4].StoneMax     = 0.6f;
        TileInfo[4].StoneMin     = 0.3f;
        TileInfo[4].WaterMax     = 0.6f;
        TileInfo[4].WaterMin     = 0.1f;
        TileInfo[4].WoodMax      = 1f;
        TileInfo[4].WoodMin      = 0.7f;

        TileInfo[5].Name         = "Sea";
        TileInfo[5].FertilityMax = 0.1f;
        TileInfo[5].FertilityMin = 0.0f;
        TileInfo[5].MetalMax     = 0.2f;
        TileInfo[5].MetalMin     = 0.0f;
        TileInfo[5].StoneMax     = 0.0f;
        TileInfo[5].StoneMin     = 0.0f;
        TileInfo[5].WaterMax     = 1f;
        TileInfo[5].WaterMin     = 1f;
        TileInfo[5].WoodMax      = 0.2f;
        TileInfo[5].WoodMin      = 0.0f;
    }
Ejemplo n.º 45
0
 public void SetMode_BuildTree()
 {
     buildModeIsObjects = false;
     buildModeTile      = TileType.Tree;
 }
Ejemplo n.º 46
0
    private void DrawTile(Location location, TileType tile)
    {
        var roadDefinition = roadTileInitializer.GetRoadDefinitions(tile);

        Instantiate(roadDefinition, location.Visual);
    }
Ejemplo n.º 47
0
 public static string Get(TileType type)
 {
     return(paths.ContainsKey(type) ? paths[type] : null);
 }
Ejemplo n.º 48
0
 public static bool AreSameBaseTileType(TileType tileTypeA, TileType tileTypeB)
 {
     return(Tile.BaseTileType(tileTypeA) == Tile.BaseTileType(tileTypeB));
 }
Ejemplo n.º 49
0
 public bool IsPartOfTask(TileType _tileType, TileTypeTag _tileTypeTag)
 {
     return(tileType == _tileType && tileTypeTag == _tileTypeTag);
 }
Ejemplo n.º 50
0
 public static string BaseTileType(TileType tileType)
 {
     return(Regex.Match(tileType.ToString(), @"[a-zA-z]+").Value);
 }
Ejemplo n.º 51
0
 private void AddLogicalTile(Location location, TileType tile)
 {
     tileTypes[location.Logical] = tile;
 }
Ejemplo n.º 52
0
 public Tile(TileType tileType, int x, int y, Grid grid, int cost = 0, bool isAdvancing = false, TileType advancingType = TileType.Dirt, float cycleTime = 0)
 {
     this.TileType      = tileType;
     this.X             = x;
     this.Y             = y;
     this.Grid          = grid;
     this.Cost          = cost;
     this.IsAdvancing   = isAdvancing;
     this.AdvancingType = advancingType;
     this.CycleTime     = cycleTime;
 }
Ejemplo n.º 53
0
        public static int GetTileTypeLevel(TileType tileType)
        {
            var r = Regex.Match(tileType.ToString(), @"[0-9]$");

            return(r.Success ? int.Parse(r.Value) : 0);
        }
Ejemplo n.º 54
0
 public Tile(uint x, uint y, TileType type)
 {
     X    = x;
     Y    = y;
     Type = type;
 }
Ejemplo n.º 55
0
        public static Tile CreateTile(TileType tileType, int x, int y, Grid grid, bool isAdvancing = false, TileType advancingType = TileType.Dirt, float cycleTime = 0)
        {
            Tile tile;

            switch (tileType)
            {
            case TileType.Dirt:
                tile = new DirtTile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Grass:
                tile = new GrassTile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Field:
                tile = new FieldTile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Construct:
                tile = new ConstructTile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Blueberry1:
                tile = new Blueberry1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Blueberry2:
                tile = new Blueberry2Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Blueberry3:
                tile = new Blueberry3Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Carrot1:
                tile = new Carrot1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Carrot2:
                tile = new Carrot2Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Carrot3:
                tile = new Carrot3Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Potato1:
                tile = new Potato1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Potato2:
                tile = new Potato2Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Potato3:
                tile = new Potato3Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Strawberry1:
                tile = new Strawberry1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Strawberry2:
                tile = new Strawberry2Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Strawberry3:
                tile = new Strawberry3Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Wheat1:
                tile = new Wheat1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Wheat2:
                tile = new Wheat2Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Wheat3:
                tile = new Wheat3Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            case TileType.Greenhouse1:
                tile = new Greenhouse1Tile(x, y, grid, isAdvancing, advancingType, cycleTime);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(tileType));
            }
            return(tile);
        }
Ejemplo n.º 56
0
        private void InitializeTile(TileType type, int x, int y)
        {
            string resourceName;

            switch (type)
            {
            case TileType.GROUND:
                resourceName = "ground";
                break;

            case TileType.SOLID_WALL:
                resourceName = "wall";
                break;

            case TileType.BREAK_BLOCK:
                resourceName = "vase";
                break;

            case TileType.BREAK_START:
                resourceName = "ground";
                var breaker = Resources.Load("Actors/breaker");
                breakerObj = Instantiate(breaker,
                                         BasePosition + new Vector3(tileLength * x - tileLength / 2f, 2.4f, tileLength * y - tileLength / 2f),
                                         Quaternion.identity) as GameObject;
                Breaker = breakerObj.GetComponent <Breaker>();
                Breaker.Initialize(mapManager, new Position(x, y));
                break;

            case TileType.FIX_BLOCK:
                resourceName = "crate_broken";
                break;

            case TileType.FIX_START:
                resourceName = "ground";
                var fixer = Resources.Load("Actors/fixer");
                fixerObj = Instantiate(fixer,
                                       BasePosition + new Vector3(tileLength * x - tileLength / 2f, 2.4f, tileLength * y - tileLength / 2f),
                                       Quaternion.identity) as GameObject;
                Fixer = fixerObj.GetComponent <Fixer>();
                Fixer.Initialize(mapManager, new Position(x, y));
                break;

            case TileType.BOTH_ACT_BLOCK:
                resourceName = "crate";
                break;

            case TileType.BUTTON:
                resourceName = "button";
                break;

            case TileType.DOOR:
                resourceName = "door";
                break;

            case TileType.HOLE:
                resourceName = "hole";
                break;

            case TileType.BREAK_EXIT:
                resourceName = "break_exit";
                break;

            case TileType.FIX_EXIT:
                resourceName = "fix_exit";
                break;

            case TileType.EXIT_BOTH:
                resourceName = "exit_both";
                break;

            default:
                return;
            }

            try
            {
                if (resourceName == "ground")
                {
                    resourceName += rand.Next(1, 4);
                }

                var tileObject = Instantiate(Resources.Load(BasePath + resourceName),
                                             BasePosition + new Vector3(tileLength * x, 0, tileLength * y),
                                             Quaternion.identity);
                var tileReference = tileObject as GameObject;
                var tile          = tileReference.GetComponent <Tile>();

                tileMap[x, y] = tile;
                gameObjects.Add(tileReference);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                var tileObject = Instantiate(Resources.Load(BasePath + "ground" + rand.Next(1, 5)),
                                             BasePosition + new Vector3(tileLength * x, 0, tileLength * y),
                                             Quaternion.identity);

                var tile = (tileObject as GameObject).GetComponent <Tile>();

                tileMap[x, y] = tile;
            }
        }
Ejemplo n.º 57
0
 //Sets the tile as empty.
 public void SetEmpty()
 {
     ClearTile();
     type = TileType.Empty;
 }
Ejemplo n.º 58
0
 /// <summary>
 /// If one of the 8 neighbouring tiles is of TileType type then this returns true.
 /// </summary>
 public bool HasNeighboursOfType(TileType tileType)
 {
     return(GetNeighbours(true).Any(tile => (tile != null && tile.Type == tileType)));
 }
Ejemplo n.º 59
0
    private Vector3 PickRandomPosition(TileType type = TileType.Grass)
    {
        Vector3 randomTilePos = board.GetRandomTile(type).transform.position;

        return(new Vector3(randomTilePos.x, 0, randomTilePos.z));
    }
    public TileType[,] Read(TextAsset file, int xSize, int ySize)
    {
        StringReader reader = new StringReader(file.text);

        TileType[,] ttmap = new TileType[xSize, ySize];

        if (reader == null)
        {
            print ("read failed");
            return null;
        }
        else
        {
            int x = 0;
            int y = ySize - 1;
            for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
            {
                //PrintMapLine(line, row);
                x = 0;
                foreach(char c in line)
                {
                    //print ("" + x + " " + y);
                    ttmap[x,y] = ConvertToTileTypeFromChar(c, x, y);
                    x++;
                }

                y--;
            }
            return ttmap;
        }
    }