示例#1
0
        void DoPlayRandomClip()
        {
            if (audioClips.Length == 0)
            {
                return;
            }

            int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomIndex != -1)
            {
                AudioClip clip = audioClips[randomIndex].Value as AudioClip;
                if (clip != null)
                {
                    if (!position.IsNone)
                    {
                        AudioSource.PlayClipAtPoint(clip, position.Value, volume.Value);
                    }
                    else
                    {
                        GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
                        if (go == null)
                        {
                            return;
                        }

                        AudioSource.PlayClipAtPoint(clip, go.transform.position, volume.Value);
                    }
                }
            }
        }
        void SwapSprites()
        {
            if (sprites == null)
            {
                return;
            }
            if (sprites.Length == 0)
            {
                return;
            }

            if (Repeat.Value)
            {
                randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
            }
            else
            {
                do
                {
                    randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
                } while (randomIndex == lastIndex);

                lastIndex = randomIndex;
            }

            if (randomIndex != -1)
            {
                spriteRenderer.sprite = sprites[randomIndex] as Sprite;
            }
        }
示例#3
0
        private void DoPlayRandomClip()
        {
            if (this.audioClips.Length == 0)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);

            if (randomWeightedIndex != -1)
            {
                AudioClip audioClip = this.audioClips[randomWeightedIndex];
                if (audioClip != null)
                {
                    if (!this.position.IsNone)
                    {
                        AudioSource.PlayClipAtPoint(audioClip, this.position.Value, this.volume.Value);
                    }
                    else
                    {
                        GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
                        if (ownerDefaultTarget == null)
                        {
                            return;
                        }
                        AudioSource.PlayClipAtPoint(audioClip, ownerDefaultTarget.transform.position, this.volume.Value);
                    }
                }
            }
        }
示例#4
0
        private void DoPlayRandomClip()
        {
            if (audioClips.Length == 0)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomWeightedIndex == -1)
            {
                return;
            }
            AudioClip audioClip = audioClips[randomWeightedIndex];

            if (!(audioClip != null))
            {
                return;
            }
            if (!position.IsNone)
            {
                AudioSource.PlayClipAtPoint(audioClip, position.Value, volume.Value);
                return;
            }
            GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(gameObject);

            if (!(ownerDefaultTarget == null))
            {
                AudioSource.PlayClipAtPoint(audioClip, ownerDefaultTarget.transform.position, volume.Value);
            }
        }
示例#5
0
        public override void OnEnter()
        {
            if (ints.Length > 0)
            {
                result.Value = ActionHelpers.GetRandomWeightedIndex(weights);
            }

            Finish();
        }
示例#6
0
 private void DoPlayRandomAnimation()
 {
     if (this.animations.Length > 0)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);
         if (randomWeightedIndex != -1)
         {
             this.DoPlayAnimation(this.animations[randomWeightedIndex].Value);
         }
     }
 }
示例#7
0
 private void DoSelectRandomGameObject()
 {
     if (gameObjects != null && gameObjects.Length != 0 && storeGameObject != null)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(weights);
         if (randomWeightedIndex != -1)
         {
             storeGameObject.Value = gameObjects[randomWeightedIndex].Value;
         }
     }
 }
 private void DoSelectRandomColor()
 {
     if (vector3Array != null && vector3Array.Length != 0 && storeVector3 != null)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(weights);
         if (randomWeightedIndex != -1)
         {
             storeVector3.Value = vector3Array[randomWeightedIndex].Value;
         }
     }
 }
 private void DoSelectRandomString()
 {
     if (strings != null && strings.Length != 0 && storeString != null)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(weights);
         if (randomWeightedIndex != -1)
         {
             storeString.Value = strings[randomWeightedIndex].Value;
         }
     }
 }
示例#10
0
 private void DoSelectRandomColor()
 {
     if (colors != null && colors.Length != 0 && storeColor != null)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(weights);
         if (randomWeightedIndex != -1)
         {
             storeColor.Value = colors[randomWeightedIndex].Value;
         }
     }
 }
示例#11
0
        void DoPlayRandomAnimation()
        {
            if (animations.Length > 0)
            {
                var randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

                if (randomIndex != -1)
                {
                    DoPlayAnimation(animations[randomIndex].Value);
                }
            }
        }
示例#12
0
		void DoSelectRandomColor()
		{
			if (vector3Array == null) return;
			if (vector3Array.Length == 0) return;
			if (storeVector3 == null) return;

			int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
			
			if (randomIndex != -1)
			{
				storeVector3.Value = vector3Array[randomIndex].Value;
			}
		}
示例#13
0
        private void DoSelectRandomColor()
        {
            if (this.colors == null)
            {
                return;
            }
            if (this.colors.Length == 0)
            {
                return;
            }
            if (this.storeColor == null)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);

            if (randomWeightedIndex != -1)
            {
                this.storeColor.Value = this.colors[randomWeightedIndex].Value;
            }
        }
示例#14
0
        private void DoSelectRandomString()
        {
            if (this.strings == null)
            {
                return;
            }
            if (this.strings.Length == 0)
            {
                return;
            }
            if (this.storeString == null)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);

            if (randomWeightedIndex != -1)
            {
                this.storeString.Value = this.strings[randomWeightedIndex].Value;
            }
        }
示例#15
0
        private void DoSelectRandomColor()
        {
            if (this.vector3Array == null)
            {
                return;
            }
            if (this.vector3Array.Length == 0)
            {
                return;
            }
            if (this.storeVector3 == null)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);

            if (randomWeightedIndex != -1)
            {
                this.storeVector3.Value = this.vector3Array[randomWeightedIndex].Value;
            }
        }
        private void DoSelectRandomGameObject()
        {
            if (this.gameObjects == null)
            {
                return;
            }
            if (this.gameObjects.Length == 0)
            {
                return;
            }
            if (this.storeGameObject == null)
            {
                return;
            }
            int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);

            if (randomWeightedIndex != -1)
            {
                this.storeGameObject.Value = this.gameObjects[randomWeightedIndex].Value;
            }
        }
示例#17
0
 public override void OnEnter()
 {
     if (this.events.Length > 0)
     {
         int randomWeightedIndex = ActionHelpers.GetRandomWeightedIndex(this.weights);
         if (randomWeightedIndex != -1)
         {
             if (this.delay.Value < 0.001f)
             {
                 base.Fsm.Event(this.events[randomWeightedIndex]);
                 base.Finish();
             }
             else
             {
                 this.delayedEvent = base.Fsm.DelayedEvent(this.events[randomWeightedIndex], this.delay.Value);
             }
             return;
         }
     }
     base.Finish();
 }
示例#18
0
        void DoSelectRandom()
        {
            if (vector2Array == null)
            {
                return;
            }
            if (vector2Array.Length == 0)
            {
                return;
            }
            if (storeVector2 == null)
            {
                return;
            }

            int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomIndex != -1)
            {
                storeVector2.Value = vector2Array[randomIndex].Value;
            }
        }
示例#19
0
        public override void OnEnter()
        {
            if (events.Length > 0)
            {
                int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

                if (randomIndex != -1)
                {
                    delayedEvent = new DelayedEvent(Fsm, events[randomIndex], delay.Value);
                    delayedEvent.Update();

                    if (delayedEvent.Finished)
                    {
                        Finish();
                    }

                    return;
                }
            }

            Finish();
        }
示例#20
0
        void DoSelectRandomString()
        {
            if (ints == null)
            {
                return;
            }
            if (ints.Length == 0)
            {
                return;
            }
            if (storeInt == null)
            {
                return;
            }

            int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomIndex != -1)
            {
                storeInt.Value = ints[randomIndex].Value;
            }
        }
        void DoSelectRandomColor()
        {
            if (colors == null)
            {
                return;
            }
            if (colors.Length == 0)
            {
                return;
            }
            if (storeColor == null)
            {
                return;
            }

            int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomIndex != -1)
            {
                storeColor.Value = colors[randomIndex].Value;
            }
        }
示例#22
0
        void DoSelectRandomObject()
        {
            if (objects == null)
            {
                return;
            }
            if (objects.Length == 0)
            {
                return;
            }
            if (storeObject == null)
            {
                return;
            }

            int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

            if (randomIndex != -1)
            {
                storeObject.Value = objects[randomIndex].Value;
            }
        }
        void PickRandom()
        {
            if (amount.Length == 0)
            {
                return;
            }

            if (Repeat.Value)
            {
                randomIndex  = ActionHelpers.GetRandomWeightedIndex(weights);
                result.Value = amount[randomIndex].Value;
            }
            else
            {
                do
                {
                    randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
                } while(randomIndex == lastIndex);

                lastIndex    = randomIndex;
                result.Value = amount[randomIndex].Value;
            }
        }
        void PickRandom()
        {
            if (ints.Length == 0)
            {
                return;
            }

            if (canHitTwiceInARow.Value)
            {
                randomIndex  = ActionHelpers.GetRandomWeightedIndex(weights);
                result.Value = ints[randomIndex].Value;
            }
            else
            {
                do
                {
                    randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
                } while (randomIndex == lastIndex);

                lastIndex    = randomIndex;
                result.Value = ints[randomIndex].Value;
            }
        }
示例#25
0
		void DoPlayRandomClip()
		{
			if (audioClips.Length == 0) return;

            if (!noRepeat.Value || weights.Length == 1)
            {
                randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
            }
            else
            {
                do
                {
                    randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);
                } while (randomIndex == lastIndex && randomIndex != -1);

                lastIndex = randomIndex;
            }

            if (randomIndex != -1)
			{
				var clip = audioClips[randomIndex].Value as AudioClip;
				if (clip != null)
				{
					if (!position.IsNone)
					{
						AudioSource.PlayClipAtPoint(clip, position.Value, volume.Value);
					}
					else
					{
						GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);
						if (go == null) return;
						
						AudioSource.PlayClipAtPoint(clip, go.transform.position, volume.Value);
					}				
				}
			}
		}
        public override void OnEnter()
        {
            if (events.Length > 0)
            {
                int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights);

                if (randomIndex != -1)
                {
                    if (delay.Value < 0.001f)
                    {
                        Fsm.Event(events[randomIndex]);
                        Finish();
                    }
                    else
                    {
                        delayedEvent = Fsm.DelayedEvent(events[randomIndex], delay.Value);
                    }

                    return;
                }
            }

            Finish();
        }