Exemplo n.º 1
0
 private void WebsiteEnter(UIEvent ev)
 {
     CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
     {
         _websiteSprite.Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
     }));
 }
Exemplo n.º 2
0
    internal override void Update()
    {
        if (Time.time - _startTime >= _timeToFinish)
        {
            //_object.localScale = _startSize;
            SetStatus(TaskStatus.Success);
        }
        Debug.Log(Easings.CircularEaseOut(Time.time - _startTime) / _timeToFinish + " " + (Time.time - _startTime) + " " + _object.localScale);
        switch (_type)
        {
        case Easings.Functions.CircularEaseOut:
            float scale = 27 * (Easings.CircularEaseOut((Time.time - _startTime) / _timeToFinish)) + 1;
            _object.localScale = new Vector3(scale, scale, 1);


            break;
        }
    }
Exemplo n.º 3
0
        protected override void InitializeScene()
        {
            GraphicsManager.Instance.Context.UseDepth(true);

            _fps            = new Text(GUI.Root);
            _fps.Dimensions = new Vector2(10000, 16);

            DefaultCamera.ClearColor = new Color(63, 136, 197, 255);
            DefaultCamera.Parent.Transform.Position2D = new Vector2(0, -46);

            ScaleGame();

            _background = AddGameObject("Background");
            TileMap map = _background.AddComponent <TileMap>();

            map.TileSize     = 16;
            map.MapData      = ResourceManager.Load <Texture2D>("Textures/backgroundData.png");
            map.MapData.Wrap = Texture2D.WrapMode.Repeat;
            map.Sprites      = ResourceManager.Load <Texture2D>("Textures/background.png");

            AudioComponent music = _background.AddComponent <AudioComponent>();

            music.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/main.mp3"));
            music.Play();

            _website                = AddGameObject("website");
            _websiteSprite          = _website.AddComponent <Sprite>();
            _websiteSprite.Texture  = ResourceManager.Load <Texture2D>("Textures/Website0.png");
            _websiteSprite.Offset   = new Vector2(-_websiteSprite.Texture.Width / 2, -_websiteSprite.Texture.Height / 2);
            _websiteSprite.Priority = 0.1f;

            EmptyUIElement websiteHit = new EmptyUIElement(GUI.Root);

            websiteHit.Dimensions = new Vector2(200, 200) * DefaultCamera.Zoom;
            websiteHit.Pivot      = UIDefaults.Centered;

            websiteHit.OnMouseUp    += WebsiteClick;
            websiteHit.OnMouseEnter += WebsiteEnter;
            websiteHit.OnMouseExit  += WebsiteExit;

            AudioComponent webAudio = _website.AddComponent <AudioComponent>();

            webAudio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/buy.mp3"));

            UIComponent websiteUI = _website.AddComponent <UIComponent>();

            websiteUI.Setup(websiteHit, this);

            GameObject buyParticles = AddGameObject("Particles");

            _websiteParticles             = buyParticles.AddComponent <BurstParticleComponent>();
            _websiteParticles.Texture     = ResourceManager.Load <Texture2D>("Textures/Dollar.png");
            _websiteParticles.Gravity     = new Vector2(0, 5);
            _websiteParticles.BurstAmount = 5;

            _websiteParticles.OnRequestParticle += () =>
            {
                Particle particle = new Particle();
                particle.particleFrames   = 1;
                particle.sourceRectangles = new Rectangle[] { new Rectangle(0, 0, 8, 8) };

                particle.velocity      = new Vector2(Random.NextRange(-1.0f, 1.0f), Random.NextRange(-0.5f, -1.0f));
                particle.color         = Color.White;
                particle.lifeTime      = Random.NextRange(0.25f, 1.0f);
                particle.totalLifeTime = particle.lifeTime;
                particle.size          = new Vector2(1, 1);

                return(particle);
            };

            _websiteParticles.OnParticleUpdate += (particle) =>
            {
                particle.size = new Vector2(2, 2) * (particle.lifeTime / particle.totalLifeTime);
            };

            _debtCounter = AddGameObject("Debt counter");
            _debtCounter.Transform.Position2D = new Vector2(0, 54);

            _debtText             = _debtCounter.AddComponent <TextComponent>();
            _debtText.Font        = ResourceManager.Load <Font>("Fonts/8-bit.bff");
            _debtText.DisplayText = GetDisplayString(debt);
            _debtText.Alignment   = TextAlignment.Center;

            _debtTextShadow             = _debtCounter.AddComponent <TextComponent>();
            _debtTextShadow.Font        = ResourceManager.Load <Font>("Fonts/8-bit.bff");
            _debtTextShadow.Color       = Color.Black;
            _debtTextShadow.Alignment   = TextAlignment.Center;
            _debtTextShadow.DisplayText = _debtText.DisplayText;
            _debtTextShadow.Offset      = new Vector2(2, -2);

            _debtPerSecondCounter = AddGameObject("DPS counter");
            _debtPerSecondCounter.Transform.Position2D = new Vector2(0, 47);
            _debtPerSecondText             = _debtPerSecondCounter.AddComponent <TextComponent>();
            _debtPerSecondText.DisplayText = GetDisplayString(debt);
            _debtPerSecondText.Alignment   = TextAlignment.Center;

            _debtPerSecondTextShadow             = _debtPerSecondCounter.AddComponent <TextComponent>();
            _debtPerSecondTextShadow.Offset      = new Vector2(1, -1);
            _debtPerSecondTextShadow.Color       = Color.Black;
            _debtPerSecondTextShadow.DisplayText = _debtPerSecondText.DisplayText;
            _debtPerSecondTextShadow.Alignment   = TextAlignment.Center;

            _fixedCharges          = new GameObject[FixedCharges.Length];
            _fixedChargesGenerated = new ulong[FixedCharges.Length];

            // Setup fixed charges objects.
            for (int i = 0; i < FixedCharges.Length; ++i)
            {
                FixedCharge fixedCharge = FixedCharges[i];

                GameObject charge = AddGameObject($"Fixed charge {i}");
                charge.Enabled = false;

                _fixedCharges[i] = charge;

                charge.Transform.Position = new Vector3(0, -80 - i * 20, 0.25f);

                Sprite chargeSprite = charge.AddComponent <Sprite>();
                chargeSprite.Texture  = ResourceManager.Load <Texture2D>("Textures/Charge.png");
                chargeSprite.Offset   = new Vector2(-chargeSprite.Texture.Width / 2, -chargeSprite.Texture.Height / 2);
                chargeSprite.Priority = 0.5f;

                EmptyUIElement chargeHit = new EmptyUIElement(GUI.Root);
                chargeHit.Dimensions = new Vector2(chargeSprite.Texture.Width * 2 * DefaultCamera.Zoom, chargeSprite.Texture.Height * DefaultCamera.Zoom);
                chargeHit.Pivot      = UIDefaults.Centered;

                TextComponent chargeText = charge.AddComponent <TextComponent>();
                chargeText.Offset      = new Vector2(-60, -9);
                chargeText.Color       = Color.Black;
                chargeText.DisplayText = $"???? {GetDisplayStringSmall(fixedCharge.price)}";

                TextComponent chargeDebtText = charge.AddComponent <TextComponent>();
                chargeDebtText.Offset      = new Vector2(22, -9);
                chargeDebtText.Color       = Color.Black;
                chargeDebtText.DisplayText = $"${fixedCharge.debtPerSecond.KiloFormat()}/s";

                UIComponent chargeUI = charge.AddComponent <UIComponent>();
                chargeUI.Setup(chargeHit, this);

                AudioComponent audio = charge.AddComponent <AudioComponent>();
                audio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/ka-ching.mp3"));

                // Setup UI events.
                chargeHit.OnMouseEnter += (ev) =>
                {
                    _popup.Transform.Position2D = charge.Transform.Position2D;
                    _popup.Enabled         = true;
                    _popupEnabledThisFrame = true;

                    CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                    {
                        chargeSprite.Size      = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
                        charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);

                        _popup.GetComponent <Sprite>().Size = new Vector2(1, 1) * (Easings.CircularEaseOut(x));
                        _popup.Transform.Scale = new Vector3(1, 1, 1) * (Easings.CircularEaseOut(x));
                    }));
                };

                chargeHit.OnMouseStay += (ev) =>
                {
                    _popup.GetComponent <TextComponent>().DisplayText = $"{fixedCharge.desc}\nHave: {fixedCharge.owned} (${fixedCharge.debtPerSecond * fixedCharge.owned}/s)\nTotal: {GetDisplayStringSmall(_fixedChargesGenerated[fixedCharge.id])}";
                };

                chargeHit.OnMouseExit += (ev) =>
                {
                    if (!_popupEnabledThisFrame)
                    {
                        _popup.Enabled = false;
                    }

                    CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                    {
                        chargeSprite.Size      = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f);
                        charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f);
                    }));
                };

                chargeHit.OnMouseUp += (ev) =>
                {
                    if (debt >= fixedCharge.price)
                    {
                        debtPerSecond    += fixedCharge.debtPerSecond;
                        debt             -= fixedCharge.price;
                        _shownDebt        = debt;
                        _helpText.Enabled = false;

                        fixedCharge.owned++;
                        fixedCharge.price      = (ulong)(fixedCharge.price * JMath.Pow(1.15f, fixedCharge.owned));
                        chargeText.DisplayText = $"{fixedCharge.name} {GetDisplayStringSmall(fixedCharge.price)}";

                        audio.Stop();
                        audio.Play();
                        audio.SetVolume(0.5f);
                    }

                    CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                    {
                        chargeSprite.Size      = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
                        charge.Transform.Scale = new Vector3(1, 1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
                    }));
                };
            }

            _popup         = AddGameObject("Popup");
            _popup.Enabled = false;

            Sprite popupSprite = _popup.AddComponent <Sprite>();

            popupSprite.Texture  = ResourceManager.Load <Texture2D>("Textures/WebsiteBuyFrame.png");
            popupSprite.Offset   = new Vector2(-popupSprite.Texture.Width / 2, popupSprite.Texture.Height / 64);
            popupSprite.Priority = 0.000001f;

            TextComponent popupText = _popup.AddComponent <TextComponent>();

            popupText.Alignment   = TextAlignment.Left;
            popupText.Offset      = new Vector2(-50, popupSprite.Texture.Height / 1.5f);
            popupText.DisplayText = "All your base\nare belong to\nus.";
            popupText.Color       = Color.Black;

            _timer = AddGameObject("Timer");
            _timer.Transform.Position2D = new Vector2(0, -68);
            _timerText             = _timer.AddComponent <TextComponent>();
            _timerText.Alignment   = TextAlignment.Center;
            _timerText.DisplayText = "2:30 remaining";

            EmptyUIElement startelement = new EmptyUIElement(GUI.Root);

            startelement.Dimensions = new Vector2(80, 20) * _defaultZoom * 2;
            startelement.Pivot      = UIDefaults.Centered;

            startelement.OnMouseEnter += (ev) =>
            {
                CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                {
                    _exit.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
                }));
            };

            startelement.OnMouseExit += (ev) =>
            {
                CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                {
                    _exit.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f);
                }));
            };

            startelement.OnMouseUp += (x) =>
            {
                SceneManager.SwitchToScene(new MainMenu(ResourceManager));
            };

            _exit = AddGameObject("Exit");
            _exit.Transform.Position2D = new Vector2(0, 108);

            _exit.AddComponent <UIComponent>().Setup(startelement, this);

            Sprite exitSprite = _exit.AddComponent <Sprite>();

            exitSprite.Texture         = ResourceManager.Load <Texture2D>("Textures/buttons.png");
            exitSprite.SourceRectangle = new Rectangle(0, 20, 128, 20);
            exitSprite.Offset          = new Vector2(-35, -9);

            _helpText             = AddGameObject("help").AddComponent <TextComponent>();
            _helpText.DisplayText = "Exchange debt to gain\n  debt automatically!";
            _helpText.Alignment   = TextAlignment.Center;

            _helpText.Parent.Transform.Position2D = new Vector2(0, -110);
            _helpText.Enabled = false;

            _exit.Enabled = false;
        }
Exemplo n.º 4
0
    // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
    public static float Interpolate(float p, Easings.Functions function)
    {
        switch (function)
        {
        default:
            return(Easings.Linear(p));

        case Easings.Functions.QuadraticEaseIn:
            return(Easings.QuadraticEaseIn(p));

        case Easings.Functions.QuadraticEaseOut:
            return(Easings.QuadraticEaseOut(p));

        case Easings.Functions.QuadraticEaseInOut:
            return(Easings.QuadraticEaseInOut(p));

        case Easings.Functions.CubicEaseIn:
            return(Easings.CubicEaseIn(p));

        case Easings.Functions.CubicEaseOut:
            return(Easings.CubicEaseOut(p));

        case Easings.Functions.CubicEaseInOut:
            return(Easings.CubicEaseInOut(p));

        case Easings.Functions.QuarticEaseIn:
            return(Easings.QuarticEaseIn(p));

        case Easings.Functions.QuarticEaseOut:
            return(Easings.QuarticEaseOut(p));

        case Easings.Functions.QuarticEaseInOut:
            return(Easings.QuarticEaseInOut(p));

        case Easings.Functions.QuinticEaseIn:
            return(Easings.QuinticEaseIn(p));

        case Easings.Functions.QuinticEaseOut:
            return(Easings.QuinticEaseOut(p));

        case Easings.Functions.QuinticEaseInOut:
            return(Easings.QuinticEaseInOut(p));

        case Easings.Functions.SineEaseIn:
            return(Easings.SineEaseIn(p));

        case Easings.Functions.SineEaseOut:
            return(Easings.SineEaseOut(p));

        case Easings.Functions.SineEaseInOut:
            return(Easings.SineEaseInOut(p));

        case Easings.Functions.CircularEaseIn:
            return(Easings.CircularEaseIn(p));

        case Easings.Functions.CircularEaseOut:
            return(Easings.CircularEaseOut(p));

        case Easings.Functions.CircularEaseInOut:
            return(Easings.CircularEaseInOut(p));

        case Easings.Functions.ExponentialEaseIn:
            return(Easings.ExponentialEaseIn(p));

        case Easings.Functions.ExponentialEaseOut:
            return(Easings.ExponentialEaseOut(p));

        case Easings.Functions.ExponentialEaseInOut:
            return(Easings.ExponentialEaseInOut(p));

        case Easings.Functions.ElasticEaseIn:
            return(Easings.ElasticEaseIn(p));

        case Easings.Functions.ElasticEaseOut:
            return(Easings.ElasticEaseOut(p));

        case Easings.Functions.ElasticEaseInOut:
            return(Easings.ElasticEaseInOut(p));

        case Easings.Functions.BackEaseIn:
            return(Easings.BackEaseIn(p));

        case Easings.Functions.BackEaseOut:
            return(Easings.BackEaseOut(p));

        case Easings.Functions.BackEaseInOut:
            return(Easings.BackEaseInOut(p));

        case Easings.Functions.BounceEaseIn:
            return(Easings.BounceEaseIn(p));

        case Easings.Functions.BounceEaseOut:
            return(Easings.BounceEaseOut(p));

        case Easings.Functions.BounceEaseInOut:
            return(Easings.BounceEaseInOut(p));
        }
    }
Exemplo n.º 5
0
        protected override void InitializeScene()
        {
            ScaleGame();

            Text text = new Text(GUI.Root);

            text.Pivot        = UIDefaults.TopCenter;
            text.Anchor       = UIDefaults.TopCenter;
            text.ShadowOffset = new Point(1, -1);
            text.DisplayText  = "Created by Mathijs Koning and Thom Zeilstra for Ludum Dare 48";
            text.ResizeToText(16);

            _background = AddGameObject("Background");
            TileMap map = _background.AddComponent <TileMap>();

            map.TileSize     = 16;
            map.MapData      = ResourceManager.Load <Texture2D>("Textures/backgroundData.png");
            map.MapData.Wrap = Texture2D.WrapMode.Repeat;
            map.Sprites      = ResourceManager.Load <Texture2D>("Textures/background.png");

            _audio = _background.AddComponent <AudioComponent>();
            _audio.SetAudioClip(ResourceManager.Load <AudioClip>("Sounds/menu.mp3"));
            _audio.Play();
            _audio.Loop(true);

            _title = AddGameObject("Title");
            _title.Transform.Position2D = new Vector2(0, 64);
            Sprite titleSprite = _title.AddComponent <Sprite>();

            titleSprite.Texture = ResourceManager.Load <Texture2D>("Textures/Title.png");
            titleSprite.Offset  = new Vector2(-titleSprite.Texture.Width / 2, -titleSprite.Texture.Height / 2);
            titleSprite.Size    = new Vector2(2, 2);

            _leaderboardText             = AddGameObject().AddComponent <TextComponent>();
            _leaderboardText.Alignment   = TextAlignment.Center;
            _leaderboardText.DisplayText = "Loading leaderboard...";
            _leaderboardText.Color       = Color.Black;

            _leaderboardText.Parent.Transform.Position2D = new Vector2(0, -48);

            _nameText             = AddGameObject().AddComponent <TextComponent>();
            _nameText.Alignment   = TextAlignment.Center;
            _nameText.DisplayText = "Logging in...";
            _nameText.Color       = Color.Black;

            UIElement ui = new EmptyUIElement(GUI.Root);

            ui.Dimensions = new Vector2(128, 16) * _defaultZoom * 2;
            ui.Pivot      = UIDefaults.BottomCenter;

            ui.OnMouseUp += (ev) =>
            {
                AskUsername("Leaderboard user name:");
            };

            ui.OnMouseEnter += (ev) =>
            {
                _nameText.Color = Color.White;
            };

            ui.OnMouseExit += (ev) =>
            {
                _nameText.Color = Color.Black;
            };

            UIComponent uiComp = _nameText.Parent.AddComponent <UIComponent>();

            uiComp.Setup(ui, this);

            _nameText.Parent.Transform.Position2D = new Vector2(0, 16);

            EmptyUIElement startelement = new EmptyUIElement(GUI.Root);

            startelement.Dimensions = new Vector2(80, 20) * _defaultZoom * 2;
            startelement.Pivot      = UIDefaults.Centered;

            startelement.OnMouseEnter += (ev) =>
            {
                CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                {
                    _start.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.CircularEaseOut(x) / 4.0f);
                }));
            };

            startelement.OnMouseExit += (ev) =>
            {
                CoroutineManager.StartCoroutine(DefaultRoutines.Linear(0.3f, (x) =>
                {
                    _start.GetComponent <Sprite>().Size = new Vector2(1, 1) * (1 + Easings.QuadraticEaseOut(1.0f - x) / 4.0f);
                }));
            };

            startelement.OnMouseUp += (x) =>
            {
                if (PlayfabManager.Identity.Username == null)
                {
                    AskUsername("Leaderboard user name:");
                }
                else
                {
                    SceneManager.SwitchToScene(new MainScene(ResourceManager));
                }
            };

            _start = AddGameObject("Start");
            _start.Transform.Position2D = new Vector2(0, 0);

            _start.AddComponent <UIComponent>().Setup(startelement, this);

            Sprite startSprite = _start.AddComponent <Sprite>();

            startSprite.Texture         = ResourceManager.Load <Texture2D>("Textures/buttons.png");
            startSprite.SourceRectangle = new Rectangle(0, 0, 128, 20);
            startSprite.Offset          = new Vector2(-35, -9);

            Login();
        }
Exemplo n.º 6
0
        private IEnumerator EscalonarSonar(int i, float delay)
        {
            yield return(new WaitForSeconds(delay));

            float lerp      = 0.0f;
            float colorLerp = 0.0f;

            while (lerp < 1.0f)
            {
                lerp      += Time.deltaTime * m_speed;
                colorLerp += Time.deltaTime * m_alphaSpeed;

                m_sonarTransform[i].localScale = Vector3.Lerp(Constantes.VECTOR_THREE_ZERO, m_maxScale, Easings.QuadraticEaseOut(lerp));

                if (m_sonarSpriteRenderer[i].color.a > 0.1f)
                {
                    m_sonarSpriteRenderer[i].color = new Color(1.0f, 1.0f, 1.0f, Mathf.Lerp(1.0f, 0.0f, Easings.CircularEaseOut(colorLerp)));
                }
                else
                {
                    m_sonarSpriteRenderer[i].color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                }

                yield return(null);
            }

            m_sonarTransform[i].gameObject.SetActive(false);

            if (i >= (m_maxSonarCount - 1))
            {
                Finish();
            }
        }