Add source files
This commit is contained in:
145
Projects/BanquetForFools/Source/Assembly-CSharp/Armor.cs
Normal file
145
Projects/BanquetForFools/Source/Assembly-CSharp/Armor.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DarkTonic.MasterAudio;
|
||||
using UnityEngine;
|
||||
|
||||
// Token: 0x02000013 RID: 19
|
||||
public class Armor : MonoBehaviour
|
||||
{
|
||||
// Token: 0x06000192 RID: 402 RVA: 0x0001F8EC File Offset: 0x0001DAEC
|
||||
private void Awake()
|
||||
{
|
||||
if (!this.tr)
|
||||
{
|
||||
this.tr = base.transform;
|
||||
}
|
||||
if (!this.camTr)
|
||||
{
|
||||
this.camTr = Links.x.worldCamera.gameObject.transform;
|
||||
}
|
||||
this.forw = Vector3.forward;
|
||||
this.up = Vector3.up;
|
||||
}
|
||||
|
||||
// Token: 0x06000193 RID: 403 RVA: 0x0001F950 File Offset: 0x0001DB50
|
||||
public void UpdateArmor(int curr)
|
||||
{
|
||||
SpriteRenderer spriteRenderer = null;
|
||||
this.currentArmor = curr;
|
||||
float num = (float)this.pieces.Count;
|
||||
float num2 = (float)this.maxArmor / num;
|
||||
float num3 = (float)curr;
|
||||
this.segments = num3;
|
||||
for (int i = 0; i < this.pieces.Count; i++)
|
||||
{
|
||||
float num4 = (float)i * num2;
|
||||
if (num3 > num4)
|
||||
{
|
||||
this.pieces[i].color = this.normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.pieces[i].color == this.normal)
|
||||
{
|
||||
spriteRenderer = this.pieces[i];
|
||||
}
|
||||
this.pieces[i].color = this.broken;
|
||||
}
|
||||
}
|
||||
if (spriteRenderer)
|
||||
{
|
||||
MasterAudio.PlaySound3DAtVector3AndForget("Armor Break", this.character.torsoPosition, 1f, new float?(1f), 0.5f, "", null);
|
||||
RectTransform hannahAnimator = Links.x.cellar.GetHannahAnimator(1);
|
||||
hannahAnimator.gameObject.SetActive(true);
|
||||
hannahAnimator.gameObject.GetComponent<HannahAnimator>().Play("Idle");
|
||||
Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(spriteRenderer.transform.position);
|
||||
vector.z = 0f;
|
||||
vector.x = vector.x * (1920f / (float)Screen.width) - 960f;
|
||||
vector.y = vector.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
|
||||
hannahAnimator.localPosition = vector;
|
||||
if (this.type == "Armor")
|
||||
{
|
||||
GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(119);
|
||||
pooledGameObject.transform.position = this.character.torsoPosition;
|
||||
pooledGameObject.SetActive(true);
|
||||
this.str.Clear();
|
||||
this.str.Append(this.character.stats.GetName());
|
||||
this.str.Append("'s armor is damaged");
|
||||
Links.x.gameFeed.AddFeed(this.str.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000194 RID: 404 RVA: 0x0001FBAB File Offset: 0x0001DDAB
|
||||
public void End()
|
||||
{
|
||||
Object.Destroy(base.gameObject);
|
||||
}
|
||||
|
||||
// Token: 0x06000195 RID: 405 RVA: 0x0001FBB8 File Offset: 0x0001DDB8
|
||||
public void Setup(Character c, int max, int curr, string counterType)
|
||||
{
|
||||
this.character = c;
|
||||
this.type = counterType;
|
||||
this.currentArmor = curr;
|
||||
this.maxArmor = max;
|
||||
this.UpdateArmor(curr);
|
||||
this.LateUpdate();
|
||||
}
|
||||
|
||||
// Token: 0x06000196 RID: 406 RVA: 0x0001FBE4 File Offset: 0x0001DDE4
|
||||
private void LateUpdate()
|
||||
{
|
||||
this.tr.LookAt(this.tr.position + this.camTr.rotation * this.forw, this.camTr.rotation * this.up);
|
||||
if (this.type == "Armor")
|
||||
{
|
||||
this.tr.position = this.character.body.GetHead().position + new Vector3(0f, 1f, 0f);
|
||||
return;
|
||||
}
|
||||
if (this.character.party)
|
||||
{
|
||||
this.tr.position = this.character.body.GetHead().position + new Vector3(0f, 1.1f, 0f);
|
||||
return;
|
||||
}
|
||||
this.tr.position = this.character.body.GetHead().position + new Vector3(0f, 1.85f, 0f);
|
||||
}
|
||||
|
||||
// Token: 0x04000342 RID: 834
|
||||
public List<SpriteRenderer> pieces = new List<SpriteRenderer>();
|
||||
|
||||
// Token: 0x04000343 RID: 835
|
||||
public Character character;
|
||||
|
||||
// Token: 0x04000344 RID: 836
|
||||
public int maxArmor;
|
||||
|
||||
// Token: 0x04000345 RID: 837
|
||||
public int currentArmor;
|
||||
|
||||
// Token: 0x04000346 RID: 838
|
||||
public float segments;
|
||||
|
||||
// Token: 0x04000347 RID: 839
|
||||
private Transform tr;
|
||||
|
||||
// Token: 0x04000348 RID: 840
|
||||
private Transform camTr;
|
||||
|
||||
// Token: 0x04000349 RID: 841
|
||||
private Vector3 forw;
|
||||
|
||||
// Token: 0x0400034A RID: 842
|
||||
private Vector3 up;
|
||||
|
||||
// Token: 0x0400034B RID: 843
|
||||
public Color normal;
|
||||
|
||||
// Token: 0x0400034C RID: 844
|
||||
public Color broken;
|
||||
|
||||
// Token: 0x0400034D RID: 845
|
||||
private StringFast str = new StringFast(32);
|
||||
|
||||
// Token: 0x0400034E RID: 846
|
||||
public string type;
|
||||
}
|
||||
Reference in New Issue
Block a user