using System;
using UnityEngine;

// Token: 0x020000AB RID: 171
public class Gauge : MonoBehaviour
{
	// Token: 0x06000FAB RID: 4011 RVA: 0x0012ED14 File Offset: 0x0012CF14
	public void Setup(string type, Character character, float t)
	{
		this.fillImg.localScale = this.startScale;
		this.fillImg.localPosition = this.startPosition;
		this.count = t * 100f;
		if (type == "Stun" || type == "Dazed")
		{
			this.count = t;
		}
		this.player = character;
		this.startCount = this.count;
		base.gameObject.SetActive(true);
		this.gaugeType = type;
		this.startTime = Links.x.gameplay.seconds;
		if (type == "Sneak")
		{
			this.sprite.sprite = this.sneakSprite;
			this.m.sharedMaterial = this.sneakMaterial;
			return;
		}
		if (type == "Item")
		{
			this.sprite.sprite = this.itemSprite;
			this.m.sharedMaterial = this.itemMaterial;
			return;
		}
		if (type == "Stun")
		{
			this.sprite.sprite = this.stunSprite;
			this.m.sharedMaterial = this.stunMaterial;
			return;
		}
		if (type == "Dazed")
		{
			this.sprite.sprite = this.stunSprite;
			this.m.sharedMaterial = this.stunMaterial;
		}
	}

	// Token: 0x06000FAC RID: 4012 RVA: 0x0012EE6C File Offset: 0x0012D06C
	public void UpdateTime(float t)
	{
		if (t > this.count)
		{
			this.count = t;
			this.startTime = Links.x.gameplay.seconds;
		}
	}

	// Token: 0x06000FAD RID: 4013 RVA: 0x0012EE94 File Offset: 0x0012D094
	private void Awake()
	{
		this.tr = base.transform;
		this.startCount = this.count;
		this.startScale = this.fillImg.localScale;
		this.startPosition = this.fillImg.localPosition;
		base.gameObject.SetActive(false);
	}

	// Token: 0x06000FAE RID: 4014 RVA: 0x0012EEE7 File Offset: 0x0012D0E7
	private void LateUpdate()
	{
		if (this.startCount > 0f)
		{
			this.UpdateGauge();
		}
	}

	// Token: 0x06000FAF RID: 4015 RVA: 0x0012EEFC File Offset: 0x0012D0FC
	private void UpdateGauge()
	{
		float num = (Links.x.gameplay.seconds - this.startTime) / this.count;
		this.fillImg.localScale = new Vector3(this.startScale.x, this.startScale.y, this.startScale.z * num);
		float num2 = 0f;
		if (this.fillImg.localScale.z > 0f)
		{
			num2 = (this.fillImg.localScale.z - this.startScale.x) / 2f * 3.4f;
		}
		this.fillImg.localPosition = new Vector3(num2, this.fillImg.localPosition.y, this.fillImg.localPosition.z);
		if (this.player.neck == this.player.body.tr)
		{
			this.tr.position = this.player.body.HeadPosition(2f);
		}
		else
		{
			this.tr.position = this.player.neck.position + new Vector3(0f, 2f, 0f);
		}
		if (num >= 1f || (this.gaugeType == "Sneak" && !this.player.IsSentient()) || this.player.dead || (this.player.stunned && !this.player.party))
		{
			if (this.gaugeType == "StunTimed")
			{
				this.player.GetUp();
			}
			this.player.EndGauge(this.gaugeType);
		}
	}

	// Token: 0x040019E7 RID: 6631
	public Transform fillImg;

	// Token: 0x040019E8 RID: 6632
	public Transform backImg;

	// Token: 0x040019E9 RID: 6633
	public float count;

	// Token: 0x040019EA RID: 6634
	public float startCount;

	// Token: 0x040019EB RID: 6635
	private Character player;

	// Token: 0x040019EC RID: 6636
	private Transform tr;

	// Token: 0x040019ED RID: 6637
	public RectTransform rt;

	// Token: 0x040019EE RID: 6638
	public float yHeight;

	// Token: 0x040019EF RID: 6639
	public float xOffset;

	// Token: 0x040019F0 RID: 6640
	private Vector3 screenPos;

	// Token: 0x040019F1 RID: 6641
	private Vector3 startScale;

	// Token: 0x040019F2 RID: 6642
	private Vector3 startPosition;

	// Token: 0x040019F3 RID: 6643
	private string gaugeType;

	// Token: 0x040019F4 RID: 6644
	private float startTime;

	// Token: 0x040019F5 RID: 6645
	public Sprite sneakSprite;

	// Token: 0x040019F6 RID: 6646
	public Sprite itemSprite;

	// Token: 0x040019F7 RID: 6647
	public Sprite stunSprite;

	// Token: 0x040019F8 RID: 6648
	public Sprite dazedSprite;

	// Token: 0x040019F9 RID: 6649
	public SpriteRenderer sprite;

	// Token: 0x040019FA RID: 6650
	public Material sneakMaterial;

	// Token: 0x040019FB RID: 6651
	public Material itemMaterial;

	// Token: 0x040019FC RID: 6652
	public Material stunMaterial;

	// Token: 0x040019FD RID: 6653
	public Material dazedMaterial;

	// Token: 0x040019FE RID: 6654
	public MeshRenderer m;
}
