Beispiel #1
0
 private static AudioEffectManager GetInstance()
 {
     if (instance == null)
     {
         instance = FindObjectOfType <AudioEffectManager>();
     }
     return(instance);
 }
 void Awake()
 {
     if (Instance != null)
     {
         Destroy(this);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
 }
Beispiel #3
0
    void Awake()
    {
        // Setup singleton
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);
        _instance = this;

        // Initialize stuff

        // Get self-references
        AudioEffectManager = GetComponent <AudioEffectManager>();
    }
Beispiel #4
0
    public override void OnAfterChange()
    {
        bool didCompleteAMission = false;

        for (int i = 0; i < objectivesScriptableObject.objectives.Count; i++)
        {
            var objective = objectivesScriptableObject.objectives[i];
            if (!completed.Contains(objective) && objective.seasons.Contains(MainGameManager.CurrentSeason))
            {
                List <ILogic> logic = new List <ILogic>(GetLogicsFor(objective, objective.objectIdsForGold));

                if (LogicAnd_True(logic.ToArray()))
                {
                    Reward(objective, rank.gold);
                    didCompleteAMission = true;
                }
                else
                {
                    logic = new List <ILogic>(GetLogicsFor(objective, objective.objectIdsForSilver));
                    if (LogicAnd_True(logic.ToArray()))
                    {
                        Reward(objective, rank.silver);
                        didCompleteAMission = true;
                    }
                    else
                    {
                        logic = new List <ILogic>(GetLogicsFor(objective, objective.objectIdsForBronze));
                        if (LogicAnd_True(logic.ToArray()))
                        {
                            Reward(objective, rank.bronze);
                            didCompleteAMission = true;
                        }
                    }
                }
            }
        }

        if (didCompleteAMission)
        {
            AudioEffectManager.Play(AudioEffectManager.Instance.missionCleared);
        }

        base.OnAfterChange();
    }
    private IEnumerator MoveCoroutine(HouseHoldItem_monobehaviour m, PlacementObject o)
    {
        var wait = new WaitForEndOfFrame();

        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();

        Vector3    startPos = m.transform.position;
        Quaternion startRot = m.transform.rotation;

        string axis        = "Fire1";
        string rotateAxis  = "Horizontal";
        float  rotateSpeed = 90f;

        float placementHelpOffset = -100;

        placementHelp.transform.position = CameraControl.RootPosition + new Vector3(0, placementHelpOffset, 0);

        float inpWas = Input.GetAxis(axis);

        do
        {
            if (Input.GetAxis("Cancel") > 0)
            {
                m.transform.position = startPos;
                m.transform.rotation = startRot;
                m.visualMaterial     = HouseHoldItem_monobehaviour.VisualMaterial.normalMaterial;
                OptionsMenu.PreventOpening();
                break;
            }

            m.transform.Rotate(Vector3.up * Input.GetAxis(rotateAxis) * rotateSpeed * Time.smoothDeltaTime);

            if (stopwatch.ElapsedMilliseconds >= 5)
            {
                var        cameraRay = CameraControl.Camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                Vector3    placementPos = m.transform.position;
                if (placementHelp.Raycast(new Ray(cameraRay.origin + new Vector3(0, placementHelpOffset, 0), cameraRay.direction), out hit, Mathf.Abs(1000 * placementHelpOffset)))
                {
                    placementPos = hit.point + new Vector3(0, -placementHelpOffset, 0);
                }

                var placementDots = PlacementManager.GetPlacementDots(placementPos, m.transform.rotation, o.width, o.depth);

                if (placementDots.Count > 0)
                {
                    m.transform.position = placementPos;
                }

                var canPlace = PlacementManager.CanPlace(placementDots);
                m.visualMaterial = canPlace ? HouseHoldItem_monobehaviour.VisualMaterial.canPlace : HouseHoldItem_monobehaviour.VisualMaterial.cannotPlace;


                if (inpWas >= 0.5f && Input.GetAxis(axis) < 0.5f && !CanvasUI_Main_cs.EventSystem.IsPointerOverGameObject())
                {
                    if (canPlace)
                    {
                        o.SetUsedDots(placementDots);
                        m.visualMaterial = HouseHoldItem_monobehaviour.VisualMaterial.normalMaterial;
                        AudioEffectManager.Play(AudioEffectManager.Instance.objectPlaced);
                        break;
                    }
                }
                stopwatch.Reset();
                stopwatch.Start();
            }
            inpWas = Input.GetAxis(axis);
            yield return(wait);
        }while (m != null && o != null);
    }
    private IEnumerator BuyCoroutine()
    {
        var wait = new WaitForEndOfFrame();

        System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();

        string axis        = "Fire1";
        string rotateAxis  = "Horizontal";
        float  rotateSpeed = 90f;

        float placementHelpOffset = -100;

        placementHelp.transform.position = CameraControl.RootPosition + new Vector3(0, placementHelpOffset, 0);

        float inpWas = Input.GetAxis(axis);

        do
        {
            if (Input.GetAxis("Cancel") > 0)
            {
                ShopManager.CancelBuy();
                OptionsMenu.PreventOpening();
                break;
            }

            currently_buying.transform.Rotate(Vector3.up * Input.GetAxis(rotateAxis) * rotateSpeed * Time.smoothDeltaTime);

            if (stopwatch.ElapsedMilliseconds >= 5)
            {
                var        cameraRay = CameraControl.Camera.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                Vector3    placementPos = currently_buying.transform.position;
                if (placementHelp.Raycast(new Ray(cameraRay.origin + new Vector3(0, placementHelpOffset, 0), cameraRay.direction), out hit, Mathf.Abs(1000 * placementHelpOffset)))
                {
                    placementPos = hit.point + new Vector3(0, -placementHelpOffset, 0);
                }

                var placementDots = PlacementManager.GetPlacementDots(placementPos, currently_buying.transform.rotation, currentlyPlacing.width, currentlyPlacing.depth);

                if (placementDots.Count > 0)
                {
                    currently_buying.transform.position = placementPos;
                }

                var canPlace = PlacementManager.CanPlace(placementDots);
                currently_buying.visualMaterial = canPlace ? HouseHoldItem_monobehaviour.VisualMaterial.canPlace : HouseHoldItem_monobehaviour.VisualMaterial.cannotPlace;


                if (inpWas >= 0.5f && Input.GetAxis(axis) < 0.5f && !CanvasUI_Main_cs.EventSystem.IsPointerOverGameObject())
                {
                    if (canPlace)
                    {
                        MainGameManager.Cash -= currently_buying.HouseHoldItemData.purchaseCost;
                        currentlyPlacing.SetUsedDots(placementDots);
                        currently_buying.visualMaterial = HouseHoldItem_monobehaviour.VisualMaterial.normalMaterial;

                        var transforms = currently_buying.gameObject.GetComponentsInChildren <Transform>();
                        foreach (var t in transforms)
                        {
                            if (t.GetComponent <MeshCollider>() == null)
                            {
                                var collider = t.gameObject.AddComponent <MeshCollider>();
                                collider.sharedMesh = t.gameObject.GetComponent <MeshFilter>().sharedMesh;
                                collider.convex     = true;
                            }
                        }

                        AudioEffectManager.Play(AudioEffectManager.Instance.objectBuy);

                        currently_buying = null;
                        currentlyPlacing = null;
                        break;
                    }
                }
                stopwatch.Reset();
                stopwatch.Start();
            }
            inpWas = Input.GetAxis(axis);
            yield return(wait);
        }while (currently_buying != null);
    }
Beispiel #7
0
 private void Awake()
 {
     _this = this;
 }
Beispiel #8
0
    protected void InitializeAudio()
    {
        //<!-- Setup All Audio Objects.
        if (audioEffect == null) {
                audioEffect = GameObject.FindGameObjectWithTag("AudioEffect").GetComponent<AudioEffectManager>();

                if(audioEffect) {
                    audioEffect.alternativeEffect_source = audioEffect.transform.GetComponentInChildren<AudioSource>();

                    audioEffect.audio.mute = !ToggleAudioActive;
                    audioEffect.alternativeEffect_source.audio.mute = !ToggleAudioActive;
                }
            }

        if (audioDescribe == null) {
                audioDescribe = GameObject.FindGameObjectWithTag("AudioDescribe").GetComponent<AudioDescribeManager>();
                audioDescribe.audio.mute = !ToggleAudioActive;
        }

        // <! Manage audio background.
        audioBackground_Obj = GameObject.FindGameObjectWithTag("AudioBackground");
        if (audioBackground_Obj == null)
        {
            audioBackground_Obj = new GameObject("AudioBackground", typeof(AudioSource));
            audioBackground_Obj.tag = "AudioBackground";
            audioBackground_Obj.audio.playOnAwake = true;
            audioBackground_Obj.audio.volume = 0.8f;
            audioBackground_Obj.audio.mute = !ToggleAudioActive;

            DontDestroyOnLoad(audioBackground_Obj);
        }
        else {
            audioBackground_Obj.audio.mute = !ToggleAudioActive;
        }
    }