public void SpawnWeapon() { List <WeaponSpawner> availableSpawners = new List <WeaponSpawner>(); foreach (WeaponSpawner spwnr in spawners) { if (spwnr.spawned == 0) { if (spwnr.lastTimeSpawned) { spwnr.lastTimeSpawned = false; continue; } availableSpawners.Add(spwnr); } } WeaponSpawner spawner = availableSpawners[RollRandom.RollBetween(0, availableSpawners.Count)]; int[] weights = new int[guns.Length]; foreach (Gun gun in guns) { weights.Append(gun.chance); } Gun g = GetRandomWeightedIndex(guns); spawner.SpawnGun(g.gun); spawning = false; }
bool alreadyPickedUp; //Explicitly to fix the bug where multiple people are on the weapon spawner at the same time void Awake() { deg = Random.Range(0f, 360f); if (transform.parent) { weaponSpawner = transform.parent.GetComponent <WeaponSpawner>(); } }
public void InitBySpawner(WeaponSpawner spawner) { isInSpawner = true; weaponSpawner = spawner; collider.enabled = false; target = transform.position.y + 0.15f; isGoingUp = true; }
// Use this for initialization void Start() { if (spawnOnStart) { Spawn(); } spawner = weaponSpawner.GetComponent <WeaponSpawner>(); }
void Start() { weaponSpawnTimer = wCooldown; spawner = GetComponent <Spawner>(); wSpawner = GetComponent <WeaponSpawner>(); RespawnEntity(0); //RespawnEntity(1); //RespawnEntity(2); RespawnEntity(3); wSpawner.spawnWeapon(); }
private void OnTriggerStay(Collider other) { if (other.CompareTag("PlayerOne") || other.CompareTag("PlayerTwo")) { gunCon = other.transform.GetChild(0).GetChild(0).GetComponent <GunController>(); weaponSpawnerScript = transform.parent.GetComponent <WeaponSpawner>(); if (gunCon.weapons[gunCon.current_weapon] == weapon.empty && gunCon.cooldown <= 0 && gunCon.shot == false) { //Player picks up a weapon of type weaponType gunCon.ammos[gunCon.current_weapon] = weapon_ammo_amount[(int)weaponType]; gunCon.weapons[gunCon.current_weapon] = weaponType; other.transform.parent.GetComponent <GunAnimationPaths>().currentWeapon = weaponType; PickupSound(weaponType); //KostinKoodi weaponSpawnerScript.SpawnerSound.setParameterByName("Spawned", 0); Destroy(this.gameObject); } else { for (var i = 0; i < gunCon.inventory_size; i++) { if ((gunCon.weapons[i] == weapon.empty || gunCon.weapons[i] == weapon.meleeFist) || gunCon.ammos[i] <= 0) { if (gunCon.current_weapon == gunCon.inventory_size) { gunCon.current_weapon = i; gunCon.ammos[gunCon.current_weapon] = weapon_ammo_amount[(int)weaponType]; gunCon.weapons[gunCon.current_weapon] = weaponType; other.transform.parent.GetComponent <GunAnimationPaths>().currentWeapon = weaponType; } else { gunCon.ammos[i] = weapon_ammo_amount[(int)weaponType]; gunCon.weapons[i] = weaponType; } //other.transform.parent.GetComponent<GunAnimationPaths>().currentWeapon = weaponType; PickupSound(weaponType); //KostinKoodi weaponSpawnerScript.SpawnerSound.setParameterByName("Spawned", 0); Destroy(this.gameObject); break; } } } } }
// Start is called before the first frame update void Start() { endOfDayUI.enabled = false; secondHalfOfDay = false; endOfDayText = endOfDayUI.GetComponentsInChildren <Text>(); endOfDayText[0].enabled = false; endOfDayText[1].enabled = false; dayEndTimer.Update(dayEndTimer.GetDuration()); wepSpawner = FindObjectOfType <WeaponSpawner>(); moneyMan = FindObjectOfType <MoneyManager>(); }
public override void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters) { this.spawner = spawner; this.firingParameters = firingParameters; spawner.SpawnMuzzleFlash(firingParameters.hardpointTransform); transform.position = transform.position + (transform.forward * spawnOffset); float accuracy = ((spreadFactor + (spreadFactor * (1 - firingParameters.accuracy))) / spreadFactor) * spreadFactor; transform.rotation *= Quaternion.Euler(UnityEngine.Random.insideUnitSphere * accuracy); rigidbody.velocity = transform.forward * speed; rigidbody.angularVelocity = Vector3.zero; origin = transform.position; collider.enabled = false; elapsedTime = 0f; }
public override void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters) { firingParameters.firingBeam = true; this.firingParameters = firingParameters; this.spawner = spawner; this.hardpoint = firingParameters.hardpointTransform; elapsedFireTime = 0f; beamLength = 0f; lineRenderer.SetPosition(1, new Vector3(0f, 0f, 0f)); if (wanderRange != 0) { float accuracy = ((wanderRange + (wanderRange * (1 - firingParameters.accuracy))) / wanderRange) * wanderRange; transform.rotation *= Quaternion.Euler(UnityEngine.Random.insideUnitSphere * accuracy); } }
public void Start() { spawner = WeaponSpawner.Get(weaponId); Entity entity = GetComponentInParent<Entity>(); firepoints = new List<Firepoint>(); firingParameters = new WeaponFiringParameters(entity); currentFirepointIndex = 0; Firepoint[] childFirepoints = GetComponentsInChildren<Firepoint>(); for (int i = 0; i < childFirepoints.Length; i++) { if (childFirepoints[i].weaponGroupId == groupId) { firepoints.Add(childFirepoints[i]); } } }
public override void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters) { this.spawner = spawner; this.firingParameters = firingParameters; this.distanceTravelled = 0f; transform.position = firingParameters.hardpointTransform.position; transform.rotation = firingParameters.hardpointTransform.rotation; if (spreadFactor != 0) { float accuracy = ((spreadFactor + (spreadFactor * (1 - firingParameters.accuracy))) / spreadFactor) * spreadFactor; transform.rotation *= Quaternion.Euler(UnityEngine.Random.insideUnitSphere * accuracy); } forward = transform.forward; spawner.SpawnMuzzleFlash(firingParameters.hardpointTransform); transform.position = transform.position + (forward * spawnOffset); }
private void CreateSpawners() { // Get normalize values for resourceCount of regions float minResources = Region.MIN_RESOURCE_COUNT; float maxResources = Region.MAX_RESOURCE_COUNT; regionsVisualParent = new GameObject(); regionsVisualParent.transform.SetParent(transform); for (int x = 0; x < regions.GetLength(0); x++) { for (int y = 0; y < regions.GetLength(1); y++) { Region current = regions[x, y]; // Spawn weapon on random location in region Vector3 min = current.bounding.center - (current.bounding.size / 2); Vector3 max = current.bounding.center + (current.bounding.size / 2); Vector3 position = VectorExtensions.RandomRange(min, max); WeaponSpawner spawner = Instantiate(weaponSpawnerPrefab, position, Quaternion.identity); // Create visual feedback for this region Vector3 newPosition = new Vector3(current.bounding.center.x, 1f, current.bounding.center.z); MeshRenderer newMeshRenderer = Instantiate(regionVisualPrefab, newPosition, Quaternion.identity); current.SetVisual(newMeshRenderer, regionGradient); Vector3 newScale = new Vector3(current.bounding.size.x, newMeshRenderer.transform.localScale.y, current.bounding.size.z) - new Vector3(1f, 0f, 1f); newMeshRenderer.transform.localScale = newScale; newMeshRenderer.transform.SetParent(regionsVisualParent.transform); } } regionsVisualParent.SetActive(false); }
[SerializeField] private bl_Joystick mJoystickController;//Joystick reference for assign in inspector // Start is called before the first frame update void Start() { mIsTouchDown = false; mV3TouchBegan = Vector3.zero; mAttackTime = 0; mNumberOfWeapon = LIMIT_NUMBER_WEAPON; mIsReceivingDame = false; mIsDoingShortAttack = false; mShortAttackTar = null; mTarForShortAtk = Vector3.zero; mCurPosWhenShortAtk = Vector3.zero; GameObject weaponGO = GameObject.Find("WeaponSpawner"); if (weaponGO) { mWSpawner = weaponGO.GetComponent <WeaponSpawner>(); if (mWSpawner == null) { Debug.Log("WARNING!!!! PlayerController can not find WeaponSpawner"); } } }
private void Start() { Instance = this; }
private void TestCreateWeapon() { WeaponSpawner weaponSpawner = gameObject.GetComponent <WeaponSpawner>(); EquipWeapon(weaponSpawner.SpawnWeapon()); }
public void Start() { spawner = WeaponSpawner.Get(weaponId); entity = GetComponentInParent<Entity>(); firingParameters = new WeaponFiringParameters(entity); }
public abstract void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters);
public void SetSpawner(WeaponSpawner spawner) { m_spawner = spawner; }
public GameObject[] weapons; // FT, FM, IT, IM, PT, PM private void Awake() { instance = this; }
public static void Register(string id, WeaponSpawner instance) { spawners[id] = instance; }
static IEnumerator DespawnTrail(GameObject weaponRoot, WeaponSpawner spawner) { TrailRenderer trail = weaponRoot.GetComponent<TrailRenderer>(); if (trail == null) { spawner.weaponPool.Despawn(weaponRoot); } else { float trailTime = trail.time; trail.time = -1; yield return 0; trail.time = trailTime; spawner.weaponPool.Despawn(weaponRoot); } }
public override void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters) { this.spawner = spawner; this.firingParameters = firingParameters; }