using System.Collections; using System.Collections.Generic; using UnityEngine; public class BasicGlider : MonoBehaviour, IObject { //Item Stats public int MaxLevel = 11; public int Tiers = 3; public Sprite[] sprites; //Rigging public Transform flightObject; public Transform model; public GameObject Tier1; public GameObject Tier2; public GameObject Tier3; public Vector3 GroundClearance; public float Radius; public Transform StageRiggingCenter; public float StageRiggingRadius; public float StageRiggingOffset; public Transform Penguin; //Stats public string[] shopStat; public string[] flavorText; public float[] Mass; public float[] Lift; public float[] Aerodynamics; public float[] Authority; public int[] Value; public PhysicsMaster physicsMaster; //Target Scripts public PurchaseBar purchaseBar; public Sprite[] trueThumb; public BodyBarDisplay bodyBarDisplay; // Start is called before the first frame update void Start() { LinkReferences(); } // Update is called once per frame void FixedUpdate() { } void LinkReferences() { //Assigning References model = this.transform; flightObject = GameObject.Find("FlightObject").transform; physicsMaster = flightObject.GetComponent(); StageRiggingCenter = GameObject.Find("Stage").transform; Penguin = GameObject.Find("Penguin").transform; purchaseBar = GameObject.Find("PurchaseBar").GetComponent(); bodyBarDisplay = GameObject.Find("BodyBar").GetComponent(); shopStat = new string[4]; shopStat[0] = "Mass"; shopStat[1] = "Lift"; shopStat[2] = "Aerodynamics"; shopStat[3] = "Authority"; //rigging stats GroundClearance = new Vector3(0, 1, 0); Radius = 1; StageRiggingCenter.localPosition = new Vector3(0, -0.26f, 0.41f); StageRiggingRadius = 0.52f; StageRiggingOffset = -0.53f; //flavor text flavorText = new string[Tiers]; flavorText[0] = "Old beat-up glider, can it really fly?"; flavorText[1] = "Your everyday, typical hang glider."; flavorText[2] = "High-Tech sailplane that enables incredible glide ratio."; //mass list Mass = new float[MaxLevel]; Mass[0] = 40; Mass[1] = 40; Mass[2] = 40; Mass[3] = 40; Mass[4] = 40; Mass[5] = 40; Mass[6] = 40; Mass[7] = 40; Mass[8] = 40; Mass[9] = 40; Mass[10] = 40; //lift list Lift = new float[MaxLevel]; Lift[0] = 1.6f; Lift[1] = 1.6f; Lift[2] = 1.6f; Lift[3] = 1.6f; Lift[4] = 1.6f; Lift[5] = 1.8f; Lift[6] = 1.8f; Lift[7] = 1.8f; Lift[8] = 1.8f; Lift[9] = 1.8f; Lift[10] = 2.1f; //aerodynamics list Aerodynamics = new float[MaxLevel]; Aerodynamics[0] = 160; Aerodynamics[1] = 260; Aerodynamics[2] = 360; Aerodynamics[3] = 440; Aerodynamics[4] = 560; Aerodynamics[5] = 720; Aerodynamics[6] = 880; Aerodynamics[7] = 1080; Aerodynamics[8] = 1280; Aerodynamics[9] = 1500; Aerodynamics[10] = 1800; //authority list Authority = new float[MaxLevel]; Authority[0] = 0.03f; Authority[1] = 0.03f; Authority[2] = 0.03f; Authority[3] = 0.03f; Authority[4] = 0.03f; Authority[5] = 0.03f; Authority[6] = 0.03f; Authority[7] = 0.03f; Authority[8] = 0.03f; Authority[9] = 0.03f; Authority[10] = 0.03f; //value list Value = new int[MaxLevel]; Value[0] = 100; Value[1] = 150; Value[2] = 300; Value[3] = 450; Value[4] = 750; Value[5] = 1000; Value[6] = 1500; Value[7] = 2100; Value[8] = 3000; Value[9] = 4000; Value[10] = 5000; } //Exports stats to the purchase bar public void Print() { LinkReferences(); if (InventoryMaster.BodyLv >= 11) { InventoryMaster.BodyTier = 3; } else if (InventoryMaster.BodyLv >= 6) { InventoryMaster.BodyTier = 2; } else { InventoryMaster.BodyTier = 1; } purchaseBar.ItemTier = InventoryMaster.BodyTier; purchaseBar.ItemValue = Value; purchaseBar.ItemMaxLevel = MaxLevel; purchaseBar.TrueThumb.sprite = trueThumb[purchaseBar.ItemTier - 1]; purchaseBar.FlavorText.text = flavorText[purchaseBar.ItemTier - 1]; purchaseBar.StatName.text = @"Mass Lift Aerodynamics Authority"; purchaseBar.Stat.text = $@"{Mass[InventoryMaster.BodyLv - 1]} {Lift[InventoryMaster.BodyLv - 1]} {Aerodynamics[InventoryMaster.BodyLv - 1]} {Authority[InventoryMaster.BodyLv - 1]}"; } public void Preview() { LinkReferences(); purchaseBar.StatName.text = @"Mass Lift Aerodynamics Authority"; purchaseBar.Stat.text = $@"{Mass[0]} {Lift[0]} {Aerodynamics[0]} {Authority[0]}"; } //Stat view on shop public void PrintLevel(string sender) { LinkReferences(); bodyBarDisplay.body.text = InventoryMaster.Body.ToString(); bodyBarDisplay.thumb.sprite = sprites[InventoryMaster.BodyTier - 1]; if (bodyBarDisplay.body.text == "Empty Body") { bodyBarDisplay.body.text = "Empty"; bodyBarDisplay.lv.text = ""; } else { if (InventoryMaster.BodyLv == MaxLevel) { bodyBarDisplay.lv.text = "Max Level"; } else { bodyBarDisplay.lv.text = "Level " + InventoryMaster.BodyLv.ToString(); } } } public void Rigging(string sender) { LinkReferences(); flightObject.position = Instantiator.MasterRiggingPoint + GroundClearance; flightObject.localEulerAngles = Instantiator.MasterRiggingOrientation; StageRiggingCenter.localPosition = new Vector3(0, -0.23f, 0.41f); Instantiator.MasterStageRiggingRadius = StageRiggingRadius; Instantiator.MasterStageRiggingOffset = StageRiggingOffset; Penguin.localPosition = new Vector3(0, -0.3f, 0.54f); Tier1.SetActive(false); Tier2.SetActive(false); Tier3.SetActive(false); switch(InventoryMaster.BodyTier) { case 1: Tier1.SetActive(true); break; case 2: Tier2.SetActive(true); break; case 3: Tier3.SetActive(true); break; } Instantiator.Mass = Instantiator.Mass + 40; } public void ExportStat() { physicsMaster.DragCoefficient = 1 / Aerodynamics[InventoryMaster.BodyLv - 1]; physicsMaster.CrossSectionalArea = 0.8; physicsMaster.LiftingArea = Lift[InventoryMaster.BodyLv - 1]; physicsMaster.Authority = physicsMaster.Weight * 2 / 9.81; //physicsMaster.Authority = Authority[InventoryMaster.BodyLv - 1] * Lift[InventoryMaster.BodyLv - 1] * physicsMaster.DynamicPressure; } }