void CmdFire(string shooter, Vector3 pos, Vector3 forward, Quaternion rotation, int damage, PlayerWeapon weapon) { var bullet = (GameObject)Instantiate(bulletPrefab, pos + forward, rotation); bullet.SetActive(false); bullet.GetComponent<Rigidbody>().velocity = forward * 50; bullet.transform.rotation = rotation; Player killer = GameManager.GetPlayer(shooter).GetComponent<Player>(); bullet.GetComponent<Bullet>().damage = damage; bullet.GetComponent<Bullet>().attacker = killer; //bullet.layer = LayerMask. bullet.SetActive(true); NetworkServer.Spawn(bullet); Destroy(bullet, 5f); }
void Update () { if (Input.GetKeyDown(KeyCode.P)) { playerState = PlayerState.PauseState; } if (Input.GetKeyDown(KeyCode.P) && isPaused) { playerState = PlayerState.ResumeState; } if (Input.GetKeyDown(KeyCode.Keypad1)) { playerWeapon = PlayerWeapon.Banana; } if (Input.GetKeyDown(KeyCode.Keypad2)) { playerWeapon = PlayerWeapon.Popsicle; } if (Input.GetKeyDown(KeyCode.Keypad3)) { playerWeapon = PlayerWeapon.Dagger; } }
// Use this for initialization void Start() { PMovement = GetComponent<PlayerMovement>(); PCamera = GetComponent<PlayerCamera>(); PInput = GetComponent<PlayerInput>(); PWeapon = GetComponent<PlayerWeapon>(); PData = GetComponent<PlayerData>(); }
void Awake() { health = maxHealth; weapon = GetComponent<PlayerWeapon>(); mainCamera = Camera.main; srenderer = GetComponent<SpriteRenderer>(); anim = GetComponent<Animator>(); movement = GetComponent<PlayerMovement>(); }
void Shoot(string shooter, Vector3 pos, Vector3 forward, LayerMask mask, PlayerWeapon weapon) { RaycastHit hit; Debug.DrawRay(pos, forward * 10, Color.red, 100, true); if(Physics.Raycast(pos, forward, out hit, weapon.range, mask)) { if(hit.collider.tag == "Player") { CmdPlayerShot(hit.collider.name, weapon.damage, shooter); } } }
private void EquipWeapon(PlayerWeapon weapon) { this._currentWeapon = weapon; GameObject weaponIns = (GameObject)Instantiate(weapon.Graphics, this._weaponHolder.position, this._weaponHolder.rotation); weaponIns.transform.SetParent(this._weaponHolder); this._currentGraphics = weaponIns.GetComponent<WeaponGraphics>(); if (this._currentGraphics == null) Debug.LogError("No WeaponGraphics component at the weapon object: " + weaponIns.name); if (this.isLocalPlayer) Util.SetLayerRecursively(weaponIns, LayerMask.NameToLayer(this._weaponLayerName)); }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponent<WeaponGraphics>(); if (currentGraphics == null) Debug.LogError("No WeaponGraphics component on the weapon object: " + _weaponIns.name); if (isLocalPlayer) Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(weaponLayerName)); }
public override void Init( GameObject parent ) { base.Init(parent); Cooldown = 12f; Description = "Heal every 12 seconds."; Duration = 0f; Icon = ""; Id = PowerupEnum.Health; Name = "Health"; Passive = true; elapsed = 0; playerWeapon = gameObject.GetComponent<PlayerWeapon>(); }
void Start() { // Set up weapons actualPrimaryWeapon1 = ((PlayerWeapon)primaryWeapon1.GetComponent("PlayerWeapon")); actualPrimaryWeapon2 = ((PlayerWeapon)primaryWeapon2.GetComponent("PlayerWeapon")); actualSecondaryWeapon = ((PlayerWeapon)secondaryWeapon.GetComponent("PlayerWeapon")); // Set up counters primaryFireTimer = 0.0f; secondaryFireTimer = 0.0f; firingPrimary = true; gateOpener = (GateOpener)(gameObject.GetComponent("GateOpener")); gateBulletCollider = (Collider)gateBulletKiller.GetComponent("Collider"); }
void Update() { currentWeapon = weaponManager.GetCurrentWeapon(); if (PauseMenu.IsOn) { return; } if (currentWeapon == null) { return; } if (currentWeapon.fireRate <= 0) { if (Input.GetButtonDown("Fire1")) { Shoot(); } } else { if (Input.GetButtonDown("Fire1")) { InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate); canResetBurstLong = false; } else if (Input.GetButtonUp("Fire1")) { CancelInvoke("Shoot"); canResetBurstLong = true; ResetBurstLong(); } } if (isLocalPlayer) { TMP_Text KillCountText = playerUIInstance.GetComponent <PlayerUi>().KillCountText; if (KillCountText != null) { KillCountText.text = "Kills: " + KillCount; } } }
public void SetWeapon(int setValue) { if (_weaponIndex >= 0) { if (_currentWeapon) { Destroy(_currentWeapon.gameObject); } if (setValue >= 0 && setValue < _weapons.Length) { _currentWeapon = Instantiate(_weapons[setValue], transform.position, Quaternion.identity); _currentWeapon.transform.parent = transform; _currentWeapon.targetTag = targetTag; } } }
private void Start() { player = GetComponent <Player>(); for (int i = 0; i < weaponList.Length; i++) { CreateWeapon(weaponList[i]); weaponList[i].graphics.SetActive(false); } primaryWeapon = weaponList[0]; currWeapon = primaryWeapon; CmdEquipWeapon(primaryWeapon, 0); foreach (PlayerWeapon weapon in weaponList) { weapon.currBullets = weapon.maxBullets; //weaponBullets.Add(weapon.currBullets); } }
public void setDefaults() { activeWeapon = null; foreach (PlayerWeapon wpn in weapons) { wpn.isUnlocked = false; } shootTimer = 0; weapons[0].isUnlocked = true; isReloading = false; if (reloadRoutine != null) { StopCoroutine(reloadRoutine); } weapons[0].currentAmmo = weapons[0].ammoInClip; setActiveWeapon(0); }
public string RegisterUser() { StringBuilder sb = new StringBuilder(); try { var player = new PlayerDto(); writer.WriteLine($"Enter player's username:"******"Enter player's password"); player.Password = Console.ReadLine(); var wand = context.Weapons.FirstOrDefault(w => w.Name == "Metal Wand"); var dbPlayer = new Player { Username = player.Username, Password = player.Password, GamesPlayed = player.GamesPlayed, Wins = player.Wins }; context.Players.Add(dbPlayer); var playerWeapon = new PlayerWeapon { Player = dbPlayer, PlayerId = dbPlayer.Id, Weapon = wand, WeaponId = wand.Id }; context.PlayerWeapons.Add(playerWeapon); context.SaveChanges(); sb.AppendLine($"Successfully created player {player.Username}"); Players.Add(dbPlayer); } catch (ArgumentException ex) { return(ex.Message); } return(sb.ToString()); }
private void Awake() { weapon = FindObjectOfType <PlayerWeapon>(); if (instance == null || instance == this) { DontDestroyOnLoad(this.gameObject); instance = this; } else { Destroy(this.gameObject); } if (instance != null) { Debug.Log(instance); Debug.Log(instance.gameObject); Debug.Log("Instances same: " + (instance == this)); } else { Debug.Log("instance = null"); } /* if (instance == null) * { * DontDestroyOnLoad(this.gameObject); * instance = this; * } else { * Destroy(this.gameObject); * } */ controller = GetComponent <Controller2D>(); animator = GetComponent <Animator>(); collider = GetComponent <BoxCollider2D>(); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; inputScale = gameObject.AddComponent <FloatTimer>().Constructor(1f); accelerationTimeAirborne = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeAirborne); accelerationTimeGrounded = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeGrounded); dashOnCooldown = gameObject.AddComponent <BoolTimer>().Constructor(false); }
void Start() { currentWeapon = primaryWeapon; ChangeCurrentVisual(); // get the attached nametag and set the name to the one we held in PlayerUI while the page loaded nameTag = transform.Find("NameTagHolder").Find("NameTag").gameObject; nameTag.GetComponent <UnityEngine.UI.Text>().text = GameObject.FindWithTag("PlayerUI").GetComponent <PlayerNameHolder>().PlayerName; if (isLocalPlayer) { isLocalCache = true; nameTag.SetActive(false); } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("no weaponGraphics component on the weapon Object " + _weaponIns.name); } if (isLocalPlayer) { Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(weaponLayerName)); } }
private void Update() { currentWeapon = weaponManager.GetCurrentWeapon(); if (PauseMenu.IsOn) { return; } if (Input.GetKeyDown(KeyCode.R)) { if (currentWeapon.bullets < currentWeapon.maxBullets) { weaponManager.Reload(); return; } } if (currentWeapon.fireRate == 0f) { if (Input.GetButtonDown("Fire1")) { Shoot(); } } else { if (Input.GetButtonDown("Fire1")) { InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate); } else if (Input.GetButtonUp("Fire1")) { CancelInvoke("Shoot"); } } if (Input.GetKeyDown(KeyCode.Alpha1)) { weaponManager.EquipPrimaryWeapon(); } if (Input.GetKeyDown(KeyCode.Alpha2)) { weaponManager.EquipSecondaryWeapon(); } }
// Update is called once per frame void Update() { currentWeapon = weaponManager.GetCurrentWeapon(); // WILL CHANGE WHEN YOU ARE ABLE TO CATCH THESE HANDS if (!gameManager.isPaused && weaponManager.GetCurrentWeaponInstance() != null) { if (Input.GetKeyDown(KeyCode.R) && currentAmmo < maxAmmo) { weaponManager.ReloadSpin(); currentAmmo = maxAmmo; playerUIScript.SetCurrentAmmo(currentAmmo.ToString()); } if (currentWeapon.fireRate <= 0f && currentAmmo > 0 && canShoot) { if (Input.GetButtonDown("Fire1")) { Shoot(); } } else { if (Input.GetButtonDown("Fire1") && canShoot && currentAmmo > 0) { InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate); } else if (Input.GetButtonUp("Fire1") || currentAmmo <= 0 && canShoot) { CancelInvoke("Shoot"); canShoot = false; StartCoroutine(CanShootAgain(currentWeapon.fireRate)); } } } if (!gameManager.isPaused) { if (Input.GetButtonDown("Fire2") && grenadeCount > 0) { LobGrenade(); } } }
// For melee attacks private void HandleMelee(bool input, PlayerWeapon weapon) { weapon.UpdateCooldown(); if (input && melee.cooldown <= 0) { float direction = (movement.is_right_facing ? 1 : -1); GameObject this_weapon = (GameObject)Instantiate( weapon.obj, transform.position + transform.up + transform.right * direction, Quaternion.identity ); // Attach melee hitbox to player this_weapon.transform.SetParent(transform); this_weapon.SendMessage("SetDirection", direction); // Side effects of attack weapon.cooldown = weapon.cooldown_max; } }
public void EquipWeapon(GameObject weapon) { //if (currentWeapon != null) //{ // Debug.Log("Destroying the previous weapon"); // affD // Destroy(currentWeapon.transform); //} GameObject weaponIns = (GameObject)Instantiate(weapon, weaponHolder.position, weaponHolder.rotation); currentWeapon = weaponIns.GetComponent <PlayerWeapon>(); weaponIns.transform.SetParent(weaponHolder); currentGFX = weaponIns.GetComponent <WeaponGFX>(); if (currentGFX == null) { Debug.LogError("No weaponGFX component on the weapon object " + weaponIns.name); } }
void EquipWeapon(PlayerWeapon weapon) { currentWeapon = weapon; GameObject weaponInst = (GameObject)Instantiate(weapon.graphics, weaponHolder.position, weaponHolder.rotation); weaponInst.transform.SetParent(weaponHolder); currentGraphics = weaponInst.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("No WeaponGraphics component on the weapon object: " + weaponInst.name); } if (isLocalPlayer) { Utils.SetLayerRecursively(weaponInst, LayerMask.NameToLayer(weaponLayerName)); } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("No WeaponGraphics component on '" + _weaponIns.name + "'."); } if (isLocalPlayer) {//sets the layers of every child of the weapon object Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(weaponLayerName)); } }
public void update(PlayerWeapon weapon) { // update filled bar if (weapon.isMaxLevel()) { base.update(1.0f, 1.0f); } else { base.update(weapon.experience, weapon.getExpForNextLevel()); } // update number of level textLevel.text = weapon.level.ToString(); // update colors changeColor(weapon.color); }
void EquipWeapon(PlayerWeapon weapon) { if (weaponHolder.childCount > 0) { Destroy(weaponHolder.GetChild(0).gameObject); } currentWeapon = weapon; GameObject o = Instantiate(weapon.graphics, weaponHolder.position, weaponHolder.rotation); o.transform.SetParent(weaponHolder); currentGraphics = o.GetComponent <WeaponGraphics>(); if (!currentGraphics) { Debug.LogError("No WeaponGraphics script on the current weapon " + o.name); } }
private void OnTriggerEnter2D(Collider2D other) { WeaponIcon icon = other.GetComponent <WeaponIcon>(); if (icon != null) { currentWeapon = null; currentWeapon = GetWeapon(weapons, icon.weaponType); Destroy(icon.gameObject); foreach (PlayerWeapon weapon in weapons) { if (weapon.weaponType != icon.weaponType) { weapon.gameObject.SetActive(false); } } } }
// For ranged attacks with travel time private void HandleProjectile(bool input, PlayerWeapon weapon) { weapon.UpdateCooldown(); // Ranged attack cannot cancel melee attack if (input && ranged.cooldown <= 0 && melee.cooldown <= 0) { float direction = (movement.is_right_facing ? 1 : -1); // Ranged attack hitbox GameObject this_weapon = (GameObject)Instantiate( weapon.obj, transform.position + transform.up + transform.right * direction, Quaternion.identity ); this_weapon.SendMessage("SetDirection", direction); // Side effects of attack weapon.cooldown = weapon.cooldown_max; } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponentInChildren <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("No WeaponGraphics component on the weapon object: " + _weaponIns.name); } if (isLocalPlayer) { _weaponIns.layer = LayerMask.NameToLayer(weaponLayerName); } }
private void WeaponDropTarget_WeaponSelected(PlayerWeapon obj) { if (obj == null) { _bigChoseHint.gameObject.SetActive(true); _upgradeName.gameObject.SetActive(false); _upgradeDesc.gameObject.SetActive(false); } else { _bigChoseHint.gameObject.SetActive(false); _upgradeName.gameObject.SetActive(true); _upgradeDesc.gameObject.SetActive(true); _upgradeName.text = "Selected Weapon Modifiers"; _upgradeDesc.text = PlayerWeapon.GetDescription(obj); } }
// Update is called once per frame private void Update() { // Only check for inputs if player is not being controlled by the AI if (!IsAI) { // The game is played by a human player if (Input.GetKeyDown(KeyCode.A)) { spriteRenderer.sprite = bowSprite; weapon = PlayerWeapon.Bow; } else if (Input.GetKeyDown(KeyCode.S)) { spriteRenderer.sprite = swordSprite; weapon = PlayerWeapon.Sword; } } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject weaponints = Instantiate(_weapon.graphics, weaponOlder.position, weaponOlder.rotation); weaponints.transform.SetParent(weaponOlder); currentGraphics = weaponints.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("Pas de WeaponGraphics sur l'arme : " + weaponints.name); } if (isLocalPlayer) { Util.SetLayerRecursively(weaponints, LayerMask.NameToLayer(weaponLayerName)); } }
private void InitContext() { var player = GameObject.FindWithTag("Player"); _playerDestruct = player.GetComponent <Destructible>(); _playerWeapon = player.GetComponentInChildren <PlayerWeapon>(); _playerScore = player.GetComponent <ScoreCounter>(); //init sliders _healthSlider.maxValue = _playerDestruct.MaxArmor; _healthSlider.value = _playerDestruct.CurrentArmor; _shieldSlider.maxValue = _playerDestruct.MaxShield; _shieldSlider.value = _playerDestruct.CurrentShield; _energySlider.maxValue = _playerWeapon.MaxEnergy; _energySlider.value = _playerWeapon.CurrentEnergy; }
private void RemoveWeapon(PlayerWeapon weapon) { int index = System.Array.IndexOf(weapons, weapon); PlayerWeapon[] mass = new PlayerWeapon[weapons.Length - 1]; int indMass = 0; for (int i = 0; i < weapons.Length; i++) { if (index != i) { mass[indMass] = weapons[i]; indMass++; } } weapons = mass; }
// For ranged attacks that hit instantly private void HandleHitscan(bool input, PlayerWeapon weapon) { weapon.UpdateCooldown(); // Ranged attack cannot cancel melee attack if (input && ranged.cooldown <= 0 && melee.cooldown <= 0) { float direction = (movement.is_right_facing ? 1 : -1); // Raycast fires forward Vector3 ray_origin_anchor = transform.position + transform.up + transform.right * direction; float ray_length = Screen.width; weapon.obj.GetComponent <LineRenderer>().SetPosition(0, ray_origin_anchor); // If ranged attack hits an enemy RaycastHit hit; if (Physics.Raycast( ray_origin_anchor, Vector3.right * direction, out hit, ray_length, collision_mask )) { if (hit.collider.gameObject.tag == "Enemy" || hit.collider.gameObject.tag == "Boss") { hit.collider.gameObject.SendMessage("OnHitRanged", weapon.hitscan_damage); } weapon.obj.GetComponent <LineRenderer>().SetPosition(1, hit.point); } // If ranged attack fires off screen else { weapon.obj.GetComponent <LineRenderer>().SetPosition(1, ray_origin_anchor + Vector3.right * direction * ray_length); } // Draw LineRenderer for shot GameObject this_weapon = (GameObject)Instantiate(weapon.obj); StartCoroutine(DestroyAfterSeconds(this_weapon, 0.13f)); Debug.DrawRay( ray_origin_anchor, Vector3.right * direction * ray_length, Color.yellow ); } }
private void UnequipCurrentWeapon() { if (_activeWeaponIndex != -1) { PlayerWeapon current = _weaponSlot.Weapon; WeaponGroup group = current.Properties.weaponGroup; _activeWeaponIndex = -1; if (group == WeaponGroup.Main) { _activeMainIndex = -1; } else if (group == WeaponGroup.Melee) { _activeMeleeIndex = -1; } else if (group == WeaponGroup.Secondary) { _activeSecondaryIndex = -1; } _weaponSlot.Weapon = null; current.gameObject.SetActive(false); current.transform.SetParent(transform); current.transform.localPosition = Vector3.zero; current.transform.rotation = transform.rotation; _activeAmmo = null; _activeAmmoIndex = -1; UpdateAmmoHUD(); _uiHUD.ShowResult(true, "Current Weapon Unequipped"); } else { _uiHUD.ShowResult(false, "No Weapon to Unequip"); } }
public IEnumerator OnWeaponProc(PlayerWeapon playerWeapon) { float startWeaponAngle = playerWeapon.WeaponParameters.WeaponAngle; float offsetAngle = 0f; bool goBack = false; while (true) { if (playerWeapon.IsNoSooting) { playerWeapon.WeaponParameters.WeaponAngle = startWeaponAngle; yield return(null); continue; } float deltaAngle = playerWeapon.WeaponParameters.SpreadAngle * WEAPON_MOVE_TIME * TimeManager.PlayerDeltaTime; if (goBack == false) { if (offsetAngle < playerWeapon.WeaponParameters.SpreadAngle / 2f) { offsetAngle += deltaAngle; } else { goBack = true; } } else { if (offsetAngle > -playerWeapon.WeaponParameters.SpreadAngle / 2f) { offsetAngle -= deltaAngle; } else { goBack = false; } } playerWeapon.WeaponParameters.WeaponAngle = startWeaponAngle + offsetAngle; yield return(null); } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("NO WEAPONGRAPHICS COMPONENT ON THE WEAPON OBJECT: " + _weaponIns.name); } if (isLocalPlayer) { Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(weaponLayerName)); } }
void EquipWeapon(PlayerWeapon _weapon) { currentWeapon = _weapon; GameObject _weaponIns = Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation); _weaponIns.transform.SetParent(weaponHolder); currentGraphics = _weaponIns.GetComponent <WeaponGraphics>(); if (currentGraphics == null) { Debug.LogError("No current Weapon Graphic assigned."); } if (isLocalPlayer) { Util.SetLayerRecursively(_weaponIns, LayerMask.NameToLayer(WEAPON_LAYER_NAME)); } }
//public void AddWeapon(NewWeaponConfig pConfig) public void AddWeapon(PlayerWeapon pWeapon) { //Debug.Log("AddWeapon " + pWeapon); PlayerWeapon weaponInInventory = weapons.Find(a => a.Id.Equals(pWeapon.Id)); if (weaponInInventory != null) { weaponInInventory.OnAddSameWeapon(pWeapon); } else { weapons.Add(pWeapon); weaponInInventory = pWeapon; } SetActiveWeapon(weapons.IndexOf(weaponInInventory)); }
//sets currentEquip to passed in equipment type //called by oncollision method of weapon pickup after it grabs the equipment handler component of collided player if it collides with a player public void ChangeEquip(ProjType p) { //TODO: implement weapon change PlayerWeapon locWeapon=null; //just for assignment reasons if (p.Equals(ProjType.straight)) { locWeapon = Straight; } else if (p.Equals(ProjType.bounce)) { locWeapon = Bounce; } else if (p.Equals(ProjType.curve)) { locWeapon = Curve; } else if (p.Equals(ProjType.missile)) { locWeapon = Missle; } else if (p.Equals(ProjType.chain)) { locWeapon = Straight; } else if (p.Equals(ProjType.columbus)) { locWeapon = Columbus; } else if (p.Equals(ProjType.spread)) { locWeapon = Spread; } else if (p.Equals(ProjType.boomerang)) { locWeapon = Straight; } equippedWeapon = locWeapon; weaponObject = locWeapon.WeaponPrefab; curryAmmo = locWeapon.ammo; Utilities.SendToListeners(new Message(gameObject, OmonoPehaviour.ms_EQUIPCHANGE)); }
private void SetWeaponRendererEnabled(PlayerWeapon weapon, bool enabled) { MeshRenderer renderer = weapon.gameObject.GetComponentInChildren<MeshRenderer>(); if(renderer != null) { renderer.enabled = enabled; } }
void Update() { currentWeapon = weaponManager.GetCurrentWeapon(); if (PauseMenu.IsOn) return; if (currentWeapon.bullets < currentWeapon.maxBullets) { if (Input.GetButtonDown("Reload")) { weaponManager.Reload(); return; } } if (currentWeapon.fireRate <= 0f) { if (Input.GetButtonDown("Fire1")) { Shoot(); } } else { if (Input.GetButtonDown("Fire1")) { InvokeRepeating("Shoot", 0f, 1f/currentWeapon.fireRate); } else if (Input.GetButtonUp ("Fire1")) { CancelInvoke("Shoot"); } } }
private void shootWeaponWherePlayerFacing(PlayerWeapon weapon) { if (this.FacingRight) { weapon.ShootRight(); } else { weapon.ShootLeft(); } }
private void Awake() { player = GetComponent<Player>(); pWeapon = GetComponent<PlayerWeapon>(); //Add this UI to the UpdateUI event UIManager.Instance.OnUIUpdate.AddListener(() => UpdateAmmoUI()); }
void Awake() { instance = this; ResetEvents(); anim = GetComponent<Animator>(); audio = GetComponent<PlayerAudio>(); damageFlash = GetComponent<SpriteFlash>(); feedback = GetComponent<PlayerForceFeedback>(); health = GetComponent<PlayerHealth>(); input = GetComponent<PlayerInput>(); interaction = GetComponent<PlayerInteraction>(); physics = GetComponent<PlayerPhysics>(); weapon = GetComponent<PlayerWeapon>(); meleeAttackBox = transform.FindChild("MeleeAttackBox").gameObject; }
void Start() { blockInv = new SortedDictionary<byte, int>(); _mesh = transform.FindChild("Mesh").gameObject; _nameTag = transform.FindChild("NameTag").gameObject.GetComponent<TextMesh>(); _playerTerrainModify = GetComponent<PlayerTerrainModify>(); _playerWeapon = GetComponent<PlayerWeapon>(); activeHandItem = ActiveHandItem.Pickaxe; _networkManager = GameObject.Find("_Scripts").GetComponent<NetworkManager>(); if (isBluTeam) { transform.position = World.BluTeamRespawnPoint; } else { transform.position = World.RedTeamRespawnPoint; } }
private void updateWeaponPosition(PlayerWeapon weapon, Vector2 offset) { Vector2 wepPos = Position; if (this.FacingRight) { wepPos.X += offset.X; } else { wepPos.X -= offset.X; } wepPos.Y += offset.Y; weapon.Position = wepPos; }
private void shootWeapon(PlayerWeapon weapon) { this.playerEvent.shootWeapon = true; // check whether this weapon should be active bool weaponActiveState = false; if (weapon.Active) weaponActiveState = true; // deactivate all other weapons deactivateWeapons(); //.. except this weapon if (weaponActiveState) weapon.Active = true; }