public LaserSource AddSource(LaserCannon e) { var src = new LaserSource(this, e.Position, _screen.GetNeutralFraction(), e, RayType.Laser); Sources.Add(src); return(src); }
// Use this for initialization void Start() { m_RigidBody = GetComponent <Rigidbody2D>(); m_laserCannon = GetComponent <LaserCannon>(); float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance)); m_xMin = leftmost.x + playerPadding; m_xMax = rightmost.x - playerPadding; }
public void init(LaserCannon owner, int projectileId, double creationTime) { this.owner = owner; this.id = projectileId; this.creationTime = creationTime; startPosition = transform.position; forward = transform.forward; lastCollisionCheck = startPosition; fixedDistance = Time.fixedDeltaTime * speed; }
private bool ProcessForwardLaserCannons(ref int p, byte[] d, long bseq, float sendertime) { int count = d[p]; p++; for (int i = 0; i < count; i++) { var id = NetworkDataTools.GetByte(d[p + 0]); var ifrac = NetworkDataTools.GetHighBits(d[p + 1], 3); var boost = NetworkDataTools.GetLowBits(d[p + 1], 5); var rotA = NetworkDataTools.GetSingle(d[p + 2], d[p + 3], d[p + 4], d[p + 5]); var rotT = NetworkDataTools.GetSingle(d[p + 6], d[p + 7], d[p + 8], d[p + 9]); var hp = NetworkDataTools.GetByte(d[p + 10]) / 255f; var ct = NetworkDataTools.GetByteFloorRange(d[p + 11], 0, Cannon.LASER_CHARGE_COOLDOWN_MAX); var shield = NetworkDataTools.GetByteFloorRange(d[p + 12], 0, Cannon.MAX_SHIELD_TIME); var frac = Screen.GetFractionByID(ifrac, out bool gfbiError); if (gfbiError) { SAMLog.Error("SNS-COMMON::PFLC_GFBI", "GetFractionByID returned error: Unknown Fraction " + ifrac + "\nData:\n" + ByteUtils.CompressBytesForStorage(d)); return(false); } Cannon c; if (Screen.CannonMap.TryGetValue(id, out c)) { LaserCannon bc = c as LaserCannon; if (bc != null && ShouldRecieveData(frac, bc)) { if (ShouldRecieveRotationData(frac, bc)) { bc.RemoteRotationUpdate(rotA, rotT, sendertime); } if (ShouldRecieveStateData(frac, bc)) { bc.RemoteUpdate(frac, hp, boost, ct, shield, sendertime); } } } p += PLEN_LASERCANNON; } return(true); }
private void ProcessForwardLaserCannons(ref int p, byte[] d, long bseq, float sendertime) { int count = d[p]; p++; for (int i = 0; i < count; i++) { var id = NetworkDataTools.GetByte(d[p + 0]); var frac = Screen.GetFractionByID(NetworkDataTools.GetHighBits(d[p + 1], 3)); var boost = NetworkDataTools.GetLowBits(d[p + 1], 5); var rotA = NetworkDataTools.GetSingle(d[p + 2], d[p + 3], d[p + 4], d[p + 5]); var rotT = NetworkDataTools.GetSingle(d[p + 6], d[p + 7], d[p + 8], d[p + 9]); var hp = NetworkDataTools.GetByte(d[p + 10]) / 255f; var ct = NetworkDataTools.GetByteFloorRange(d[p + 11], 0, Cannon.LASER_CHARGE_COOLDOWN_MAX); var shield = NetworkDataTools.GetByteFloorRange(d[p + 12], 0, Cannon.MAX_SHIELD_TIME); Cannon c; if (Screen.CannonMap.TryGetValue(id, out c)) { LaserCannon bc = c as LaserCannon; if (bc != null && ShouldRecieveData(frac, bc)) { if (ShouldRecieveRotationData(frac, bc)) { bc.RemoteRotationUpdate(rotA, rotT, sendertime); } if (ShouldRecieveStateData(frac, bc)) { bc.RemoteUpdate(frac, hp, boost, ct, shield, sendertime); } } } p += PLEN_LASERCANNON; } }
private void LoadLevelFromBlueprint() { Fraction[] fracList = { fractionNeutral, fractionPlayer, fractionComputer1, fractionComputer2, fractionComputer3 }; //---------------------------------------------------------------- MapFullBounds = new FRectangle(0, 0, Blueprint.LevelWidth, Blueprint.LevelHeight); MapViewportCenterX = Blueprint.LevelViewX; MapViewportCenterY = Blueprint.LevelViewY; WrapMode = (GameWrapMode)Blueprint.WrapMode; if (WrapMode == GameWrapMode.Donut || WrapMode == GameWrapMode.Reflect) { VAdapterGame.ChangeVirtualSize(GDConstants.VIEW_WIDTH + GDConstants.TILE_WIDTH, GDConstants.VIEW_HEIGHT + GDConstants.TILE_WIDTH); MapViewportCenterX = Blueprint.LevelViewX; MapViewportCenterY = Blueprint.LevelViewY; } if (MainGame.Inst.Profile.EffectsEnabled && WrapMode == GameWrapMode.Donut) { Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.NN)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.EE)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.SS)); Entities.AddEntity(new DonutParticleEmitter(this, Blueprint, FlatAlign4.WW)); } if (MainGame.Inst.Profile.EffectsEnabled) { Background = new GDCellularBackground(this, Blueprint); } else { Background = new GDStaticGridBackground(this, WrapMode); } //---------------------------------------------------------------- var cannonList = new List <Cannon>(); var portalList = new List <Portal>(); var fractionList = new List <Fraction>(); var laserworld = false; fractionList.Add(fractionNeutral); foreach (var bPrint in Blueprint.BlueprintCannons) { var e = new BulletCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintMinigun) { var e = new MinigunCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintRelayCannon) { var e = new RelayCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintTrishotCannon) { var e = new TrishotCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintVoidWalls) { var e = new VoidWall(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintVoidCircles) { var e = new VoidCircle(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintGlassBlocks) { var e = new GlassBlock(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintBlackHoles) { var e = new BlackHole(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintPortals) { var e = new Portal(this, bPrint); Entities.AddEntity(e); portalList.Add(e); } foreach (var bPrint in Blueprint.BlueprintLaserCannons) { var e = new LaserCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); laserworld = true; if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintShieldProjector) { var e = new ShieldProjectorCannon(this, bPrint, fracList); Entities.AddEntity(e); cannonList.Add(e); laserworld = true; if (!fractionList.Contains(e.Fraction)) { fractionList.Add(e.Fraction); } } foreach (var bPrint in Blueprint.BlueprintMirrorBlocks) { var e = new MirrorBlock(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintMirrorCircles) { var e = new MirrorCircle(this, bPrint); Entities.AddEntity(e); } foreach (var bPrint in Blueprint.BlueprintBackgroundText) { var e = new BackgroundText(this, bPrint); Entities.AddEntity(e); } //---------------------------------------------------------------- if (laserworld) { Entities.AddEntity(new LaserRenderer(this, LaserNetwork, Blueprint)); } AddEdgeMarker(); //---------------------------------------------------------------- foreach (var cannon in cannonList) { cannon.OnAfterLevelLoad(); } foreach (var portal in portalList) { portal.OnAfterLevelLoad(portalList); } CannonMap = cannonList.ToDictionary(p => p.BlueprintCannonID, p => p); foreach (var f in fracList) { if (!fractionList.Contains(f)) { fractionList.Add(f); } } fractionIDList = fractionList.ToArray(); //---------------------------------------------------------------- if (!IsPreview && (Blueprint.LevelWidth > GDConstants.VIEW_WIDTH || Blueprint.LevelHeight > GDConstants.VIEW_HEIGHT)) { AddAgent(new GameDragAgent(this)); } }
/// <summary> /// Command. /// An object to be actioned at a later date. /// </summary> /// <param name="laserCannon">A laser cannon. To be fired at a later date.</param> public Command(LaserCannon laserCannon) { LaserCannon = laserCannon; }
// Use this for initialization void Start() { _tr = transform; laserCannon = GetComponent<LaserCannon>(); }
/// <summary> /// Ship. /// Stores a laser cannon to be fired at a later date. /// </summary> /// <param name="laserCannon">A laser cannon. To be fired at a later date.</param> public Ship(LaserCannon laserCannon) : base(laserCannon) { }
/// <summary> /// Execute. /// Executes the stored command. /// In this case it fires a laser. /// </summary> public override void Execute() { LaserCannon.Fire(); }
void initWeapon(string s, Unit script) { if (GameDirector.Instance.isMultiPlayer()) { script.gameObject.GetPhotonView().RPC("AddWeapon", PhotonTargets.AllBuffered, s); return; } if (script.weapons == null) { script.weapons = new List <Weapon>(); } switch (s) { case "Sword": { Weapon sword = new BeamSword(script); script.weapons.Add(sword); script.Equip(sword); break; } case "Rifle": { Weapon rifle = new Rifle(script); script.weapons.Add(rifle); script.Equip(rifle); break; } case "Frag": { Weapon frag = new Frag(script); script.weapons.Add(frag); script.Equip(frag); break; } case "Laser": { Weapon laser = new LaserCannon(script); script.weapons.Add(laser); script.Equip(laser); break; } case "Chain": { Weapon chain = new EnergyChain(script); script.weapons.Add(chain); script.Equip(chain); break; } case "Photon": { Weapon photon = new PhotonEqualizer(script); script.weapons.Add(photon); script.Equip(photon); break; } default: { Debug.Log("Unit not found"); break; } } }
public void PlaceObject() { Object temp; switch (ObjectListBox.SelectedItem.ToString()) { case "Key": temp = new Key(); PlacedObjectListBox.Items.Add(temp); break; case "Ammo": temp = new Ammo(); PlacedObjectListBox.Items.Add(temp); break; case "Health": temp = new Health(); PlacedObjectListBox.Items.Add(temp); break; case "Adrenaline": temp = new Adrenaline(); PlacedObjectListBox.Items.Add(temp); break; case "Barrel": temp = new Barrel(); PlacedObjectListBox.Items.Add(temp); break; case "Pipe": temp = new Pipe(); PlacedObjectListBox.Items.Add(temp); break; case "Couch": temp = new Couch(); PlacedObjectListBox.Items.Add(temp); break; case "Wardrobe": temp = new Wardrobe(); PlacedObjectListBox.Items.Add(temp); break; case "Lamp": temp = new Lamp(); PlacedObjectListBox.Items.Add(temp); break; case "Desk": temp = new Desk(); PlacedObjectListBox.Items.Add(temp); break; case "Tree": temp = new Tree(); PlacedObjectListBox.Items.Add(temp); break; case "China": temp = new China(); PlacedObjectListBox.Items.Add(temp); break; case "Table": temp = new Table(); PlacedObjectListBox.Items.Add(temp); break; case "Chair": temp = new Chair(); PlacedObjectListBox.Items.Add(temp); break; case "Pistol": temp = new Pistol(); PlacedObjectListBox.Items.Add(temp); break; case "Door": temp = new Door(); PlacedObjectListBox.Items.Add(temp); break; case "Assault Rifle": temp = new AssaultRifle(); PlacedObjectListBox.Items.Add(temp); break; case "Shotgun": temp = new Shotgun(); PlacedObjectListBox.Items.Add(temp); break; case "Rocket Launcher": temp = new RocketLauncher(); PlacedObjectListBox.Items.Add(temp); break; case "Laser Cannon": temp = new LaserCannon(); PlacedObjectListBox.Items.Add(temp); break; case "Player": temp = new Player(); PlacedObjectListBox.Items.Add(temp); break; case "Enemy": temp = new Enemy(); PlacedObjectListBox.Items.Add(temp); break; case "Civilian": temp = new Civilian(); PlacedObjectListBox.Items.Add(temp); break; case "Boss": temp = new Boss(); PlacedObjectListBox.Items.Add(temp); break; case "Cop": temp = new Cop(); PlacedObjectListBox.Items.Add(temp); break; } ; }
// Use this for initialization void Start() { laserCannon = GetComponent<LaserCannon>(); }
// Use this for initialization void Start() { m_laserCannon = GetComponent <LaserCannon>(); }
public void AddWeapon(string s) { Unit script = gameObject.GetComponent <Unit>(); if (script.weapons == null) { script.weapons = new List <Weapon>(); } switch (s) { case "Sword": { Weapon sword = new BeamSword(script); script.weapons.Add(sword); script.Equip(sword); break; } case "Rifle": { Weapon rifle = new Rifle(script); script.weapons.Add(rifle); script.Equip(rifle); break; } case "Frag": { Weapon frag = new Frag(script); script.weapons.Add(frag); script.Equip(frag); break; } case "Laser": { Weapon laser = new LaserCannon(script); script.weapons.Add(laser); script.Equip(laser); break; } case "Chain": { Weapon chain = new EnergyChain(script); script.weapons.Add(chain); script.Equip(chain); break; } case "Photon": { Weapon photon = new PhotonEqualizer(script); script.weapons.Add(photon); script.Equip(photon); break; } default: { Debug.Log("Unit not found"); break; } } }
void SetupWeapons() { laserCannon = this.gameObject.AddComponent <LaserCannon>(); //laserCannon.Init(objectID, controller.statHandler.FireRate, controller.audioSystem, aimAssist); }