/// <summary> /// 选择了一种工具后的响应方法 /// </summary> /// <param name="tool">Tool.</param> /// <param name="mapItem">Map item.</param> private void OnToolChoiceButtonClick(Consumables tool, MapItem mapItem) { QuitToolChoicePlane(); // 背包中的工具数量-1 player.RemoveItem(tool, 1); // 播放对应的音效 SoundManager.Instance.PlayAudioClip("MapEffects/" + mapItem.audioClipName); Vector3 mapItemPos = mapItem.transform.position; MapGenerator mapGenerator = TransformManager.FindTransform("ExploreManager").GetComponent <MapGenerator> (); int[,] mapWalkableInfoArray = mapGenerator.mapWalkableInfoArray; switch (mapItem.mapItemType) { case MapItemType.Stone: case MapItemType.Tree: (mapItem as Obstacle).DestroyObstacle(null); mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1; break; case MapItemType.TreasureBox: TreasureBox tb = mapItem as TreasureBox; tb.UnlockTreasureBox(null); mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1; mapGenerator.SetUpAwardInMap(tb.awardItem, mapItemPos); break; case MapItemType.Plant: Plant plant = mapItem as Plant; mapGenerator.AddMapItemInPool(mapItem.transform); mapWalkableInfoArray [(int)mapItemPos.x, (int)mapItemPos.y] = 1; mapGenerator.SetUpAwardInMap(plant.attachedItem, mapItemPos); break; } SetUpBottomConsumablesButtons(); }