コード例 #1
0
    void Start()
    {
        if (!target)
        {
            if (GameObject.FindObjectOfType <QK_Character_Movement>())
            {
                target    = (Transform)GameObject.FindObjectOfType <QK_Character_Movement>().transform;
                player    = target;
                _curState = CameraState.Normal;
            }
            else
            {
                Debug.Error("camera", "Cannot find this.target. Please connect the GameObject to the component using the inspector.");
                target = transform;
            }
            if (!gameObject.GetComponent <CheckTargets>())
            {
                Debug.Warning("camera", "\"CheckTargets\" object not on Camera. Targeting is not enabled");
            }
        }

        Go.defaultUpdateType = GoUpdateType.FixedUpdate;
        distance             = Mathf.Clamp(distance, distanceMin, distanceMax);
        cameraLatency        = Mathf.Clamp(cameraLatency, 0.05f, 1f);
        // Bit Shift our layermasks
        PlayerLM      = 1 << playerLayer | 1 << IgnoreRaycastLayer;
        NoOcclusionLM = 1 << noOcclusionLayer |
                        1 << noTartedOccludionLayer |
                        1 << IgnoreRaycastLayer;
        // Inverse both masks
        PlayerLM      = ~PlayerLM;
        NoOcclusionLM = ~NoOcclusionLM;
        Reset();
    }
コード例 #2
0
    //!callback function, builds audio source once a clip is loaded
    void finishedLoading(AudioClip clip, AudioMixer mixerGroup, GameObject go, string name, string loadType)
    {
        AudioSource source = go.AddComponent <AudioSource>();

        AudioMixerGroup[] groupArray = mixerGroup.FindMatchingGroups(name);
        Debug.Log("audio", "FinishedLoading: group array length is " + groupArray.Length);

        if (groupArray.Length == 1)
        {
            source.outputAudioMixerGroup = groupArray[0];           //how i set the output for the source's mixergroup
            source.clip = clip;

            source.Play();
            //Add to active audio dictionary
            activeAudio.Add(name, source);

            Debug.Log("audio", "FinishedLoading: source name is " + name + " and has been added to active audio");
            Debug.Log("audio", "FinishedLoading: clip length is " + source.clip.length);

            //start a new coroutine to wait for DESTRUCTION TIME
            StartCoroutine(reclaimSource(source, name, loadType));
        }
        else if (groupArray.Length > 1)
        {
            Debug.Warning("audio", "FinishedLoading: more than 1 mixer group exists for the sound " + name);
        }
        else
        {
            Debug.Warning("audio", "FinishedLoading: No mixer group exists for sound " + name);
        }
    }
コード例 #3
0
    public void playMe(GameObject target, string type, string name)
    {
        string loadType;

        if (!target)
        {
            target = GameObject.Find("_Player");
            Debug.Log("audio", "PlayMe: target object was null, target is now the player");
        }
        if (playingCurrently(target))
        {
            Debug.Warning("audio", "PlayMe: target object is already playing audio");
        }
        else
        {
            if (priorityAudio.ContainsKey(name))
            {
                loadType = "priority";
            }
            else
            {
                loadType = "play";
            }

            StartCoroutine(loadAudio(target, type, name, loadType));
        }
    }
コード例 #4
0
 void Start()
 {
     if (eventPath.Count == 0)
     {
         Debug.Warning("camera", "Warning: Camera Event " + this.gameObject.name + " has no path");
         Destroy(this.gameObject);
     }
 }
コード例 #5
0
 public static void RemoveTopObject(string s)
 {
     if (TopObjects.ContainsKey(s))
     {
         GameObject.Destroy(TopObjects[s].gameObject);
     }
     else
     {
         Debug.Warning("core", "TopObjects does not contain object named \'" + s + "\'");
     }
 }
コード例 #6
0
 // Returns current gameobject or null if none is targeted
 public GameObject CurrentTarget()
 {
     if (targetedObjects != null && targetedObjects.Count > 0)
     {
         return(targetedObjects[targetindex]);
     }
     else
     {
         Debug.Warning("camera", "No current object targeted");
         return(null);
     }
 }
コード例 #7
0
    void DetermineCharacterState()
    {
        if (!IsInActionState())
        {
            if (Input.GetKey(KeyCode.E))
            {
                iObject = GetActionObject();

                if (iObject != null)
                {
                    if (iObject.Type == Interactable.ObjectType.Ladder)
                    {
                        _stateModifier = CharacterState.Ladder;
                    }
                    else if (iObject.Type == Interactable.ObjectType.Sidle)
                    {
                        _stateModifier = CharacterState.Sidle;
                    }
                    else if (iObject.Type == Interactable.ObjectType.Door)
                    {
                        _stateModifier = CharacterState.Wait;
                    }
                    else
                    {
                        Debug.Warning("player", "No player action for type " + iObject.Type);
                        _stateModifier = CharacterState.Normal;
                    }

                    // We have an action to do, break out
                    return;
                }
            }

            if (Input.GetButton("Jump"))
            {
                Jump();
                return;
            }

            if (false)
            {
                _stateModifier = CharacterState.Sprint;
            }
            else if (false)
            {
                _stateModifier = CharacterState.Crouch;
            }
            else
            {
                _stateModifier = CharacterState.Normal;
            }
        }
    }
コード例 #8
0
    //! Unity Start function
    void Start()
    {
        Debug.Log("audio", "SoundManager has started");

        #region singletonCreation
        if (_instance == null)
        {
            //If I am the first instance, make me the Singleton
            Debug.Log("audio", "Audio Singleton did not exist, creating");
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            //If a Singleton already exists and you find
            //another reference in scene, destroy it!
            Debug.Error("audio", "There is more than one Audio Singleton, Destroying");
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }
        #endregion

        if (testing)
        {
            player = new GameObject("PlayerTest");
            Debug.Warning("audio", "Audio testing is enabled");
        }


        //JSON file load check
        if (!loadListFromFile(soundListFilePath))
        {
            Debug.Error("audio", "JSON file did not load");
        }
        else
        {
            Debug.Log("audio", "JSON file loaded");
        }

        changeVol("master", 40f);

        generatePriority();
    }
コード例 #9
0
 private void LoadScenesDictionary()
 {
     try{
         TextAsset textAsset = Resources.Load(StringManager.SCENELIST) as TextAsset;
         string    text      = textAsset.ToString();
         if (text == "")
         {
             Debug.Warning("core", "SceneList empty");
         }
         else
         {
             JSONNode N = JSON.Parse(text);
             scenes.Clear();
             for (int i = 0; i < N.Count; i++)
             {
                 scenes.Add(N[i].Value);
             }
             Debug.Log("core", "Scenes dictionary loaded.");
         }
     }catch (NullReferenceException e) {
         Debug.Error("core", "SceneList missing: " + e);
     }
 }
コード例 #10
0
    public static void InvokeAction(PopEvent popEvent)
    {
        popEvent.hasExecuted = true;
        bool destroyAfterwards = false;

        foreach (EventHalf action in popEvent.actions)
        {
            if (action.args == null)
            {
                action.SetParameters();
            }
            if (action.args.Length > 5)
            {
                Debug.Warning("core", "Event functions cannot have more than 5 parameters");
                continue;
            }
            if (action.e_categoryString == "Static Script")
            {
                EventLibrary.staticClasses[action.e_classString].GetMethod(action.e_fieldString).Invoke(null, action.args);
            }
            //			else if (action.e_categoryString == "GUI") {
            //				if (action.e_classString == "Set Objective") {
            //					GameHUD.UpdateObjectiveText(action.p_string[0]);
            //				}else if (action.e_classString == "Set Dialogue") {
            //					GameHUD.SetDialogueBoxText(action.p_string[0], action.p_string[1]);
            //				}
            //			}
            else if (action.e_categoryString == "System")
            {
                if (action.e_classString == "Debug Message")
                {
                    Debug.Log("event", action.p_string[0]);
                    //MonoBehaviour.print(action.p_string[0]);
                }
                else if (action.e_classString == "Activate Next Event")
                {
                    popEvent.ActivateNextEvent();
                }
                else if (action.e_classString == "Activate Another Event")
                {
                    ActivateById(action.p_string[0], true);
                }
                else if (action.e_classString == "Deactivate Another Event")
                {
                    ActivateById(action.p_string[0], false);
                }
                else if (action.e_classString == "Create Prefab At Position")
                {
                    if (action.p_GameObject[0] != null)
                    {
                        MonoBehaviour.Instantiate(action.p_GameObject[0], action.p_Vector3[0], Quaternion.Euler(action.p_Vector3[1]));
                    }
                }
                else if (action.e_classString == "Create Prefab Here")
                {
                    if (action.p_GameObject[0] != null)
                    {
                        MonoBehaviour.Instantiate(action.p_GameObject[0], popEvent.gameObject.transform.position, Quaternion.identity);
                    }
                }
                else if (action.e_classString == "Move This Object")
                {
                    popEvent.gameObject.transform.position    = action.p_Vector3[0];
                    popEvent.gameObject.transform.eulerAngles = action.p_Vector3[1];
                }
                else if (action.e_classString == "Destroy This Object")
                {
                    destroyAfterwards = true;
                }
            }
            else
            {
                if (action.e_fieldString != string.Empty && action.e_MonoBehaviour != null)
                {
                    action.e_MonoBehaviour.GetType().GetMethod(action.e_fieldString).Invoke(action.e_MonoBehaviour, action.args);
                }
            }
        }
        if (popEvent.executeOnce == true)
        {
            popEvent.MakeActive(false);
        }
        if (destroyAfterwards == true)
        {
            MonoBehaviour.Destroy(popEvent.gameObject);
        }
    }