Inheritance: EntityComponent
コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _modelEntityComponent = _modelEntityComponent ?? Parent.GetComponent <ModelEntityComponent>();

            var movementDirection = Parent.LastTranslation;

            if (movementDirection.LengthSquared() > 0.0f)
            {
                if (movementDirection.X > 0.0f)
                {
                    PlayAnimation(RightAnimation);
                }
                else if (movementDirection.X < 0.0f)
                {
                    PlayAnimation(LeftAnimation);
                }
                else
                {
                    PlayAnimation(movementDirection.Z > 0.0f ? ForwardAnimation : BackwardAnimation);
                }
            }
            else
            {
                StopAnimation();
                if (_modelEntityComponent != null)
                {
                    _modelEntityComponent.Material.TexcoordOffset = Vector2.Zero;
                }
            }
        }
コード例 #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            _modelEntityComponent = _modelEntityComponent ?? Parent.GetComponent<ModelEntityComponent>();

            var movementDirection = Parent.LastTranslation;

            if (movementDirection.LengthSquared() > 0.0f)
            {
                if (movementDirection.X > 0.0f)
                {
                    PlayAnimation(RightAnimation);
                }
                else if (movementDirection.X < 0.0f)
                {
                    PlayAnimation(LeftAnimation);
                }
                else
                {
                    PlayAnimation(movementDirection.Z > 0.0f ? ForwardAnimation : BackwardAnimation);
                }
            }
            else
            {
                StopAnimation();
                if (_modelEntityComponent != null) _modelEntityComponent.Material.TexcoordOffset = Vector2.Zero;
            }
        }
コード例 #3
0
 private void OnUpdateAnimationFrame(int textureIndex)
 {
     _modelComponent = _modelComponent ?? ReferringEntity.GetComponent<ModelEntityComponent>();
     if (_modelComponent != null && textureIndex < _modelComponent.Regions.Count)
     {
         _modelComponent.SetTexture(textureIndex);
     }
 }
コード例 #4
0
 private void OnUpdateAnimationFrame(int textureIndex)
 {
     _modelComponent = _modelComponent ?? Parent.GetComponent <ModelEntityComponent>();
     if (_modelComponent != null && textureIndex < _modelComponent.Regions.Count)
     {
         _modelComponent.SetTexture(textureIndex);
     }
 }
コード例 #5
0
        public override EntityComponent Clone(Entity target)
        {
            var clonedComponent = new ModelEntityComponent(target);
            clonedComponent._regions = _regions != null ? new List<TextureRegion>(_regions) : null;
            clonedComponent._drawableElement = GameInstance.GetService<SceneRenderer>().CreateDrawableElement(target.IsInitializing);
            clonedComponent._drawableElement.Material = Material;
            clonedComponent._drawableElement.Mesh = Mesh;
            clonedComponent.IsBillboard = IsBillboard;
            clonedComponent.IsActive = target.IsActive;

            return clonedComponent;
        }
コード例 #6
0
        public override EntityComponent Clone(Entity target)
        {
            var clonedComponent = new ModelEntityComponent(target);
            clonedComponent._regions = _regions != null ? new List<TextureRegion>(_regions) : null;
            clonedComponent._drawableElement = GameInstance.GetService<SceneRenderer>().CreateDrawableElement(target.IsInitializing);
            clonedComponent._drawableElement.Material = Material;
            clonedComponent._drawableElement.Mesh = Mesh;
            clonedComponent.IsBillboard = IsBillboard;
            clonedComponent.IsActive = target.IsActive;

            return clonedComponent;
        }