示例#1
0
 // Use this for initialization
 void Start()
 {
     normalAnimation   = this.transform.Find("NormalAnimation").GetComponent <Animation2D>();
     openDoorAnimation = this.transform.Find("OpenDoorAnimation").GetComponent <Animation2D>();
     deathSound        = this.transform.Find("DeathSound").GetComponent <AudioSource>();
     onHitSound        = this.transform.Find("OnHitSound").GetComponent <AudioSource>();
 }
示例#2
0
        /// <summary>
        /// Add coins
        /// </summary>
        private void AddCoins()
        {
            var         cratesLayer = this.tiledMap.ObjectLayers["Coins"];
            Animation2D anim;

            int i = 0;

            foreach (var obj in cratesLayer.Objects)
            {
                Entity crateEntity = new Entity("coin_" + (i++))
                {
                    Tag = "coin"
                }
                .AddComponent(new Transform2D()
                {
                    LocalPosition = new Vector2(obj.X, obj.Y), Origin = Vector2.Center, DrawOrder = -9
                })
                .AddComponent(new Sprite("Content/coin.png")
                {
                    SourceRectangle = new Rectangle(0, 128, 16, 16)
                })
                .AddComponent(anim = Animation2D.Create <TexturePackerGenericXml>("Content/coin.xml").Add("flip", new SpriteSheetAnimationSequence()
                {
                    First = 1, Length = 8, FramesPerSecond = 12
                }))
                .AddComponent(new AnimatedSpriteRenderer(DefaultLayers.Alpha, AddressMode.PointWrap))
                .AddComponent(new CircleCollider())
                ;

                this.EntityManager.Add(crateEntity);

                anim.CurrentAnimation = "flip";
                anim.Play(true);
            }
        }
示例#3
0
    void LoadAnimations()
    {
        //Load aniamtions
        foreach (NamedSprite animatedSprite in animations)
        {
            Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut);
            _resourceManager.GetAnimationManager().AddAnimation(anim);
        }
        //Load animation Sets
        foreach (NamedSpriteSet animatedSpriteSet in animationSets)
        {
            List <Animation2D> animList = new List <Animation2D>();
            foreach (NamedSprite animatedSprite in animatedSpriteSet.spriteList)
            {
                Animation2D anim = new Animation2D(animatedSprite.sprite, animatedSprite.priority, animatedSprite.name, false, animatedSprite.loop, animatedSprite.fadeOut);
                animList.Add(anim);
            }
            AnimationSet2D animSet = new AnimationSet2D(animatedSpriteSet.name, animList);
            _resourceManager.GetAnimationManager().AddAnimationSet(animSet);
        }

        //Load Temporary Sprites in the same fasion
        foreach (NamedSprite tempSprite in temporarySprites)
        {
            Animation2D anim = new Animation2D(tempSprite.sprite, tempSprite.priority, tempSprite.name, true, tempSprite.loop, tempSprite.fadeOut);
            TempSpriteManager.GetInstance().AddAnimation(anim);
        }
    }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Kite" /> class.
        /// </summary>
        public Kite()
        {
            this.Transform = new Transform2D()
            {
                X      = WaveServices.ViewportManager.VirtualWidth / 4,
                Y      = WaveServices.ViewportManager.VirtualHeight / 2,
                Origin = Vector2.Center
            };

            this.entity = new Entity("kite")
                          .AddComponent(this.Transform)
                          .AddComponent(new Sprite(Textures.KITE_ANIMS))
                          .AddComponent(Animation2D.Create <TexturePackerGenericXml>(Textures.KITE_ANIMS_XML)
                                        .Add(this.kiteAnimations[0], new SpriteSheetAnimationSequence()
            {
                First = 1, Length = 9, FramesPerSecond = 27
            })
                                        .Add(this.kiteAnimations[1], new SpriteSheetAnimationSequence()
            {
                First = 10, Length = 9, FramesPerSecond = 27
            })
                                        .Add(this.kiteAnimations[2], new SpriteSheetAnimationSequence()
            {
                First = 19, Length = 9, FramesPerSecond = 27
            }))
                          .AddComponent(new AnimatedSpriteRenderer(typeof(ObstaclesLayer)))
                          .AddComponent(new PerPixelCollider(Textures.KITE_COLLID, 0.5f))
                          .AddComponent(new KiteBehavior());
        }
示例#5
0
 private void Animation_AnimationPlay(Animation2D sender)
 {
     if (sender.CurrentFrame == sender.FrameCount / 3)
     {
         TBAR.Instance.PlaySound("Sounds/StandAbilityEffects/TimeSkip");
     }
 }
示例#6
0
    public void PlayAnimation(string animation_name, float speed, bool loop = true)
    {
        bool already_playing = false;

        if (curr_animation != null)
        {
            if (curr_animation.GetName() == animation_name)
            {
                already_playing = true;
            }
        }

        if (!already_playing)
        {
            Animation2D anim = GetAnimation(animation_name);

            if (anim != null)
            {
                curr_animation = anim;

                this.speed = speed;
                this.loop  = loop;

                timer.Start();
                curr_animation_sprite = 0;
            }
        }
    }
示例#7
0
 /// <summary>
 /// Создание объекта, отвечающего за сборку ракет по заданным правилам.
 /// </summary>
 /// <param name="scene">Сцена, в которой будут создаваться ракеты.</param>
 /// <param name="rocketTex">Текстура создаваемой ракеты.</param>
 /// <param name="explosionAnim">Анимация взрыва создаваемой ракеты.</param>
 /// <param name="rocket">Компонент создаваемой ракеты.</param>
 public RocketBuilder(Scene scene, Texture2D rocketTex, Animation2D explosionAnim, Rocket rocket)
 {
     this.scene         = scene;
     this.rocketTex     = rocketTex;
     this.explosionAnim = explosionAnim;
     this.rocket        = rocket;
 }
示例#8
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        Animation2D        anim     = target as Animation2D;
        SerializedProperty sp       = serializedObject.FindProperty("m_animator");
        Animator           animator = sp.objectReferenceValue as Animator;

        for (int i = 0; i < (int)GameType.AnimationState.Max; i++)
        {
            Animation2D.AnimStateInfo stateInfo = anim.m_animStateInfo.Find(arg => arg.state == (GameType.AnimationState)i);

            if (stateInfo == null)
            {
                stateInfo = new Animation2D.AnimStateInfo();
                anim.m_animStateInfo.Add(stateInfo);
            }

            stateInfo.state    = (GameType.AnimationState)i;
            stateInfo.name     = ((GameType.AnimationState)i).ToString();
            stateInfo.nameHash = Animator.StringToHash(stateInfo.name);
            stateInfo.clip     = EditorGUILayout.ObjectField(stateInfo.name, stateInfo.clip, typeof(AnimationClip), false) as AnimationClip;

            EditorUtility.SetDirty(anim);
            EditorUtility.SetDirty(animator);
            serializedObject.ApplyModifiedProperties();
        }

        base.OnInspectorGUI();
    }
示例#9
0
 // This player plays the given animation
 public void Animate(Animation2D a)
 {
     curAnimation.Stop();
     curAnimation     = a;
     a.outputRenderer = GetComponent <SpriteRenderer>();
     curAnimation.Play(true);
 }
示例#10
0
 public void OnAnimationDone(Animation2D animation2D)
 {
     if (animation2D.name == animationToPlay.name)
     {
         contentToShow.active = true;
     }
 }
示例#11
0
        /// <summary>
        /// Create Yurei, the main character
        /// </summary>
        private void CreateYurei()
        {
            Entity startDust = new Entity("dust")
            {
                Enabled = false
            }
            .AddComponent(new Transform2D()
            {
                Position  = new Vector2(0, WaveServices.ViewportManager.BottomEdge - 27),
                DrawOrder = 140,
                Origin    = new Vector2(0.75f, 1)
            })
            .AddComponent(new Sprite("Content/Dust/Dust"))
            .AddComponent(Animation2D.Create <TexturePackerGenericXml>("Content/Dust/Dust.xml")
                          .Add("start", new SpriteSheetAnimationSequence()
            {
                First = 0, Length = 13, FramesPerSecond = 30
            }))
            .AddComponent(new AnimatedSpriteRenderer(typeof(ForegroundLayer)));

            EntityManager.Add(startDust);

            this.yurei = new YureiDecorator(
                "yurei",
                new Vector3(
                    500,
                    WaveServices.ViewportManager.BottomEdge - 82,
                    150),
                Vector3.One * 0.85f,
                startDust,
                typeof(ForegroundLayer));

            EntityManager.Add(yurei);
        }
示例#12
0
    private void ChangeAnimation()
    {
        if (animation_changed)
        {
            animation_changed = false;

            bool already_playing = false;

            if (curr_animation != null)
            {
                if (curr_animation.GetName() == animation_to_change)
                {
                    already_playing = true;
                }
            }

            if (!already_playing)
            {
                Animation2D anim = GetAnimation(animation_to_change);

                if (anim != null)
                {
                    curr_animation = anim;

                    this.speed = speed_to_set;
                    this.loop  = loop_to_set;

                    timer.Start();
                    curr_animation_sprite = 0;
                }
            }
        }
    }
    public void Initialize()
    {
        if (!isInitialized)
        {
            isInitialized = true;
            animations    = new List <Animation2D>(this.GetComponentsInChildren <Animation2D>());

            foreach (Animation2D animation2D in animations)
            {
                animation2D.Initialize();

                if (!animationsByName.ContainsKey(animation2D.name))
                {
                    animationsByName.Add(animation2D.name, animation2D);

                    if (!animation2D.playOnStartup)
                    {
                        animation2D.Stop();
                        animation2D.Hide();
                    }
                    else
                    {
                        currentAnimation = animation2D;
                    }
                }
            }
        }
    }
示例#14
0
        private void CreateBackground()
        {
            var background = new Entity("Background")
                             .AddComponent(new Sprite("Content/BG.wpk"))
                             .AddComponent(new SpriteRenderer(DefaultLayers.Opaque))
                             .AddComponent(new Transform2D {
                DrawOrder = 1
            });

            this.EntityManager.Add(background);

            var countdownAnimation = new Entity("Countdown")
                                     .AddComponent(new Transform2D()
            {
                X      = WaveServices.ViewportManager.VirtualWidth - 20,
                Y      = 20,
                Origin = Vector2.UnitX
            })
                                     .AddComponent(new Sprite("Content/Countdown.wpk"))
                                     .AddComponent(Animation2D.Create <TexturePackerGenericXml>("Content/Countdown.xml")
                                                   .Add("Default", new SpriteSheetAnimationSequence()
            {
                First = 1, Length = 5, FramesPerSecond = 1
            }))
                                     .AddComponent(new AnimatedSpriteRenderer());

            this.EntityManager.Add(countdownAnimation);

            this.countdownAnimationComponent = countdownAnimation.FindComponent <Animation2D>();
        }
    public void PlayAnimationByNameReversed(string animationName)
    {
        Animation2D foundAnimation;

        animationsByName.TryGetValue(animationName, out foundAnimation);

        if (!canSwitchAnimations)
        {
            return;
        }

        if (foundAnimation)
        {
            if (currentAnimation)
            {
                if (currentAnimation.GetComponent <Blink2D>())
                {
                    currentAnimation.GetComponent <Blink2D>().StopBlinking();
                }

                currentAnimation.Stop();
                currentAnimation.Hide();
            }

            foundAnimation.Show();
            foundAnimation.Play(false, true, false);

            currentAnimation = foundAnimation;
        }
    }
    public virtual void PlayAnimationByName(string animationName, bool reset = false, bool useTimeOut = false, bool force = false)
    {
        Animation2D foundAnimation;

        animationsByName.TryGetValue(animationName, out foundAnimation);

        if (!force && !canSwitchAnimations)
        {
            return;
        }

        if (foundAnimation)
        {
            if (currentAnimation)
            {
                if (currentAnimation.GetComponent <Blink2D>())
                {
                    currentAnimation.GetComponent <Blink2D>().StopBlinking();
                }

                currentAnimation.Stop();
                currentAnimation.Hide();
            }

            foundAnimation.Show();
            foundAnimation.Play(reset, false, useTimeOut);

            currentAnimation = foundAnimation;
        }
    }
 public void OnReverseAnimationDone(Animation2D animation2D)
 {
     if (animation2D.name == "SwitchingHat")
     {
         DispatchMessage("OnHatTakenOff", null);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="drawing">is this sprite drawing?</param>
 /// <param name="spriteBatch">spritebatch from game class</param>
 /// <param name="location">sprite location on screen</param>
 /// <param name="tex">texture</param>
 /// <param name="col">color overlay for texture</param>
 /// <param name="effects">spriteeffects to be applied at draw</param>
 /// <param name="rotation">sprite rotation</param>
 /// <param name="rotationOrigin">Origin of Rotation</param>
 /// <param name="depth">depth layer of sprite</param>
 /// <param name="startinganimation">name of starting animation</param>
 /// <param name="startingframe">frame to start on</param>
 /// <param name="updating">is the sprite updating?</param>
 /// <param name="startingAnim">the Animation that is used at start</param>
 public CollidingAdvancedSprite(string name, Vector2 location, Texture2D tex, Color col,
                                SpriteEffects effects, float rotation, Vector2 rotationOrigin, float depth, string startinganimation,
                                int startingframe, bool updating, Animation2D startingAnim, bool drawing)
     : base(name, location, tex, col, effects, rotation, rotationOrigin, depth, startinganimation,
            startingframe, updating, startingAnim, drawing)
 {
 }
示例#19
0
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.explisionAnimation2D = this.Owner.FindChild("Particles")
                                        .FindComponent <Animation2D>();
        }
示例#20
0
 // fills fields with appropriate Animation2D objects for later reference
 private void animationSetup()
 {
     // ready animations
     Animation2D[] allAnimations = GetComponentsInChildren <Animation2D>();
     foreach (Animation2D a in allAnimations)
     {
         if (a.gameObject == this.gameObject)
         {// animations on this
             if (a.name.Equals("Idle"))
             {
                 idleAnim     = a;
                 curAnimation = a;
             }
         }
         else
         {// animations on children of this
             if (a.name.Equals("BusterCharging"))
             {
                 chargingAnim = a;
             }
             else if (a.name.Equals("BusterCharged"))
             {
                 chargedAnim = a;
             }
         }
     }
 }
    public void ShowAnimationAdditive(string name)
    {
        Animation2D found = GetAnimationByName(name);

        currentAdditiveAnimation = found;
        currentAdditiveAnimation.Show();
    }
示例#22
0
 // Use this for initialization
 void Awake()
 {
     sadAnimation    = this.transform.Find("Sad Animation").GetComponent <Animation2D>();
     happyAnimation  = this.transform.Find("Happy Animation").GetComponent <Animation2D>();
     triggerListener = this.GetComponentInChildren <TriggerListener2D>();
     triggerListener.AddEventListener(this.gameObject);
 }
    public void ResumeAnimationSynced(string animationName, bool useTimeOut = false)
    {
        Animation2D foundAnimation;

        animationsByName.TryGetValue(animationName, out foundAnimation);

        if (foundAnimation)
        {
            if (currentAnimation != foundAnimation)
            {
                int savedFrame = 0;
                if (currentAnimation)
                {
                    savedFrame = currentAnimation.GetPreviousFrame();
                    currentAnimation.Stop();
                    currentAnimation.Hide();
                }

                foundAnimation.SetCurrentFrame(savedFrame);
                foundAnimation.Show();
                foundAnimation.Play(false, false, useTimeOut);
            }
            currentAnimation = foundAnimation;
        }
    }
示例#24
0
        private Inventory.RocketBuilder[] CreateRockets()
        {
            Texture2D rocketTex = Texture2D.LoadTexture(ROCKET_TEXTURE_PATH);

            AddTexture(rocketTex);
            Texture2D powerfulRocketTex = Texture2D.LoadTexture(POWERFULROCKET_TEXTURE_PATH);

            AddTexture(powerfulRocketTex);
            Texture2D fastRocketTex = Texture2D.LoadTexture(FASTROCKET_TEXTURE_PATH);

            AddTexture(fastRocketTex);

            Animation2D explosionAnim = Animation2D.LoadAnimation(EXPLOSION_ANIMATION_PATH, 5);

            explosionAnim.AnimationTime = 120;
            AddTexture(explosionAnim);

            return(new Inventory.RocketBuilder[]
            {
                new Inventory.RocketBuilder(this, powerfulRocketTex, explosionAnim,
                                            new DoubleDamageRocket(new DoubleCooldownRocket(new BaseRocket()))),
                new Inventory.RocketBuilder(this, fastRocketTex, explosionAnim,
                                            new HalfDamageRocket(new HalfCooldownRocket(new BaseRocket()))),
                new Inventory.RocketBuilder(this, rocketTex, explosionAnim,
                                            new BaseRocket())
            });
        }
示例#25
0
 public TimeSkipVisual()
 {
     Animation =
         new Animation2D("Textures/TimeSkipVFX", 22, 30)
     {
         Active = true
     };
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnimatedSpriteRenderer" /> class.
 /// </summary>
 /// <param name="layer">Layer type.</param>
 /// <param name="samplerMode">The sampler mode.</param>
 public AnimatedSpriteRenderer(Type layer, AddressMode samplerMode = AddressMode.LinearClamp)
     : base("AnimatedSpriteRenderer" + instances++, layer)
 {
     this.Transform2D = null;
     this.Sprite      = null;
     this.Animation2D = null;
     this.samplerMode = samplerMode;
 }
    public Animation2D GetAnimationByName(string animationName)
    {
        Animation2D foundAnimation = null;

        animationsByName.TryGetValue(animationName, out foundAnimation);

        return(foundAnimation);
    }
示例#28
0
 public void PlayAnimation(AnimationType type)
 {
     frameIndex       = 0;
     timer            = 0;
     IsPlaying        = true;
     currentAnimation = GetAnimationByType(type);
     renderer.flipY   = currentAnimation.Mirror;
 }
示例#29
0
 // While the animation is still running, pauses and unpauses it as necessary
 private IEnumerator pauseCheck(Animation2D anim)
 {
     while (!anim.isStopped)
     {
         anim.paused = Controller.paused;
         yield return(0);
     }
 }
示例#30
0
 public TimBehavior()
     : base("TimBehavior")
 {
     this.direction    = NONE;
     this.anim2D       = null;
     this.trans2D      = null;
     this.currentState = AnimState.Idle;
 }
示例#31
0
 void assignAnimation2DParentValues(string spriteType, Animation2DParent animation2DParent, Animation2D animation2D, GameObject spriteContainer)
 {
     switch(spriteType)
     {
     case "body":
     {
         animation2DParent.body = animation2D;
         assignAnimationGameObject(spriteContainer,animation2D);
         break;
     }
     default:
     {
         break;
     }
     }
 }
示例#32
0
    void Awake()
    {
        this.scoreLabelTexture = (Texture2D)Resources.Load("UI/score");
        this.stageLabelTexture = (Texture2D)Resources.Load("UI/stage");
        this.gameOverTexture = (Texture2D)Resources.Load("UI/gameover");
        this.brokenTexture = (Texture2D)Resources.Load("UI/broken");
        this.outerTexture = (Texture2D)Resources.Load("UI/outer");
        this.lifeTexture = (Texture2D)Resources.Load ("UI/life");
        this.continueTexture = (Texture2D)Resources.Load ("UI/continue");
        this.scoreNumberTexture = new NumberTexture("UI/numbers", 37, 50);
        this.stageNumberTexture = new NumberTexture("UI/numbers", 37, 50);
        this.audio.volume = this.maxVolume;

        this.state = GameState.Start;
        this.levelManager = GameObject.FindWithTag("LevelManager");
        this.currentLevel = this.initialLevel;
        this.audioPlayer = GameObject.Find("AudioPlayer").GetComponent<AudioSource>();
        this.initialLevel = this.currentLevel;
        this.lives[0] = this.initialLife;
        this.lives[1] = this.initialLife;
        this.startAnimation = new Animation2D(new Rect((Screen.width - 800) / 2, (Screen.height - 600) / 2, 800, 600), "UI/Start/start", 57);
        this.destroyedEnemies = new List<Enemy>();
        this.Replay();
    }
    void Start()
    {
        GetComponent<Rigidbody>().sleepThreshold = 0; // a good player never sleeps!
        tag = "Player"; // WE are the player, okaaaay?!
        if(GetComponent<Animation2D>())
        {
            animation_2d_component = GetComponent<Animation2D>() as Animation2D; // get the animation component
        }

        if(!player_graphic_pointer) // no graphic plane? then we must be the graphic plane!
            player_graphic_pointer=transform;
    }
示例#34
0
 public void SetSelectionSprite(Animation2D selectionSprite)
 {
     Vector2 screenDimensions = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
     selectionLoader = new DrawableAsset<Animation2D>(Vector2.Zero, new Vector2(0, -1), new Vector2(screenDimensions.X / 4.0f, screenDimensions.X / 4.0f), selectionSprite);
 }
示例#35
0
 void SwitchAnimation(string animationName)
 {
     if(_animDict.ContainsKey(animationName))
     {
         _currentAnimation = _animDict[animationName];
         _currentFrameX = 0;
         _currentFrameY = _currentAnimation.frameY - 1;
         InitMaterial();
         _playing = true;
     }
 }
示例#36
0
 void assignAnimationGameObject(GameObject spriteContainer, Animation2D animation2D)
 {
     switch (spriteContainer.name)
     {
     case "walking_s":
     {
         walking_s = spriteContainer;
         break;
     }
     case "idle_s":
     {
         idle_s = spriteContainer;
         break;
     }
     case "attack_s":
     {
         attack_s = spriteContainer;
         break;
     }
     case "walking_e":
     {
         walking_e = spriteContainer;
         break;
     }
     case "idle_e":
     {
         idle_e = spriteContainer;
         break;
     }
     case "walking_n":
     {
         walking_n = spriteContainer;
         break;
     }
     case "idle_n":
     {
         idle_n = spriteContainer;
         break;
     }
     case "walking_w":
     {
         walking_w = spriteContainer;
         break;
     }
     case "idle_w":
     {
         idle_w = spriteContainer;
         break;
     }
     default:
     {
         break;
     }
     }
 }