コード例 #1
0
 // recursively searches through tree
 private static Node searchHelper(Node other, Vector3 loc, Node closestNode)
 {
     if (other != null && other.NULL == false)
     {
         closestNode = other;
     }
     if (other.firstChild != null && loc.x >= other.location.x && loc.z >= other.location.z)
     {
         closestNode = searchHelper(other.firstChild, loc, closestNode);
     }
     else if (other.secondChild != null && loc.x >= other.location.x && loc.z < other.location.z)
     {
         closestNode = searchHelper(other.secondChild, loc, closestNode);
     }
     else if (other.thirdChild != null && loc.x < other.location.x && loc.z >= other.location.z)
     {
         closestNode = searchHelper(other.thirdChild, loc, closestNode);
     }
     else if (other.fourthChild != null && loc.x < other.location.x && loc.z < other.location.z)
     {
         closestNode = searchHelper(other.fourthChild, loc, closestNode);
     }
     Debug.Log("checkpoint", "timesSearched" + ++timesSearched);
     return(closestNode);
 }
コード例 #2
0
    //!checks JSON file isnt empty and loads data into audio dictionaries
    public bool loadListFromJson(string json)
    {
        JSONNode soundData = JSON.Parse(json);                          //the whole JSON file

        if (soundData == null)
        {
            Debug.Error("audio", "Json file is empty");
            return(false);
        }

        JSONNode audioNode = soundData["audio"];                        //Just the ones under audio

        string[] types = { "ambience", "effect", "music", "voice" };

        foreach (string type in types)
        {
            JSONArray tempArray = audioNode[type].AsArray;              //just the objects under the type
            foreach (JSONNode j in tempArray)
            {
                var  name     = j[0];                           //j[0] is name of object
                bool priority = j[1].AsBool;                    //j[1] priority of object
                addSound(type, name, priority);
                //if(priority)
                //	loadPriority(type, name);
            }
        }
        return(true);
    }
コード例 #3
0
 void initializeCheckpoints()
 {
     // initialize variables
     x = 0;
     z = 0;
     numCheckpoints = 0;
     // using array because GameObject.FindGameObjectsWithTag only returns an array
     GameObject[] temps;
     // loop through all Respawn Objects in Scene and set it to array
     temps = GameObject.FindGameObjectsWithTag("Respawn");
     // calculate totals of x position, z position, and number of checkpoints
     foreach (GameObject temp in temps)
     {
         x += temp.transform.position.x;
         z += temp.transform.position.z;
         numCheckpoints++;
     }
     // add each checkpoint from array to list
     for (int i = 0; i < numCheckpoints; i++)
     {
         checkpoints.Add(temps [i]);
     }
     Debug.Log("checkpoint", "Number of checkpoints in list " + checkpoints.Count);
     // set m_root to empty node; a node with no location value indicated by boolean
     m_root = new Node(new Vector3(x / numCheckpoints, 0, z / numCheckpoints), null, null, null, null, null, true);
     // send list to recursive insert function
     recursiveInsertHelper(checkpoints);
 }
コード例 #4
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);
        }
    }
コード例 #5
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));
        }
    }
コード例 #6
0
    //! Sets all achievements to false(0)
    public bool ClearAchievements()
    {
        //Checking to see if achievement json file exists if it doesnt return
        if (!System.IO.File.Exists(Application.dataPath + "/Resources/Json/achievementJson"))
        {
            Debug.Error("serilaization", "Could not find Achievement JSON file");
            return(false);
        }

        //read in achievement json file
        string   jsonRead   = System.IO.File.ReadAllText(Application.dataPath + "/Resources/Json/achievementJson");
        JSONNode jsonParsed = JSON.Parse(jsonRead);

        //iterate through json file and load each key and its value into to check against playerpref keys and set them to false(0)
        for (int count = 0; count < jsonParsed["Achievements"].Count; count = count + 1)
        {
            string loadedAchievement = jsonParsed["Achievements"][count];
            PlayerPrefs.SetInt(loadedAchievement, 0);
        }

        //save to playerprefs just in case
        PlayerPrefs.Save();

        //return true when operation is complete
        return(true);
    }
コード例 #7
0
    // Draws Gizmos when Camera is selected in scene editor to assist in targetable object placing
    void OnDrawGizmosSelected()
    {
#if UNITY_EDITOR
        if (Debug.IsKeyActive("camera"))
        {
            foreach (GameObject target in allTargetables)
            {
                if (Vector3.Distance(this.target.position, target.transform.position) <= target.GetComponent <Targetable> ().range)
                {
                    if (target.GetComponent <Targetable> ().isTargetable)
                    {
                        if (Vector3.Angle(this.transform.forward, target.transform.position - this.transform.position) <= screenTargetArea)
                        {
                            Gizmos.color = Color.green;
                            Gizmos.DrawRay(target.transform.position, (this.transform.position - target.transform.position));
                        }
                        else
                        {
                            Gizmos.color = Color.red;
                            Gizmos.DrawRay(target.transform.position, (this.transform.position - target.transform.position));
                        }
                    }
                    else
                    {
                        Gizmos.color = Color.red;
                        Gizmos.DrawRay(target.transform.position, (this.transform.position - target.transform.position));
                    }
                }
            }

            Gizmos.color = new Color(1, 1, 1, 0.5f);
            Gizmos.DrawSphere(this.target.position, targetingRange);
        }
#endif
    }
コード例 #8
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();
    }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     initializeCheckpoints();
     // print closest node using search function
     Debug.Log("checkpoint", "Closest Node " + search(new Vector3(5, 5, 5)).location);
     print("Closest Node " + search(new Vector3(0, 0, 0)).location);
 }
コード例 #10
0
    //!Adds sound info from JSON to Dictionaries
    public void addSound(string type, string name, bool priority)
    {
        switch (type.ToLower())
        {
        case "ambience":
            ambienceDict.Add(name, priority);
            break;

        case "effect":
            effectDict.Add(name, priority);
            break;

        case "music":
            musicDict.Add(name, priority);
            break;

        case "voice":
            voiceDict.Add(name, priority);
            break;

        default:
            Debug.Log("audio", type + "is not an option, or you spelled it wrong");
            break;
        }
        if (priority)
        {
            priorityDict.Add(name, type);
        }
    }
コード例 #11
0
 public void Investigate()
 {
     Debug.Log("ai", "works");
     //play animation
     //after animation ChangeNavPoint(startPoint.name, startPoint.transform.position);
     //set noiseHeard to false
     //Searching = false;
 }
コード例 #12
0
 //!Pause all active audio
 void unpauseAll()
 {
     foreach (string entry in activeAudio.Keys)
     {
         activeAudio[entry].UnPause();
     }
     Debug.Log("audio", "All active audio has been unpaused");
 }
コード例 #13
0
 void Start()
 {
     if (path.Count == 0)
     {
         Debug.Log("safety", "ActionPath at " + transform.position + " has less than 2 positions.");
         Destroy(this.gameObject);
     }
 }
コード例 #14
0
 //!stops all active playing sound
 void stopAll()
 {
     foreach (string entry in activeAudio.Keys)
     {
         activeAudio[entry].Stop();
     }
     Debug.Log("audio", "All active audio stopped");
 }
コード例 #15
0
 //!Pause all active audio
 void pauseAll()
 {
     foreach (string entry in activeAudio.Keys)
     {
         activeAudio[entry].Pause();
     }
     Debug.Log("audio", "All active audio paused");
 }
コード例 #16
0
//END OLD CODE

    //!Set variable LatestWorldCheckpoint

    /*!
     * Sets LatestWorldCheckpoint
     * Takes one argument, the transform of the \a checkpoint
     * Created for testing purposes.
     *
     * \param checkpoint the transform of the checkpoint being set as the latest world checkpoint
     */
    public void SetLatestWorldCheckpoint(Transform checkpoint)
    {
        LatestWorldCheckpoint = checkpoint;
        Debug.Log("Checkpoint", checkpoint.gameObject.name + " is the LatestWorldCheckpoint");
//TESTING
        latestWorldName = LatestWorldCheckpoint.name;
//END TESTING
    }
コード例 #17
0
 void Start()
 {
     if (eventPath.Count == 0)
     {
         Debug.Warning("camera", "Warning: Camera Event " + this.gameObject.name + " has no path");
         Destroy(this.gameObject);
     }
 }
コード例 #18
0
    //!Set the variable LatestQuestCheckpoint

    /*!
     * Sets LatestQuestCheckpoint
     * Takes one argument, the transform of the \a checkpoint
     * Created for testing purposes
     *
     * \param checkpoint the transform of the checkpoint being set as the latest quest checkpoint
     */
    public void SetLatestQuestCheckpoint(Transform checkpoint)
    {
        LatestQuestCheckpoint = checkpoint;
        Debug.Log("checkpoint", checkpoint.gameObject.name + " is LatestQuestCheckpoint");

//TESTING
        latestQuestName = LatestQuestCheckpoint.name;
//END TESTING
    }    //END public void SetLatestQuestCheckpoint(Transform checkpoint)
コード例 #19
0
 public bool BuildCheck()
 {
     if (path.Count == 0)
     {
         Debug.Log("safety", "ActionPath at " + transform.position + " is invalid.");
         return(false);
     }
     return(true);
 }
コード例 #20
0
 string GetInputOrFail(Dictionary <string, string> type, string input)
 {
     try {
         return(GetKey(type, input));
     }
     catch (System.ArgumentException e) {
         Debug.Log("input", e.Message);
         return(null);
     }
 }
コード例 #21
0
    //!checks JSON file exists and loads it
    public bool loadListFromFile(string path)                   //checks to make sure json file is there
    {
        if (!System.IO.File.Exists(Application.dataPath + path))
        {
            Debug.Error("audio", "File does not exist: " + Application.dataPath + path);
            return(false);
        }
        string json = System.IO.File.ReadAllText(Application.dataPath + path);

        return(loadListFromJson(json));
    }
コード例 #22
0
    void Awake()
    {
        #region singletonEnforcement
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
            Debug.Error("core", "Second GameHUD detected. Deleting gameOject.");
            return;
        }
        #endregion

        UIhud          = GameObject.Find("_UI");
        mainHUDCanvas  = GameObject.Find("mainHUD");
        worldMapCanvas = GameObject.Find("worldMapCanvas");
        gameMap        = GameObject.Find("mapBG");
        player         = GameObject.Find("_Player");
        testObjective  = GameObject.Find("TestObjective");
        if (!pauseMenu)
        {
            pauseMenu = GameObject.Find("pauseMenu");
        }
        pauseMenu.SetActive(false);

        //!Turn on UI stuff
        worldMapCanvas.SetActive(true);

        //!Fill mapLabels array
        mapLabels      = GameObject.FindGameObjectsWithTag("worldMapLabel");
        closeMapButton = GameObject.Find("CloseMapButton");
        closeMapButton.SetActive(false);

        //!Set mapcam reference
        mapCam = GameObject.Find("mapCam");
        //!Set compassCameraPoint reference
        compassCameraPoint = GameObject.Find("compassCameraPoint");
        compass            = GameObject.Find("compassSlider");
        slider             = compass.transform.FindChild("Handle Slide Area").gameObject;
        slider.SetActive(false);
        leftArrow = compass.transform.FindChild("leftArrow").gameObject;
        leftArrow.SetActive(false);
        rightArrow = compass.transform.FindChild("rightArrow").gameObject;
        rightArrow.SetActive(false);

        //!Set objective text reference
        objectiveText = GameObject.Find("objectiveText");

        phoneButtons = GameObject.Find("PhoneButtons");
        mapElements  = GameObject.Find("MapElements");
        mapElements.SetActive(false);
    }
コード例 #23
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 + "\'");
     }
 }
コード例 #24
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;
            }
        }
    }
コード例 #25
0
    }    //END public Transform FindNearestCheckpointByPath(Vector3 player)

    //creates debug error and returns true if list is empty, false if list contains a checkpoint
    bool ListEmpty()
    {
        if (AllCheckpoints.Count < 1)
        {
            Debug.Error("checkpoint", "list AllCheckpoints is empty");
            return(true);
        }
        else
        {
            return(false);
        }
    }    //END bool ListEmpty()
コード例 #26
0
 //! Load string
 protected string Load(string key)
 {
     if (PlayerPrefs.HasKey(key))
     {
         return(PlayerPrefs.GetString(key));
     }
     else
     {
         Debug.Error("core", "Loading from PlayerPrefs failed. Key \"" + key + "\" does not exist.");
     }
     return(null);
 }
コード例 #27
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);
     }
 }
コード例 #28
0
    //JSON load stuff
    private bool loadListFromFile(string filePath)
    {
        if (!System.IO.File.Exists(Application.dataPath + filePath))
        {
            Debug.Log("input", "File does not exist: " + Application.dataPath + filePath);
            return(false);
        }
        string json     = System.IO.File.ReadAllText(Application.dataPath + filePath);
        string platform = Application.platform.ToString();

        return(loadListFromJson(json, platform));
    }
コード例 #29
0
 void Awake()
 {
     if (!loadListFromFile(StringManager.INPUTKEYS))
     {
         Debug.Log("input", "JSON file did not load");
         //return false;
     }
     else
     {
         Debug.Log("input", "JSON file loaded");
         //return true;
     }
 }
コード例 #30
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
         Debug.Error("core", "Second MasterSceneManager detected. Deleting gameOject.");
         return;
     }
 }