// Sound is created as a BFS search. protected void MakeSound() { int depth = 0; switch (ExecTime) { case (int)Speed.Medium: depth = 2; break; case (int)Speed.Fast: depth = 3; break; } SoundNode n = new SoundNode(null, Location, depth); Noise = Planner.Search(n).ToList(); if (Noise != null) { Noise.Remove(Location); } Piece.DisplayFeature(Noise, Feature.Sound); }
public override Node ChildNode(Location loc) { SoundNode n = new SoundNode(this, origin, depth); n.CurLocation = loc; return(n); }
/// <summary> /// Remove SoundNode p_nodule to currentNodeList. /// </summary> public void RemoveNode(int p_id) { SoundNode __node = this.currentNodeList.FirstOrDefault <SoundNode>(t => t.id == p_id); if (__node != null) { __node.Clear(); _currentNodeList.Remove(__node); } }
// A BFS search to generate sound. public SoundNode(SoundNode parent, Location origin, int depth) : base(parent) { this.origin = origin; this.depth = depth; if (ReferenceEquals(parent, null)) { CurLocation = origin; } }
private void Start() { // go from List to dictionary for quick retrieval for (int i = 0; i < listSoundList.Count; ++i) { SoundNode soundNode = listSoundList[i]; soundNode.soundObject.audioSource = gameObject.AddComponent <AudioSource>(); soundNode.soundObject.audioSource.volume = soundNode.soundObject.volume; soundNode.soundObject.audioSource.loop = soundNode.soundObject.type == SoundObject.soundType.music ? true : false; soundDictionary.Add(soundNode.id, soundNode); } }
public void Play(Tags p_tag) { if (!_dictAudioTriggers.ContainsKey(p_tag)) { Debug.LogWarning($"Trigger for tag '{p_tag}' does not exist."); return; } AudioTrigger __trigger = _dictAudioTriggers[p_tag]; __trigger.Node?.Cancel(); SoundNode __node = Sound.Play2DSound(__trigger.GetRandomClip(), __trigger.isLoop, GetVolumeForLayer(__trigger.layer), __trigger.layer); __trigger.SetNode(__node); }
/// <summary> /// Function that display the information of passed node. /// </summary> public void DisplayTweenNodeData(SoundNode __node) { if (__node.onFinishedPlaying != null) { GUILayout.Label("\tUsedByClass: " + __node.onFinishedPlaying.Method.ReflectedType.FullName); GUILayout.Label("\tMethod: " + __node.onFinishedPlaying.Method.Name); } GUILayout.BeginHorizontal(); GUILayout.Label("\tAudioclip: "); EditorGUILayout.ObjectField(__node.VoxVoxSource.audioSource.clip, typeof(AudioClip), true); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("\tAudioSource: "); EditorGUILayout.ObjectField(__node.VoxVoxSource.audioSource, typeof(AudioSource), true); GUILayout.EndHorizontal(); GUILayout.Label("\tIsLoop:" + __node.VoxVoxSource.audioSource.loop); }
void Start() { // go from List to dictionary for quick retrieval for (int i = 0; i < listSoundList.Count; ++i) { SoundNode soundNode = listSoundList[i]; soundNode.soundObject.audioSource = gameObject.AddComponent <AudioSource>(); soundNode.soundObject.audioSource.volume = soundNode.soundObject.volume; soundNode.soundObject.audioSource.loop = soundNode.soundObject.type == SoundObject.soundType.music ? true : false; soundDictionary.Add(soundNode.id, soundNode); } // instantiate the event if (playSoundEvent == null) { playSoundEvent = new PlaySoundEvent(); } // trigger func playSoundEvent.AddListener(PlaySound); }
public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (obj.GetType() != this.GetType()) { return(false); } SoundNode n = (SoundNode)obj; return(!System.Object.ReferenceEquals(null, CurLocation) && CurLocation.Equals(n.CurLocation)); }
public void SetNode(SoundNode p_node) => Node = p_node;
/// <summary> /// Add SoundNode p_nodule to currentNodeList. /// </summary> public void AddNode(SoundNode p_nodule) { _currentNodeList.Add(p_nodule); }
void GenerateBehaviors() { Animator a = GetAnimator(); ////////////////////////////////// Movement ////////////////////////////////// EvadeNode evade = new EvadeNode(this.rB, speed, 0.4f, 25); IsBlockedNode isBlocked = new IsBlockedNode(transform, evade, 1, 1); MoveNode move = new MoveNode(rB, target, speed, atkRange); SequenceNode evading = new SequenceNode(new List <Node>() { isBlocked, evade }); SelectorNode movement = new SelectorNode(new List <Node>() { evading, move }); ////////////////////////////////// Death ////////////////////////////////// HealthCheckNode isDead = new HealthCheckNode(this, 0, true); ClampSuccessNode isDeadClamped = new ClampSuccessNode(isDead); AnimationNode deathAnim = new AnimationNode(a, "Die"); OnAnimationCompleteNode onDeathAnimComplete = new OnAnimationCompleteNode(a, "Die"); DestroyNode destroy = new DestroyNode(this.gameObject); SequenceNode death = new SequenceNode(new List <Node> { isDeadClamped, deathAnim, onDeathAnimComplete, destroy }); ////////////////////////////////// Cover ////////////////////////////////// HealthCheckNode isLow = new HealthCheckNode(this, consideredLowHP, true); SoundNode hurtSFX = new SoundNode(Sound.SeaMonsterHurt); RandomNode chanceHurtSFX = new RandomNode(hurtSFX, 0.4f); ColorFlashNode hurtFlash = new ColorFlashNode(GetMaterial(), Color.red, 3, 1); RecoverHealthNode hpRecover = new RecoverHealthNode(this, hpRecoveryMultiplier); FindCover findCover = new FindCover(this, target, 10); SequenceNode hurting = new SequenceNode(new List <Node>() { chanceHurtSFX, hurtFlash }); SequenceNode recovering = new SequenceNode(new List <Node>() { hpRecover, hurting }); SequenceNode covering = new SequenceNode(new List <Node>() { findCover, movement }); ParallelNode recoveringAndCovering = new ParallelNode(new List <Node>() { recovering, covering }, 2); SequenceNode cover = new SequenceNode(new List <Node>() { isLow, recoveringAndCovering }); ////////////////////////////////// Attack ////////////////////////////////// // Condition To Start Attack Sequence IsInRangeNode isInATKRange = new IsInRangeNode(atkRange, transform, target); // Attack Sequence AnimationNode readyUpAnim = new AnimationNode(a, "Aim"); LookNode aim = new LookNode(rB, target, 1, 12, 7); AnimationNode strikeAnim = new AnimationNode(a, "Fire"); TimerNode atkTimer = new TimerNode(1); // Wrapping Nodes SequenceNode attackPattern = new SequenceNode(new List <Node>() { readyUpAnim, aim, strikeAnim, atkTimer }); ResetOnStateNode resetATK = new ResetOnStateNode(attackPattern, NodeState.SUCCESS); SequenceNode attacking = new SequenceNode(new List <Node>() { isInATKRange, resetATK }); SelectorNode attack = new SelectorNode(new List <Node>() { attacking, movement }); ////////////////////////////////// Patrol ////////////////////////////////// PatrolNode patrolMove = new PatrolNode(rB, Mathf.RoundToInt(speed * 0.7f), 0.5f, 6, 20, 1.5f, 4); SelectorNode evadeAndPatrol = new SelectorNode(new List <Node>() { evading, patrolMove }); SpotTargetNode spotTarget = new SpotTargetNode(transform, 40, 80, LayerMask.NameToLayer("Target"), LayerMask.NameToLayer("Enemy")); FlagNode flag = new FlagNode(NodeState.SUCCESS, NodeState.FAILURE); FlagActivator flagActivator = new FlagActivator(flag); SequenceNode spotAndStop = new SequenceNode(new List <Node>() { spotTarget, flagActivator }); SelectorNode patroling = new SelectorNode(new List <Node>() { spotAndStop, evadeAndPatrol }); SequenceNode patrol = new SequenceNode(new List <Node>() { flag, patroling }); ////////////////////////////////// Top Node ////////////////////////////////// topNode = new Tree(new SelectorNode(new List <Node>() { death, cover, patrol, attack })); BehaviorTreeManager.AddTree(topNode); }