当前位置: 首页>>代码示例>>C#>>正文


C# AnimationState.AddTime方法代码示例

本文整理汇总了C#中AnimationState.AddTime方法的典型用法代码示例。如果您正苦于以下问题:C# AnimationState.AddTime方法的具体用法?C# AnimationState.AddTime怎么用?C# AnimationState.AddTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnimationState的用法示例。


在下文中一共展示了AnimationState.AddTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Derpy

        public Derpy(ThingBlock block, ThingDefinition def)
            : base(block, def)
        {
            bodyComponent = ModelComponents[0];
            flagComponent = ModelComponents[1];
            startLightComponent = ModelComponents[2];

            bodyFacing = new Euler(0, 0, 0);
            neckFacing = new Euler(0, 0, 0);

            Skeleton skeleton = bodyComponent.Entity.Skeleton;
            skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;

            blinkState = bodyComponent.Entity.GetAnimationState("Blink2");
            blinkState.Enabled = true;
            blinkState.Loop = true;
            blinkState.Weight = 1f;
            blinkState.AddTime(ID);

            neckBone = skeleton.GetBone("Neck");
            neckBone.SetManuallyControlled(true);
            foreach (var state in bodyComponent.Entity.AllAnimationStates.GetAnimationStateIterator())
            {
                // don't add a blend mask to the blink state because we'll make a different one for it
                if (state == blinkState)
                    continue;

                state.CreateBlendMask(skeleton.NumBones);
                state.SetBlendMaskEntry(neckBone.Handle, 0f);
            }
            neckBone.InheritOrientation = false;

            blinkState.CreateBlendMask(skeleton.NumBones, 0f);
            ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowTop.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);

            LKernel.GetG<AnimationManager>().Add(blinkState);

            interpNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode("DerpyInterpNode" + ID, Vector3.ZERO);

            anim = DerpyAnimation.Hover1;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:48,代码来源:Derpy.cs

示例2: Update

        public override void Update()
        {
            walkAnim = Entity.GetAnimationState("WALK");
            idleAnim = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim = Entity.GetAnimationState("DEAD");
            Tree.e_Visit(this);

            if (Statistics.aktualnaZywotnosc <= 0)
                State = StateTypes.DEAD;

            double Distance = Engine.Distance(Position, Engine.Singleton.HumanController.Character.Position);
            Distance = System.Math.Abs(Distance);

            if (Distance <= _ZasiegWzroku && State != StateTypes.DEAD)
            {
                PredicateRaycast raycast = new PredicateRaycast((b => !(b.UserData is TriggerVolume)));
                raycast.Go(Engine.Singleton.NewtonWorld, Position + Profile.HeadOffset, Engine.Singleton.HumanController.Character.Position);

                if (raycast.Contacts.Count <= 1)
                {
                    isSeen = true;

                    TurnTo(Engine.Singleton.HumanController.Character.Position);
                }

                else
                    isSeen = false;
            }

            if (Distance <= _ZasiegOgolny)
            {
                isReachable = true;
            }

            else
                isReachable = false;

            if ((isReachable == true) && Distance > Profile.DystansKontaktu && State != StateTypes.DEAD && FriendlyType == Character.FriendType.ENEMY)
            {
                Engine.Singleton.CurrentLevel.navMesh.AStar(Position, Engine.Singleton.HumanController.Character.Position);
                if (Engine.Singleton.CurrentLevel.navMesh.TriPath.Count > 1)
                {
                    Engine.Singleton.CurrentLevel.navMesh.GetPortals();
                    WalkPath = Engine.Singleton.CurrentLevel.navMesh.Funnel();

                    idleAnim.Enabled = false;
                    walkAnim.Enabled = true;
                    attackAnim.Enabled = false;
                    walkAnim.Loop = true;
                    walkAnim.AddTime(1.0f / 90.0f);

                    FollowPathOrder = true;
                    //MoveOrder = true;
                    State = StateTypes.WALK;
                }
            }

            else
            {
                FollowPathOrder = false;

                if (State == StateTypes.WALK)
                    State = StateTypes.IDLE;

                switch (State)
                {
                    case StateTypes.IDLE:
                        walkAnim.Enabled = false;
                        idleAnim.Enabled = true;
                        attackAnim.Enabled = false;
                        idleAnim.Loop = true;
                        idleAnim.AddTime(1.0f / 90.0f);
                        break;
                    case StateTypes.DEAD:
                        walkAnim.Enabled = false;
                        idleAnim.Enabled = false;
                        attackAnim.Enabled = false;
                        deadAnim.Enabled = true;
                        deadAnim.AddTime(1.0f / 90.0f);
                        deadAnim.Loop = false;
                        //Animacja deda.

                        if (deadAnim.HasEnded && !recalculatedAfterDead)
                        {
                            //recalculatedAfterDead = true;
                            //RecalculateCollision();           //<- FIX THAT SHIET!
                        }

                        break;
                    //Animacja ataku bedzie tam nizej w case StateTypes.Attack, nie tutaj!!

                }
                if (isReachable)
                {
                    switch (State)
                    {
                        case StateTypes.IDLE:
                            //Console.WriteLine(FriendlyType.ToString());
                            if (FriendlyType == Character.FriendType.ENEMY)
//.........这里部分代码省略.........
开发者ID:janPierdolnikParda,项目名称:RPG,代码行数:101,代码来源:Enemy.cs

示例3: BackgroundPony


//.........这里部分代码省略.........
                            SetMaterialFragmentParameter(newMat, 0, "OutlineColour", hairAOColour2);
                        else if (int.Parse(_data[32], culture) == 1)
                            SetMaterialFragmentParameter(newMat, 0, "OutlineColour", hairAOColour1);
                    }
                    hairEnt.SetMaterial(newMat);
                    maneEnt.SetMaterial(newMat);
                    tailEnt.SetMaterial(newMat);
                }
                // one colour
                else {
                    MaterialPtr originalMat = MaterialManager.Singleton.GetByName("BgPonyHair_Single_" + hairstyleID);
                    MaterialPtr newMat = MaterialManager.Singleton.GetByName("BgPonyHair_Single_" + hairstyleID + nameOfPonyCharacter);
                    if (newMat == null) {
                        newMat = originalMat.Clone("BgPonyHair_Single_" + hairstyleID + nameOfPonyCharacter);

                        var ps = newMat.GetTechnique(0).GetPass(1).GetFragmentProgramParameters();
                            ps.SetNamedConstant("HairColour", hairColour1);
                            ps.SetNamedConstant("AOColour", hairAOColour1);
                        newMat.GetTechnique(0).GetPass(1).SetFragmentProgramParameters(ps);

                        SetMaterialFragmentParameter(newMat, 0, "OutlineColour", hairAOColour1);
                    }
                    hairEnt.SetMaterial(newMat);
                    maneEnt.SetMaterial(newMat);
                    tailEnt.SetMaterial(newMat);
                }
            }
            #endregion

            #region animation
            // make sure our animations add their weights and don't just average out. The AnimationBlender already handles averaging between two anims.
            Skeleton skeleton = bodyEnt.Skeleton;
            skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;

            // set up the blink animation state with some stuff
            blinkState = bodyEnt.GetAnimationState("Blink2");
            blinkState.Enabled = true;
            blinkState.Loop = true;
            blinkState.Weight = 1;
            blinkState.AddTime(ID);

            // set up all of the animation states to not use the neck bone
            neckbone = skeleton.GetBone("Neck");
            neckbone.SetManuallyControlled(true);
            foreach (var state in bodyEnt.AllAnimationStates.GetAnimationStateIterator()) {
                // don't add a blend mask to the blink state because we'll make a different one for it
                if (state == blinkState)
                    continue;

                state.CreateBlendMask(skeleton.NumBones);
                state.SetBlendMaskEntry(neckbone.Handle, 0f);
            }
            neckbone.InheritOrientation = false;

            neckFacing = new Euler(0, 0, 0);

            // set up a blend mask so only the eyebrow bones have any effect on the blink animation
            blinkState.CreateBlendMask(skeleton.NumBones, 0f);
            ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowTop.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);

            // add the blink state to the animation manager so it has time added to it
            AnimationManager animMgr = LKernel.GetG<AnimationManager>();
            animMgr.Add(blinkState);

            // set up other animated things
            bodyBlender = new AnimationBlender(bodyEnt);
            bodyBlender.Init("Stand1", true);
            animMgr.Add(bodyBlender);

            maneBlender = new AnimationBlender(maneEnt);
            maneBlender.Init("Stand1", true);
            animMgr.Add(maneBlender);

            tailBlender = new AnimationBlender(tailEnt);
            tailBlender.Init("Stand1", true);
            animMgr.Add(tailBlender);

            if (PonyType == Type.FlyingPegasus) {
                wingsBlender = new AnimationBlender(wingsEnt);
                wingsBlender.Init("Flap1", true);
                animMgr.Add(wingsBlender);
            }

            // set up some timers to handle animation changing
            animTimer = new Timer(new TimerCallback(AnimTimerTick), null, random.Next(ANIMATION_TIMESPAN_MINIMUM, ANIMATION_TIMESPAN_MAXIMUM), Timeout.Infinite);

            // add a bit of time to things so the animations aren't all synced at the beginning
            AddTimeToBodyManeAndTail();
            #endregion

            followKart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;
            LKernel.GetG<Root>().FrameStarted += FrameStarted;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:101,代码来源:BackgroundPony.cs

示例4: Lyra

        public Lyra(ThingBlock block, ThingDefinition def)
            : base(block, def)
        {
            foreach (ModelComponent mc in ModelComponents) {
                if (mc.Name.EndsWith("Body"))
                    bodyComponent = mc;
                else if (mc.Name.EndsWith("Mane"))
                    maneComponent = mc;
                else if (mc.Name.EndsWith("Tail"))
                    tailComponent = mc;
            }

            // make sure our animations add their weights and don't just average out. The AnimationBlender already handles averaging between two anims.
            Skeleton skeleton = bodyComponent.Entity.Skeleton;
            skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;

            // set up the blink animation state with some stuff
            blinkState = bodyComponent.Entity.GetAnimationState("Blink2");
            blinkState.Enabled = true;
            blinkState.Loop = true;
            blinkState.Weight = 1;
            blinkState.AddTime(ID);

            // set up all of the animation states to not use the neck bone
            neckbone = skeleton.GetBone("Neck");
            neckbone.SetManuallyControlled(true);
            foreach (var state in bodyComponent.Entity.AllAnimationStates.GetAnimationStateIterator()) {
                // don't add a blend mask to the blink state because we'll make a different one for it
                if (state == blinkState)
                    continue;

                state.CreateBlendMask(skeleton.NumBones);
                state.SetBlendMaskEntry(neckbone.Handle, 0f);
            }
            neckbone.InheritOrientation = false;

            neckFacing = new Euler(0, 0, 0);

            // set up a blend mask so only the eyebrow bones have any effect on the blink animation
            blinkState.CreateBlendMask(skeleton.NumBones, 0f);
            ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowTop.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);

            // add the blink state to the animation manager so it has time added to it
            LKernel.GetG<AnimationManager>().Add(blinkState);

            // set up some timers to handle animation changing
            random = new Random(IDs.Random);
            animTimer = new System.Threading.Timer(new TimerCallback(AnimTimerTick), null, random.Next(ANIMATION_TIMESPAN_MINIMUM, ANIMATION_TIMESPAN_MAXIMUM), Timeout.Infinite);

            // add a bit of time to things so the animations aren't all synced at the beginning
            float rand = (float) random.NextDouble();
            bodyComponent.AnimationBlender.AddTime(rand);
            tailComponent.AnimationState.AddTime(rand);

            followKart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;
            LKernel.GetG<Root>().FrameStarted += FrameStarted;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:64,代码来源:Lyra.cs


注:本文中的AnimationState.AddTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。