void Start() { audioController = GameObject.Find("AudioController").GetComponent <AudioController>(); gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>(); hardpoint = GetComponentInChildren <HardPoint>(); wave = gameController.GetWave(true); rb = GetComponent <Rigidbody2D>(); shootDelay = Random.Range(0.0f, 1.0f); //It goes in the order: startPoint, endControl, startControl, endPoint - //Note: the control for the end and start are reversed! This is just a quirk of the API. enemyPaths = new LTBezierPath[] { new LTBezierPath(new Vector3[] { Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 1.1f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.7f, 0.9f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.3f, 0.3f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(1.1f, -0.1f, 0.0f)) }), new LTBezierPath(new Vector3[] { Camera.main.ViewportToWorldPoint(new Vector3(1.1f, 1.1f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.1f, 0.7f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.7f, 0.3f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(-0.1f, -0.1f, 0.0f)) }), new LTBezierPath(new Vector3[] { Camera.main.ViewportToWorldPoint(new Vector3(0.6f, 1.1f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.2f, 0.5f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.7f, 0.5f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.1f, 1.1f, 0.0f)) }), new LTBezierPath(new Vector3[] { Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 1.1f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.7f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f)), Camera.main.ViewportToWorldPoint(new Vector3(1.0f, 1.1f, 0.0f)) }) }; //StartCoroutine(Evade()); }
void Start() { boss = transform.parent.GetComponent <Boss>(); closedSprite = transform.Find("Closed").GetComponent <SpriteRenderer>(); deadSprite = transform.Find("Dead").GetComponent <SpriteRenderer>(); coll = GetComponent <Collider2D>(); hp = GetComponentInChildren <HardPoint>(); audioController = GameObject.Find("AudioController").GetComponent <AudioController>(); SwitchState(EyeState.CLOSED); }
public void EquipRight(scrWeapon attachment) { if (rightHardPointsUsed == rightHardPointIndexes.Length) { // Replace a random hardpoint's attachment. RightHardPoints[Random.Range(0, rightHardPointIndexes.Length)].Attach(attachment); } else { // Get a random index that hasnt been used. int index = Random.Range(rightHardPointsUsed, rightHardPointIndexes.Length); // Get the hardpoint. HardPoint hp = RightHardPoints[rightHardPointIndexes[index]]; hp.Attach(attachment); // Swap the index with the first available one. int temp = rightHardPointIndexes[index]; rightHardPointIndexes[index] = rightHardPointIndexes[rightHardPointsUsed]; rightHardPointIndexes[rightHardPointsUsed] = temp; ++rightHardPointsUsed; } }
void inventoryView() { Inventory inventory = GetComponent <ShootObjects>().inventory; weaponSlider = GUI.VerticalScrollbar(new Rect(Screen.width / 2 - 15, 125, 15, 200), weaponSlider, 8.0F, 0.0F, ((inventory.weapons.Length < 8) ? 8 : inventory.weapons.Length)); GUI.Box(new Rect(Screen.width / 2 - 265, 125, 250, 200), ""); // Weapon box attachmentSlider = GUI.VerticalScrollbar(new Rect(Screen.width / 2 + 200, 125, 15, 200), attachmentSlider, 8.0F, 0.0F, ((ItemElements < 8) ? 8 : ItemElements)); GUI.Box(new Rect(Screen.width / 2, 125, 215, 200), ""); // Attachment box int i = 0; GUI.Label(new Rect(Screen.width / 2 - 250, 100, 200, 25), "Weapons"); GUI.Label(new Rect(Screen.width / 2, 100, 150, 25), "Grenades, Attachments"); foreach (Weapon weapon in inventory.weapons) { if (weapon.IsValid && i < 8 + (int)weaponSlider && i >= (int)weaponSlider) { if (GUI.Button(new Rect(Screen.width / 2 - 265, 125 + (25 * (i - (int)weaponSlider)), 250, 25), weapon.DisplayName)) { SelectedWeapon = weapon; SelectedModSlot = null; SelectedAttachment = null; } if (SelectedWeapon == weapon) { int p = 1; for (int o = 0; o < weapon.attachments.Length; o++) { if (weapon.attachments[o].attachment.isValid) { if (GUI.Button(new Rect(Screen.width / 2 - 250, 125 + (25 * (i + 1 - (int)weaponSlider)), 235, 25), weapon.attachments[o].name + ": " + weapon.attachments[o].attachment.railType.ToString() + " " + weapon.attachments[o].attachment.type.ToString())) { // Pluck thingy inventory.attachments.Add(weapon.attachments[o].attachment); weapon.attachments[o].attachment = new WeaponAttachment(); } p++; } else { if (GUI.Button(new Rect(Screen.width / 2 - 250, 125 + (25 * (i + 1 - (int)weaponSlider)), 235, 25), weapon.attachments[o].name + ": " + weapon.attachments[o].connectionType.ToString() + ". Open.")) { // Prepare to attach thingy SelectedModSlot = weapon.attachments[o]; } p++; } i++; } // End for each hardpoint. } i++; } // End for each gun. } int a = 0; foreach (WeaponAttachment att in inventory.attachments) { if (i < 8 + (int)attachmentSlider && i >= (int)attachmentSlider) { //GUI.Box(new Rect(Screen.width/2+150, 125+(25*i), 50, 25), "$"+AmmoPrice.Get((AmmoType)a).ToString()); if (GUI.Button(new Rect(Screen.width / 2, 125 + (25 * (a - (int)attachmentSlider)), 200, 25), att.name)) { if (SelectedModSlot != null) { if (SelectedModSlot.connectionType == att.railType) { // Afix part. SelectedModSlot.attachment = att; // Clean up. SelectedModSlot = null; SelectedAttachment = att; } } } a++; GUI.Label(new Rect(Screen.width / 2, 125 + (25 * (a - (int)attachmentSlider)), 200, 25), att.railType.ToString() + " " + att.type.ToString()); } a++; } if (SelectedAttachment != null) { inventory.attachments.Remove(SelectedAttachment); SelectedAttachment = null; } }
void inventoryView() { Inventory inventory = GetComponent<ShootObjects>().inventory; weaponSlider = GUI.VerticalScrollbar(new Rect(Screen.width/2-15, 125, 15, 200), weaponSlider, 8.0F, 0.0F, ((inventory.weapons.Length < 8) ? 8 : inventory.weapons.Length)); GUI.Box(new Rect(Screen.width/2-265, 125, 250, 200), ""); // Weapon box attachmentSlider = GUI.VerticalScrollbar(new Rect(Screen.width/2+200, 125, 15, 200), attachmentSlider, 8.0F, 0.0F, ((ItemElements < 8) ? 8 : ItemElements)); GUI.Box(new Rect(Screen.width/2, 125, 215, 200), ""); // Attachment box int i = 0; GUI.Label(new Rect(Screen.width/2-250, 100, 200, 25), "Weapons"); GUI.Label(new Rect(Screen.width/2, 100, 150, 25), "Grenades, Attachments"); foreach (Weapon weapon in inventory.weapons) { if (weapon.IsValid && i < 8 + (int)weaponSlider && i >= (int)weaponSlider) { if (GUI.Button(new Rect(Screen.width/2-265, 125+(25*(i-(int)weaponSlider)), 250, 25), weapon.DisplayName)) { SelectedWeapon = weapon; SelectedModSlot = null; SelectedAttachment = null; } if (SelectedWeapon == weapon) { int p = 1; for (int o = 0; o<weapon.attachments.Length; o++) { if (weapon.attachments[o].attachment.isValid) { if (GUI.Button(new Rect(Screen.width/2-250, 125+(25*(i+1-(int)weaponSlider)), 235, 25), weapon.attachments[o].name + ": " + weapon.attachments[o].attachment.railType.ToString()+ " "+weapon.attachments[o].attachment.type.ToString())) { // Pluck thingy inventory.attachments.Add(weapon.attachments[o].attachment); weapon.attachments[o].attachment = new WeaponAttachment(); } p++; } else { if (GUI.Button(new Rect(Screen.width/2-250, 125+(25*(i+1-(int)weaponSlider)), 235, 25), weapon.attachments[o].name + ": " + weapon.attachments[o].connectionType.ToString()+ ". Open.")) { // Prepare to attach thingy SelectedModSlot = weapon.attachments[o]; } p++; } i++; } // End for each hardpoint. } i++; } // End for each gun. } int a = 0; foreach (WeaponAttachment att in inventory.attachments) { if (i < 8 + (int)attachmentSlider && i >= (int)attachmentSlider) { //GUI.Box(new Rect(Screen.width/2+150, 125+(25*i), 50, 25), "$"+AmmoPrice.Get((AmmoType)a).ToString()); if (GUI.Button(new Rect(Screen.width/2, 125+(25*(a-(int)attachmentSlider)), 200, 25), att.name)) { if (SelectedModSlot != null) { if (SelectedModSlot.connectionType == att.railType) { // Afix part. SelectedModSlot.attachment = att; // Clean up. SelectedModSlot = null; SelectedAttachment = att; } } } a++; GUI.Label(new Rect(Screen.width/2, 125+(25*(a-(int)attachmentSlider)), 200, 25), att.railType.ToString()+" "+att.type.ToString()); } a++; } if (SelectedAttachment != null) { inventory.attachments.Remove(SelectedAttachment); SelectedAttachment = null; } }