Exemplo n.º 1
0
        IEnumerator On()
        {
            float time = GameRNG.Rand(onTimeMin, onTimeMax);

            yield return(new WaitForSeconds(time));

            bodyCollider.enabled = true;
            currentState         = Off();
            yield break;
        }
Exemplo n.º 2
0
        IEnumerator Off()
        {
            float time = GameRNG.Rand(offTimeMin, offTimeMax);

            yield return(new WaitForSeconds(time));

            ObjectIsInRange      = false;
            bodyCollider.enabled = false;
            currentState         = On();
            yield break;
        }
Exemplo n.º 3
0
        static protected Vector2 GetVelocityToTarget(Vector2 self, Vector2 projectile, Vector2 target, float speed, float spread = 0f)
        {
            float num  = target.y + projectile.y - self.y;
            float num2 = target.x + projectile.x - self.x;
            float num3 = Mathf.Atan2(num, num2) * 57.2957764f;

            if (Mathf.Abs(spread) > Mathf.Epsilon)
            {
                num3 += GameRNG.Rand(-spread, spread);
            }
            float   x = speed * Mathf.Cos(num3 * 0.0174532924f);
            float   y = speed * Mathf.Sin(num3 * 0.0174532924f);
            Vector2 velocity;

            velocity.x = x;
            velocity.y = y;
            return(velocity);
        }
Exemplo n.º 4
0
        //change the throw to aim at the hero
        protected override IEnumerator CanThrow()
        {
            Dev.Where();

            HeroController hero            = HeroController.instance;
            Vector3        currentPosition = gameObject.transform.position;

            Vector2 throwOrigin = currentPosition;

            float lead = GameRNG.Rand(0f, .2f);

            //aim a bit ahead of our hero
            Vector2 target = hero.GetComponent <Rigidbody2D>().velocity *lead + (Vector2)hero.transform.position;

            //clamp the y prediction so we don't throw into the ground
            if (target.y < throwOrigin.y)
            {
                target.y = throwOrigin.y;
            }

            Vector2 throwDirection = (target - throwOrigin).normalized;

            throwRay     = new Ray(throwOrigin, throwDirection);
            throwRaycast = Physics2D.Raycast(throwOrigin, throwDirection, throwDistance, 1 << 8);
            //Dev.CreateLineRenderer( throwOrigin, throwRaycast.point, Color.white, -2f, .1f );
            //Dev.Log( "ray hit " + throwRaycast.collider.gameObject );

            if (throwRaycast.collider != null && throwRaycast.collider.gameObject != null && throwRaycast.distance < 2f)
            {
                Dev.Log("Target is too close! Skipping throw.");
                Dev.Log("" + throwRaycast.point);

                //TODO: alter this code so that we can throw, but make it shorter and/or have hornet grapple
                //there's a wall, we cannot throw!
                nextState = MoveChoiceB;
            }
            else
            {
                //we can throw!
                nextState = MoveChoiceA;
            }

            yield break;
        }
Exemplo n.º 5
0
        protected override IEnumerator Init()
        {
            yield return(base.Init());

            maxHP = hardMaxHP + GameRNG.Rand(0, hardMaxHPBonus);

            tk2dAnimator.GetClipByName("Evade Antic").fps *= evadeSpeedModifier;
            evadeJumpAwayTimeLength /= evadeSpeedModifier;
            evadeJumpAwaySpeed      *= evadeSpeedModifier;

            idleWaitMin *= idleWaitModifier;
            idleWaitMax *= idleWaitModifier;

            evadeRange.onTimeMin *= evadeRangeOnTimeMod;
            evadeRange.onTimeMax *= evadeRangeOnTimeMod;

            evadeCooldownMin *= evadeRangeCooldownMod;
            evadeCooldownMax *= evadeRangeCooldownMod;

            tk2dAnimator.GetClipByName("Run").fps *= runSpeedMod;
            runSpeed   *= runSpeedMod;
            runWaitMin *= runWaitMod;
            runWaitMax *= runWaitMod;

            tk2dAnimator.GetClipByName("Throw Antic").fps *= throwAnticMod;
            throwWindUpTime    *= throwWindUpMod;
            throwMaxTravelTime *= throwMaxTravelTimeMod;

            throwDistance = newThrowDistance;

            needle.GetComponent <DamageHero>().damageDealt = needleDamage;

            stunControl.maxStuns = maxStunCount;

            yield break;
        }
Exemplo n.º 6
0
        public static T GetRandomElementFromList <T>(this List <T> list)
        {
            int index = GameRNG.Rand(0, list.Count);

            return(list[index]);
        }