예제 #1
0
    // Use this for initialization
    public void Init()
    {
        m_dInputToPosition               = new Dictionary <KeyCode, int>();
        m_dInputToPosition[m_kLeftKey]   = STAKE_LEFT;
        m_dInputToPosition[m_kCenterKey] = STAKE_NORMAL;
        m_dInputToPosition[m_kRightKey]  = STAKE_RIGHT;

        m_dPositionToRotation               = new Dictionary <int, float>();
        m_dPositionToRotation[STAKE_LEFT]   = 20f;
        m_dPositionToRotation[STAKE_NORMAL] = 0f;
        m_dPositionToRotation[STAKE_RIGHT]  = -20f;

        //Set up Bar
        GameObjectHolder component = gameObject.GetComponent <GameObjectHolder>();

        if (component)
        {
            Debug.Log("StakeGame: Init: Component: Found It");
            m_gPlayerStake = component.FocusItem0;
            m_gAIStake     = component.FocusItem1;
            m_gHammer      = component.AnimatedObj;
            m_gAudio       = component.AudioObj;

            m_animHammerAnim = m_gHammer.GetComponent <Animator>();
            m_audAudioSource = m_gAudio.GetComponent <AudioSource>();
            m_cAudioHolder   = m_gAudio.GetComponent <AudioHolder>();
        }
        else
        {
            Debug.Log("StakeGame: Init: Failed");
        }

        Reset();
    }
예제 #2
0
 public static void Initialize(AudioInfoHolder info)
 {
     if (!Instance)
     {
         audioInfo = info;
         Object.DontDestroyOnLoad(Instance = new GameObject("Audio holder").AddComponent <AudioHolder>());
     }
 }
예제 #3
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
예제 #4
0
    private void AddRemoveTypeList(AudioHolder holder, int type, bool add = true)
    {
        var l = type == SOUND ? m_sounds : type == VOICE ? m_voices : m_musics;

        if (add)
        {
            l.Add(holder);
        }
        else
        {
            l.Remove(holder);
        }
    }
예제 #5
0
파일: Zombie.cs 프로젝트: ash-eff/LD48
    private void Awake()
    {
        audioHolder = FindObjectOfType <AudioHolder>();
        zombieHurt  = audioHolder.zombieHurt;
        zombieDead  = audioHolder.zombieDead;

        gameController   = FindObjectOfType <GameController>();
        playerController = FindObjectOfType <PlayerController>();
        matWhite         = Resources.Load("WhiteFlash", typeof(Material)) as Material;
        matDefault       = spr.material;
        zombieSpawner    = FindObjectOfType <ZombieSpawner>();
        currentSpeed     = 6f;
        randomOffset     = new Vector3(Random.Range(-.5f, .5f), Random.Range(-.5f, .5f), 0);
    }
예제 #6
0
    private AudioHolder CreateAudioHolder(string name, AudioClip clip, bool play, int type)
    {
        AudioHolder holder = null;

        while (m_cachedAudioSources.Count > 0 && !holder)
        {
            holder = m_cachedAudioSources.Dequeue();
        }
        if (!holder)
        {
            holder = AudioHolder.Create(name);
        }

        holder.id   = ++m_cachedID;
        holder.type = (AudioTypes)type;

        if (!holder.source)
        {
            holder.source = holder.GetComponentDefault <AudioSource>();
        }

        var source = holder.source;

        source.playOnAwake = false;
        source.enabled     = true;
        source.name        = name;
        source.transform.SetParent(m_playing);
        source.spatialBlend = 0;
        source.loop         = false;

        source.clip   = clip;
        source.volume = holder.volume;

        if (play)
        {
            source.Play();
        }

        m_playList.Add(holder);
        m_hashList.Set(holder.id, holder);

        AddRemoveTypeList(holder, type);

        return(holder);
    }
예제 #7
0
    // Use this for initialization
    public void Init()
    {
        m_gGameplayObject = Instantiate(Resources.Load(STAGE_BOSS_FIGHT)) as GameObject;

        mapController = m_gGameplayObject.AddComponent <BossMapController>();
        mapController.Init();

        m_cAudioHolder      = m_gGameplayObject.GetComponent <AudioHolder>();
        m_cAudioSource      = m_gGameplayObject.AddComponent <AudioSource>();
        m_cAudioSource.clip = m_cAudioHolder.Audio[0];
        m_cAudioSource.Play();

        comboMaker = m_gGameplayObject.AddComponent <BossComboController>();
        comboMaker.Init();

        m_cBeatGame = m_gGameplayObject.AddComponent <BeatGame>();
        m_cBeatGame.Init();

        Reset();
    }
예제 #8
0
    private IEnumerator WaitPlayComplete(AudioHolder holder, int type, float bgmFadeDuration)
    {
        var id   = holder.id;
        var wait = new WaitUntil(() => { return(!holder || !holder.isPlaying && !holder.isPaused); });

        yield return(wait);

        if (holder && holder.globalBgmVolume >= 0)
        {
            Level.current?.audioHelper?.SetGlobalVolume(holder.globalBgmVolume, bgmFadeDuration);
        }

        m_playList.Remove(holder);
        m_hashList.Remove(id);

        AddRemoveTypeList(holder, type, false);

        if (holder)
        {
            if (holder.source)
            {
                holder.source.clip = null;
            }

            if (m_cachedAudioSources.Count >= MAX_CACHED_AUDIO_HOLDERS)
            {
                DestroyImmediate(holder.gameObject);
            }
            else
            {
                holder.Stop();

                holder.transform.SetParent(m_pool);
                holder.enabled = false;

                m_cachedAudioSources.Enqueue(holder);
            }
        }
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        inputManager = game.gameObject.AddComponent <InputManagerHandler>();

        m_arrLevelOrder = new string[] { LEVEL_FARMLAND, LEVEL_MOUNTAIN, LEVEL_OCEAN, LEVEL_ARCTIC, LEVEL_SKY, LEVEL_SPACE };

        m_dLevelOrder[LEVEL_FARMLAND] = Farmland;
        m_dLevelOrder[LEVEL_MOUNTAIN] = Mountain;
        m_dLevelOrder[LEVEL_OCEAN]    = Ocean;
        m_dLevelOrder[LEVEL_ARCTIC]   = Arctic;
        m_dLevelOrder[LEVEL_SKY]      = Sky;
        m_dLevelOrder[LEVEL_SPACE]    = Space;

        m_cAudioHolder = game.GetComponent <AudioHolder>();
        for (int i = 0; i < m_arrLevelOrder.Length; ++i)
        {
            if (i < m_cAudioHolder.Audio.Length)
            {
                m_arrLevelAudio[m_arrLevelOrder[i]] = m_cAudioHolder.Audio[i];
            }
        }

        ChangeState(STATE_TITLE);
    }
예제 #10
0
 void Awake()
 {
     Instance = this;
 }