public void CmdThrust(float thrusting, int spin) { if (PlayGame.GetComplete() || !tc.alive) { this.thrusting = 0; this.spin = 0; return; } this.thrusting = thrusting; this.spin = spin; }
void Update() { if (!isLocalPlayer) { return; } if (PlayGame.GetComplete()) { if (Input.GetKeyDown(KeyCode.Space)) { CmdFinishLevel(); } } }
public void CmdBeginFireMachineGun() { if (PlayGame.GetComplete()) { return; } if (!alive) { return; } if (ammunitionMG > 0) { firingMG = true; } }
public void CmdRotateTurret(float angle) { if (!tc.alive) { return; } if (PlayGame.GetComplete()) { return; } Vector3 rotationVector = new Vector3(0, 0, angle); turret.transform.rotation = Quaternion.Euler(rotationVector); turretAngle = angle; }
public void CmdFireTurret() { if (PlayGame.GetComplete()) { return; } if (!CanFireTurret()) { return; } heat += tt.fireHeat; ammunitionTurret -= 1; fireTurretTimer = Time.time + tt.fireRateTurret; GameObject missile = (GameObject)GameObject.Instantiate(missilePrefab, muzzle.position, muzzle.rotation); missile.GetComponent <Rigidbody2D>().velocity = muzzle.right * 10; missile.GetComponent <Missile>().damage = tt.turretDamage; missile.GetComponent <Missile>().team = team; NetworkServer.Spawn(missile); }
void OnGUI() { Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); int myTeam = -1; if (NetworkClient.active && ClientScene.localPlayers.Count > 0 && ClientScene.localPlayers[0].gameObject != null) { TankCombat localPlayerTc = ClientScene.localPlayers[0].gameObject.GetComponent <TankCombat>(); myTeam = localPlayerTc.team; } // your team is green, other teams are red Color teamColor = Color.white; if (myTeam == tc.team) { teamColor = Color.green; } else { teamColor = Color.red; } // draw the name with a shadow (colored for buf) GUI.color = Color.black; GUI.Label(new Rect(pos.x - 50, Screen.height - pos.y - 62, 150, 30), tc.tankName); GUI.color = teamColor; GUI.Label(new Rect(pos.x - 51, Screen.height - pos.y - 61, 150, 30), tc.tankName); if (tc.alive && tc.tt != null) { DrawBar(teamColor, pos, 40, tc.health, tc.tt.maxHealth); DrawBar(Color.yellow, pos, 34, tc.heat, tc.tt.maxHeat); } else { GUI.color = Color.black; GUI.Label(new Rect(pos.x - 40, Screen.height - pos.y - 42, 150, 30), "YOU ARE DEAD"); GUI.color = Color.white; GUI.Label(new Rect(pos.x - 41, Screen.height - pos.y - 41, 150, 30), "YOU ARE DEAD"); } if (!isLocalPlayer) { return; } // draw direction damage indicators DrawArmour(new Rect(20, 100, 64, 32), front, tc.armorFront); DrawArmour(new Rect(20, 210, 64, 32), back, tc.armorBack); DrawArmour(new Rect(20, 136, 24, 72), left, tc.armorLeft); DrawArmour(new Rect(60, 136, 24, 72), right, tc.armorRight); if (damageTimer > Time.time) { Rect r = new Rect(0, 0, 0, 0); if (damageSide == 0) { r = new Rect(40, 80, 40, 40); } else if (damageSide == 1) { r = new Rect(100, 160, 40, 40); } else if (damageSide == 2) { r = new Rect(40, 260, 40, 40); } else if (damageSide == 3) { r = new Rect(2, 160, 40, 40); } GUI.color = Color.red; GUI.Label(r, "[" + damageAmount + "]"); } GUI.color = Color.white; GUI.Label(new Rect(5, 5, 180, 60), "Arrows to move, mouse buttons to fire. Escape to exit. Destroy three barrels."); GUI.Label(new Rect(10, 250, 200, 20), "Turret Ammo: " + tc.ammunitionTurret + "/" + tc.tt.maxAmmunitionTurret); GUI.Label(new Rect(10, 270, 200, 20), "Flame Ammo: " + tc.ammunitionMG + "/" + tc.tt.maxAmmunitionMG); GUI.Label(new Rect(200, 10, 200, 20), "Barrels: " + PlayGame.GetBarrelScore()); if (myTeam == 0) { GUI.color = Color.green; } else { GUI.color = Color.red; } GUI.Label(new Rect(200, 30, 200, 20), "Control(0): " + PlayGame.GetControlScore(0)); if (myTeam == 1) { GUI.color = Color.green; } else { GUI.color = Color.red; } GUI.Label(new Rect(200, 50, 200, 20), "Control(1): " + PlayGame.GetControlScore(1)); GUI.color = Color.white; if (NetworkClient.active) { GUI.Label(new Rect(5, 5, 180, 60), "RTT: " + NetworkClient.allClients[0].GetRTT()); } GUI.color = Color.white; if (PlayGame.GetComplete()) { GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 100, 200, 40), "--- Level Complete ---\nPRESS SPACE TO RESTART"); } }
void OnGUI() { Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); var myTeam = "-"; if (NetworkClient.active && ClientScene.localPlayers.Count > 0 && ClientScene.localPlayers[0].gameObject != null) { FighterController localPlayerFc = ClientScene.localPlayers[0].gameObject.GetComponent <FighterController>(); myTeam = localPlayerFc.team; } // your team is green, other teams are red Color teamColor = Color.white; if (myTeam == fc.team) { // draw the name with a shadow (colored for buf) GUI.color = Color.black; GUI.Label(new Rect(pos.x - 50, Screen.height - pos.y - 62, 150, 30), fc.fighterName); GUI.color = Color.green; GUI.Label(new Rect(pos.x - 51, Screen.height - pos.y - 61, 150, 30), fc.fighterName); } if (!isLocalPlayer) { return; } if (fc.alive && fc.ft != null) { DrawBar(teamColor, pos, 40, fc.health, fc.ft.maxHealth); DrawBar(Color.yellow, pos, 34, (int)fc.energy, fc.ft.maxEnergy); } else { GUI.color = Color.black; GUI.Label(new Rect(pos.x - 40, Screen.height - pos.y - 42, 150, 30), "YOU ARE DEAD"); GUI.color = Color.white; GUI.Label(new Rect(pos.x - 41, Screen.height - pos.y - 41, 150, 30), "YOU ARE DEAD"); } if (damageTimer > Time.time) { Rect r = new Rect(0, 0, 0, 0); if (damageSide == 0) { r = new Rect(40, 80, 40, 40); } else if (damageSide == 1) { r = new Rect(100, 160, 40, 40); } else if (damageSide == 2) { r = new Rect(40, 260, 40, 40); } else if (damageSide == 3) { r = new Rect(2, 160, 40, 40); } GUI.color = Color.red; GUI.Label(r, "[" + damageAmount + "]"); } GUI.color = Color.grey; GUI.Box(new Rect(Screen.width - 80, Screen.height - 65, 80, 65), ""); if (fc.equippedGun != null) { GUI.color = Color.white; GUI.Label(new Rect(Screen.width - 75, Screen.height - 60, 75, 30), fc.equippedGun.gunName); GUI.Label(new Rect(Screen.width - 75, Screen.height - 30, 75, 30), fc.equippedGun.ammo + "/" + fc.equippedGun.maxAmmo); } /*GUI.Label(new Rect(10, 250, 200, 20), "Turret Ammo: " + fc.ammunitionTurret + "/" + fc.ft.maxAmmunitionTurret ); * GUI.Label(new Rect(10, 270, 200, 20), "Flame Ammo: " + fc.ammunitionMG + "/" + fc.ft.maxAmmunitionMG);*/ GUI.color = Color.white; if (NetworkClient.active) { //GUI.Label(new Rect(5, 5, 180, 60), "RTT: " + NetworkClient.allClients[0].GetRTT()); } GUI.color = Color.white; if (PlayGame.GetComplete()) { GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 100, 200, 40), "--- Winner Winner ---\nPRESS SPACE TO RESTART"); } }
bool fighterActionsAllowed() { return(!PlayGame.GetComplete() && alive); }