Example #1
0
    public static GameObject CreateAnimation(Sprite[] frames, float speed, int x, int y)
    {
        GameObject go = Primitives.CreateActor(frames[0], x, y);

        go.name = "animation";
        S_Animation anim = go.AddComponent <S_Animation>();

        anim.Init(frames, speed);
        return(go);
    }
Example #2
0
    public void AddTutorial(TutorialType type, bool initial)
    {
        if (initial)
        {
            this.currentTutorial = type;
        }
        if (tutorialAnimation != null)
        {
            GameObject.Destroy(tutorialAnimation);
        }

        if (!Game.KEYBOARD)
        {
            abilityPanel.Flash(type == TutorialType.Ability);
            if (type == TutorialType.Ability)
            {
                return;
            }
        }

        Sprite[] sprites = null;
        switch (type)
        {
        case TutorialType.Move: sprites = Game.KEYBOARD ? Sprites.tutorial_0_keyboard : Sprites.tutorial_0_touch; break;

        case TutorialType.Ability: sprites = Game.KEYBOARD ? Sprites.tutorial_1_keyboard : Sprites.tutorial_1_touch; break;
        }
        int x = (int)(mapObject.transform.position.x + gridWidth / 2 - Sprites.GetBounds(sprites[0]).x / 2 * S_Camera.scale);

        if (type == TutorialType.Ability)
        {
            x = (int)(abilityPanel.gameObject.transform.position.x + Sprites.GetBounds(Sprites.ability_border).x *S_Camera.scale / 2 - Sprites.GetBounds(sprites[0]).x / 2 * S_Camera.scale);
        }
        int y = (int)(Screen.height / 2 + gridHeight / 2 + (Screen.height - gridHeight) / 4 - Sprites.GetBounds(sprites[0]).y / 2 * S_Camera.scale);

        if (type == TutorialType.Ability)
        {
            y = (int)(Screen.height / 2 - gridHeight / 2 - (Screen.height - gridHeight) / 4 - Sprites.GetBounds(sprites[0]).y / 2 * S_Camera.scale) + 20 * S_Camera.scale;
        }
        tutorialAnimation = S_Animation.CreateAnimation(sprites, .45f, x, y);
        Util.SetLayer(tutorialAnimation, Util.LayerName.UI, 0);
        S_Camera.SetupScale(tutorialAnimation.transform);
        tutorialAnimation.transform.SetParent(slider.transform, false);
        Util.SetZ(tutorialAnimation.gameObject, Util.ZLayer.Gameplay);
    }