Ejemplo n.º 1
0
    public MahjongTile FindMahjongTileFromPocketList(TileDef def)
    {
        MahjongTile tile = null;

        for (int i = 0; i < _sortPocketList.Count; ++i)
        {
            tile = _sortPocketList [i];
            if (tile.Def.Value == def.Value)
            {
                return(tile);
            }
        }
        return(null);
    }
Ejemplo n.º 2
0
    public void OnClickHuanpai(UIController ctrl)
    {
        MahjongTile.TotalClickCount = 1;
        UIGameSetingController seting = (UIGameSetingController)ctrl;

        seting.CloseHuanpaiTips();

        List <byte> cards = new List <byte> ();


        MahjongUserPlayer userPlayer = GameClient.Instance.MG.Self as MahjongUserPlayer;
        bool checkSelect             = true;

        if (userPlayer != null)
        {
            List <MahjongTile> mahjongTiles = userPlayer.Clicked;
            if (mahjongTiles.Count > 0)
            {
                TileDef.Kind kind = mahjongTiles [0].Def.GetKind();
                foreach (var temp in mahjongTiles)
                {
                    if (kind != temp.Def.GetKind())
                    {
                        checkSelect = false;
                    }
                    cards.Add(temp.Def.Value);
                }
            }
        }

        if (cards.Count == 0 || !checkSelect)
        {
            foreach (var temp in _HuanPaiOldDef)
            {
                cards.Add(temp.Value);
            }
        }
        else
        {
            for (int i = 0; i < GameMessage.MAXHUANPAINUM; i++)
            {
                if (i < cards.Count)
                {
                    _HuanPaiOldDef [i] = TileDef.Create(cards[i]);
                }
            }
        }

        GameClient.Instance.MG.Self.Proxy.Huanpai(cards);
    }
Ejemplo n.º 3
0
    void ProcessEnemyMove()
    {
        if (GAME_ENEMY_MOVE_PROGRESS_PROCESSED == false)
        {
            GAME_ENEMY_MOVE_PROGRESS_PROCESSED = true;
            if (RunTheGauntlet() == false)
            {
                GAME_ENEMY_MOVE_PROGRESS = 0;
                AudioPlay("GAME_SOUND_MOVE");
            }
            else
            {
                AudioPlay("GAME_SOUND_SPOTTED");
            }
        }
        else if (GAME_ENEMY_MOVE_PROGRESS == 15)
        {
            if (GAME_ENEMY_THREATEN == true)
            {
                // Capture the player's piece
                TileDef enemyPiece = BoardManager.Instance.GetTile(GAME_ENEMY_SOLDIER_X, GAME_ENEMY_SOLDIER_Y);
//				TileDef myPiece = BoardManager.Instance.GetTile(GAME_ENEMY_THREATEN_X, GAME_ENEMY_THREATEN_Y);
                BoardManager.Instance.PutTileData(GAME_ENEMY_THREATEN_X, GAME_ENEMY_THREATEN_Y, enemyPiece);
                BoardManager.Instance.PutTileData(GAME_ENEMY_SOLDIER_X, GAME_ENEMY_SOLDIER_Y, GetEmptyPiece());

                AudioPlay("GAME_SOUND_CAPTURED");

                GAME_ENEMY_THREATEN = false;
            }
            else
            {
                // Something bad happened
                Debug.LogWarning("Something bad happened\n");
            }
        }

        if (GAME_ENEMY_MOVE_PROGRESS <= 0)
        {
            ClearHighlights();
            gameState = GameState.White;
            GAME_ENEMY_MOVE_PROGRESS_PROCESSED = false;

            CheckForLossCondition();

            // Re-highlight wherever the user's mouse was
            Enter(GAME_MOUSE_X, GAME_MOUSE_Y, BoardManager.Instance.GetTile(GAME_MOUSE_X, GAME_MOUSE_Y));
        }

        GAME_ENEMY_MOVE_PROGRESS--;
    }
Ejemplo n.º 4
0
        public static int Comparison(TileDef a, TileDef b)
        {
            if ((int)a.SortID > (int)b.SortID)
            {
                return(1);
            }

            if ((int)a.SortID < (int)b.SortID)
            {
                return(-1);
            }

            return(0);
        }
Ejemplo n.º 5
0
    public static MahjongTile Create(TileDef def)
    {
        if (!TileDef.IsValid(def.Value))
        {
            Debug.LogError("tile : " + def.Value + " is not a valid tile");
            return(null);
        }

        Transform inst = null;

        MahjongTile._Pool = PoolManager.Pools ["mahjongres"];

        int point = def.GetPoint();

        switch (def.GetKind())
        {
        case TileDef.Kind.CRAK:
            inst = MahjongTile._Pool.Spawn("Crak_" + point);
            break;

        case TileDef.Kind.BAM:
            inst = MahjongTile._Pool.Spawn("Bam_" + point);
            break;

        case TileDef.Kind.DOT:
            inst = MahjongTile._Pool.Spawn("Dot_" + point);
            break;

        default:
            Debug.LogError("UnValid kind : " + def.GetKind());
            return(null);
        }

        inst.gameObject.SetActive(true);
        inst.transform.parent   = null;
        inst.transform.rotation = Quaternion.identity;
        inst.transform.position = Vector3.one * 9999f;

        MahjongTile tile = inst.gameObject.GetComponent <MahjongTile> () ?? inst.gameObject.AddComponent <MahjongTile> ();

        tile._def       = def;
        tile.ClickCount = 0;

        BoxCollider collider = inst.gameObject.AddComponent <BoxCollider> ();

        collider.center = Vector3.zero;
        collider.size   = ColliderSize;

        return(tile);
    }
Ejemplo n.º 6
0
    public void RemoveExplodingBricksTile(GameObject explodingBricksTileGameObject)
    {
        Vector3Int cellPosition                = StaticGridManager.GetSingleton().nonCollidableGroundTilemap.WorldToCell(explodingBricksTileGameObject.transform.position);
        Vector3Int bottomNextCellPosition      = cellPosition + Vector3Int.down;
        Vector3    bottomNextCellWorldPosition = StaticGridManager.GetSingleton().nonCollidableGroundTilemap.GetCellCenterWorld(bottomNextCellPosition);
        TileDef    bottomNextTileDef           = tileDefs[bottomNextCellPosition.x, bottomNextCellPosition.y];

        if (bottomNextTileDef != null && bottomNextTileDef.tileType == TileDef.TileType.Grass)
        {
            networkManager.RemoveObject(bottomNextTileDef.gameObject);
            networkManager.AddGridTile((int)CustomNetworkManager.SpawnPrefabs.GrassTile, bottomNextCellWorldPosition);
        }

        networkManager.RemoveObject(explodingBricksTileGameObject);
    }
Ejemplo n.º 7
0
 bool PiecesLeft(TileDef.TileOwner owner)
 {
     for (int y = 0; y < GameConstants.BOARD_H; y++)
     {
         for (int x = 0; x < GameConstants.BOARD_W; x++)
         {
             TileDef piece = BoardManager.Instance.GetTile(x, y);
             if (piece.owner == owner)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
    bool RunTheGauntlet()
    {
        TileDef.TileType[] pieceTypes = new TileDef.TileType[]
        {
            TileDef.TileType.pawn,
            TileDef.TileType.knight,
            TileDef.TileType.bishop,
            TileDef.TileType.rook,
            TileDef.TileType.queen,
            TileDef.TileType.king
        };

        // Loop over the piece tyeps
        for (int i = 0; i < pieceTypes.Length; i++)
        {
            TileDef.TileType pieceType = pieceTypes[i];

            // Loop over the board
            for (int y = 0; y < GameConstants.BOARD_H; y++)
            {
                for (int x = 0; x < GameConstants.BOARD_W; x++)
                {
                    // Inspect the piece there
                    TileDef piece = BoardManager.Instance.GetTile(x, y);
                    if (piece.owner == TileDef.TileOwner.black && piece.type == pieceType)
                    {
                        DrawPieceHighlights(x, y, piece);

                        if (GAME_ENEMY_THREATEN == true)
                        {
                            // Clear others and redraw for special fx
                            ClearHighlights();
                            DrawPieceHighlights(x, y, piece);

                            GAME_ENEMY_SOLDIER_X = x;
                            GAME_ENEMY_SOLDIER_Y = y;
                            return(true);
                        }
                    }
                }
            }
        }

        // Don't let the player see the mess we made
        ClearHighlights();

        return(false);
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tile"/> class.
        /// </summary>
        /// <param name="tileDef">The tile definition.</param>
        public Tile(TileDef tileDef)
        {
            Id    = tileDef.Id;
            Glyph = tileDef.Glyph;

            var attrIsPassable = tileDef.Attributes["IsPassable"]; //.SingleOrDefault(s => s.Name == "");

            if (attrIsPassable != null)
            {
                IsPassable = (bool)attrIsPassable.Value;
            }
            else
            {
                IsPassable = true;
            }
        }
Ejemplo n.º 10
0
    private static bool BuildFromJSON(JSONNode rootNode)
    {
        m_tilesDef.Clear();

        JSONNode tilesInfo = rootNode["tilesInfo"];

        if (tilesInfo == null)
        {
            return(false);
        }

        foreach (var tileNode in tilesInfo.Childs)
        {
            JSONNode resNode = tileNode["resource"];
            if (resNode == null)
            {
                continue;
            }

            string filename = resNode["file"];
            int    x        = resNode["x"].AsInt;
            int    y        = resNode["y"].AsInt;
            int    w        = resNode["w"].AsInt;
            int    h        = resNode["h"].AsInt;
            int    count    = resNode["count"].AsInt;

            TileResourceDef trd = new TileResourceDef(filename, new Rect(x, y, w, h), count);

            ETile  id   = (ETile)tileNode["id"].AsInt;
            string name = tileNode["name"];

            TileProperties tileProperties = new TileProperties(tileNode["properties"]);

            TileDef td = new TileDef(id, name, trd, tileProperties);

            if (m_tilesDef.ContainsKey(id))
            {
                Debug.Log(string.Format("Ignoring duplicate id {0}", id));
                continue;
            }

            m_tilesDef.Add(id, td);
        }

        return(true);
    }
Ejemplo n.º 11
0
    public bool RemoveMahjonTileFromPocketList(TileDef def, int num)
    {
        int count = 0;

        for (int i = _sortPocketList.Count - 1; i >= 0; --i)
        {
            if (_sortPocketList [i].Def.Value == def.Value)
            {
                _sortPocketList.RemoveAt(i);
                ++count;
                if (count == num)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Ejemplo n.º 12
0
    public Sprite GetMJSprite(TileDef def)
    {
        switch (def.GetKind())
        {
        case TileDef.Kind.CRAK:
            return(_wanSprites[def.GetPoint() - 1]);

        case TileDef.Kind.BAM:
            return(_tiaoSprites[def.GetPoint() - 1]);

        case TileDef.Kind.DOT:
            return(_tongSprites[def.GetPoint() - 1]);

        case TileDef.Kind.HUA:
            return(_ziSprites[def.GetPoint() - 1]);
        }
        return(null);
    }
Ejemplo n.º 13
0
        public override void LoadContent(JContent contentManager)
        {
            TreeLines       = contentManager.Load <Sprite>("NewTreeLines");
            TreeColor       = contentManager.Load <Sprite>("NewTreeColor");
            NoiseTileSprite = contentManager.Load <Sprite>("TileNoise");
            MissileSprite   = contentManager.Load <Sprite>("Missile");
            Character       = contentManager.Load <Sprite>("Character");
            IconWood        = contentManager.Load <Sprite>("Wood Icon");

            NoiseTileDef            = new TileDef(1, "Test Tile");
            NoiseTileDef.BaseSprite = NoiseTileSprite;
            TileDef.Register(NoiseTileDef);
            TileDef.Register(new TestLinkedTile());
            TileDef.Register(new TreeTile());
            TileDef.Register(new WindTurbineTileDef());

            ItemDef.Register(new WoodItem());
        }
Ejemplo n.º 14
0
 // Can we pick up a piece, or click on some UI?
 void Click(int x, int y, TileDef data)
 {
     if (gameState == GameState.Black)
     {
         // The enemy is moving, not you
     }
     else if (GAME_CLICK_LATCH == false && data.owner == TileDef.TileOwner.white)
     {
         // Clicked somewhere to start a move
         ProcessBetweenTurns();
         BoardManager.Instance.PutTileData(x, y, GetEmptyPiece());
         GAME_CLICK_LATCH = true;
         GAME_CLICK_DATA  = data;
         GAME_CLICK_X     = x;
         GAME_CLICK_Y     = y;
         HighlightDrag(x, y, true);
     }
 }
Ejemplo n.º 15
0
    public void ResetPlayList()
    {
        TileDef     def  = null;
        MahjongTile tile = null;

        destroyChildren(PlayLocator);

        for (int i = 0; i < Proxy.PlayList.Count; ++i)
        {
            def = Proxy.PlayList [i];
            if (TileDef.IsValid(def.Value))
            {
                tile = MahjongTile.Create(def);
                if (tile != null)
                {
                    placePlayed(tile, false);
                }
            }
        }
    }
Ejemplo n.º 16
0
    // Mouse over to highlight moves
    void Enter(int x, int y, TileDef data)
    {
        GAME_MOUSE_X = x;
        GAME_MOUSE_Y = y;

        if (gameState == GameState.Black || gameState == GameState.Won)
        {
            // The enemy is moving, not you
        }
        else if (GAME_CLICK_LATCH == true)
        {
            DrawPieceAt(x, y, GAME_CLICK_DATA);
            DrawPieceHighlights(GAME_CLICK_X, GAME_CLICK_Y, GAME_CLICK_DATA);
            HighlightDrag(x, y, true);
        }
        else
        {
            DrawPieceHighlights(x, y, data);
        }
    }
Ejemplo n.º 17
0
    public void SetPocketCount(int index, int num)
    {
        MahjongPlayer player = _playPlayers [index];

        if (player != _self)
        {
            if (player.Proxy.PocketList.Count > num)
            {
                int count = player.Proxy.PocketList.Count - num;
                player.Proxy.RemovePocketList(count);
            }
            else if (player.Proxy.PocketList.Count < num)
            {
                for (int i = 0; i < (num - player.Proxy.PocketList.Count); ++i)
                {
                    player.Proxy.PocketList.Add(TileDef.Create());
                }
            }
        }
    }
Ejemplo n.º 18
0
    // Released a piece
    void Release(int x, int y, TileDef data)
    {
        if (GAME_CLICK_LATCH == true)
        {
            GAME_CLICK_LATCH = false;
            bool allowMove = (data.type == TileDef.TileType.empty || data.owner == TileDef.TileOwner.black) && (BoardManager.Instance.GetIsHighlighted(x, y));

            ClearHighlights();

            if (allowMove)
            {
                if (data.type != TileDef.TileType.empty)
                {
                    GAME_CLICK_DATA.type = data.type;                           // Assume this piece's identity

                    if (GAME_CLICK_DATA.type == TileDef.TileType.king)
                    {
                        //TODO: Save manager
//						SAVE.CompleteLevel(GAME_level);
                        gameState = GameState.Won;
                        AudioPlay("GAME_SOUND_WIN");
                        StatusText("Nice work. Press any key to continue.");
                    }
                }

                BoardManager.Instance.PutTileData(GAME_CLICK_X, GAME_CLICK_Y, GetEmptyPiece());
                BoardManager.Instance.PutTileData(x, y, GAME_CLICK_DATA);
                HighlightDrag(x, y, false);

                // Time for the opponent to move
                if (gameState != GameState.Won)
                {
                    MakeEnemyMove();
                }
            }
            else
            {
                Unlatch(x, y, data);
            }
        }
    }
Ejemplo n.º 19
0
	public static void GenerateTileDefTemplate()
	{
		// Gotta get our Filepath Combined for where we wanna put this template.
		string fileName = "TileDefTemplate.json";
		string templateDirectory = Path.Combine(TileDefDirectory, fileName);
		string filePath = Path.Combine(Application.dataPath, templateDirectory);

		// Create a meaningful TileDef for the Template
		TileDef template = new TileDef("TileDef_Template", "Template", "Tile_Blank", "TemplateAbility", new List<ActionDef>());
		template.Actions.Add(new ActionDef(ActionType.INVALID, Vector2.zero));

		// Convert the TileDef Template to a JSON String with clean formatting for editing
		string templateJSON = JsonConvert.SerializeObject(template, Formatting.Indented, new StringEnumConverter());

		// Grab a StreamWriter and write the JSON to the filepath we've made
		using (StreamWriter stream = new StreamWriter(filePath))
		{
			stream.Write(templateJSON);
		}

		Debug.Log(string.Format("TileDef Template saved to {0}", filePath));
	}
Ejemplo n.º 20
0
    //random play one tile from network command
    public virtual bool Play(TileDef def)
    {
        MahjongTile tile = null;

        if (((Player)_proxy).Play(def))
        {
            for (int i = 0; i < _sortPocketList.Count; ++i)
            {
                if (_sortPocketList [i].Def.Value == def.Value)
                {
                    _playIndex = i;
                    tile       = _sortPocketList [_playIndex];
                    _sortPocketList.Remove(tile);
                    placePlayed(tile);
                    return(true);
                }
            }
            Debug.Log(_sortPocketList.Count);
            Debug.Log(Proxy.Index + " Play(TileDef def)####################" + _playIndex);
            tile = MahjongTile.Create(def);
            placePlayed(tile);
            _playIndex = Random.Range(0, _sortPocketList.Count);
            tile       = _sortPocketList [_playIndex];
            _sortPocketList.Remove(tile);
            tile.Despawn();
        }
        else
        {
            _proxy.RemovePocketList(1);
            tile = MahjongTile.Create(def);
            placePlayed(tile);
            _playIndex = Random.Range(0, _sortPocketList.Count);
            tile       = _sortPocketList [_playIndex];
            _sortPocketList.Remove(tile);
            tile.Despawn();
        }

        return(false);
    }
Ejemplo n.º 21
0
    public bool getCreatureSprite(UnitDefinition unit, out Material mat, out int index, out bool colored)
    {
        ProfessionMatcher <TileDef> prof;

        if (!creatureMatcher.TryGetValue(unit.race, out prof))
        {
            mat     = null;
            index   = 0;
            colored = true;
            return(false);
        }
        TileDef def = new TileDef(-1, -1, true);
        bool    set = false;

        foreach (var item in unit.noble_positions)
        {
            if (prof.TryGetValue(item, out def))
            {
                set = true;
                break;
            }
        }
        if (!set)
        {
            prof.TryGetValue((DF.Enums.profession)unit.profession_id, out def);
            set = (def.page != -1);
        }
        if (!set || def.page == -1)
        {
            mat     = null;
            index   = 0;
            colored = true;
            return(false);
        }
        mat     = mats[def.page];
        index   = def.index;
        colored = def.colored;
        return(true);
    }
Ejemplo n.º 22
0
    /*
     * Ilumina la celda de la possicion (x,z) si esta es de tipo goal.
     * Si estaba encendida, la apaga.
     */
    public int SwitchLight(int x, int z)
    {
        if (this.board_def [x, z].type != TileType.goal)
        {
            return(0);
        }

        TileDef    td = this.board_def[x, z];
        GameObject go = this.board [x, z];

        Renderer rmat = null;

        foreach (Transform t in go.transform)
        {
            if (t.name == "cover")
            {
                rmat = t.gameObject.GetComponent <Renderer>();
            }
        }


        if (td.isOn == false)
        {
            rmat.material = this.onCover_material;
            td.isOn       = true;

            return(1);
        }
        else
        {
            rmat.material = this.offCover_material;
            td.isOn       = false;

            return(-1);
        }
    }
Ejemplo n.º 23
0
 public void TileDefSelected(TileDef def)
 {
     CurrentSelectedTileDef = def;
     IsTileDefSelected      = true;
 }
Ejemplo n.º 24
0
 public BasicTile(TileDef def) : base(def)
 {
 }
Ejemplo n.º 25
0
    void DrawPieceHighlights(int x, int y, TileDef piece)
    {
        Debug.LogWarning("type: " + piece.type + "\n");
        bool me = (piece.owner == TileDef.TileOwner.white);

        TileDef.TileType type = piece.type;
        int dir     = me ? 1 : -1;
        int pawnRow = me ? GameConstants.BOARD_H - 2 : 1;

        // Pawn
        if (type == TileDef.TileType.pawn)
        {
            if (me)
            {
                // Move forward
                if (IsClear(x, y - 1 * dir))
                {
                    HighlightPotentialMove(piece, x, y - 1 * dir);
                    // Double move on starting row
                    if (y == pawnRow)
                    {
                        if (IsClear(x, y - 2 * dir))
                        {
                            HighlightPotentialMove(piece, x, y - 2 * dir);                              // Double move on first row
                        }
                    }
                }
                // Capture right
                if (!IsClear(x + 1, y - 1 * dir))
                {
                    HighlightPotentialMove(piece, x + 1, y - 1 * dir);
                }
                // Capture left
                if (!IsClear(x - 1, y - 1 * dir))
                {
                    HighlightPotentialMove(piece, x - 1, y - 1 * dir);
                }
            }
            else
            {
                HighlightPotentialMove(piece, x + 1, y - 1 * dir);
                HighlightPotentialMove(piece, x - 1, y - 1 * dir);
            }
        }

        // Knight
        if (type == TileDef.TileType.knight)
        {
            HighlightPotentialMove(piece, x + 1, y - 2 * dir);
            HighlightPotentialMove(piece, x + 1, y + 2 * dir);
            HighlightPotentialMove(piece, x - 1, y - 2 * dir);
            HighlightPotentialMove(piece, x - 1, y + 2 * dir);
            HighlightPotentialMove(piece, x + 2, y - 1 * dir);
            HighlightPotentialMove(piece, x + 2, y + 1 * dir);
            HighlightPotentialMove(piece, x - 2, y - 1 * dir);
            HighlightPotentialMove(piece, x - 2, y + 1 * dir);
        }

        if (type == TileDef.TileType.bishop || type == TileDef.TileType.queen)
        {
            DrawPieceHighlightTravel(piece, x, y, 1, 1);
            DrawPieceHighlightTravel(piece, x, y, 1, -1);
            DrawPieceHighlightTravel(piece, x, y, -1, 1);
            DrawPieceHighlightTravel(piece, x, y, -1, -1);
        }

        if (type == TileDef.TileType.rook || type == TileDef.TileType.queen)
        {
            for (var i = 1; i < 8; i++)
            {
                DrawPieceHighlightTravel(piece, x, y, 1, 0);
                DrawPieceHighlightTravel(piece, x, y, -1, 0);
                DrawPieceHighlightTravel(piece, x, y, 0, 1);
                DrawPieceHighlightTravel(piece, x, y, 0, -1);
            }
        }

        if (type == TileDef.TileType.king)
        {
            HighlightPotentialMove(piece, x + 1, y + 1);
            HighlightPotentialMove(piece, x + 0, y + 1);
            HighlightPotentialMove(piece, x - 1, y + 1);

            HighlightPotentialMove(piece, x + 1, y + 0);
            HighlightPotentialMove(piece, x - 1, y + 0);

            HighlightPotentialMove(piece, x + 1, y - 1);
            HighlightPotentialMove(piece, x + 0, y - 1);
            HighlightPotentialMove(piece, x - 1, y - 1);
        }
    }
Ejemplo n.º 26
0
 public void PutTileData(int x, int y, TileDef tile)
 {
     _boardDef.PutTile(x, y, tile);
 }
Ejemplo n.º 27
0
 public void TileDefUnselected(TileDef def)
 {
     CurrentSelectedTileDef = null;
     IsTileDefSelected      = false;
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Adds a Tile to the game
        /// </summary>
        /// <param name="Tparam">The Tile data to add to the game</param>
        /// <param name="param">Common object loading parameters</param>
        public static void AddToGame(TileParameters Tparam, LoadParameters param)
        {
            int type = Defs.tileNextType++;

            TileDef.ResizeTiles(Defs.tileNextType);

            if (!Main.dedServ)
            {
                Main.tileTexture[type] = Tparam.Texture;
            }

            if (!String.IsNullOrEmpty(param.SubClassTypeName))
            {
                TileDef.codeClass[type] = (ModTile)param.Assembly.CreateInstance(param.SubClassTypeName, false, BindingFlags.Public | BindingFlags.Instance, null,
                                                                                 new object[] { param.ModBase }, CultureInfo.CurrentCulture, new object[] { });

                if (TileDef.codeClass[type] != null)
                {
                    Defs.FillCallPriorities(TileDef.codeClass[type].GetType());
                }
            }

            TileDef.name[type]        = param.ModBase.modName + ":" + param.Name;
            TileDef.displayName[type] = param.Name;

            TileDef.width[type]        = Tparam.Width;
            TileDef.height[type]       = Tparam.Height;
            TileDef.frameWidth[type]   = Tparam.FrameWidth;
            TileDef.frameHeight[type]  = Tparam.FrameHeight;
            TileDef.sheetColumns[type] = Tparam.SheetColumns;
            TileDef.sheetLines[type]   = Tparam.SheetLines;

            TileDef.solid[type]          = Tparam.Solid;
            TileDef.solidTop[type]       = Tparam.SolidTop;
            TileDef.frameImportant[type] = Tparam.FrameImportant;

            TileDef.breaksFast[type]     = Tparam.BreaksFast;
            TileDef.breaksByPick[type]   = Tparam.BreaksByPic;
            TileDef.breaksByAxe[type]    = Tparam.BreaksByAxe;
            TileDef.breaksByHammer[type] = Tparam.BreaksByHammer;
            TileDef.breaksByCut[type]    = Tparam.BreaksByCut;
            TileDef.breaksByWater[type]  = Tparam.BreaksByWater;
            TileDef.breaksByLava[type]   = Tparam.BreaksByLava;

            TileDef.table[type]       = Tparam.Table;
            TileDef.rope[type]        = Tparam.Rope;
            TileDef.noAttach[type]    = Tparam.NoAttach;
            TileDef.tileDungeon[type] = Tparam.Dungeon;

            TileDef.blocksLight[type]  = Tparam.BlocksAnyLight;
            TileDef.blocksSun[type]    = Tparam.BlocksSunlight;
            TileDef.glows[type]        = Tparam.Glows;
            TileDef.shines[type]       = Tparam.Shines;
            TileDef.shineChance[type]  = Tparam.ShineChance;
            TileDef.frame[type]        = Tparam.Frame;
            TileDef.frameCounter[type] = Tparam.FrameCounter;

            TileDef.brick[type]     = Tparam.Brick;
            TileDef.moss[type]      = Tparam.Moss;
            TileDef.stone[type]     = Tparam.Stone;
            TileDef.mergeDirt[type] = Tparam.Dirt;

            TileDef.tileSand[type]      = Tparam.Sand;
            TileDef.tileFlame[type]     = Tparam.Flame;
            TileDef.alchemyflower[type] = Tparam.AlchemyFlower;
        }
Ejemplo n.º 29
0
        public override void ReadFromBuffer(NetIncomingMessage buffer)
        {
            MessageType = (MapMessage)buffer.ReadByte();
            switch (MessageType)
            {
            case MapMessage.TurfUpdate:
                MapIndex   = new MapId(buffer.ReadInt32());
                GridIndex  = new GridId(buffer.ReadInt32());
                SingleTurf = new Turf()
                {
                    X    = buffer.ReadInt32(),
                    Y    = buffer.ReadInt32(),
                    Tile = buffer.ReadUInt32()
                };
                break;

            case MapMessage.SendTileMap:
                GridIndex = new GridId(buffer.ReadInt32());
                MapIndex  = new MapId(buffer.ReadInt32());

                //tile defs
                var numTileDefs = buffer.ReadInt32();
                var tileDefs    = new TileDef[numTileDefs];
                for (var i = 0; i < numTileDefs; i++)
                {
                    tileDefs[i] = new TileDef()
                    {
                        Name = buffer.ReadString()
                    };
                }
                TileDefs = tileDefs;

                // map chunks
                ChunkSize = buffer.ReadUInt16();
                var numChunks = buffer.ReadInt32();
                ChunkDefs = new ChunkDef[numChunks];

                for (var i = 0; i < numChunks; i++)
                {
                    var newChunk = new ChunkDef()
                    {
                        X = buffer.ReadInt32(),
                        Y = buffer.ReadInt32()
                    };

                    var chunkCount = ChunkSize * ChunkSize;
                    var tiles      = new uint[chunkCount];
                    for (var j = 0; j < chunkCount; j++)
                    {
                        tiles[j] = buffer.ReadUInt32();
                    }
                    newChunk.Tiles = tiles;
                    ChunkDefs[i]   = newChunk;
                }
                break;

            case MapMessage.SendMapInfo:
                MapGridsToSend = buffer.ReadInt32();
                break;

            case MapMessage.CreateMap:
            case MapMessage.DeleteMap:
                MapIndex = new MapId(buffer.ReadInt32());
                break;
            }
        }
Ejemplo n.º 30
0
    //dealer and opposite dealer are 14 tons, others are 13tons
    public List <TileDef> RebuildStack(int a, int b, int count, int drawFront, int drawBehind)
    {
        int stackIndex = 0;
        int pointMin   = Math.Min(a, b);
        int pointSum   = a + b;
        int skipCount  = pointMin * 2;        // pointMin tons to keep

        // 4, 8, 12, banker's left
        if (pointSum % 4 == 0)
        {
            stackIndex = 3;
        }
        // 2, 6, 10, banker's right
        else if (pointSum % 2 == 0)
        {
            stackIndex = 1;
        }
        // 1, 3, 5, 7, 9, 11, banker's front
        else
        {
            stackIndex = 2;
        }

        _wall.Clear();
        for (int i = 0; i < count; ++i)
        {
            _wall.Add(TileDef.Create((byte)0x11));
        }

        /*
         * for (int i = 0; i < _playPlayers.Length; ++i) {
         *      _players [i] = _playPlayers [i];
         * }
         *
         * //hard code
         * if (_playPlayers.Length == 3) {
         *      if (_players [0] == _self) {
         *              _players [3] = _players [2];
         *              _players [2] = _front;
         *      } else if (_players [1] == _self) {
         *              _players [3] = _front;
         *      } else if (_players [2] == _self) {
         *              _players [0] = _right;
         *              _players [1] = _front;
         *              _players [2] = _left;
         *              _players [3] = _self;
         *      }
         * }
         *
         * int stackCount = _players [stackIndex].GetStack ().Count;
         * _wall.Clear ();
         * _wall.AddRange (_players [stackIndex].GetStack (skipCount, stackCount - skipCount));
         * _wall.AddRange (_players [(stackIndex + 3) % 4].GetStack ());
         * _wall.AddRange (_players [(stackIndex + 2) % 4].GetStack ());
         * _wall.AddRange (_players [(stackIndex + 1) % 4].GetStack ());
         * _wall.AddRange (_players [stackIndex].GetStack (0, skipCount));
         *
         * UIControllerGame.Instance.SetPaiRestInfo (_wall.Count);
         * UIControllerGame.Instance.RefreshPaiRestInfo ();
         */
        return(_wall);
    }