Skip to content

Commit

Permalink
v0.1.2.x
Browse files Browse the repository at this point in the history
add random next
  • Loading branch information
StellEdge committed Mar 17, 2021
1 parent 28439ab commit f7f4685
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 1 deletion.
1 change: 1 addition & 0 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Assets\scripts\NAudioPlayer.cs" />
<Compile Include="Assets\scripts\PlayButton.cs" />
<Compile Include="Assets\scripts\ProgressIcon.cs" />
<Compile Include="Assets\scripts\RandomNext.cs" />
<Compile Include="Assets\scripts\Reshuffle.cs" />
<Compile Include="Assets\scripts\Scrolling.cs" />
<Compile Include="Assets\scripts\SongProgressbar.cs" />
Expand Down
Binary file added Assets/Graphics/random.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 132 additions & 0 deletions Assets/Scenes/gameplay.unity
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ RectTransform:
- {fileID: 1610915245}
- {fileID: 764225839}
- {fileID: 1052748394}
- {fileID: 1329624221}
m_Father: {fileID: 195393353}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -2456,6 +2457,137 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1307926492}
m_CullTransparentMesh: 0
--- !u!1 &1329624220
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1329624221}
- component: {fileID: 1329624225}
- component: {fileID: 1329624224}
- component: {fileID: 1329624223}
- component: {fileID: 1329624222}
m_Layer: 5
m_Name: RandomNextButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1329624221
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329624220}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 85128991}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -151.9, y: -53}
m_SizeDelta: {x: 32, y: 32}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1329624222
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329624220}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ed9247e65ec4394fa63667845692f35, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1329624223
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329624220}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1329624224}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1329624224
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329624220}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 671a499bcb827d242a025155b5fb3636, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1329624225
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329624220}
m_CullTransparentMesh: 0
--- !u!1 &1332371255
GameObject:
m_ObjectHideFlags: 0
Expand Down
1 change: 0 additions & 1 deletion Assets/scripts/MusicLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ public static void ReshuffleSongList()
SongList = Shuffle<MusicData>(SongList);
CreateWheelItems(SongList);
}

public static List<T> Shuffle<T>(List<T> original)
{
System.Random randomNum = new System.Random();
Expand Down
3 changes: 3 additions & 0 deletions Assets/scripts/MusicWheelItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class MusicWheelItem : MonoBehaviour
public Button button;
public Image image;
public Image side_image;
public bool played;
// Start is called before the first frame update
void Start()
{
Expand Down Expand Up @@ -68,6 +69,7 @@ void Start()
side_image.transform.localPosition = new Vector3(-1.2f, 0, 0);
side_image.color = new Color(0 / 255f, 0 / 255f, 0 / 255f, 125 / 255f);
side_image_obj.SetActive(false);
played = false;
}

// Update is called once per frame
Expand Down Expand Up @@ -101,6 +103,7 @@ public void ButtonClicked()
{
print(string.Format("{0} clicked. Play {1}", index,text_title_tm.text));
side_image_obj.SetActive(true);
played = true;
GameObject.Find("SongTitleText").GetComponent<Text>().text = LanguageManager.UTF8String(MusicLoader.SongList[index].title);
GameObject.Find("SongAnimeText").GetComponent<Text>().text = LanguageManager.UTF8String(MusicLoader.SongList[index].animation);
//text_title_tm.text = LanguageManager.UTF8String(MusicLoader.SongList[index].title);
Expand Down
42 changes: 42 additions & 0 deletions Assets/scripts/RandomNext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RandomNext : MonoBehaviour
{
// Start is called before the first frame update
private Button m_Button;
void Start()
{
m_Button = gameObject.GetComponent<Button>();
m_Button.onClick.AddListener(ButtonOnClickEvent);
}
void Update()
{

}
public void ButtonOnClickEvent()
{
if (MusicPlayer.GetIsPlaying())
{
Debug.Log("Paused");
MusicPlayer.PauseAudio();
}
List<int> itemlist = new List<int>();
for(int i = 0;i< MusicWheelBase.GetWheelItemCount(); i++)
{
MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", i)).GetComponent<MusicWheelItem>();
if (!item_t.played)
{
itemlist.Add(i);
}
}

int index = Random.Range(0,itemlist.Count);
MusicWheelItem item = GameObject.Find("WheelItem"+string.Format("{0}",itemlist[index])).GetComponent<MusicWheelItem>();
item.ButtonClicked();

float pos = Random.Range(0f, 0.8f);
GameObject.Find("SongProgressBar").GetComponent<SongProgressbar>().SetProgress(pos);
}
}
6 changes: 6 additions & 0 deletions Assets/scripts/SongProgressbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ private void OnValueChangedPrivate(float T)

//print("代码控制" + T);
}
public void SetProgress(float T)
{
MusicPlayer.PlayAudioAtPos(T);
m_Scrollbar.value = T;
//print("代码控制" + T);
}

}

0 comments on commit f7f4685

Please sign in to comment.