public void setWeaponShooting(Weapon.Kind kind, bool shooting) { Weapon weapon = weapons[(int)kind]; if (weapon != null) { weapon.setShooting(shooting); } }
/// <summary> /// Positionates the ammo tiles after the SquareEdges /// </summary> /// <param name="kind">The kind of gun represented</param> private void positionAmmoTiles(Weapon.Kind kind, float precision) { Vector3 origin = new Vector3(); Vector3 expandingDirection = new Vector3(); Vector3 ammoEndEdgeScale = new Vector3(); Vector3 ammoBarScale = new Vector3(); switch (kind) { case Weapon.Kind.LongstandLeft: origin = new Vector3(-1, -1, 0) * precision; expandingDirection = Vector3.left; ammoBarScale = Vector3.down; ammoEndEdgeScale = Vector3.right + Vector3.down; break; case Weapon.Kind.LongstandRight: origin = new Vector3(1, -1, 0) * precision; expandingDirection = Vector3.right; ammoBarScale = Vector3.down; ammoEndEdgeScale = Vector3.left + Vector3.down; break; case Weapon.Kind.ShortstandLeft: origin = new Vector3(-1, 1, 0) * precision; expandingDirection = Vector3.left; ammoBarScale = Vector3.up; ammoEndEdgeScale = Vector3.right + Vector3.up; break; case Weapon.Kind.ShortstandRight: origin = new Vector3(1, 1, 0) * precision; expandingDirection = Vector3.right; ammoBarScale = Vector3.up; ammoEndEdgeScale = Vector3.left + Vector3.up; break; } Vector3 ammoEdgePos = Vector3.up * origin.y + expandingDirection * ammoEdgeDistanceToX0; Vector3 ammoBarPos = origin + expandingDirection * ammoBarEdgeSeparation; Vector3 ammoBarEnd = ammoEdgePos - expandingDirection * ammoBarEdgeSeparation; fullAmmoBarLength = ammoBarEnd.x - ammoBarPos.x; ammoBar.localPosition = ammoBarPos; ammoBar.localScale = ammoBarScale; resizeAmmoBar(1); ammoEndEdge.localPosition = ammoEdgePos; ammoEndEdge.localScale = ammoEndEdgeScale; }
public void ejectWeapon(Weapon.Kind kind) { Weapon weapon = weapons[(int)kind]; if (weapon != null) { weapon.setShooting(false); weapon.transform.parent = null; weapon.disoccupy(); } setWeapon(kind, null); }
private void setWeapon(Weapon.Kind kind, Weapon weapon) { if (weapon == null) { return; } groundWeapon(weapon); weapons[(int)kind] = weapon; if (_hudComponent != null) { _hudComponent.setWeapon(kind, weapon); } }
private void updateTxtWeaponKind(Weapon.Kind kind) { if (txtWeaponKind == null) { Debug.Log("Can't change text of unexisting WeaponKind label"); return; } string stand = "[?]"; string side = "?"; switch (kind) { case Weapon.Kind.LongstandLeft: case Weapon.Kind.LongstandRight: stand = "(L)"; break; case Weapon.Kind.ShortstandLeft: case Weapon.Kind.ShortstandRight: stand = "[S] "; break; } switch (kind) { case Weapon.Kind.LongstandLeft: case Weapon.Kind.ShortstandLeft: side = "Left"; txtWeaponKind.alignment = TextAnchor.UpperLeft; break; case Weapon.Kind.LongstandRight: case Weapon.Kind.ShortstandRight: side = "Right"; txtWeaponKind.alignment = TextAnchor.UpperRight; break; } txtWeaponKind.text = string.Format(weaponKindMessage, stand, side); }
public void setWeapon(Weapon.Kind kind, Weapon weapon) { weapons[(int)kind] = weapon; reticles[(int)kind].setWeapon(weapon); }