Example #1
0
    IEnumerator SpawnProjectiles()
    {
        inSpawn = true;
        while (currActiveProjs < maxActiveMagicalBalls)
        {
            GameObject t      = projPool[currIndex];
            Vector3    offset = new Vector3(Random.Range(1f, 1.5f) * MoreRandom.Pick(-1, 1), Random.Range(1f, 1.5f) * MoreRandom.Pick(-1, 1), 0);
            t.transform.position = transform.position + offset;
            t.GetComponent <Projectile>().SetOffset(offset);
            if (targets.Count == 0 || targets[0] == null)
            {
                inSpawn = false;
                yield break;
            }
            t.GetComponent <Projectile>().SetTarget(targets[0].transform);
            t.SetActive(true);

            currIndex++;
            if (currIndex >= projPool.Length)
            {
                currIndex = 0;
            }
            currActiveProjs++;
            yield return(new WaitForSeconds(Random.Range(0.25f, 0.4f)));
        }
        inSpawn = false;
    }
Example #2
0
        public Gas Crazy()
        {
            velocity    *= (float)MoreRandom.NextDouble(0.5, 0.7);
            rateOfDecay *= (float)MoreRandom.NextDouble(0.1, 0.5);

            return(this);
        }
Example #3
0
        public Gas(float x, float y)
        {
            initialRadius = MoreRandom.Next(8, 17);
            initialColor  = colors[MoreRandom.Next(0, colors.Length)];

            Circle = new Circle(x, y, initialRadius)
            {
                Color = initialColor
            };
            Circle.ApplyChanges();

            velocity = Vector2Ext.Random() * MoreRandom.Next(25, 120);

            rateOfDecay = (float)MoreRandom.NextDouble(8, 40);
            Lingering   = true;
        }
Example #4
0
        // methods

        IEnumerator Start()
        {
            yield return(new WaitForSeconds(2));

            assets  = GetComponentsInChildren <IMarkable> ();
            indexes = new int[assets.Length];
            Markable m;

            foreach (IMarkable a in assets)
            {
                m = a.getGameObject().AddComponent <Markable> ();
                a.setMark(m);
                m.markSet            = this;
                m.isSolid            = isSolid;
                m.activeMarkRef      = activeMarkRef;
                m.activeMarkOffset   = activeMarkOffset;
                m.activeMarkRotation = activeMarkRotation;
                m.usedMarkRef        = usedMarkRef;
                m.usedMarkOffset     = usedMarkOffset;
                m.usedMarkRotation   = usedMarkRotation;
            }
            for (int i = 0; i < indexes.Length; i++)
            {
                indexes[i] = i;
            }
            if (indexes.Length > 0)
            {
                areNoAssets = false;
            }
            Debug.Log("Started markset with " + indexes.Length + " indexes and " + assets.Length + " assets.");
            MoreRandom.Shuffle(indexes);

            yield return(new WaitForSeconds(2));

            ActivateFirst();
        }
Example #5
0
 public void MoreT()
 {
     fartOffset = (float)MoreRandom.NextDouble(0.2, 0.8);
     //Circle.ApplyChanges();
 }
Example #6
0
        public override void Update()
        {
            input.Update();

            float   speed          = 60 * Engine.DeltaTime;
            Vector2 playerVelocity = Vector2.Zero;

            if (input.Pressing("up"))
            {
                playerVelocity = new Vector2(playerVelocity.X, -1);
            }
            if (input.Pressing("down"))
            {
                playerVelocity = new Vector2(playerVelocity.X, 1);
            }
            if (input.Pressing("left"))
            {
                playerVelocity = new Vector2(-1, playerVelocity.Y);
            }
            if (input.Pressing("right"))
            {
                playerVelocity = new Vector2(1, playerVelocity.Y);
            }


            if (playerVelocity == Vector2.Zero)
            {
                // Not Moving
                dtSpeed         = 1000 * Engine.DeltaTime;
                targetAmplitude = 0.2f;
                dt += dtSpeed * 0.75f;
            }
            else
            {
                playerVelocity.Normalize();
                playerVelocity *= speed;

                // sprite.X += playerVelocity.X;
                // sprite.Y += playerVelocity.Y;
                SetPosition(X + playerVelocity.X, Y + playerVelocity.Y);


                // MOving
                dtSpeed         = 200 * Engine.DeltaTime;
                targetAmplitude = 0.1f;
                dt += dtSpeed * 5f;


                if (canStep)
                {
                    SoundManager.PlaySoundEffect("step", 0.4f);
                    canStep = false;
                    stepSoundTracker.Reset();
                    stepSoundTracker.Start();
                }
            }

            if (!canStep)
            {
                stepSoundTracker.Update();

                if (stepSoundTracker.Done)
                {
                    canStep = true;
                }
            }

            if (!(targetAmplitude - 0.01 < amplitude && amplitude < targetAmplitude + 0.01))
            {
                float desired = targetAmplitude - amplitude;
                amplitude += desired * Engine.DeltaTime;
            }

            sprite.Rotation = (float)Math.Sin(dt * 0.01f) * amplitude;
            sprite.Scale    = new Vector2((float)Math.Sin(dt * 0.01f) * 0.1f + 1, 1);

            // FArts
            fartTimer.Update();
            if (fartTimer.Done)
            {
                if (MoreRandom.NextDouble(0, 1) < 0.25)
                {
                    int total = MoreRandom.Next(16, 64);
                    for (int i = 0; i < total; i++)
                    {
                        Vector2 offset = Vector2Ext.Random() * MoreRandom.Next(16, 48 + 1);
                        Farts.Add(new Gas(sprite.X + offset.X, sprite.Y + offset.Y));
                    }


                    if (CanFart)
                    {
                        SoundManager.PlaySoundEffect($"fart_{MoreRandom.Next(0, 3)}", 0.8f);
                        CanFart = false;
                        fartSoundTracker.Reset();
                        fartSoundTracker.Start();
                    }
                }
                fartTimer.Reset();
                fartTimer.Start();
            }

            if (input.Pressing("air"))
            {
                if (airCooldown.Done)
                {
                    airTimer.Update();
                    int total = MoreRandom.Next(4, 8);
                    for (int i = 0; i < total; i++)
                    {
                        Vector2 offset = Vector2Ext.Random() * MoreRandom.Next(8, 16 + 1);
                        Gas     g      = new Gas(sprite.X + offset.X, sprite.Y + offset.Y).Crazy();

                        if (playerVelocity != Vector2.Zero)
                        {
                            g.AddToVelocity(-playerVelocity.X * 100, -playerVelocity.Y * 100);
                        }
                        g.MoreT();
                        Farts.Add(g);
                    }
                    if (airTimer.Done)
                    {
                        airCooldown.Reset();
                        airTimer.Reset();
                        airCooldown.Start();
                        airTimer.Start();
                    }
                }
            }
            else
            {
                airCooldown.Update();
            }

            if (!CanFart)
            {
                fartSoundTracker.Update();

                sprite.Scale = new Vector2((float)Math.Cos(Engine.TotalGameTime.Milliseconds) * 0.25f + 1, (float)Math.Sin(Engine.TotalGameTime.Milliseconds) * 0.25f + 1);

                if (fartSoundTracker.Done)
                {
                    CanFart = true;
                }
            }

            for (int i = Farts.Count - 1; i >= 0; i--)
            {
                Farts[i].Update();

                if (!Farts[i].Lingering)
                {
                    Farts.RemoveAt(i);
                }
            }



            TableCollision();

            DebugManager.GetDebugEntry("playerPos").SetInformation(X, Y);


            if (Bounds.Right < 0)
            {
                SetPosition(WindowManager.PixelWidth * 2 - Width, Y);
            }

            if (Bounds.Left > WindowManager.PixelWidth * 2)
            {
                SetPosition(4, Y);
            }


            if (Bounds.Bottom < 0)
            {
                SetPosition(X, WindowManager.PixelHeight * 2 - Width);
            }

            if (Bounds.Top > WindowManager.PixelHeight * 2)
            {
                SetPosition(X, 4);
            }
        }