You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/LevelGroup.cs

104 lines
2.8 KiB
C#

2 months ago
/*
http://www.cgsoso.com/forum-211-1.html
CG Unity3d Unity3d VIP
CGSOSO CG
daily assets update for try.
U should buy the asset from home store if u use it in your project!
*/
using UnityEngine;
[CreateAssetMenu(fileName = "LevelGroup", menuName = "PipeOut/Create LevelGroup", order = 1)]
public class LevelGroup : ScriptableObject
{
1 month ago
public string LevelGroupName = "Easy";
public int TotalLevel = 50;
public string ResourcesFolderPath = "Easy\\";
public Color bgColor;
public int StarXPReward = 1;
public int NoOfHint = 4;
public Sprite LevelDetailBG;
public Sprite LevelHeaderBG;
public int CompletedLevel
{
get
{
return PlayerPrefs.GetInt("Completed_" + LevelGroupName.ToUpper(), 0);
}
set
{
PlayerPrefs.SetInt("Completed_" + LevelGroupName.ToUpper(), value);
}
}
public int CompletedLevel_Timer
{
get
{
return PlayerPrefs.GetInt("Completed_" + LevelGroupName.ToUpper() + "_Timer", 0);
}
set
{
PlayerPrefs.SetInt("Completed_" + LevelGroupName.ToUpper() + "_Timer", value);
}
}
public float AverageCompletedTime
{
get
{
return PlayerPrefs.GetFloat("AverageTime_" + LevelGroupName.ToUpper(), 0f);
}
set
{
PlayerPrefs.SetFloat("AverageTime_" + LevelGroupName.ToUpper(), value);
}
}
public string AverageCompletedTimeString
{
get
{
int num = Mathf.FloorToInt(AverageCompletedTime);
return (num / 60).ToString("00") + " : " + (num % 60).ToString("00");
}
}
public void SetLevelCompleted(int LevelNo, float TimeToComplete)
{
if (!GamePlayManager.isTimerLevel)
{
if (CompletedLevel <= LevelNo)
{
CompletedLevel = LevelNo;
}
float averageCompletedTime = AverageCompletedTime;
averageCompletedTime = Mathf.Abs(averageCompletedTime * (float)(CompletedLevel - 1) + TimeToComplete);
averageCompletedTime = (AverageCompletedTime = averageCompletedTime / (float)CompletedLevel);
}
else
{
if (CompletedLevel_Timer <= LevelNo)
{
CompletedLevel_Timer = LevelNo;
}
float averageCompletedTime = AverageCompletedTime;
averageCompletedTime = Mathf.Abs(averageCompletedTime * (float)(CompletedLevel_Timer - 1) + TimeToComplete);
averageCompletedTime = (AverageCompletedTime = averageCompletedTime / (float)CompletedLevel_Timer);
}
}
2 months ago
}