Esempio n. 1
0
    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>();
        }
    }
Esempio n. 3
0
 public void InitBySpawner(WeaponSpawner spawner)
 {
     isInSpawner      = true;
     weaponSpawner    = spawner;
     collider.enabled = false;
     target           = transform.position.y + 0.15f;
     isGoingUp        = true;
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        if (spawnOnStart)
        {
            Spawn();
        }

        spawner = weaponSpawner.GetComponent <WeaponSpawner>();
    }
Esempio n. 5
0
    void Start()
    {
        weaponSpawnTimer = wCooldown;

        spawner  = GetComponent <Spawner>();
        wSpawner = GetComponent <WeaponSpawner>();
        RespawnEntity(0);
        //RespawnEntity(1);
        //RespawnEntity(2);
        RespawnEntity(3);
        wSpawner.spawnWeapon();
    }
Esempio n. 6
0
    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;
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
 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]);
         }
     }
 }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
    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);
    }
Esempio n. 13
0
    [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");
            }
        }
    }
Esempio n. 14
0
 private void Start()
 {
     Instance = this;
 }
Esempio n. 15
0
    private void TestCreateWeapon()
    {
        WeaponSpawner weaponSpawner = gameObject.GetComponent <WeaponSpawner>();

        EquipWeapon(weaponSpawner.SpawnWeapon());
    }
Esempio n. 16
0
 public void Start()
 {
     spawner = WeaponSpawner.Get(weaponId);
     entity = GetComponentInParent<Entity>();
     firingParameters = new WeaponFiringParameters(entity);
 }
Esempio n. 17
0
 public abstract void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters);
Esempio n. 18
0
 public void SetSpawner(WeaponSpawner spawner)
 {
     m_spawner = spawner;
 }
Esempio n. 19
0
    public GameObject[] weapons; // FT, FM, IT, IM, PT, PM

    private void Awake()
    {
        instance = this;
    }
Esempio n. 20
0
 public static void Register(string id, WeaponSpawner instance)
 {
     spawners[id] = instance;
 }
Esempio n. 21
0
 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);
     }
 }
Esempio n. 22
0
 public override void Fire(WeaponSpawner spawner, WeaponFiringParameters firingParameters)
 {
     this.spawner = spawner;
     this.firingParameters = firingParameters;
 }