예제 #1
0
 // Using fixed update because it's physics what is being updated
 void FixedUpdate()
 {
     // Update emitter location
     _attributes3D = RuntimeUtils.To3DAttributes(gameObject, _rigidBody);
     _channel.set3DAttributes(ref _attributes3D.position, ref _attributes3D.velocity, ref _alt_pan_pos);
 }
예제 #2
0
 public static object CreateDefaultValue(this Type type)
 {
     return(RuntimeUtils.CreateDefaultValue(type));
 }
        public void Play(string audioFile)
        {
            if (String.IsNullOrEmpty(audioFile))
            {
                return;
            }

            if (TriggerOnce && hasTriggered)
            {
                return;
            }

            if (String.IsNullOrEmpty(Event))
            {
                return;
            }

            if (!eventDescription.isValid())
            {
                Lookup();
            }

            bool isOneshot = false;

            if (!Event.StartsWith("snapshot", StringComparison.CurrentCultureIgnoreCase))
            {
                eventDescription.isSnapshot(out isOneshot);
            }

            bool is3D = false;

            eventDescription.is3D(out is3D);

            if (!instance.isValid())
            {
                instance.clearHandle();
            }

            if (isOneshot && instance.isValid())
            {
                instance.release();
                instance.clearHandle();
            }

            if (!instance.isValid())
            {
                eventDescription.createInstance(out instance);

                if (is3D)
                {
                    var rigidBody   = GetComponent <Rigidbody>();
                    var rigidBody2D = GetComponent <Rigidbody2D>();
                    var transform   = GetComponent <Transform>();
                    if (rigidBody)
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody);
                    }
                    else
                    {
                        instance.set3DAttributes(RuntimeUtils.To3DAttributes(gameObject, rigidBody2D));
                        RuntimeManager.AttachInstanceToGameObject(instance, transform, rigidBody2D);
                    }
                }
            }

            foreach (var param in Params)
            {
                instance.setParameterValue(param.Name, param.Value);
            }

            if (is3D && OverrideAttenuation)
            {
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, OverrideMinDistance);
                instance.setProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, OverrideMaxDistance);
            }
            ExtensionsManager.PlayProgrammerSound(audioFile, this.instance);

            hasTriggered = true;
        }
예제 #4
0
    public void RenderEveryTick(float dt)
    {
        ListPool <Sound, LoopingSoundManager> .PooledList pooledList = ListPool <Sound, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList2 = ListPool <int, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList3 = ListPool <int, LoopingSoundManager> .Allocate();

        List <Sound> dataList    = sounds.GetDataList();
        bool         flag        = Time.timeScale == 0f;
        SoundCuller  soundCuller = CameraController.Instance.soundCuller;

        for (int i = 0; i < dataList.Count; i++)
        {
            Sound sound = dataList[i];
            if ((UnityEngine.Object)sound.transform != (UnityEngine.Object)null)
            {
                sound.pos = sound.transform.GetPosition();
                if ((UnityEngine.Object)sound.animController != (UnityEngine.Object)null)
                {
                    Vector3 offset = sound.animController.Offset;
                    sound.pos.x += offset.x;
                    sound.pos.y += offset.y;
                }
            }
            bool flag2     = !sound.IsCullingEnabled || (sound.ShouldCameraScalePosition && soundCuller.IsAudible(sound.pos, sound.falloffDistanceSq)) || soundCuller.IsAudibleNoCameraScaling(sound.pos, sound.falloffDistanceSq);
            bool isPlaying = sound.IsPlaying;
            if (flag2)
            {
                pooledList.Add(sound);
                if (!isPlaying)
                {
                    SoundDescription soundDescription = GetSoundDescription(sound.path);
                    sound.ev    = KFMOD.CreateInstance(soundDescription.path);
                    dataList[i] = sound;
                    pooledList2.Add(i);
                }
            }
            else if (isPlaying)
            {
                pooledList3.Add(i);
            }
        }
        LoopingSoundParameterUpdater.Sound sound2;
        foreach (int item in pooledList2)
        {
            Sound            value             = dataList[item];
            SoundDescription soundDescription2 = GetSoundDescription(value.path);
            value.ev.setPaused(flag && value.ShouldPauseOnGamePaused);
            Vector2 v = value.pos;
            if (value.ShouldCameraScalePosition)
            {
                v = SoundEvent.GetCameraScaledPosition(v);
            }
            value.ev.set3DAttributes(RuntimeUtils.To3DAttributes(v));
            value.ev.start();
            value.flags |= Sound.Flags.PLAYING;
            if (value.firstParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.firstParameter), value.firstParameterValue);
            }
            if (value.secondParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.secondParameter), value.secondParameterValue);
            }
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value.ev;
            sound2.path        = value.path;
            sound2.description = soundDescription2;
            sound2.transform   = value.transform;
            LoopingSoundParameterUpdater.Sound sound3     = sound2;
            SoundDescription.Parameter[]       parameters = soundDescription2.parameters;
            for (int j = 0; j < parameters.Length; j++)
            {
                SoundDescription.Parameter   parameter = parameters[j];
                LoopingSoundParameterUpdater value2    = null;
                if (parameterUpdaters.TryGetValue(parameter.name, out value2))
                {
                    value2.Add(sound3);
                }
            }
            dataList[item] = value;
        }
        pooledList2.Recycle();
        foreach (int item2 in pooledList3)
        {
            Sound            value3            = dataList[item2];
            SoundDescription soundDescription3 = GetSoundDescription(value3.path);
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value3.ev;
            sound2.path        = value3.path;
            sound2.description = soundDescription3;
            sound2.transform   = value3.transform;
            LoopingSoundParameterUpdater.Sound sound4      = sound2;
            SoundDescription.Parameter[]       parameters2 = soundDescription3.parameters;
            for (int k = 0; k < parameters2.Length; k++)
            {
                SoundDescription.Parameter   parameter2 = parameters2[k];
                LoopingSoundParameterUpdater value4     = null;
                if (parameterUpdaters.TryGetValue(parameter2.name, out value4))
                {
                    value4.Remove(sound4);
                }
            }
            if (value3.ShouldCameraScalePosition)
            {
                value3.ev.stop(STOP_MODE.IMMEDIATE);
            }
            else
            {
                value3.ev.stop(STOP_MODE.ALLOWFADEOUT);
            }
            value3.flags &= ~Sound.Flags.PLAYING;
            value3.ev.release();
            dataList[item2] = value3;
        }
        pooledList3.Recycle();
        float velocityScale = TuningData <Tuning> .Get().velocityScale;

        foreach (Sound item3 in pooledList)
        {
            Sound         current3   = item3;
            ATTRIBUTES_3D attributes = SoundEvent.GetCameraScaledPosition(current3.pos).To3DAttributes();
            attributes.velocity = (current3.velocity * velocityScale).ToFMODVector();
            current3.ev.set3DAttributes(attributes);
        }
        foreach (KeyValuePair <HashedString, LoopingSoundParameterUpdater> parameterUpdater in parameterUpdaters)
        {
            parameterUpdater.Value.Update(dt);
        }
        pooledList.Recycle();
    }
예제 #5
0
 /// <summary>
 /// returns the current path of a selected project folder or "Assets"
 /// </summary>
 /// <returns></returns>
 public static string selectedProjectWindowPath()
 {
     return(RuntimeUtils.inEditorSelectedProjectWindowPath());
 }
예제 #6
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(FileStoreManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(FileStoreManager), "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    param = config.Get(typeof(FileStoreManager), "basePath");
                                    if (param != null)
                                    {
                                        tName = param.Value as string;
                                        if (!string.IsNullOrEmpty(tName))
                                        {
                                            if (Directory.Exists(tName))
                                            {
                                                FileStoreManager.basePath = tName;
                                                Log(meth, LogLevel.Info, "Succeeded");
                                                this.State = RunState.Initialized;
                                                return;
                                            }
                                            else
                                            {
                                                Log(meth, LogLevel.Error, "BasePath directory does not exist: " + tName);
                                            }
                                        }
                                        else
                                        {
                                            Log(meth, LogLevel.Error, "Failed to get basePath param value");
                                        }
                                    }
                                    else
                                    {
                                        Log(meth, LogLevel.Error, "Failed to get basePath param");
                                    }
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
예제 #7
0
        public static string GetScript(int publishmentSystemID, ECategoryLoadingType loadingType, NameValueCollection additional)
        {
            var script = @"
<script language=""JavaScript"">
function getTreeLevel(e) {
	var length = 0;
	if (!isNull(e)){
		if (e.tagName == 'TR') {
			length = parseInt(e.getAttribute('treeItemLevel'));
		}
	}
	return length;
}

function getTrElement(element){
	if (isNull(element)) return;
	for (element = element.parentNode;;){
		if (element != null && element.tagName == 'TR'){
			break;
		}else{
			element = element.parentNode;
		} 
	}
	return element;
}

function getImgClickableElementByTr(element){
	if (isNull(element) || element.tagName != 'TR') return;
	var img = null;
	if (!isNull(element.childNodes)){
		var imgCol = element.getElementsByTagName('IMG');
		if (!isNull(imgCol)){
			for (x=0;x<imgCol.length;x++){
				if (!isNull(imgCol.item(x).getAttribute('isOpen'))){
					img = imgCol.item(x);
					break;
				}
			}
		}
	}
	return img;
}

var weightedLink = null;

function fontWeightLink(element){
    if (weightedLink != null)
    {
        weightedLink.style.fontWeight = 'normal';
    }
    element.style.fontWeight = 'bold';
    weightedLink = element;
}

var completedNodeID = null;
function displayChildren(img){
	if (isNull(img)) return;

	var tr = getTrElement(img);

    var isToOpen = img.getAttribute('isOpen') == 'false';
    var isByAjax = img.getAttribute('isAjax') == 'true';
    var nodeID = img.getAttribute('id');

	if (!isNull(img) && img.getAttribute('isOpen') != null){
		if (img.getAttribute('isOpen') == 'false'){
			img.setAttribute('isOpen', 'true');
            img.setAttribute('src', '{iconMinusUrl}');
		}else{
            img.setAttribute('isOpen', 'false');
            img.setAttribute('src', '{iconPlusUrl}');
		}
	}

    if (isToOpen && isByAjax)
    {
        var div = document.createElement('div');
        div.innerHTML = ""<img align='absmiddle' border='0' src='{iconLoadingUrl}' /> 栏目加载中,请稍候..."";
        img.parentNode.appendChild(div);
        $(div).addClass('loading');
        loadingChannels(tr, img, div, nodeID);
    }
    else
    {
        var level = getTreeLevel(tr);
        
	    var collection = new Array();
	    var index = 0;

	    for ( var e = tr.nextSibling; !isNull(e) ; e = e.nextSibling) {
		    if (!isNull(e) && !isNull(e.tagName) && e.tagName == 'TR'){
		        var currentLevel = getTreeLevel(e);
		        if (currentLevel <= level) break;
		        if(e.style.display == '') {
			        e.style.display = 'none';
		        }else{
			        if (currentLevel != level + 1) continue;
			        e.style.display = '';
			        var imgClickable = getImgClickableElementByTr(e);
			        if (!isNull(imgClickable)){
				        if (!isNull(imgClickable.getAttribute('isOpen')) && imgClickable.getAttribute('isOpen') =='true'){
					        imgClickable.setAttribute('isOpen', 'false');
                            imgClickable.setAttribute('src', '{iconPlusUrl}');
					        collection[index] = imgClickable;
					        index++;
				        }
			        }
		        }
            }
	    }
        
	    if (index > 0){
		    for (i=0;i<=index;i++){
			    displayChildren(collection[i]);
		    }
	    }
    }
}
";

            script += $@"
function loadingChannels(tr, img, div, nodeID){{
    var url = '{BackgroundService.GetRedirectUrl(publishmentSystemID, BackgroundService.TYPE_GetLoadingCategorys)}';
    var pars = 'parentID=' + nodeID + '&loadingType={ECategoryLoadingTypeUtils.GetValue(loadingType)}&additional={RuntimeUtils
                .EncryptStringByTranslate(TranslateUtils.NameValueCollectionToString(additional))}'; 
    jQuery.post(url, pars, function(data, textStatus)
    {{
        $($.parseHTML(data)).insertAfter($(tr));
        img.setAttribute('isAjax', 'false');
        img.parentNode.removeChild(div);
    }});
    completedNodeID = nodeID;
}}

function loadingChannelsOnLoad(paths){{
    if (paths && paths.length > 0){{
        var nodeIDs = paths.split(',');
        var nodeID = nodeIDs[0];
        var img = $('#' + nodeID);
        if (img.attr('isOpen') == 'false'){{
            displayChildren(img[0]);
//            if (completedNodeID && completedNodeID == nodeID){{
//                if (paths.indexOf(',') != -1){{
//                    setTimeout(""loadingChannelsOnLoad("" + paths + "")"", 3000);
//                }}
//            }} 
        }}
    }}
}}
</script>
";

            var item = new CategoryTreeItem();

            script = script.Replace("{iconEmptyUrl}", item.iconEmptyUrl);
            script = script.Replace("{iconFolderUrl}", item.iconFolderUrl);
            script = script.Replace("{iconMinusUrl}", item.iconMinusUrl);
            script = script.Replace("{iconPlusUrl}", item.iconPlusUrl);

            script = script.Replace("{iconLoadingUrl}", PageUtils.GetIconUrl("loading.gif"));

            script = script.Replace("loadingChannels", "loadingChannels_Category");
            script = script.Replace("displayChildren", "displayChildren_Category");

            return(script);
        }
예제 #8
0
    void OnMove(float dist)
    {
        movementEvent.set3DAttributes(RuntimeUtils.To3DAttributes(transform));

        movementEvent.setParameterByName(SPEED_PARAM, collisions.Collisions.below ? dist : 0);
    }
예제 #9
0
 internal static void OnUnknownAttribute(object sender, XmlAttributeEventArgs e)
 {
     if ((ValidateSettings(Asmx, TraceEventType.Warning) && (e.Attr != null)) && !RuntimeUtils.IsKnownNamespace(e.Attr.NamespaceURI))
     {
         string name = (e.ExpectedAttributes == null) ? "WebUnknownAttribute" : ((e.ExpectedAttributes.Length == 0) ? "WebUnknownAttribute2" : "WebUnknownAttribute3");
         TraceEvent(TraceEventType.Warning, Res.GetString(name, new object[] { e.Attr.Name, e.Attr.Value, e.ExpectedAttributes }));
     }
 }
예제 #10
0
 public static FieldInfo TransformToDeclaringType(this FieldInfo fieldInfo)
 {
     return(RuntimeUtils.TransformToDeclaringTypeFieldInfo(fieldInfo));
 }
예제 #11
0
 public void BindEvent(int eventID, Transform targetTransform, Rigidbody2D targetBody = null)
 {
     RuntimeManager.AttachInstanceToGameObject(m_SpawnedInstances[eventID], targetTransform, targetBody);
     m_SpawnedInstances[eventID].set3DAttributes(RuntimeUtils.To3DAttributes(targetTransform));
 }
예제 #12
0
 public static PropertyInfo TransformToDeclaringType(this PropertyInfo propertyInfo)
 {
     return(RuntimeUtils.TransformToDeclaringTypePropertyInfo(propertyInfo));
 }
예제 #13
0
        private object GetDefaultValue(object targetProperty)
        {
            var propertyType = GetPropertyType(targetProperty);

            return(propertyType == null ? null : RuntimeUtils.CreateDefaultValue(propertyType));
        }
예제 #14
0
        protected override void BootstrapImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Bootstrappable(this.State))
                {
                    string meth = "Bootstrap";
                    this.State  = RunState.Bootstrapping;
                    this.logger = LogManager.Instance.GetProvider(typeof(SessionManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(SessionManager), "provider");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                TypeNameReference typeName = TypeNameReference.Parse(tName);
                                if (typeName != null)
                                {
                                    uint sessionDuration;
                                    param = config.Get(typeof(SessionManager), "duration");
                                    if (param != null)
                                    {
                                        try
                                        {
                                            sessionDuration = (uint)(int)param.Value;
                                            if (sessionDuration == 0)
                                            {
                                                sessionDuration = 900; //default if not provided 15 minutes
                                            }
                                            this.Bootstrap(typeName, sessionDuration);
                                            return;
                                        }
                                        catch
                                        { }

                                        Log(meth, LogLevel.Error, "Failed to parse duration param value");
                                    }
                                    else
                                    {
                                        Log(meth, LogLevel.Error, "Failed to get duration param");
                                    }
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to parse provider param value");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get provider param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get provider param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedBootstrapping;
                }
            }
        }
예제 #15
0
 /// <summary>
 /// Attach an event to current transform
 /// </summary>
 /// <param name="_eventInstance">fmod event instance</param>
 /// <param name="_emitterTransform">transform to attach event</param>
 public void AttachSfx(EventInstance _eventInstance, Transform _emitterTransform)
 {
     RuntimeManager.AttachInstanceToGameObject(_eventInstance, _emitterTransform, GetComponent <Rigidbody2D>());
     _eventInstance.set3DAttributes(RuntimeUtils.To3DAttributes(_emitterTransform.position));
 }
예제 #16
0
 /// <summary>
 /// Sets the handling data for this server event.
 /// </summary>
 /// <param name="owner">The owner of the handler, if static, the owner is null</param>
 /// <param name="handler">The handling method as handler</param>
 internal void SetHandler(object owner, MethodInfo handler)
 {
     _handler = handler;
     _owner   = owner;
     Usage    = RuntimeUtils.GetUsage(_handler);
 }