Ejemplo n.º 1
0
        public void DropItem()
        {
            GameObject go   = null;
            ItemKind   kind = (randomDrop) ? _rndList[AntMath.RandomRangeInt(0, _rndList.Length - 1)] : dropKind;

            switch (kind)
            {
            case ItemKind.Bomb:
                go = GameObject.Instantiate((GameObject)_gameCore.bombItemPrefab);
                break;

            case ItemKind.Gun:
                go = GameObject.Instantiate((GameObject)_gameCore.gunItemPrefab);
                break;

            case ItemKind.Ammo:
                go = GameObject.Instantiate((GameObject)_gameCore.ammoItemPrefab);
                break;

            case ItemKind.Heal:
                go = GameObject.Instantiate((GameObject)_gameCore.healItemPrefab);
                break;
            }

            if (go != null)
            {
                go.GetComponent <Transform>().position = _t.position;
                AntEngine.Current.AddEntity(go.GetComponent <AntEntity>());
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Starts playing current animation from the random frame.
 /// </summary>
 public void PlayRandomFrame()
 {
     if (_isAnimInitialized)
     {
         GotoAndPlay(AntMath.RandomRangeInt(1, TotalFrames));
     }
 }
        /// <summary>
        /// Returns random point on the map. Useful if we don’t know
        /// where to send the tank, send it to a random point.
        /// </summary>
        /// <returns>Random point on the map.</returns>
        public Vector2 GetRandomPoint()
        {
            // Select random node in the NavMesh for random movement.
            int index = AntMath.RandomRangeInt(0, Game.NavMesh.nodes.Count - 1);

            // Get the center of node as our target.
            return(Game.NavMesh.GetNodeCenter(index));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets random value from the Array.
        /// </summary>
        /// <param name="aSource">Array</param>
        /// <typeparam name="T">Type of Array.</typeparam>
        /// <returns>Random value of the Array.</returns>
        public static T GetRandom <T>(ref T[] aSource)
        {
            T result = default(T);

            if (aSource.Length > 0)
            {
                result = aSource[AntMath.RandomRangeInt(0, aSource.Length - 1)];
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Pops random value from the array.
        /// </summary>
        /// <param name="aSource">Array.</param>
        /// <typeparam name="T">Type of Array.</typeparam>
        /// <returns>Random value of the Array.</returns>
        public static T PopRandom <T>(ref T[] aSource)
        {
            T result = default(T);

            if (aSource.Length > 0)
            {
                int i = AntMath.RandomRangeInt(0, aSource.Length - 1);
                result = aSource[i];
                RemoveAt <T>(ref aSource, i);
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Shuffle all values in the array.
        /// </summary>
        /// <param name="aList">Array.</param>
        /// <typeparam name="T">Type of Array.</typeparam>
        public static void Shuffle <T>(ref T[] aList)
        {
            T   temp;
            int newPos;
            int index = aList.Length;

            while (index > 1)
            {
                index--;
                newPos        = AntMath.RandomRangeInt(0, index);
                temp          = aList[newPos];
                aList[newPos] = aList[index];
                aList[index]  = temp;
            }
        }
        public void Reset(AntEmitter aEmitter)
        {
            _sprite = (Preset.actor.useChildActor)
                                ? _particle.GameObject.GetComponentInChildren <SpriteRenderer>()
                                : _particle.GameObject.GetComponent <SpriteRenderer>();

            _actor = (Preset.actor.useChildActor)
                                ? _particle.GameObject.GetComponentInChildren <AntActor>()
                                : _particle.GameObject.GetComponent <AntActor>();

            _actor.timeScale = Preset.actor.timeScale + AntMath.RandomRangeFloat(Preset.actor.rndToTimeScale);
            _sprite.flipX    = (Preset.actor.rndFlipX)
                                ? (AntMath.RandomRangeInt(0, 1) == 1)
                                : Preset.actor.flipX;

            _sprite.flipY = (Preset.actor.rndFlipY)
                                ? (AntMath.RandomRangeInt(0, 1) == 1)
                                : Preset.actor.flipY;

            _actor.reverse   = Preset.actor.reverse;
            _actor.loop      = Preset.actor.loop;
            _actor.loopDelay = Preset.actor.loopDelay + AntMath.RandomRangeFloat(Preset.actor.rndToLoopDelay);

            if (Preset.actor.playAnimation)
            {
                if (Preset.actor.selectRandomFrame)
                {
                    _actor.PlayRandomFrame();
                }
                else
                {
                    _actor.GotoAndPlay(Preset.actor.startFrame);
                }
            }
            else
            {
                if (Preset.actor.selectRandomFrame)
                {
                    _actor.GotoAndStop(AntMath.RandomRangeInt(1, _actor.TotalFrames));
                }
                else
                {
                    _actor.GotoAndStop(Preset.actor.startFrame);
                }
            }

            IsActive = false;             // Выкл. обработку компонента.
        }
Ejemplo n.º 8
0
        public bool NewParticleIsReady()
        {
            if (IsActive && _delay <= 0.0f)
            {
                _count = AntMath.RandomRangeInt(
                    _preset.list[_currentIndex].min,
                    _preset.list[_currentIndex].max
                    );

                _currentIndex++;
                IsActive = (_currentIndex < _preset.list.Length);
                if (IsActive)
                {
                    _delay = _preset.list[_currentIndex].time;
                }

                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
 public void PlayRandomFrame()
 {
     GotoAndPlay(AntMath.RandomRangeInt(1, TotalFrames));
 }
Ejemplo n.º 10
0
        public WayPoint GetRandomPoint()
        {
            int index = AntMath.RandomRangeInt(0, points.Count - 1);

            return((index >= 0 && index < points.Count) ? points[index] : null);
        }