private void Awake() { weaponsManager = GetComponent <WeaponsManager>(); zoomAnim = transform.Find(Tags.LOOK_ROOT).transform.Find(Tags.ZOOM_CAM).GetComponent <Animator>(); crosshair = GameObject.FindGameObjectWithTag(Tags.CROSSHAIR); mainCam = Camera.main; }
// Use this for initialization void Start() { flightControl = transform.GetComponent <SpaceFlightController>(); weaponsControl = transform.GetComponent <WeaponsManager>(); weaponsControl.SetPlayerWeapon(true); }
void Start() { timeCreated = Time.timeSinceLevelLoad; bubbleGenerator = GameObject.FindGameObjectWithTag("BubbleGenerator").GetComponent <BubbleGenerator>(); weaponsManager = GameObject.FindGameObjectWithTag("WeaponsManager").GetComponent <WeaponsManager> (); StartCoroutine(BubblePath()); }
private void Start() { PlayerPrefs.DeleteAll(); cash = 500; selectedWeaponIndex = 0; store.hasWeapon = 1; weapons.playerHasWeapon = false; weaponsManager.weapons[0].playerHasWeapon = true; playerWeaponAmount = 0; for (int i = 1; i < weaponsManager.weapons.Count; i++) { weaponsManager.weapons[i].playerHasWeapon = false; weaponsManager.weapons[i].ammoPrice = weaponsManager.weapons[i].startAmmoPrice; } playerWeaponAmount = 2; playerWeaponAmount = 0; weaponSlot1 = 0; storeUI.SetActive(false); Cursor.visible = false; cash = PlayerPrefs.GetInt("Cash", 500); store = FindObjectOfType <Store>().GetComponent <Store>(); weaponsManager = this.GetComponent <WeaponsManager>(); selectedWeaponIndex = PlayerPrefs.GetInt("SelectedWeaponIndex", 0); weapons = weaponsManager.weapons[0]; weapons.clipSize = weapons.fullClipSize; weapons.reserveAmmoSize = weapons.fullReserveAmmoSize; nessaHealth = this.GetComponent <NessaHealth>(); }
// Use this for initialization void Start() { m_WeaponManager = new WeaponsManager(); setWeapon(SelectedWeapon); IsGameRunning = true; Debug.Log("Player started with weapon = " + SelectedWeapon); }
public void UpdateWeaponUI() { //todo get rid of singlton approach WeaponsManager weaponManager = WeaponsManager.Instance; ActivateOccupiedSlots(); for (int i = 0; i < weaponManager.WeaponInventory.Length; i++) { if (i == weaponManager.WeaponIndex) { weaponSlots[i].activeBackground.SetActive(true); for (int j = 0; j < icons.Length; j++) { if (icons[j].ammoType == weaponManager.CurrentWeapon.WeaponType && weaponManager.CurrentWeapon.MaxAmmoReserves >= 0) { icons[j].activeBackground.SetActive(true); icons[j].inactiveForeground.SetActive(false); } else { icons[j].activeBackground.SetActive(false); icons[j].inactiveForeground.SetActive(true); } } } else { weaponSlots[i].activeBackground.SetActive(false); } } weaponIcon.sprite = weaponManager.WeaponInventory[weaponManager.WeaponIndex].GetComponent <WeaponPickup>().WeaponSprite; //todo also wonky rn, implement mor eexplicit way to set icon }
public void UpdateAmmoUI() { WeaponsManager weaponManager = WeaponsManager.Instance; if (weaponManager.CurrentWeapon.MaxAmmoReserves < 0) { ammoResevesText.text = "/∞"; } else { ammoResevesText.text = "/" + Mathf.CeilToInt(weaponManager.RemainingReservesOfCurrentWeapon() * weaponManager.CurrentWeapon.MaxAmmoReserves); } if (weaponManager.CurrentWeapon.MaxMagSizes < 0) { ammoText.text = "∞"; } else { ammoText.text = "" + weaponManager.CurrentWeapon.RemainingMag; } foreach (var v in icons) { v.fillImage.fillAmount = WeaponsManager.Instance.RemainingReservesOfType(v.ammoType); } }
public override void PickUp() { WeaponsManager manager = WeaponsManager.Instance; manager.RefillReserves(ammoType, refillPercentage); base.PickUp(); }
// Start is called before the first frame update void Start() { // 监听武器改变事件 weaponsManager = Director.GetInstance().CurrentWeaponsManager; weaponsManager.WeaponTypeChange += WeaponChange; weaponsManager.WeaponBulletClipChange += WeaponClipChange; weaponImage.sprite = weaponsManager.bulletSprites[0]; }
// Use this for initialization void Start() { _instance = this; weapons = new Dictionary <string, GameObject>(); foreach (GameObject g in Weapons) { weapons.Add(g.name, g); } }
protected override void Update() { base.Update(); if (healthbar.health > 0) { return; } GameManager.AddPlayerHealth(10); WeaponsManager.AddMoreAmmo(10, 0); Destroy(gameObject); }
private void Update() { if (healthbar.health > 0) { return; } WeaponsManager.FillNowWeapon(30, 10); GameManager.FillPlayerHealth(500); GameManager.OpenDoor("System32"); GameManager.OpenDoor("AppData"); Destroy(gameObject); }
private void Update() { if (healthBar.health > 0) { return; } WeaponsManager.FillNowWeapon(30, 3); GameManager.FillPlayerHealth(100); GameManager.OpenDoor("task manager"); GameManager.OpenDoor("Registry"); Destroy(gameObject); }
void Start () { Cursor.visible = false; if(currentCamera != null) { currentCameraPositionOffset = currentCamera.transform.position - transform.position; } playerRigidBody = GetComponent<Rigidbody>(); health = GetComponent<Health>(); groundedCooldown = 0f; weaponsManager = GetComponent<WeaponsManager> (); }
void OnTriggerEnter(Collider c) { WeaponsManager manager = c.GetComponentInParent <WeaponsManager>(); if (manager) { manager.CollectShield(); gameObject.SetActive(false); if (onCollected != null) { onCollected(); } } }
void Start() { weapons = GetComponent <WeaponsManager>(); //player = Camera.main.GetComponent<Player>(); Debug.Log("Player " + player.pname); navAgent = GetComponent <NavMeshAgent>(); objName = "Unit"; //GetComponent<Renderer>().material.color = player.TeamColor; IAction[] unitActions = new IAction[weapons.weapons.Length]; for (int i = 0; i < weapons.weapons.Length; i++) { unitActions[i] = new AttackAction(weapons.weapons[i]); } actions = unitActions; }
void Start() { WeaponsManager weaponsManager = Director.GetInstance().CurrentWeaponsManager; weaponsManager.WeaponTypeChange += WeaponChange; if (toggleImage.Count != Director.GetInstance().CurrentWeaponsManager.bulletSprites.Count) { Debug.LogError("可选的武器UI列表与提供的UI数量不同"); } for (int i = 0; i < toggleImage.Count; i++) { toggleImage[i].sprite = Director.GetInstance().CurrentWeaponsManager.bulletSprites[i]; } }
void Awake() { if (instance == null) { DontDestroyOnLoad(gameObject); instance = this; } else { if (instance != this) { Destroy(gameObject); } } }
public bool SetWeaponsManager() { if (player != null) { weaponsManager = player.GetComponentInChildren <WeaponsManager> (); } if (weaponsManager != null) { return(true); } else { return(false); } }
private void ActivateOccupiedSlots() { WeaponsManager weaponManager = WeaponsManager.Instance; for (int i = 0; i < weaponManager.WeaponInventory.Length; i++) { if (weaponManager.WeaponInventory[i]) { weaponSlots[i].gameObject.SetActive(true); } else { weaponSlots[i].gameObject.SetActive(false); } } }
/// <summary> /// Destrói esta instância de sprite, retirando-a de todas as listas /// </summary> public void Destroy() { if (this is Bala) { WeaponsManager.removeBala((Bala)this); } if (this is Missil) { WeaponsManager.removeMissil((Missil)this); } if (this is NPC) { EnemyManager.removeEnemy((NPC)this); } this.scene.RemoveSprite(this); }
void Awake() { s_instance = this; int weaponTypeCount = Enum.GetNames(typeof(WeaponBase.WeaponType)).Length; //get the number of different weapon types _indexedWeapons = new WeaponBase[weaponTypeCount + 1]; foreach (WeaponBase weaponBase in _weapons) { int index = (int)weaponBase.weaponType; //convert enum to rank index if (_indexedWeapons[index] != null) { Debug.LogError("There are more than one weapon of the same type in weaponsManager. This is not allowed. Create a new weapon type if you want to add a weapon with a different property"); } _indexedWeapons[index] = weaponBase; } }
/// <summary> /// Carrega os assets do jogo e o estado inicial /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); scene = new Scene(spriteBatch); Cena = scene; font = Content.Load <SpriteFont>("MyFont"); WeaponsManager.LoadContent(Content); EnemyManager.LoadContent(Content, random); kbLimit = 0; timeToRestart = 0; timerTextos = 0; texto = new KeyValuePair <string, Vector2>("", Vector2.Zero); textoBridge1 = new KeyValuePair <string, Vector2>("", Vector2.Zero); textoBridge2 = new KeyValuePair <string, Vector2>("", Vector2.Zero); textoEnd = new KeyValuePair <string, Vector2>("", Vector2.Zero); LoadLevel(GameState.Menu); }
protected override void Update() { base.Update(); if (healthbar.health > 0) { return; } GameManager.appDataDroneNumbers--; if (GameManager.appDataDroneNumbers == 0) { GameManager.FillPlayerHealth(100); WeaponsManager.FillNowWeapon(30, 3); GameManager.OpenDoor("Registry"); GameManager.OpenDoor("System32"); } WeaponsManager.AddMoreAmmo(10, 0); Destroy(gameObject); }
// Start is called before the first frame update void Start() { MatchController.RegisterOnPause(Pause); MatchController.RegisterOnResume(Resume); _startingPosition = _movingTransform.position; ResetPlayer(); //Invert the ratio in order to use multiplication instead of division later on. Faster calculations. _energyToHPRatio = 1.0f / _energyToHPRatio; _weaponsManager = GetComponentInChildren <WeaponsManager>(); if (_weaponsManager == null) { throw new Exception("Error: weapon manager not found in player."); } if (_collisionResolver == null) { throw new Exception("Error: Collision Resolver not found in player!"); } var playerWeapons = new List <WeaponData>(); playerWeapons.Add(new WeaponData() { GloveType = GloveType.Glove, ProjectileType = ProjectileTypeEnum.Physical }); playerWeapons.Add(new WeaponData() { GloveType = GloveType.Glove, ProjectileType = ProjectileTypeEnum.Energy }); _weaponsManager.CreateWeapons(playerWeapons); _currentWeapon = _weaponsManager.GetCurrentWeapon(); InputController.RegisterOnMouseLeftDown(UsePrimaryWeapon); InputController.RegisterOnMouseLeftUp(StopUsingPrimaryWeapon); InputController.RegisterOnMouseRightPressed(SwitchPrimaryWeapon); InputController.RegisterOnTriggerDown(UsePrimaryWeapon); InputController.RegisterOnTriggerUp(StopUsingPrimaryWeapon); InputController.RegisterOnTouchPressed(SwitchPrimaryWeapon); }
private void Start() { instance = this; foreach (GameObject GO in bodyHips) { hitboxPoints.Add(GO.name, "body"); } foreach (GameObject GO in legsHips) { hitboxPoints.Add(GO.name, "leg"); } foreach (GameObject GO in handsHips) { hitboxPoints.Add(GO.name, "hand"); } foreach (GameObject GO in headHips) { hitboxPoints.Add(GO.name, "head"); } }
/// <summary> /// 被选中 /// </summary> public void Selected() { if (weaponsManager == null) { weaponsManager = Director.GetInstance().CurrentWeaponsManager; } // 通知切换武器的子弹数量 weaponsManager.ChangeWeaponBulletClip(currentBulletClipNumer, singleBulletClipNumer); // 没有子弹 隐藏武器 if (totalBulletNumber == 0 && currentBulletClipNumer == 0) { gameObject.SetActive(false); return; } // 播放动画 currentState = WeaponState.Selected; animator.SetBool("idle", false); animator.SetTrigger("selected"); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { // 增加子弹 WeaponsManager weaponsManager = Director.GetInstance().CurrentWeaponsManager; for (int i = 0; i < weaponsManager.weaponTypes.Count; i++) { if (weaponsManager.weaponTypes[i] == type) { weaponsManager.myWeapons[i].totalBulletNumber += addBulletNumer; FindObjectOfType <WeaponBulletAdd>().ShowUI(i, addBulletNumer); } } // 播放音频 PlayerController player = other.gameObject.GetComponent <PlayerController>(); player.footAudioPlayer.PlayClip(bulletAddPropClip, 0.8f, 1.1f); // 销毁自身 Destroy(this.gameObject); } }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } controlsMap = new ControlsMap(); controlsMap.Gameplay.AimDirection.performed += ctx => aimDirection = ctx.ReadValue <Vector2>(); controlsMap.Gameplay.MousePos.performed += ctx => mousePosition = ctx.ReadValue <Vector2>(); controlsMap.Gameplay.Shot.started += ctx => StartPrimaryShot(); controlsMap.Gameplay.Shot.canceled += ctx => StopPrimaryShot(); controlsMap.Gameplay.SecondaryShot.started += ctx => StartSecondaryShot(); controlsMap.Gameplay.SecondaryShot.canceled += ctx => StopSecondaryShot(); aimDirection = transform.right; }
/// <summary> /// Called after creating a weapon and assigning it's parameters, such are WeaponData and HUD texture. /// Use this method to assign aim animations and timings, or initialize anything else related to weapon. /// </summary> protected virtual void InitWeapon() { // set default weapon anims and other params string animGroup = ExtractAnimGroupName(this.Data.gunData.AssocGroupId); this.CanCrouchAim = this.HasFlag(GunFlag.CROUCHFIRE); if (this.HasFlag(GunFlag.CROUCHFIRE)) { this.CrouchAimAnim = new AnimId(animGroup, animGroup + "_crouchfire"); } else { this.CrouchAimAnim = new AnimId("RIFLE", "RIFLE_crouchfire"); } this.CrouchAimAnimMaxTime = WeaponsManager.ConvertAnimTime(this.Data.gunData.animLoop2Start); this.CrouchAimAnimFireMaxTime = WeaponsManager.ConvertAnimTime(this.Data.gunData.animLoop2End); this.CrouchSpineRotationOffset = WeaponsSettings.crouchSpineRotationOffset; }
private void Start() { weaponsManager = Director.GetInstance().CurrentWeaponsManager; weaponsManager.ChangeWeaponBulletClip(currentBulletClipNumer, singleBulletClipNumer); }
private void InitLevelBuilder() { int LevelSize = LevelMapDirector.GetLevelSize(); Builder = new LevelBuilder (); Builder.SetLevelSize (LevelSize); Builder.BuildLevelGrid (); Builder.BuildLevelBorder (); GameObject WeaponFactoryObject = GameObject.Find("WeaponManager"); WeaponDirector = WeaponFactoryObject.GetComponent<WeaponsManager>(); }