Skip to content

Commit

Permalink
simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
hani-sayegh committed Mar 10, 2017
1 parent cca0bf3 commit e3abf8e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
10 changes: 5 additions & 5 deletions Assets/Scene/Test Scenes/Networking Test.unity
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ RectTransform:
m_GameObject: {fileID: 202315549}
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_LocalScale: {x: 1, y: 10, z: 1}
m_Children: []
m_Father: {fileID: 101545229}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -0.5}
m_SizeDelta: {x: 1, y: 1}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &202315551
Expand All @@ -397,7 +397,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
Expand Down
35 changes: 13 additions & 22 deletions Assets/hanisstuff/scripts/TimeLineUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class TimeLineUI : MonoBehaviour
void Start()
{
playerTimeLine = GameObject.FindGameObjectWithTag("PlayerTimeLine").GetComponent<Image>();
//once drawn the first time should never be touched again.
playerTimeLine.rectTransform.localScale = new Vector3(Screen.width, 55, 1);
//thisTimeLine = GetComponent<LineRenderer>();
startTime = Time.time;
latestSecond = intervalCount;
Expand Down Expand Up @@ -54,10 +56,13 @@ void Update()
playerTimeLineScale = widthBetweenSeconds * Time.time;
}

foreach (var second in secondsOnScreen)
{
animate(second);
}

if (transform.anchoredPosition.x < midpoint)
{
//once drawn the first time should never be touched again.
playerTimeLine.rectTransform.localScale = new Vector3(widthBetweenSeconds * Time.time, 1, 1);

//transform.anchoredPosition = Vector2.right * direction * widthBetweenSeconds * (Time.time - startTime);
transform.anchoredPosition += Vector2.right * direction * widthBetweenSeconds * Time.deltaTime;
Expand All @@ -68,7 +73,6 @@ void Update()
{
foreach (var second in secondsOnScreen)
{
animate(second);
second.rectTransform.anchoredPosition += Vector2.left * direction * widthBetweenSeconds * Time.deltaTime;
var charOrigin = second.rectTransform.anchoredPosition.x;
//In pixels
Expand Down Expand Up @@ -108,27 +112,14 @@ void Update()
void animate(Text second)
{
var currPos = second.rectTransform.position.x;
var offsetFromMidpoint = 150;
if (currPos < midpoint + offsetFromMidpoint && currPos > midpoint)
//10 percent of the screen
var offsetFromMidpoint = Screen.width / 10;
var tickPosition = transform.position.x;
if (currPos < tickPosition + offsetFromMidpoint && currPos > tickPosition - offsetFromMidpoint)
{
var distanceFromMidpoint = currPos - midpoint;
var ratio = (offsetFromMidpoint - distanceFromMidpoint) / offsetFromMidpoint;
second.fontSize = 15 + (int)(ratio * 15);
//remove this
if (second.fontSize > 30)
second.fontSize = 30;
}
else if (currPos > midpoint - offsetFromMidpoint && currPos < midpoint)
{
//take abs
var distanceFromMidpoint = midpoint - currPos;
var distanceFromMidpoint = Mathf.Abs(currPos - tickPosition);
var ratio = (offsetFromMidpoint - distanceFromMidpoint) / offsetFromMidpoint;
second.fontSize = 15 + (int)(ratio * 15);
}
}
}


//current + scale* 15;
//015--------------|301
// distance = x;
}

0 comments on commit e3abf8e

Please sign in to comment.