Пример #1
0
    // -- PUBLIC
    // .. OPERATIONS
    public void Fade(float target_alpha, float time, EasingFunctions.TYPE easing_type = EasingFunctions.TYPE.Regular)
    {
        StopCoroutine("UpdateFade");

        object[] args = new object[] { target_alpha, time, easing_type };
        StartCoroutine("UpdateFade", args);
    }
        public void StartAnimation(
            EasingFunctions.TYPE ease_type,
            Vector3 start_position,
            Vector3 end_position,
            float time
            )
        {
            object[]
                parameters = { time, ease_type, start_position, end_position };

            StopCoroutine( "UpdateTranslation" );
            StartCoroutine( "UpdateTranslation", parameters );
        }
    // -- PUBLIC
    // .. OPERATIONS
    public void StartAnimation(
        EasingFunctions.TYPE ease_type,
        Vector3 start_scale,
        Vector3 end_scale,
        float time
        )
    {
        object[]
            parameters = { time, ease_type, start_scale, end_scale };

        StopCoroutine( "UpdateScale" );
        StartCoroutine( "UpdateScale", parameters );
    }
Пример #4
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Point3dKeyFrame(EasingFunctions function)
 {
     KeyTime = TimeSpan.Zero;
 }
Пример #5
0
    // Coroutine destruction / activation
    public IEnumerator Destroying()
    {
        if (birth == SessionAssistant.main.eventCount)
        {
            chip.destroying = false;
            yield break;
        }


        chip.busy    = true;
        chip.gravity = false;

        chip.Play("Flying");
        AudioAssistant.Shot("LadybirdCreate");

        foreach (SpriteRenderer sr in GetComponentsInChildren <SpriteRenderer>())
        {
            sr.sortingLayerName = "Foreground";
        }

        if (chip.slot)
        {
            FieldAssistant.main.BlockCrush(chip.slot.coord, false);
            FieldAssistant.main.JellyCrush(chip.slot.coord);
        }

        chip.ParentRemove();

        Vector3 startPosition = chip.transform.position;
        Vector3 lastPosition  = transform.position;
        Vector3 tagetPosition;

        if (!target)
        {
            target = FindTarget();
        }

        float speed = Random.Range(3f, 4f) / Vector3.Distance(startPosition, target.transform.position);

        Vector3 normal = (target.transform.position - startPosition).normalized;

        normal  = new Vector3(-normal.y, normal.x, 0);
        normal *= Vector3.Distance(target.transform.position, startPosition) * Random.Range(0.2f, 0.4f);
        if (Random.value > 0.5f)
        {
            normal *= -1;
        }

        float time  = 0f;
        float angle = 0;

        while (time < 1)
        {
            time += Time.deltaTime * speed;

            tagetPosition      = target.transform.position + normal * Mathf.Sin(Mathf.PI * time);
            transform.position = Vector3.Lerp(startPosition, tagetPosition, EasingFunctions.easeInOutQuad(time));

            angle = Vector3.Angle(directionSprite.up, transform.position - lastPosition);
            if (Vector3.Angle(-directionSprite.right, transform.position - lastPosition) > 90)
            {
                angle *= -1;
            }

            directionSprite.Rotate(0, 0, angle * Time.deltaTime * 15);

            lastPosition = transform.position;
            yield return(0);
        }

        SessionAssistant.main.EventCounter();

        Slot _target = target;

        if (seed != "")
        {
            Chip pu = FieldAssistant.main.AddPowerup(_target.coord, seed);
            pu.busy      = true;
            _target.chip = pu;
            yield return(0);

            SessionAssistant.main.EventCounter();
        }
        Crush(_target.coord);
        chip.busy    = false;
        chip.gravity = true;

        AudioAssistant.Shot("LadybirdCrush");
        SessionAssistant.main.EventCounter();

        targetStack.Remove(target);

        yield return(new WaitForSeconds(0.1f));

        chip.Play("Destroying");
        AnimationAssistant.main.Explode(transform.position, 5, 7);

        while (chip.IsPlaying("Destroying"))
        {
            yield return(0);
        }

        Destroy(gameObject);
    }
Пример #6
0
        public override void LoadContent()
        {
            base.LoadContent();

            Game.EngineComponents.Get <AudioManager>().PreloadSongs("Audio\\joinScreen", "Audio\\gamePlay");

            joinAnimationDefinition = Game.Content.LoadFromJson <AnimationDefintion>("Animations/join_anim");
            availablePlayerNames    = Game.Content.LoadFromJson <PlayerNamesDefinition>("Text/player_names_text").Names;

            // [FOREACH PERFORMANCE] Should not allocate garbage
            foreach (var p in Game.CurrentGameMode.PlayerInfos)
            {
                JoinPlayer(p.IsKeyboardPlayer, p.GamepadIndex, p);
            }

            // Player mode
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.05f),
                                 new HUDComponent(Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All ? "gameMode_freeForAll_" : "gameMode_2VS2_", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f)),
                                 new HUDTextComponent(MainFont, 0.04f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "Team 1" : "", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.25f, 0f)),
                                 new HUDTextComponent(MainFont, 0.04f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "Team 2" : "", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.25f, 0f))
                                 ));



            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.95f), pressStartToStart = new HUDTextComponent(MainFont, 0.08f, "PRESS START", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            }
                                 ));

            pressStartToStartAnimation = Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartToStart.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn)).Set(a => a.IsRunning = false));

            // Keyboard Entity
            AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(true, 0)));
            // Gamepads
            AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 0)));
            AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 1)));
            AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 2)));
            AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 3)));


            AddEntity(new Entity(this, EntityType.UI,
                                 joinComponent     = new HUDAnimatedComponent(joinAnimationDefinition, new Vector2(0.4f, 0.4f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.5f, 0.5f)),
                                 joinTextComponent = new HUDTextComponent(MainFont, 0.05f, "Press A to join", offset: new Vector2(0.5f, 0.575f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.1f)
                                 ));


            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game,
                                 new SpriteComponent("joinscreen_outerBorder", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(0, GameConstants.ScreenHeight / 2.0f), 0), 1)),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(0, -GameConstants.ScreenHeight / 2.0f), 0), 1)),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(GameConstants.ScreenWidth / 2.0f, 0), 0), 1)),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(-GameConstants.ScreenWidth / 2.0f, 0), 0), 1))
                                 ));
            AddEntity(new Entity(this, EntityType.Game,
                                 new SpriteComponent("joinscreen_trees_center", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new CircleShape(GameConstants.ScreenHeight / 6.0f, 1f))
                                 ));
            AddEntity(new Entity(this, EntityType.Game,
                                 new SpriteComponent("joinscreen_trees_top", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(0, -GameConstants.ScreenHeight / 4.0f), 0), 1))
                                 ));
            AddEntity(new Entity(this, EntityType.Game,
                                 new SpriteComponent("joinscreen_trees_bottom", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                 new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(0, GameConstants.ScreenHeight / 4.0f), 0), 1))
                                 ));
            if (Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All)
            {
                AddEntity(new Entity(this, EntityType.Game,
                                     new SpriteComponent("joinscreen_trees_left", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                     new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(-GameConstants.ScreenWidth / 4.0f, 0), 0), 1))
                                     ));
                AddEntity(new Entity(this, EntityType.Game,
                                     new SpriteComponent("joinscreen_trees_right", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f),
                                     new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(GameConstants.ScreenWidth / 4.0f, 0), 0), 1))
                                     ));
            }

            AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)));


            this.TransitionIn();
        }
Пример #7
0
        private void PlayerIsReady(JoinState player)
        {
            if (player.CurrentState == JoinState.State.Joined)
            {
                NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                player.Next();

                // Animate text
                var textChooser = player.HUD.GetComponentByName <HUDTextComponent>("nameTextchooser");
                Dispatcher.AddAnimation(Animation.Get(textChooser.Opacity, 0f, 1f, false, (o) => textChooser.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
                var boardChooser = player.HUD.GetComponentByName <HUDComponent>("namechooser");
                Dispatcher.AddAnimation(Animation.Get(boardChooser.Opacity, 0f, 1f, false, (o) => boardChooser.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));

                var text = player.HUD.GetComponentByName <HUDTextComponent>("nameText");
                Dispatcher.AddAnimation(Animation.Get(text.Opacity, 1f, 1f, false, (o) => text.Opacity = o, EasingFunctions.QuadIn));
                var board = player.HUD.GetComponentByName <HUDComponent>("name");
                Dispatcher.AddAnimation(Animation.Get(board.Opacity, 1f, 1f, false, (o) => board.Opacity = o, EasingFunctions.QuadIn));
                Dispatcher.NextFrame(() => player.Player.UnFreeze());

                if (players.Count(j => j.CurrentState == JoinState.State.Ready) >= (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? 4 : 1))
                {
                    pressStartToStartAnimation.IsRunning = true;
                }
            }
        }
Пример #8
0
 public float GetValue(EasingFunctions show, EasingFunctions hide)
 {
     return(GetValue(Show ? show : hide));
 }
Пример #9
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Point3dKeyFrame(EasingFunctions function)
 {
     KeyTime = TimeSpan.Zero;
 }
Пример #10
0
        public override void LoadContent()
        {
            base.LoadContent();

            if (Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All)
            {
                LoadContentFree4All();
            }
            else
            {
                LoadContent2vs2();
            }

            HUDComponent vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: -0.8f)
            {
                MaintainAspectRation = false,
                OnVirtualUIScreen    = false,
                Color = Color.FromNonPremultiplied(22, 59, 59, 163)
            };

            AddEntity(new Entity(this, EntityType.UI, vignetteComponent));

            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f)));
            var inputEntity = new Entity(this, EntityType.LayerIndependent);

            // [FOREACH PERFORMANCE] Should not allocate garbage
            foreach (var player in Game.CurrentGameMode.PlayerInfos)
            {
                if (player.IsKeyboardPlayer)
                {
                    inputEntity.AddComponent(new InputComponent(player.GamepadIndex,
                                                                new InputMapping(InputFunctions.KeyboardMenuStart, FadeInMenu)
                                                                ));
                }
                else
                {
                    inputEntity.AddComponent(new InputComponent(player.GamepadIndex,
                                                                new InputMapping(InputFunctions.MenuStart, FadeInMenu)
                                                                ));
                }
            }
            AddEntity(inputEntity);


            HUDTextComponent pressStartText = new HUDTextComponent(MainFont, 0.04f, "press start to continue", offset: new Vector2(0.5f, 0.9f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0f)
            {
                Opacity = 0
            };

            Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn), delay: 5f));
            AddEntity(new Entity(this, EntityType.UI, pressStartText));

            // Add continue overlay
            AddEntity(new Entity(this, EntityType.UI, continueBackground = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0.99f)
            {
                Color   = Color.Black,
                Opacity = 0,
                MaintainAspectRation = false,
                OnVirtualUIScreen    = false
            }));

            AddEntity(continueMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.5f), layerDepth: 1f,
                                                           menuEntries: new[] { new HUDListEntity.ListEntry("Rematch", Rematch), new HUDListEntity.ListEntry("Rejoin", Rejoin)
                                                                                , new HUDListEntity.ListEntry("Back to main menu", BackToMainMenu) })
            {
                Enabled = false,
                Opacity = 0
            });

            AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)));

            this.TransitionIn();
        }
Пример #11
0
        public override void LoadContent()
        {
            base.LoadContent();

            //Game.CurrentGameMode.ClearPlayers();
            Game.EngineComponents.Get <AudioManager>().PreloadSongs("Audio\\joinScreen", "Audio\\gamePlay");
            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -0.9f)));

            // UI
            HUDTextComponent pressStartText    = new HUDTextComponent(MainFont, 0.04f, "PRESS START", offset: new Vector2(0.5f, 0.9f), origin: new Vector2(0.5f, 0.5f), layerDepth: 1f);
            HUDComponent     vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0)
            {
                MaintainAspectRation = false, OnVirtualUIScreen = false,
                Color = Color.FromNonPremultiplied(22, 59, 59, 163)
            };
            Vector2      logoSize      = new Vector2(1, 0.7684f);
            HUDComponent logoComponent = new HUDComponent("titleScreen", 0.9f * logoSize, offset: new Vector2(0.5f, 0.5f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.9f);

            AddEntity(new Entity(this, EntityType.UI, Vector2.Zero, pressStartText, vignetteComponent, logoComponent));
            Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn)));


            var inputEntity = new Entity(this, EntityType.LayerIndependent,
                                         new InputComponent(0, new InputMapping(f => InputFunctions.KeyboardMenuStart(f), StartPressed))
                                         );

            for (int i = 0; i < 4; i++)
            {
                inputEntity.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuStart(f), StartPressed)));
            }
            AddEntity(inputEntity);

            AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)));

            this.TransitionIn();
        }
Пример #12
0
        public override void LoadContent()
        {
            base.LoadContent();

            var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight);

            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f)));
            AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f)));

            // UI
            var buttonBackground = new HUDComponent("overlayInstructionBox", new Vector2(1.2f, 0.2f), offset: new Vector2(0.5f, 0.05f), origin: new Vector2(0.5f, 0.05f));

            AddEntity(new Entity(this, EntityType.UI, buttonBackground,
                                 new HUDTextComponent(MainFont, 0.1f, "Game mode",
                                                      offset: buttonBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)),
                                                      origin: new Vector2(0.5f, 0.5f), layerDepth: 0.1f)
                                 ));

            // Player mode selection
            playerMode2vs2 = new HUDComponent("gameMode_2VS2_notselected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.16f, 0))
            {
                Opacity = 0f
            };
            playerMode2vs2Selected     = new HUDComponent("gameMode_2VS2_selected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.16f, 0));
            playerModeFree4All         = new HUDComponent("gameMode_freeForAll_notselected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.16f, 0));
            playerModeFree4AllSelected = new HUDComponent("gameMode_freeForAll_selected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.16f, 0))
            {
                Opacity = 0f
            };

            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.3f), playerMode2vs2, playerModeFree4All, playerMode2vs2Selected, playerModeFree4AllSelected));


            // Game mode selection
            gameModeWaves = new HUDTextComponent(MainFont, 0.05f, "WAVES", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.11f, 0), color: Color.Yellow)
            {
                Opacity = InActiveOpacity
            };
            gameModeBigHerd = new HUDTextComponent(MainFont, 0.05f, "BIG HERD", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.11f, 0))
            {
                Opacity = InActiveOpacity
            };

            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.55f), gameModeWaves, gameModeBigHerd));

            // Runtime mode selection
            runtimeModeOptions = Enumerable.Range(0, 4).Select(i => new HUDTextComponent(MainFont, 0.05f, "", origin: new Vector2(0.5f, 0.5f),
                                                                                         offset: new Vector2(-0.225f, 0) + new Vector2(0.15f, 0) * i)
            {
                Opacity = InActiveOpacity, Color = i == 0 ? Color.Yellow : Color.Wheat
            }).ToArray();
            UpdateRuntimeTexts();
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.65f), runtimeModeOptions));

            // CONTINUE TEXT
            continueText = new HUDTextComponent(MainFont, 0.05f, "press A to continue", origin: new Vector2(0.5f, 0.5f))
            {
                Opacity = 0
            };
            AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.8f), continueText));
            continueTextAnimation = Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => continueText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn))
                                                            .Set(a => a.IsRunning = false));


            // add controls
            var layerIndependent = new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera));

            for (int i = 0; i < 4; i++)
            {
                layerIndependent.AddComponent(new InputComponent(i,
                                                                 new InputMapping(f => InputFunctions.MenuSelect(f) || InputFunctions.MenuDown(f), OnNextPressed),
                                                                 new InputMapping(f => InputFunctions.MenuBack(f) || InputFunctions.MenuUp(f), OnBackPressed),
                                                                 new InputMapping(f => InputFunctions.MenuStart(f), OnStartPressed),
                                                                 new InputMapping(f => InputFunctions.MenuLeft(f), OnLeftPressed),
                                                                 new InputMapping(f => InputFunctions.MenuRight(f), OnRightPressed)));
            }


            layerIndependent.AddComponent(new InputComponent(
                                              new InputMapping(f => InputFunctions.KeyboardMenuSelect(f) || InputFunctions.KeyboardMenuDown(f), OnNextPressed),
                                              new InputMapping(f => InputFunctions.KeyboardMenuBack(f) || InputFunctions.KeyboardMenuUp(f), OnBackPressed),
                                              new InputMapping(f => InputFunctions.KeyboardMenuStart(f), OnStartPressed),
                                              new InputMapping(f => InputFunctions.KeyboardMenuLeft(f), OnLeftPressed),
                                              new InputMapping(f => InputFunctions.KeyboardMenuRight(f), OnRightPressed)));
            AddEntity(layerIndependent);

            GoToMenuState(MenuState.ChoosePlayerMode);


            this.TransitionIn();
        }
 private void SetDashFunctions()
 {
     _dashFunction              = EasingFunctions.GetEasingFunction(dashEasingFunction);
     _dashDerivativeFunction    = EasingFunctions.GetEasingFunctionDerivative(dashEasingFunction);
     _currentDashEasingFunction = dashEasingFunction;
 }
Пример #14
0
 public static float Evaluate(EasingFunctions easing, float t)
 {
     return(GetFunction(easing)(t));
 }
Пример #15
0
 public static Func <float, float> GetFunc(this EasingFunctions easing)
 {
     return(GetFunction(easing));
 }
Пример #16
0
        public double GetEasingFromFrame(EasingFunctions easing, int currentFrame)
        {
            var step = (double)currentFrame / (double)MaximumFrame;

            return(Easings.Interpolate(step, easing));
        }
Пример #17
0
 public float GetValueInv(EasingFunctions function) => (1f - GetValue(function));
Пример #18
0
 public float GetValue(EasingFunctions function)
 {
     return(Easing.Interpolate(_value, function));
 }
Пример #19
0
        private void SelectItem(int index)
        {
            if (SelectedAction >= 0)
            {
                int old = SelectedAction;
                Scene.Dispatcher.AddAnimation(Animation.Get(1, 0, 0.3f, false, (t) => itemComponents[old].Color = Color.Lerp(Color.BlanchedAlmond, Color.Goldenrod, t), EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
            }

            SelectedAction = index;
            Scene.Dispatcher.AddAnimation(Animation.Get(0, 1, 0.3f, false, (t) => itemComponents[index].Color = Color.Lerp(Color.BlanchedAlmond, Color.Goldenrod, t), EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
        }
Пример #20
0
    public override void Update()
    {
        Vector2 new_pos = Vector2.zero;

        switch (movement_type)
        {
        case MovementType.MOVEMENT_LINEAR:
        {
            new_pos.x = EasingFunctions.Linear(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.Linear(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_IN:
        {
            new_pos.x = EasingFunctions.ExpoIn(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoIn(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_OUT:
        {
            new_pos.x = EasingFunctions.ExpoOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_EXPO_IN_OUT:
        {
            new_pos.x = EasingFunctions.ExpoInOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.ExpoInOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_BOUNCE:
        {
            new_pos.x = EasingFunctions.Bounce(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.Bounce(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_IN:
        {
            new_pos.x = EasingFunctions.QuadIn(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadIn(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_OUT:
        {
            new_pos.x = EasingFunctions.QuadOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }

        case MovementType.MOVEMENT_QUAD_IN_OUT:
        {
            new_pos.x = EasingFunctions.QuadInOut(distance.x, timer.ReadRealTime(), starting_pos.x, duration);
            new_pos.y = EasingFunctions.QuadInOut(distance.y, timer.ReadRealTime(), starting_pos.y, duration);

            break;
        }
        }

        affected_element.transform.position = new_pos;

        if (timer.ReadRealTime() >= duration)
        {
            affected_element.transform.position = final_pos;
            Finish();
        }
    }
Пример #21
0
        /// <summary>
        /// Interpolate using the specified function.
        /// </summary>
        public static float Interpolate(float p, EasingFunctions function)
        {
            switch (function)
            {
            default:
            case EasingFunctions.Linear: return(Linear(p));

            case EasingFunctions.QuadraticEaseOut: return(QuadraticEaseOut(p));

            case EasingFunctions.QuadraticEaseIn: return(QuadraticEaseIn(p));

            case EasingFunctions.QuadraticEaseInOut: return(QuadraticEaseInOut(p));

            case EasingFunctions.CubicEaseIn: return(CubicEaseIn(p));

            case EasingFunctions.CubicEaseOut: return(CubicEaseOut(p));

            case EasingFunctions.CubicEaseInOut: return(CubicEaseInOut(p));

            case EasingFunctions.QuarticEaseIn: return(QuarticEaseIn(p));

            case EasingFunctions.QuarticEaseOut: return(QuarticEaseOut(p));

            case EasingFunctions.QuarticEaseInOut: return(QuarticEaseInOut(p));

            case EasingFunctions.QuinticEaseIn: return(QuinticEaseIn(p));

            case EasingFunctions.QuinticEaseOut: return(QuinticEaseOut(p));

            case EasingFunctions.QuinticEaseInOut: return(QuinticEaseInOut(p));

            case EasingFunctions.SineEaseIn: return(SineEaseIn(p));

            case EasingFunctions.SineEaseOut: return(SineEaseOut(p));

            case EasingFunctions.SineEaseInOut: return(SineEaseInOut(p));

            case EasingFunctions.CircularEaseIn: return(CircularEaseIn(p));

            case EasingFunctions.CircularEaseOut: return(CircularEaseOut(p));

            case EasingFunctions.CircularEaseInOut: return(CircularEaseInOut(p));

            case EasingFunctions.ExponentialEaseIn: return(ExponentialEaseIn(p));

            case EasingFunctions.ExponentialEaseOut: return(ExponentialEaseOut(p));

            case EasingFunctions.ExponentialEaseInOut: return(ExponentialEaseInOut(p));

            case EasingFunctions.ElasticEaseIn: return(ElasticEaseIn(p));

            case EasingFunctions.ElasticEaseOut: return(ElasticEaseOut(p));

            case EasingFunctions.ElasticEaseInOut: return(ElasticEaseInOut(p));

            case EasingFunctions.BackEaseIn: return(BackEaseIn(p));

            case EasingFunctions.BackEaseOut: return(BackEaseOut(p));

            case EasingFunctions.BackEaseInOut: return(BackEaseInOut(p));

            case EasingFunctions.BounceEaseIn: return(BounceEaseIn(p));

            case EasingFunctions.BounceEaseOut: return(BounceEaseOut(p));

            case EasingFunctions.BounceEaseInOut: return(BounceEaseInOut(p));
            }
        }
Пример #22
0
    public override void _Process(float delta)
    {
        var root            = GetParent().GetParent <Node2D>();
        var menuContainer   = root.GetNode <VBoxContainer>("Background/MenuContainer");
        var marginContainer = root.GetNode <MarginContainer>("Background/MenuContainer/MarginContainer");
        var label           = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/No");

        if (Input.IsActionJustPressed("ui_up") || Input.IsActionJustPressed("ui_down"))
        {
            if (choice == Choices.Yes)
            {
                choice = Choices.No;
            }
            else
            {
                choice = Choices.Yes;
            }

            prevPos = Position;
            time    = 0;
        }

        if (Input.IsActionJustPressed("ui_accept"))
        {
            GetTree().Paused = false;

            if (choice == Choices.Yes)
            {
                GetTree().ChangeScene("res://Scenes/Rooms/TitleScreen.tscn");
            }
            else
            {
                root.Visible = false;
            }

            SetProcess(false);
        }

        if (Input.IsActionJustPressed("ui_cancel"))
        {
            root.Visible = false;
            SetProcess(false);
        }

        switch (choice)
        {
        case Choices.Yes:
            label = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/Yes");
            break;

        case Choices.No:
            label = marginContainer.GetNode <Label>("HBoxContainer/ChoiceContainer/No");
            break;
        }

        var x        = menuContainer.RectPosition.y + 112;
        var y        = menuContainer.RectPosition.y + marginContainer.RectPosition.y + label.RectPosition.y + label.RectSize.y / 2;
        var labelPos = new Vector2(x, y);

        // Ease movement

        if (time < duration)
        {
            time++;
        }

        x = EasingFunctions.EaseOutQuint(time, prevPos.x, labelPos.x - prevPos.x, duration);
        y = EasingFunctions.EaseOutQuint(time, prevPos.y, labelPos.y - prevPos.y, duration);

        Position = new Vector2(x, y);
    }
Пример #23
0
        static void Main(string[] args)
        {
            const int maxValue = 1000;

            var easings = new EasingFunctions();

            Console.OutputEncoding = Encoding.UTF8;

            Console.CursorVisible = false;

            Console.WriteLine($"Linear Quadra  Cubic  Quart  Quint Bounce Elasti   Expo   Circ   Back   Sine Mapped");
            Console.WriteLine($"===================================================================================");

            for (int i = 0; i <= maxValue; i++)
            {
                double x = 1.0 * i / maxValue;

                int easedInOutQuad  = (int)(easings.EaseInOutQuad(x) * maxValue);
                int easedInOutCubic = (int)(easings.EaseInOutCubic(x) * maxValue);
                int easedInOutQuart = (int)(easings.EaseInOutQuart(x) * maxValue);
                int easedInOutQuint = (int)(easings.EaseInOutQuint(x) * maxValue);

                int easedInOutBounce  = (int)(easings.EaseInOutBounce(x) * maxValue);
                int easedInOutElastic = (int)(easings.EaseInOutElastic(x) * maxValue);
                int easedInOutExpo    = (int)(easings.EaseInOutExpo(x) * maxValue);
                int easedInOutCirc    = (int)(easings.EaseInOutCirc(x) * maxValue);
                int easedInOutBack    = (int)(easings.EaseInOutBack(x) * maxValue);
                int easedInOutSine    = (int)(easings.EaseInOutSine(x) * maxValue);

                int easedInOutElasticMapped = (int)Mapping.Map(easings.EaseInOutElastic(x), 0.0, 1.0, 0.0, maxValue);

                Console.CursorTop = 2;

                Console.Write($"\r");
                Console.Write($"{i,6} ");
                Console.Write($"{easedInOutQuad,6} ");
                Console.Write($"{easedInOutCubic,6} ");
                Console.Write($"{easedInOutQuart,6} ");
                Console.Write($"{easedInOutQuint,6} ");

                Console.Write($"{easedInOutBounce,6} ");
                Console.Write($"{easedInOutElastic,6} ");
                Console.Write($"{easedInOutExpo,6} ");
                Console.Write($"{easedInOutCirc,6} ");
                Console.Write($"{easedInOutBack,6} ");
                Console.Write($"{easedInOutSine,6} ");

                Console.Write($"{easedInOutElasticMapped,6} ");

                Console.WriteLine();
                Console.WriteLine($"===================================================================================");

                Console.WriteLine();

                Console.WriteLine($"\rLinear    : {StarPosition(x, 1)}");
                Console.WriteLine($"\rInOutQuad : {StarPosition(easedInOutQuad, maxValue)}");
                Console.WriteLine($"\rInOutCubic: {StarPosition(easedInOutCubic, maxValue)}");
                Console.WriteLine($"\rInOutQuart: {StarPosition(easedInOutQuart, maxValue)}");
                Console.WriteLine($"\rInOutQuint: {StarPosition(easedInOutQuint, maxValue)}");

                Console.WriteLine($"\rInOutBounc: {StarPosition(easedInOutBounce, maxValue)}");
                Console.WriteLine($"\rInOutElast: {StarPosition(easedInOutElastic, maxValue)}");
                Console.WriteLine($"\rInOutExpo : {StarPosition(easedInOutExpo, maxValue)}");
                Console.WriteLine($"\rInOutCirc : {StarPosition(easedInOutCirc, maxValue)}");
                Console.WriteLine($"\rInOutBack : {StarPosition(easedInOutBack, maxValue)}");
                Console.WriteLine($"\rInOutSine : {StarPosition(easedInOutSine, maxValue)}");

                Thread.Sleep(5);
            }

            Console.CursorVisible = true;

            Console.WriteLine();
            Console.ReadKey();
        }
Пример #24
0
        private InputComponent MakeInput(bool isKeyboard, int gamepadIndex)
        {
            return(new InputComponent(gamepadIndex,
                                      new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuStart(f) : InputFunctions.MenuStart(f), f => StartIfReady()),
                                      new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuSelect(f) : InputFunctions.MenuSelect(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);

                if (player != null)
                {
                    PlayerIsReady(player);
                }
                else
                {
                    JoinPlayer(isKeyboard, gamepadIndex);
                }
            }), new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuBack(f) : InputFunctions.MenuBack(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);

                if (player != null)
                {
                    if (player.CurrentState == JoinState.State.Joined)
                    {
                        NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                        Game.CurrentGameMode.RemovePlayer(gamepadIndex, isKeyboard);
                        RemoveEntity(player.HUD);
                        RemoveEntity(player.Player);
                        players.Remove(player);
                        numJoinedPlayer--;

                        if (numJoinedPlayer < 4)
                        {
                            Dispatcher.AddAnimation(Animation.Get(joinComponent.Opacity, 1, 0.2f, false, (val) =>
                            {
                                joinComponent.Opacity = val;
                                joinTextComponent.Opacity = val;
                            }, EasingFunctions.QuadIn));
                        }
                    }
                    else if (player.CurrentState == JoinState.State.Ready)
                    {
                        NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                        player.Back();

                        // Animate text
                        var textChooser = player.HUD.GetComponentByName <HUDTextComponent>("nameTextchooser");
                        Dispatcher.AddAnimation(Animation.Get(textChooser.Opacity, 1f, 1f, false, (o) => textChooser.Opacity = o, EasingFunctions.QuadIn));
                        var boardChooser = player.HUD.GetComponentByName <HUDComponent>("namechooser");
                        Dispatcher.AddAnimation(Animation.Get(boardChooser.Opacity, 1f, 1f, false, (o) => boardChooser.Opacity = o, EasingFunctions.QuadIn));

                        var text = player.HUD.GetComponentByName <HUDTextComponent>("nameText");
                        Dispatcher.AddAnimation(Animation.Get(text.Opacity, 0f, 1f, false, (o) => text.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
                        var board = player.HUD.GetComponentByName <HUDComponent>("name");
                        Dispatcher.AddAnimation(Animation.Get(board.Opacity, 0f, 1f, false, (o) => board.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));

                        player.Player.Freeze();

                        if (players.Count(j => j.CurrentState == JoinState.State.Ready) >= (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? 4 : 1))
                        {
                            pressStartToStartAnimation.IsRunning = false;
                            Dispatcher.AddAnimation(Animation.Get(pressStartToStart.Opacity, 0f, 0.3f, false, (o) => pressStartToStart.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn)));
                        }
                    }
                }
                else if (!players.Any())
                {
                    this.TransitionOutAndSwitchScene(new GameModeScene(Game));
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuRandom(f)
                        : InputFunctions.MenuRandom(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetRandomName(player);
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuLeft(f) || InputFunctions.KeyboardMenuUp(f)
                        : InputFunctions.MenuLeft(f) || InputFunctions.MenuUp(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetNextOrPreviousName(player, 1);
                }
            }),
                                      new InputMapping(
                                          f => (isKeyboard)
                        ? InputFunctions.KeyboardMenuRight(f) || InputFunctions.KeyboardMenuDown(f)
                        : InputFunctions.MenuRight(f) || InputFunctions.MenuDown(f), f =>
            {
                var player = players.FindPlayer(gamepadIndex, isKeyboard);
                if (player != null && player.CurrentState == JoinState.State.Joined)
                {
                    NonPositionalAudio.PlaySound("Audio/MenuActionSound");
                    SetNextOrPreviousName(player, -1);
                }
            })
                                      ));
        }
Пример #25
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public DoubleKeyFrame(EasingFunctions function)
 {
     KeyTime = TimeSpan.Zero;
 }
Пример #26
0
 public float GetValueInv(EasingFunctions show, EasingFunctions hide) => (1f - GetValue(show, hide));