/// <summary> /// 铁镐 /// </summary> public void Mattock() { List <Vector2> _tempPos = new List <Vector2> { GM.MStartPos.MPosition + Vector2Int.left, GM.MStartPos.MPosition + Vector2Int.right, GM.MStartPos.MPosition + Vector2Int.up, GM.MStartPos.MPosition + Vector2Int.down }; foreach (Vector2 _e in _tempPos) { if (_e.x < 0 || _e.x > (Dict.MapWidth - 1) || _e.y < 0 || _e.y > (Dict.MapHeight - 1)) { continue; } if (GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].IsWall) { GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].Clear(); } } SaveHeroInfo.Props[13] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 芭蕉扇 /// </summary> public void BaJiaoShan() { string _dbName = Dict.SqlDBName; string _tabName = "map_obj"; int _mapWidth = Dict.MapWidth; int _mapHeight = Dict.MapHeight; for (int _x = 0; _x < _mapWidth; _x++) { for (int _y = 0; _y < _mapHeight; _y++) { if (GM.MPointGrid[_x, _y].IsObj) { int _mapObjId = GM.MPointGrid[_x, _y].MMapObjId; if (_mapObjId == 0) { continue; } //MapObj的TypeId == 70 即火焰山 if (Dict.GetInt(_dbName, _tabName, "type_id", _mapObjId) == 70) { //0 显示 1 消失 Dict.SetInt(_dbName, _tabName, "value", _mapObjId, 1); GM.MPointGrid[_x, _y].UpdateSelf(); ////保存Map Obj Id数据 //GM.SaveMapObjById(GM.MPointGrid[Mathf.RoundToInt(_x), Mathf.RoundToInt(_y)].MMapObjId); } } } } SaveHeroInfo.Props[11] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 向上飞行器 /// </summary> public void FloorUp() { //type id == 7 向上飞行器 int _tarMapId = SaveHeroInfo.CurMapId + 1 <= 68 ? SaveHeroInfo.CurMapId + 1 : 68; GM.EnterMapId(_tarMapId); SaveHeroInfo.Props[6] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 向下飞行器 /// </summary> public void FloorDown() { //type id == 6 向下飞行器 int _tarMapId = SaveHeroInfo.CurMapId - 1 >= 1 ? SaveHeroInfo.CurMapId - 1 : 1; GM.EnterMapId(_tarMapId); SaveHeroInfo.Props[5] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 圣水的功能 /// </summary> public void HolyWater() { //增加生命值 = ( 攻 + 防 ) * 10; int _increase = (SaveHeroInfo.Attributes[2] + SaveHeroInfo.Attributes[3]) * 10; GM.DoChange(1, _increase); //0 出现 1 为消失 SaveHeroInfo.Props[3] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 地震卷轴 /// </summary> public void ShakeScroll() { //string _dbName = Dict.SqlDBName; int _mapWidth = Dict.MapWidth; int _mapHeight = Dict.MapHeight; string _dbName = ""; string _tabName = ""; //暗墙和彩蛋墙全部移除 for (int _x = 0; _x < _mapWidth; _x++) { for (int _y = 0; _y < _mapHeight; _y++) { if (GM.MPointGrid[_x, _y].IsWall) { _dbName = Dict.WallDBName; _tabName = "map_" + SaveHeroInfo.CurMapId; //普通墙体全部移除 Dict.SetInt(_dbName, _tabName, "value", GM.MPointGrid[_x, _y].MWallId, 1); GM.MPointGrid[_x, _y].UpdateSelf(); } if (GM.MPointGrid[_x, _y].IsObj && GM.MPointGrid[_x, _y].MMapObjId != 0) { _dbName = Dict.SqlDBName; _tabName = "map_obj"; int _mapObjTypeId = Dict.GetInt(_dbName, _tabName, "type_id", GM.MPointGrid[_x, _y].MMapObjId); _tabName = "map_obj_type"; if (Dict.GetInt(_dbName, _tabName, "id", _mapObjTypeId) == 67 || Dict.GetInt(_dbName, _tabName, "id", _mapObjTypeId) == 72 || Dict.GetInt(_dbName, _tabName, "id", _mapObjTypeId) == 73 || Dict.GetInt(_dbName, _tabName, "id", _mapObjTypeId) == 74 || Dict.GetInt(_dbName, _tabName, "id", _mapObjTypeId) == 75 ) { Dict.SetInt(_dbName, "map_obj", "value", GM.MPointGrid[_x, _y].MMapObjId, 1); } GM.MPointGrid[_x, _y].UpdateSelf(); } } } SaveHeroInfo.Props[14] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }
/// <summary> /// 猴毛 /// </summary> public void HouMao() { if (SaveHeroInfo.CurMapId != 61) { return; } string _dbName = Dict.SqlDBName; string _tabName = "map_obj"; int _mapWidth = Dict.MapWidth; int _mapHeight = Dict.MapHeight; bool _attack = false; for (int _x = 0; _x < _mapWidth; _x++) { for (int _y = 0; _y < _mapHeight; _y++) { if (GM.MPointGrid[_x, _y].IsObj) { //是怪物 int _mapObjId = GM.MPointGrid[_x, _y].MMapObjId; if (_mapObjId == 0) { continue; } //MapObj的TypeId == 14 即怪物 if (Dict.GetInt(_dbName, _tabName, "type_id", _mapObjId) == 14) { int _tarX = Dict.GetInt(_dbName, _tabName, "pos_x", _mapObjId); int _tarY = Dict.GetInt(_dbName, _tabName, "pos_y", _mapObjId) - 1; //如果位置为空 if (GM.MPointGrid[_tarX, _tarY].MGameObject == null) { Sprite _sprite = Resources.LoadAll <Sprite>("Textures/Actor01")[12]; GM.GetMap().CreateMapObj(GM.GetMap().Path.transform, _sprite, _tarX, _tarY); //保存Map Obj Id数据 //GM.SaveMapObjById(GM.MPointGrid[Mathf.RoundToInt(_tarY), Mathf.RoundToInt(_tarY)].MMapObjId); } //如果位置不为空 else { GM.DestroyMapObj(GM.MPointGrid[_x, _y]); GM.DestroyMapObj(GM.MPointGrid[_tarX, _tarY]); GM.UpdateSwitch(497); SaveHeroInfo.Props[12] = 1; SaveHeroInfo.RefreshUI(); _attack = true; //保存Map Obj Id数据 //GM.SaveMapObjById(GM.MPointGrid[Mathf.RoundToInt(_tarY), Mathf.RoundToInt(_tarY)].MMapObjId); } } } } } if (_attack) { Object.Instantiate(Resources.Load <Object>("VFXs/hit-white-1"), GM.MStartPos.MPosition, Quaternion.identity); //音效 GM.MyCommon.MusicSource[0].Play(); } GM.CloseUIBox(); }
/// <summary> /// 炸药 /// </summary> public void Explosive() { string _dbName = Dict.SqlDBName; string _tabName = "map_obj"; //需要遍历的位置 List <Vector2> _tempPos = new List <Vector2> { GM.MStartPos.MPosition + Vector2Int.left, GM.MStartPos.MPosition + Vector2Int.right, GM.MStartPos.MPosition + Vector2Int.up, GM.MStartPos.MPosition + Vector2Int.down }; //去除超出边界的点 foreach (Vector2 _e in _tempPos) { //限定边界之内 if (_e.x >= 0 && _e.x <= 10 && _e.y >= 0 && _e.y <= 10) { int _mapObjId = GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].MMapObjId; if (_mapObjId == 0) { continue; } //MapObj TypeId == 14 为怪物 if (Dict.GetInt(_dbName, _tabName, "type_id", _mapObjId) == 14) { //MapObj MiniTypeId 为普通怪物 可以炸 switch (Dict.GetInt(_dbName, _tabName, "mini_type_id", _mapObjId)) { case 1: //为普通怪物 case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 10: case 11: case 12: case 13: case 14: case 16: case 17: case 18: case 19: case 21: case 22: case 24: case 25: case 26: case 27: case 28: case 29: case 35: case 38: case 39: //清除 前后左右 的普通怪物 //0存在 1消失 Dict.SetInt(_dbName, _tabName, "value", GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].MMapObjId, 1); //刷新点状态 GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].UpdateSelf(); ////保存Map Obj Id数据 //GM.SaveMapObjById(GM.MPointGrid[Mathf.RoundToInt(_e.x), Mathf.RoundToInt(_e.y)].MMapObjId); break; case 9: //为Boss case 15: case 20: case 23: case 30: case 31: case 32: case 33: case 34: case 36: case 37: case 40: break; } } } } SaveHeroInfo.Props[8] = 1; SaveHeroInfo.RefreshUI(); GM.CloseUIBox(); }