示例#1
0
    void GetIndex()
    {
        enemyType = this.gameObject.GetComponent <UnitStore>().index;

        switch (enemyType)
        {
        case 0:
            br = this.GetComponentInChildren <BurstRifle>();
            break;

        case 1:
            ps = this.GetComponentInChildren <Pistol>();
            break;

        case 2:
            sg = this.GetComponentInChildren <Shotgun>();
            break;
        }
    }
示例#2
0
    /**
     * Spawn burst rifles in the area
     */
    private void SpawnBurstRifles()
    {
        string funcName = "SpawnBurstRifles";

        FunctionPeriodic.Create(
            () =>
        {
            if (WeaponManager.WeaponCount <BurstRifle>() < _BURST_RIFLE_MAX_SPAWNS)
            {
                Vector3 burstRifleWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_BurstRifle().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                BurstRifle burstRifle = Instantiate(
                    AssetManager.Get_Prefab_BurstRifle(),
                    burstRifleWorldPosition,
                    Quaternion.identity
                    );

                WeaponManager.AddWeapon(burstRifle);
            }
        },
            funcName,
            0f,
            0f,
            () =>
        {
            if (WeaponManager.WeaponCount <BurstRifle>() >= _BURST_RIFLE_MAX_SPAWNS)
            {
                Destroy(GameObject.Find(funcName));
            }
        }
            );
    }