void OnTriggerStay(Collider Col) { GameObject theFuel = GameObject.Find("TheFuel"); fuel = theFuel.GetComponent <FuelBar> (); fuel.fuel += 10; Destroy(Col.gameObject); }
// Start is called before the first frame update void Start() { if (instance != null) { Destroy(instance); } instance = this; fuelSlider = GetComponent <Slider>(); }
public void EnableOrDisableFuelBar(bool enable) { fuelBarUI.SetActive(enable); if (enable) { //Obtains the fuel atributes playerWeaponFuel = player.GetComponentInChildren <Fuel>(); playerFuelBar = GetComponentInChildren <FuelBar>(); playerFuelBar.SetMaxFuel(playerWeaponFuel.GetMaxFuel()); playerFuelBar.SetCurrentFuel(playerWeaponFuel.GetMaxFuel()); } }
void Start() { title = GameObject.Find("Title"); pauseMenu = GameObject.Find("Pause"); bgm = GameObject.Find("bgm"); BGM = bgm.GetComponent <AudioSource>(); playerbullet = GameObject.Find("PlayerBullet"); title.SetActive(false); pauseMenu.SetActive(false); GameStart(); fuelBar = GetComponent <FuelBar>(); }
public Player(Vector2 position, World world) : base(position, world, (float)Player.width, (float)Player.height) { body.BodyType = BodyType.Dynamic; PlayerFixture = FixtureFactory.CreateEllipse(width / 2, height / 2, 32, .2f, body); //PlayerFixture = FixtureFactory.CreateRectangle(width, height, .05f, Vector2.Zero, body, null); PlayerFixture.Restitution = .8f; texture = TextureStatic.Get("solitudePlayer"); enterPosition = new Vector2(900, 830); Reset(); hpBar = new HealthBar(oxygen, oxygenCap); fBar = new FuelBar(fuel, fuelCap); //lCnt = new LivesCount(); }
private void beginMessages() { if (txtIP.Text.Trim().Length == 0) { MessageBox.Show("You must enter the IP address of the server", "Connection Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } client = UdpUser.ConnectTo(txtIP.Text.Trim(), 32123); client.Send("Connected: " + Environment.UserName); //addText("Connected: " + Environment.UserName); // 10.33.7.192 string msg; string[] parts; Task.Factory.StartNew(async() => { while (true) { try { msg = (await client.Receive()).Message.ToString(); parts = msg.Split(':'); fixParts(parts); if (parts[0].Equals("quit")) { break; } else if (parts[0].Equals("connected")) { gameOn = parts[1].Equals("true"); if (gameOn) { txtIP.Invoke(new Action(() => txtIP.BackColor = Color.Green)); btnConnect.Invoke(new Action(() => btnConnect.BackColor = Color.Green)); txtIP.Invoke(new Action(() => txtIP.ReadOnly = true)); txtIP.Invoke(new Action(() => txtIP.Enabled = false)); btnConnect.Invoke(new Action(() => btnConnect.Enabled = false)); addText("You have joined the game...\n"); region = Convert.ToString(parts[2]); sector = Convert.ToInt32(parts[3]); col = Convert.ToInt32(parts[4]); row = Convert.ToInt32(parts[5]); lblSector.Invoke(new Action(() => lblSector.Text = region.ToUpper() + "-" + sector)); prbHealth.Invoke(new Action(() => prbHealth.Value = 100)); FuelBar.Invoke(new Action(() => FuelBar.Value = 50)); torpedoBar.Invoke(new Action(() => torpedoBar.Value = 10)); phasorBar.Invoke(new Action(() => phasorBar.Value = 50)); } else { addText("Connection not established\n"); sector = row = col = -1; } panCanvas.Invoke(new Action(() => panCanvas.Refresh())); } else if (parts[0].Equals("loc")) { string playerData = parts[1]; string[] realData = playerData.Split('-'); region = Convert.ToString(realData[0]); sector = Convert.ToInt32(realData[1]); row = Convert.ToInt32(realData[2]); col = Convert.ToInt32(realData[3]); health = Convert.ToInt32(realData[4]); fuel = Convert.ToInt32(realData[5]); phasorCount = Convert.ToInt32(realData[6]); torpedoCount = Convert.ToInt32(realData[7]); FuelBar.Invoke(new Action(() => FuelBar.Value = fuel)); if (health <= 0) { MessageBox.Show(new Form() { TopMost = true }, "You have died."); } prbHealth.Invoke(new Action(() => prbHealth.Value = health)); prbHealth.Invoke(new Action(() => phasorBar.Value = phasorCount)); prbHealth.Invoke(new Action(() => torpedoBar.Value = torpedoCount)); lblSector.Invoke(new Action(() => lblSector.Text = region.ToUpper() + "-" + sector)); panCanvas.Invoke(new Action(() => panCanvas.Refresh())); } else if (parts[0].Equals("loc2")) { rows = new List <int>(); cols = new List <int>(); angles = new List <int>(); string playerData = parts[1]; string[] realData = playerData.Split('-'); region = Convert.ToString(realData[0]); sector = Convert.ToInt32(realData[1]); row = Convert.ToInt32(realData[2]); col = Convert.ToInt32(realData[3]); health = Convert.ToInt32(realData[4]); fuel = Convert.ToInt32(realData[5]); phasorCount = Convert.ToInt32(realData[6]); torpedoCount = Convert.ToInt32(realData[7]); string otherData = parts[2]; string[] realData2 = otherData.Split('-'); for (int i = 0; i < realData2.Length - 1; i++) { int k = Convert.ToInt32(realData2[i]); rows.Add(k); int k2 = Convert.ToInt32(realData2[i + 1]); cols.Add(k2); int k3 = Convert.ToInt32(realData2[i + 2]); angles.Add(k3); i = i + 2; } FuelBar.Invoke(new Action(() => FuelBar.Value = fuel)); if (health <= 0) { addText("A"); MessageBox.Show(new Form() { TopMost = true }, "You have died."); } prbHealth.Invoke(new Action(() => prbHealth.Value = health)); prbHealth.Invoke(new Action(() => phasorBar.Value = phasorCount)); lblSector.Invoke(new Action(() => lblSector.Text = region.ToUpper() + "-" + sector)); prbHealth.Invoke(new Action(() => torpedoBar.Value = torpedoCount)); panCanvas.Invoke(new Action(() => panCanvas.Refresh())); } else if (parts[0].Equals("phasors")) { FuelBar.Invoke(new Action(() => phasorBar.Value = Convert.ToInt32(parts[1]))); } else if (parts[0].Equals("universe")) { addText("reached"); addText(parts[1].ToUpper()); } else if (parts[0].Equals("display")) { addText(parts[1]); } else if (parts[0].Equals("torpedos")) { FuelBar.Invoke(new Action(() => torpedoBar.Value = Convert.ToInt32(parts[1]))); } else if (parts[0].Equals("healthMessage")) { MessageBox.Show(new Form() { TopMost = true }, "You have died."); } else { data = msg; } } catch (Exception e) { MessageBox.Show(e.Message); } } Environment.Exit(0); }); }
//private Slider slider; void Awake() { ship = GetComponent <Ship>(); pBank = GetComponent <PowerBank>(); fBar = GetComponent <FuelBar>(); }
public void Start() { slider = GetComponent <Slider>(); instance = this; defaultValue = slider.maxValue; }
void Awake() { spaceship = GetComponent <Spaceship>(); fuelBar = GetComponent <FuelBar>(); }