optimized the code according to the requirements

Achievements
Mahamfatimaee 16 hours ago
parent 3224f24efd
commit 58edc43cdd

@ -9530,7 +9530,7 @@ MonoBehaviour:
skipCoinObj: {fileID: 1790415148045804968}
skipCoinValueText: {fileID: 1024550697}
hintcheck: 0
debugHints: 0
debugHints: 1
--- !u!114 &1790415148045805191
MonoBehaviour:
m_ObjectHideFlags: 0
@ -10788,7 +10788,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1790415148045805237}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1790415148045805217}
m_TargetAssemblyTypeName: GamePlayManager, Assembly-CSharp
m_MethodName: HintCheck
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &1790415148045805239
MonoBehaviour:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

@ -6,19 +6,19 @@ using UnityEngine.UI;
using System;
public class instantiateprefab : MonoBehaviour
{
public GameObject prefab, panel;
public GameObject[] positionArray;
public Transform parentTf;
public GameObject panel;
public Button TAdsbutton;
public Slider SliderPrefabSpawner;
public Transform ParentOfLayout;
public List<LevelGroup> levelGroups;
public int numberOfInstances = 9;
public int minIndex = 0;
public int maxIndex = 8;
public int points;
public string Mode;
public string pointtext;
public AchievementManager manger;
public string pointtext;
public AchievementManager manger;
public ScoreButton score;
public Button changeValueButton;
public GameManager gameManager;
public GameManager gameManager;
private List<Slider> sliders = new List<Slider>();
public GamePlayManager gameplay;
public Slider sliderprefabalue, hintcheckvalue;
@ -30,37 +30,14 @@ public class instantiateprefab : MonoBehaviour
}
void Start()
{
for (int i = 0; i < positionArray.Length; i++)
{
if (positionArray[i] != null)
{
InstantiateSlider(i, positionArray[i].transform.position);
}
}
InstantiateExtraSlider(positionArray.Length, new Vector3(0, -100, 0));
InstantiateExtraSlider(positionArray.Length + 1, new Vector3(0, -200, 0));
InstantiateExtraSlider(positionArray.Length + 2, new Vector3(0, -300, 0));
InstantiateExtraSlider(positionArray.Length + 3, new Vector3(0, -400, 0));
// Add listener to the button
changeValueButton.onClick.AddListener(ChangeSliderValueAtIndex7);
changeValueButton.onClick.AddListener(SliderValueAtIndex9);
changeValueButton.onClick.AddListener(ChangeSliderValueAtIndex8);
changeValueButton.onClick.AddListener(SliderValueAtIndex10);
InstantiatePrefabsInLayoutGroup();
}
private void InstantiateSlider(int index, Vector3 position)
/* private void InstantiateSlider(int index, Vector3 position)
{
GameObject sliderObject = Instantiate(prefab, position, Quaternion.identity, parentTf);
GameObject sliderObject = Instantiate(prefab, position, Quaternion.identity, ParentOfLayout);
sliderObject.GetComponent<ScoreButton>().myIndex = index + 1;
foreach (Transform child in sliderObject.transform)
@ -90,114 +67,57 @@ public class instantiateprefab : MonoBehaviour
}
}
public void InstantiateExtraSlider(int index, Vector3 position)
{
GameObject sliderObject = Instantiate(prefab, position, Quaternion.identity, parentTf);
sliderObject.GetComponent<ScoreButton>().myIndex = index + 1;
// Assign a name to the slider object based on the achievement list or create a fallback for extra sliders
if (index < manger.AchievementList.Count)
{
string achievementName = manger.AchievementList[index].DisplayName.ToString();
sliderObject.name = "Slider - " + achievementName;
}
else
{
sliderObject.name = "" + (index - manger.AchievementList.Count + 1);
}
// Set the Mode text for extra sliders
foreach (Transform child in sliderObject.transform)
{
if (child.name == Mode)
{
Text modeText = child.GetComponent<Text>();
if (modeText != null)
{
// Set mode text based on the achievement name if within the achievement list range
if (index < manger.AchievementList.Count)
{
modeText.text = manger.AchievementList[index].DisplayName.ToString();
}
else
{
modeText.text = "" + (index - manger.AchievementList.Count + 1);
}
}
}
if (child.name == pointtext)
{
Text progress = child.GetComponent<Text>();
progress.text = (index < manger.AchievementList.Count) ?
manger.AchievementList[index].ProgressGoal + " / " + manger.AchievementList[index].ProgressSuffix.ToString() :
"0 / 10"; // Fallback for extra sliders
}
}
Slider slider = sliderObject.GetComponent<Slider>();
if (slider != null)
{
slider.minValue = 0;
slider.maxValue = (index < manger.AchievementList.Count) ? manger.AchievementList[index].ProgressGoal : 10;
sliders.Add(slider); // Store the slider in the list
}
}
}*/
public void ChangeSliderValueAtIndex7()
public void Watch10AdsButton()
{
if (sliders.Count > 6)
{
Slider sliderAtIndex7 = sliders[6];
sliderAtIndex7.value += 1;
sliderAtIndex7.maxValue = 10;
sliderAtIndex7.minValue = 0;
Slider TenAds = sliders[6];
TenAds.value += 1;
TenAds.maxValue = 10;
TenAds.minValue = 0;
}
}
public void ChangeSliderValueAtIndex8()
public void Watch20Adsutton()
{
if (sliders.Count > 7)
{
Slider sliderAtIndex8 = sliders[7];
sliderAtIndex8.value += 1;
sliderAtIndex8.maxValue = 20;
sliderAtIndex8.minValue = 0;
Slider TwentyAds = sliders[7];
TwentyAds.value += 1;
TwentyAds.maxValue = 20;
TwentyAds.minValue = 0;
if(TwentyAds.value==20)
{
TwentyAds.maxValue = 20;
}
}
}
public void Update()
{
SliderValueAtIndex9();
SliderValueAtIndex10();
HintandPipeRotationAchivementValue();
}
public void SliderValueAtIndex9()
public void HintandPipeRotationAchivementValue()
{
if (sliders.Count > 8)
if (sliders.Count > 5)
{
Slider sliderAtIndex9 = sliders[8];
sliderAtIndex9.value = sliderprefabalue.value;
sliderAtIndex9.maxValue = 1000;
// score.completetargets = value;
Slider Hint = sliders[5];
Hint.value = hintcheckvalue.value;
Hint.maxValue = 1000;
}
}
public void SliderValueAtIndex10()
{
if (sliders.Count > 5)
if (sliders.Count > 8)
{
Slider sliderAtIndex10 = sliders[5];
sliderAtIndex10.value = hintcheckvalue.value;
sliderAtIndex10.maxValue = 1000;
Slider PipeRotationvalue = sliders[8];
PipeRotationvalue.value = sliderprefabalue.value;
PipeRotationvalue.maxValue = 1000;
}
}
@ -211,9 +131,13 @@ public class instantiateprefab : MonoBehaviour
{
if (sliders.Count > 7)
{
Slider sliderAtIndex8 = sliders[7];
sliderAtIndex8.maxValue = 20;
sliderAtIndex8.minValue = 0;
Slider twentyAds = sliders[7];
twentyAds.maxValue = 20;
if(twentyAds.value==20)
{
TAdsbutton.interactable = false;
}
}
}
@ -222,32 +146,61 @@ public class instantiateprefab : MonoBehaviour
panel.SetActive(false);
}
public void ChangeTotalvalue()
{
for (int i = 0; i < sliders.Count; i++)
{
if (levelGroups[i].CompletedLevel == levelGroups[i].TotalLevel)
{
sliders[i].maxValue = levelGroups[i].TotalLevel;
// Increment the TotalLevel by 5 immediately
levelGroups[i].TotalLevel += 5;
/* public void ChangeTotalvalue()
{
for (int i = 0; i < sliders.Count; i++)
{
if (levelGroups[i].CompletedLevel == levelGroups[i].TotalLevel)
{
sliders[i].maxValue = levelGroups[i].TotalLevel;
// Increment the TotalLevel by 5 immediately
levelGroups[i].TotalLevel += 5;
score.completetargets += 1;
score.points += 50 * score.myIndex;
score.completetargets += 1;
score.points += 50 * score.myIndex;
// score. targetText.text = "" + completetargets.ToString();
// score. targetText.text = "" + completetargets.ToString();
if (levelGroupButton != null)
{
levelGroupButton.UpdateUI();
}
}
}
}*/
private void InstantiatePrefabsInLayoutGroup()
{
for (int i = 0; i < numberOfInstances; i++)
{
Slider instance = Instantiate(SliderPrefabSpawner);
instance.transform.SetParent(ParentOfLayout, false);
instance.transform.localScale = Vector3.one;
instance.transform.localPosition = Vector3.zero;
ScoreButton scoreButton = instance.GetComponent<ScoreButton>();
if (scoreButton != null)
{
scoreButton.myIndex = i + 1;
scoreButton.levelname.text = manger.AchievementList[i].DisplayName;
}
if (levelGroupButton != null)
{
levelGroupButton.UpdateUI();
}
sliders.Add(instance);
if (i < 5)
{
instance.minValue = 0;
instance.maxValue = levelGroups[i].TotalLevel;
instance.value = levelGroups[i].CompletedLevel;
}
}
}
}
}

@ -41,32 +41,33 @@ public class ScoreButton : MonoBehaviour
PointShowText.SetActive(true);
completeclaimbutton.SetActive(false);
if (slider.maxValue < 50)
{
points += 50 * myIndex;
completetargets += 1;
targetText.text = "" + completetargets.ToString();
SavePoints();
// slider.maxValue += 5;
if (myIndex != 7&&myIndex!=8)
if (myIndex<=5&& slider.maxValue < 50)
{
slider.maxValue += 5;
points += 50 * myIndex;
// pointsAwarded = true;
}
pointsAwarded = true;
UpdateProgressText();
}

@ -568,10 +568,8 @@ public void Undo()
Debug.Log("hint check");
hintslider.value += 1;
valas += 1;
// Save the hintslider value to PlayerPrefs
PlayerPrefs.SetFloat("HintSliderValue", hintslider.value);
PlayerPrefs.Save(); // Make sure to call Save() to persist changes
PlayerPrefs.Save();
boolcheck.hintcheck = false;
}

@ -2633,7 +2633,7 @@ MonoBehaviour:
LockOverlay: 0
AchievedIcon: {fileID: 21300000, guid: 0d8865599692486aa71d755c6f5687f2, type: 3}
Spoiler: 0
Progression: 1
Progression: 0
ProgressGoal: 50
NotificationFrequency: 0
ProgressSuffix:
@ -2703,7 +2703,7 @@ MonoBehaviour:
ProgressGoal: 0
NotificationFrequency: 0
ProgressSuffix:
- Key: Watch Ads
- Key: Watch Ads
DisplayName: Watch 20 Ads
Description: Ads
LockedIcon: {fileID: 0}
@ -2714,9 +2714,9 @@ MonoBehaviour:
ProgressGoal: 0
NotificationFrequency: 0
ProgressSuffix:
- Key: Pipe Rotation Count
DisplayName: Pipe Rotation Number
Description: Pipe Rotation
- Key: Watch Ads
DisplayName: PipeRotationCount
Description: Ads
LockedIcon: {fileID: 0}
LockOverlay: 0
AchievedIcon: {fileID: 0}

@ -50,7 +50,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7d4d1386b58481ac8338b97496451549, type: 3}
m_Name:
m_EditorClassIdentifier:
slider: {fileID: 0}
slider: {fileID: 5885820980592021006, guid: dda90d41bf5587f4ea2905ee372f4608, type: 3}
hintslider: {fileID: 1051964499492098825, guid: 31cb6cbadbc791844a2c5d75437211f4,
type: 3}
_cellPrefab:
- {fileID: 1790415148045804981, guid: 4f7a5f448033b8e4c895a7d4fcb89e3e, type: 3}
- {fileID: 1790415148045804992, guid: 6fd6ed12f3e506d44b59ac7c04ffb652, type: 3}
@ -62,11 +64,15 @@ MonoBehaviour:
- {fileID: 1790415148045804980, guid: 5f338f4bcc2ac7e438ef280b1357749e, type: 3}
menuPopup: {fileID: 0}
gameOverPopup: {fileID: 0}
rankedUpPopup: {fileID: 0}
starLevel: {fileID: 0}
nextStarLevel: {fileID: 0}
LevelCompleteText: {fileID: 0}
RankedUpText: {fileID: 0}
confettiParticle: {fileID: 0}
nextBtn: {fileID: 0}
closeBtn: {fileID: 0}
fillBar: {fileID: 0}
goParticle: {fileID: 0}
_levelContainer: {fileID: 4385550723351327410}
_space: 0
levelGroups:
@ -75,6 +81,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: d606e6845dd447e2bf40638facbc7c7e, type: 2}
- {fileID: 11400000, guid: e5f4032f73074b45aa468e2ecf71f81c, type: 2}
- {fileID: 11400000, guid: cf6a4a494d684237bcf9ce01e1ac77ae, type: 2}
boolcheck: {fileID: 0}
allCellList:
- {fileID: 0}
- {fileID: 0}
@ -111,7 +118,10 @@ MonoBehaviour:
closeGameOver: 0
row: 0
column: 0
levepopup: {fileID: 0}
prefeb: {fileID: 3103223411245280076, guid: a839d31fd6b8ca7409802d7859982b69, type: 3}
pointadd: {fileID: 0}
valas: 0
--- !u!222 &1820762587381449173
CanvasRenderer:
m_ObjectHideFlags: 0

@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 3302384439994717084}
- component: {fileID: 5312961109301411640}
m_Layer: 5
m_Name: mode
m_Name: Levelsname
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -34,8 +34,8 @@ 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: -82.32208, y: 99}
m_SizeDelta: {x: 464.556, y: 90.4606}
m_AnchoredPosition: {x: -113.90439, y: 838.02576}
m_SizeDelta: {x: 685.4338, y: 131.4911}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3302384439994717084
CanvasRenderer:
@ -78,7 +78,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: New Text
m_Text: Pipe Rotation Count
--- !u!1 &701865384461308020
GameObject:
m_ObjectHideFlags: 0
@ -113,8 +113,8 @@ 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: 252.3002, y: 11.05}
m_SizeDelta: {x: 535.7232, y: 227.85}
m_AnchoredPosition: {x: 379.81732, y: 710.184}
m_SizeDelta: {x: 790.4382, y: 331.1966}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1093246351141616226
CanvasRenderer:
@ -271,8 +271,8 @@ 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: 0.0421, y: 54.363792}
m_SizeDelta: {x: 660.1237, y: 4.009}
m_AnchoredPosition: {x: 7.6207, y: 773.1437}
m_SizeDelta: {x: 973.986, y: 5.8274}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5622952279504925448
CanvasRenderer:
@ -424,8 +424,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.25}
m_AnchorMax: {x: 1, y: 0.75}
m_AnchoredPosition: {x: -89.20987, y: 10.0005}
m_SizeDelta: {x: 290.7863, y: 41.892}
m_AnchoredPosition: {x: -124.06708, y: 708.6584}
m_SizeDelta: {x: 505.117, y: 65.4288}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3287479843908220233
GameObject:
@ -461,7 +461,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 13.1609955, y: 0}
m_AnchoredPosition: {x: 13.161011, y: 0}
m_SizeDelta: {x: 26.322, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3985938169314706363
@ -536,8 +536,8 @@ 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: 252.5, y: 10.1}
m_SizeDelta: {x: 932.384, y: 394.0165}
m_AnchoredPosition: {x: 380.11218, y: 708.8029}
m_SizeDelta: {x: 1375.6951, y: 572.7319}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3624833579523548153
CanvasRenderer:
@ -611,8 +611,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.25}
m_AnchorMax: {x: 1, y: 0.75}
m_AnchoredPosition: {x: -79.75073, y: 10}
m_SizeDelta: {x: 309.6985, y: 41.893}
m_AnchoredPosition: {x: -110.11044, y: 708.6576}
m_SizeDelta: {x: 533.0214, y: 65.4304}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2759710510704159206
CanvasRenderer:
@ -687,8 +687,8 @@ 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: -293.7, y: 6}
m_SizeDelta: {x: 63.6645, y: 83.1183}
m_AnchoredPosition: {x: -425.78406, y: 702.8434}
m_SizeDelta: {x: 93.9344, y: 120.8186}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8305387493103526714
CanvasRenderer:
@ -762,8 +762,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.4013087}
m_AnchorMax: {x: 0.5, y: 0.4013087}
m_AnchoredPosition: {x: 241.45422, y: 2.3703613}
m_SizeDelta: {x: 54.0873, y: 57.6009}
m_AnchoredPosition: {x: 363.8145, y: 696.67206}
m_SizeDelta: {x: 79.8037, y: 83.7271}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3504944960721326489
CanvasRenderer:
@ -839,8 +839,8 @@ 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: 252.31, y: 10.975}
m_SizeDelta: {x: 927.16, y: 412.0821}
m_AnchoredPosition: {x: 379.8319, y: 710.0748}
m_SizeDelta: {x: 1367.9875, y: 598.9916}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6746793553173100828
CanvasRenderer:
@ -970,8 +970,8 @@ 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: -49, y: 11.3}
m_SizeDelta: {x: 193.0787, y: 39.7046}
m_AnchoredPosition: {x: -64.73895, y: 710.54736}
m_SizeDelta: {x: 284.8799, y: 57.7135}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4793097550234252573
CanvasRenderer:
@ -1042,7 +1042,7 @@ RectTransform:
m_GameObject: {fileID: 8666872430276523867}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.5039, y: 1.5039, z: 1.5039}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2018436702493492130}
@ -1130,7 +1130,7 @@ MonoBehaviour:
PointShowText: {fileID: 701865384461308020}
completeclaimbutton: {fileID: 702766074229443011}
points: 0
completetargets: 0
completetargets: 1
pointText: {fileID: 6332626369289920644}
targetText: {fileID: 6785021422751795216}
btn: {fileID: 3103223411245280076, guid: a839d31fd6b8ca7409802d7859982b69, type: 3}
@ -1174,8 +1174,8 @@ 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: 0.1798, y: 48.558437}
m_SizeDelta: {x: 681.9675, y: 193.0229}
m_AnchoredPosition: {x: 7.8239, y: 764.705}
m_SizeDelta: {x: 1006.216, y: 280.573}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3313326267222951269
CanvasRenderer:

Loading…
Cancel
Save