Skip to content

Commit

Permalink
fixbug slider chickens/flags and setting initials chickens & flags to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
aescurra committed Nov 16, 2017
1 parent 16ba15d commit f740e40
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
25 changes: 14 additions & 11 deletions Unity/Assets/Scenes/LobbyScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ RectTransform:
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: -43, y: 136}
m_AnchoredPosition: {x: -32, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &17061254
Expand Down Expand Up @@ -599,7 +599,7 @@ RectTransform:
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: 134, y: 136}
m_AnchoredPosition: {x: 143, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &195324374
Expand Down Expand Up @@ -667,7 +667,7 @@ RectTransform:
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: -286, y: 135.15}
m_AnchoredPosition: {x: -259, y: 135.15}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &220391682
Expand Down Expand Up @@ -1307,7 +1307,7 @@ RectTransform:
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: -164, y: 135.14996}
m_AnchoredPosition: {x: -146, y: 135.14996}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &358379493
Expand Down Expand Up @@ -1477,6 +1477,8 @@ MonoBehaviour:
numFlagsLabel: {fileID: 1521665277}
healthInputField: {fileID: 273486978}
limitedAmmoToggle: {fileID: 301527853}
chickenSlider: {fileID: 1123134533}
flagsSlider: {fileID: 1671643167}
--- !u!114 &420130620
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -1488,6 +1490,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ddfe587e5cba74d9d8a491e3f4754f8e, type: 3}
m_Name:
m_EditorClassIdentifier:
cursorMode: 0
--- !u!1 &460647000
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1520,7 +1523,7 @@ RectTransform:
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: 76, y: 136}
m_AnchoredPosition: {x: 85, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &460647002
Expand Down Expand Up @@ -2042,7 +2045,7 @@ RectTransform:
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: -102, y: 135.1}
m_AnchoredPosition: {x: -89, y: 135.1}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &692479675
Expand Down Expand Up @@ -2340,7 +2343,7 @@ RectTransform:
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: 194, y: 136}
m_AnchoredPosition: {x: 203, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &812549927
Expand Down Expand Up @@ -2747,7 +2750,7 @@ MonoBehaviour:
m_MinValue: 0
m_MaxValue: 10
m_WholeNumbers: 1
m_Value: 0
m_Value: 1
m_OnValueChanged:
m_PersistentCalls:
m_Calls:
Expand Down Expand Up @@ -2864,7 +2867,7 @@ RectTransform:
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: 17, y: 136}
m_AnchoredPosition: {x: 27, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1167566270
Expand Down Expand Up @@ -3039,7 +3042,7 @@ RectTransform:
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: 256, y: 136}
m_AnchoredPosition: {x: 270, y: 136}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1346605003
Expand Down Expand Up @@ -3890,7 +3893,7 @@ RectTransform:
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: -225, y: 135.14996}
m_AnchoredPosition: {x: -202, y: 135.14996}
m_SizeDelta: {x: 50, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1830720179
Expand Down
4 changes: 2 additions & 2 deletions Unity/Assets/Scripts/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class Globals : MonoBehaviour {
public const int PISTOL_AMMO = 10; //If limitedAmmo is true

//STATIC
public static int numChickens = 0; //initial chickens to gameplay
public static int numFlags = 0; //initial chickens to gameplay
public static int numChickens = 2; //initial chickens to gameplay
public static int numFlags = 2; //initial chickens to gameplay
public static bool limitedAmmo = true;
public static int health = 200;
internal static readonly int MAXTEAMS = 2;
Expand Down
29 changes: 19 additions & 10 deletions Unity/Assets/Scripts/LobbyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ public class LobbyObject : MonoBehaviour {
public Text numFlagsLabel;
public InputField healthInputField;
public Toggle limitedAmmoToggle;

public Slider chickenSlider;
public Slider flagsSlider;
/*
* To set number of chickens per Player into globals variables
* Its necessary pass float to make dynamic method
*/
public void SetChickenToGamePlay(float value){
int va = (int)value;
int temp = (Globals.numChickens == 0) ? 1: Globals.numChickens;
//this only to show/hide chickens in lobby scene
if (Globals.numChickens >= value) chickens[va].SetActive(false);
else chickens[va-1].SetActive(true);
if (Globals.numChickens > value) {
for (int i = Globals.numChickens; i > va; i--) chickens[i-1].SetActive (false);
} else {
for (int i = temp; i <= va; i++) chickens[i-1].SetActive(true);//UI chicken image hide
}
Globals.numChickens = va;//setting num chickens to gameplay
numChickenLabel.text = va.ToString();

}

/*
Expand All @@ -32,9 +38,12 @@ public void SetChickenToGamePlay(float value){
*/
public void SetFlagsToGamePlay(float value){
int va = (int)value;//change to int, because need access idx position in array
//this only to show/hide chickens in lobby scene
if (Globals.numFlags >= value) flags[va].SetActive(false);
else flags[va-1].SetActive(true);
int temp = (Globals.numFlags == 0) ? 1: Globals.numFlags;
if (Globals.numFlags > value) {
for (int i = Globals.numFlags; i > va; i--) flags[i-1].SetActive (false);
} else {
for (int i = temp; i <= va; i++) flags[i-1].SetActive(true);//UI chicken image hide
}
Globals.numFlags = va;//setting num flags to gameplay
numFlagsLabel.text = va.ToString();
}
Expand All @@ -56,10 +65,10 @@ public void setLimitedAmmo(){
// Use this for initialization
void Start () {
healthInputField.text = Globals.health.ToString ();
for(int i = 0; i <= 9; i++){
chickens[i].SetActive(false);//UI chicken image hide
flags[i].SetActive(false);//UI flags image hide
}
for(int i = Globals.numChickens; i <= 9; i++) chickens[i].SetActive(false);//UI chicken image hide
for(int i = Globals.numFlags; i <= 9; i++) flags[i].SetActive(false);//UI flags image hide
chickenSlider.value = Globals.numChickens;
flagsSlider.value = Globals.numFlags;

}

Expand Down

0 comments on commit f740e40

Please sign in to comment.