/// <summary> /// 加载副武器(子类重写该方法可加特效) /// </summary> public virtual void LoadSecondaryWeapon() { //错误检测 if (primaryWeapon == null) { Debug.LogError("必须先有主武器才能加载副武器!"); return; } //若已存在则延时删除 GameObject toDestroy = null; if (secondaryWeapon != null) { toDestroy = secondaryWeapon.gameObject; } //加载 secondaryWeapon = GameObject.Instantiate(GameSystem.WeaponSystem.getPrefab(secondaryWeaponEnum), transform).GetComponent <SecondaryWeapon>(); secondaryWeapon.AttachICP(this); secondaryWeapon.SetPosition(primaryWeapon.secondaryWeaponPositionL, primaryWeapon.secondaryWeaponPositionR); //删除 if (toDestroy != null) { DestroyImmediate(toDestroy); } }
protected override void UpdateInternal(GameTime time) { Body.SleepingAllowed = false; UnsafeDisableEvents(); var velocity = InputState.MovementSpeed * MovementSpeed; var rotationAmount = InputState.RotationSpeed * RotationSpeed * (time.ElapsedGameTime.TotalMilliseconds / 16.66666); //calculate the actual movement by axis var x = velocity * Math.Sin(Rotation); var y = velocity * -Math.Cos(Rotation); LinearVelocity = new Vector2((float)x, (float)y); AngularVelocity = 0; Rotation += (float)rotationAmount; UnsafeEnableEvents(); //Set the active weapon SetActiveWeapon(); //And update weapons PrimaryWeapon?.Update(time); SecondaryWeapon?.Update(time); TertiaryWeapon?.Update(time); if (ActiveWeapon.Recharged && InputState.FirePressed) { ActiveWeapon.Fire(); } }
public void ToStream(XmlWriter s, Managers.TagManager tag, TI.Definition owner) { s.WriteStartElement("entry"); s.WriteAttributeString("name", Name.ToString()); if (!AppSlot1.Handle.IsNull) { s.WriteAttributeString("appSlot1", AppSlot1.ToString()); } if (!AppSlot2.Handle.IsNull) { s.WriteAttributeString("appSlot2", AppSlot2.ToString()); } if (!PrimaryWeapon.Handle.IsNull) { s.WriteAttributeString("primary", PrimaryWeapon.ToString()); } if (!SecondaryWeapon.Handle.IsNull) { s.WriteAttributeString("secondary", SecondaryWeapon.ToString()); } if (!Equipment.Handle.IsNull) { s.WriteAttributeString("equipment", Equipment.ToString()); } s.WriteEndElement(); }
public override void Start() { base.Start(); Weapon.Init(this); SecondaryWeapon.Init(this); Laser.Init(this); Flashlight.Init(this); }
protected override void GetTypeStateHeader(ByteArrayWriter writer) { writer.Write(PrimaryWeapon != null); PrimaryWeapon?.GetFullState(writer); writer.Write(SecondaryWeapon != null); SecondaryWeapon?.GetFullState(writer); writer.Write(TertiaryWeapon != null); TertiaryWeapon?.GetFullState(writer); }
public Player(string Name, int Health, int Mana, PrimaryWeapon EquippedWeapon, SecondaryWeapon equippedSecondaryWeapon, Item EquippedItem, Inventory Inventory) { name = Name; health = Health; mana = Mana; equippedPrimaryWeapon = EquippedWeapon; equippedItem = EquippedItem; inventory = Inventory; }
public override void Update() { base.Update(); m_IsShooting = false; Laser.RenderLaser(); Flashlight.Update(); Weapon.Update(); SecondaryWeapon.Update(); }
public override void FireSecondary() { if (!GetOverheat()) { SecondaryWeapon.Fire(); PrimaryWeapon.Fire(); PrimaryWeapon.SetFireRate(PFireRate * (((GetHeat() / GetMaxHeat()) + 1)) * 10); SecondaryWeapon.SetFireRate(PFireRate * (((GetHeat() / GetMaxHeat()) + 1)) * 10); } }
protected override void SetTypeStateHeader(ByteArrayReader reader) { if (reader.ReadBool() && PrimaryWeapon != null) { PrimaryWeapon.SetFullState(reader); } if (reader.ReadBool() && SecondaryWeapon != null) { SecondaryWeapon.SetFullState(reader); } if (reader.ReadBool() && TertiaryWeapon != null) { TertiaryWeapon.SetFullState(reader); } }
public void SetSecondaryWeapon(SecondaryWeapon.Type type) { DropSecondaryWeapon(secondaryWeapon); secondaryWeapon = null; foreach (SecondaryWeapon sw in secondaryWeaponList) { if (sw.type == type) { sw.gameObject.SetActive(true); secondaryWeapon = sw; } else { sw.gameObject.SetActive(false); } } }
static void Main(string[] args) { List <Player> players = new List <Player>(); List <AbstractItem> items = new List <AbstractItem>(); //List<Player> players = JsonData.LoadDataPlayers().ToList(); //List<AbstractItem> items = JsonData.LoadDataItems().ToList(); // user Player player1 = new Player("Matan", 1.80, 23, PlayerGender.Male); Player player2 = new Player("Agam", 2.10, 27, PlayerGender.Female); Player player3 = new Player("Anztasia", 1.56, 14, PlayerGender.Female); players.Add(player1); players.Add(player2); players.Add(player3); //items = to plaers AbstractItem item1 = new Backpack(StorageBag.BackpackLeval3, ColorType.Green, 34, "34", "pictures/Backpacing/BackpackLeval3.png", 387, 10, 0); AbstractItem item2 = new SecondaryWeapon(12, KnifeType.Leatherman, ColorType.Green, "Or", 1475, 78, true, 49029, "Gclass", "Pictures/WeaponImg/knife1.png", 250, 100, 99); // add itmes to itmes list items.Add(item1); items.Add(item2); // add itmes to Player player1.AddItem(item1); player1.AddItem(item2); JsonData.SaveDataItems(items); JsonData.SaveDataUsers(players); }
private void DropSecondaryWeapon(SecondaryWeapon w) { if (w == null) { return; } GameObject drop = GameObject.Instantiate(pickablePrefabSW); drop.transform.position = transform.position + Vector3.up; drop.transform.parent = GameObject.Find("Resetables(Clone)").transform; drop.SetActive(true); Vector2 u = pushAmplitude * new Vector2(Random.Range(-pushAmplitude, pushAmplitude), Random.Range(-pushAmplitude, pushAmplitude)).normalized; drop.GetComponent <Rigidbody>().velocity = Vector3.up + u.x * Vector3.left + u.y * Vector3.right; GameObject PickableEmptySW = drop.transform.Find("PickableEmptySW").gameObject; SecondaryWeapon targetWeapon = PickableEmptySW.GetComponent <SecondaryWeapon>(); targetWeapon.type = w.type; targetWeapon.alignment = w.alignment; if (w.iconPrefab != null) { GameObject icon = Instantiate(w.iconPrefab); icon.transform.parent = PickableEmptySW.transform.Find("Slot"); icon.transform.localPosition = new Vector3(0, 0, 0); icon.transform.localRotation = Quaternion.identity; icon.transform.localScale = new Vector3(1, 1, 1); } try { TextMesh tm = PickableEmptySW.transform.Find("Icon").Find("Billboard-icon").Find("Name").GetComponent <TextMesh>(); tm.GetComponent <Renderer>().material.color = (w.alignment < 0 ? new Color32(255, 194, 71, 255) : new Color32(99, 255, 88, 255)); tm.text = w.weaponName; } catch (System.Exception e) { } }
private void WeaponPreAttack(RoundResult rr) { PrimaryWeapon.PreAttack(this, rr); SecondaryWeapon.PreAttack(this, rr); }
public void UpdatePlayerWeapons(GameTime gameTime) { // Waffenaiming if (PrimaryWeapon != null) { PrimaryWeapon.AimAt(); } if (SecondaryWeapon != null) { SecondaryWeapon.AimAt(); } // End Fire foreach (KeyValuePair <WeaponType, IWeapon> pair in weapons) { if (pair.Value != PrimaryWeapon && pair.Value != SecondaryWeapon && pair.Key != WeaponType.NO_WEAPON) { pair.Value.EndFire(); } } // Waffenfeuer if (game.Input.IsKeyDown("Player1.PrimaryFire")) { if (PrimaryWeapon != null) { PrimaryWeapon.BeginFire(); } } else { if (PrimaryWeapon != null) { PrimaryWeapon.EndFire(); } } if (game.Input.IsKeyDown("Player1.SecondaryFire")) { if (SecondaryWeapon != null) { SecondaryWeapon.BeginFire(); } } else { if (SecondaryWeapon != null) { SecondaryWeapon.EndFire(); } } // Waffenwechsel if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.Select1")) { SetPrimaryWeapon(WeaponType.ULTRA_PHASER); } if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.Select2")) { SetPrimaryWeapon(WeaponType.MINIGUN); } if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.Select3")) { SetPrimaryWeapon(WeaponType.ROCKET_STINGER); } if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.Select4")) { SetPrimaryWeapon(WeaponType.PLASMAGUN); } if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.SwitchUp")) { SwitchUp(true); } if (game.Input.HasKeyJustBeenPressed("Player1.PrimaryWeapon.SwitchDown")) { SwitchDown(true); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.Select1")) { SetSecondaryWeapon(WeaponType.ULTRA_PHASER); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.Select2")) { SetSecondaryWeapon(WeaponType.MINIGUN); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.Select3")) { SetSecondaryWeapon(WeaponType.ROCKET_STINGER); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.Select4")) { SetSecondaryWeapon(WeaponType.PLASMAGUN); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.SwitchUp")) { SwitchUp(false); } if (game.Input.HasKeyJustBeenPressed("Player1.SecondaryWeapon.SwitchDown")) { SwitchDown(false); } }
public ItemMenuOption(Point icon, string text, int count, Point position, SecondaryWeapon p_weapon) { this.item = ObjectType.ItemPickup; this.secondaryWeapon = p_weapon; base.Init(icon, text, "0", position, 0x2b); }
void RemoveSecondary() { secondaryWeapon = null; }
void UpdateSecondary(SecondaryWeapon secondary) { secondaryWeapon = secondary; }
/// <summary> /// SecondaryRangedWeapon will fire one shot. /// </summary> public virtual void RangedWeaponSecondaryFireOneShot() { SecondaryWeapon.FireOneShot(GetTargetTransform()); }
/// <summary> /// SecondaryRangedWeapon will stop fireing /// </summary> public virtual void RangedWeaponSecondaryStop() { SecondaryWeapon.Stop(); }
static void Main(string[] args) { SecondaryWeapon a = new SecondaryWeapon(); a.test = testEnum. }
private void SelectSecondaryWeapon(PlayerInput input, SecondaryWeapon weapon, bool silent = false) { if (weapon == selectedSecondaryWeapon) { //Debug.LogFormat("Secondary weapon '{0}' already selected.", weapon); return; } if (selectedLeftSecondaryWeapon != null) selectedLeftSecondaryWeapon.OnDeselect(); if (selectedRightSecondaryWeapon != null) selectedRightSecondaryWeapon.OnDeselect(); switch (weapon) { case SecondaryWeapon.None: selectedLeftSecondaryWeapon = null; selectedRightSecondaryWeapon = null; leftWeaponIndicatorIcon.enabled = false; leftWeaponIndicatorNoneIcon.enabled = true; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = false; TurnLockingSystemOff(); break; case SecondaryWeapon.UnguidedMissiles: selectedLeftSecondaryWeapon = leftUnguidedMissileCannon; selectedRightSecondaryWeapon = rightUnguidedMissileCannon; leftWeaponIndicatorIcon.sprite = unguidedMissilesIcon; leftWeaponIndicatorIcon.enabled = true; leftWeaponIndicatorNoneIcon.enabled = false; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = true; TurnLockingSystemOff(); break; case SecondaryWeapon.GuidedMissiles: selectedLeftSecondaryWeapon = leftGuidedMissileCannon; selectedRightSecondaryWeapon = rightGuidedMissileCannon; leftWeaponIndicatorIcon.sprite = guidedMissilesIcon; leftWeaponIndicatorIcon.enabled = true; leftWeaponIndicatorNoneIcon.enabled = false; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = true; TurnLockingSystemOn(); break; default: throw new Exception("Unexpected PrimaryWeapon."); } if (selectedLeftSecondaryWeapon != null) selectedLeftSecondaryWeapon.OnSelect(input); if (selectedRightSecondaryWeapon != null) selectedRightSecondaryWeapon.OnSelect(input); selectedSecondaryWeapon = weapon; }
private void SelectSecondaryWeapon(PlayerInput input, SecondaryWeapon weapon, bool silent = false) { if (weapon == selectedSecondaryWeapon) { //Debug.LogFormat("Secondary weapon '{0}' already selected.", weapon); return; } if (selectedLeftSecondaryWeapon != null) { selectedLeftSecondaryWeapon.OnDeselect(); } if (selectedRightSecondaryWeapon != null) { selectedRightSecondaryWeapon.OnDeselect(); } switch (weapon) { case SecondaryWeapon.None: selectedLeftSecondaryWeapon = null; selectedRightSecondaryWeapon = null; leftWeaponIndicatorIcon.enabled = false; leftWeaponIndicatorNoneIcon.enabled = true; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = false; TurnLockingSystemOff(); break; case SecondaryWeapon.UnguidedMissiles: selectedLeftSecondaryWeapon = leftUnguidedMissileCannon; selectedRightSecondaryWeapon = rightUnguidedMissileCannon; leftWeaponIndicatorIcon.sprite = unguidedMissilesIcon; leftWeaponIndicatorIcon.enabled = true; leftWeaponIndicatorNoneIcon.enabled = false; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = true; TurnLockingSystemOff(); break; case SecondaryWeapon.GuidedMissiles: selectedLeftSecondaryWeapon = leftGuidedMissileCannon; selectedRightSecondaryWeapon = rightGuidedMissileCannon; leftWeaponIndicatorIcon.sprite = guidedMissilesIcon; leftWeaponIndicatorIcon.enabled = true; leftWeaponIndicatorNoneIcon.enabled = false; leftWeaponIndicatorInfiniteIcon.enabled = false; leftWeaponIndicatorAmmoLabel.enabled = true; TurnLockingSystemOn(); break; default: throw new Exception("Unexpected PrimaryWeapon."); } if (selectedLeftSecondaryWeapon != null) { selectedLeftSecondaryWeapon.OnSelect(input); } if (selectedRightSecondaryWeapon != null) { selectedRightSecondaryWeapon.OnSelect(input); } selectedSecondaryWeapon = weapon; }
public SecondaryWeaponDTO(SecondaryWeapon item) : base(item) { KnifeLength = item.KnifeLength; TypeKnife = item.TypeKnife; }
public virtual void RangedWeaponSecondaryFireBurst(int _shots) { SecondaryWeapon.FireBurst(GetTargetTransform(), _shots); }
public void SelectWeapon(SecondaryWeapon weapon) { this.secondaryWeapon = null; this.secondaryWeapon = weapon; }