예제 #1
0
 public PointLight(ICanyonShooterGame game, float r, float g, float b)
     : base(game as Game)
 {
     transformable = new Transformable(game, this, null);
     this.game     = game;
     color         = new Color(new Vector3(r, g, b));
 }
예제 #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Key()
 {
     OutlineColor             = Color.White;
     OutlineThickness         = 0;
     Color                    = Color.White;
     Transform                = new Transformable();
     PosFunction              = Fct.LINEAR;
     PosFctCoeff              = 1;
     OriginFunction           = Fct.LINEAR;
     OriginFctCoeff           = 1;
     ScaleFunction            = Fct.LINEAR;
     ScaleFctCoeff            = 1;
     RotFunction              = Fct.LINEAR;
     RotFctCoeff              = 1;
     OpacityFunction          = Fct.LINEAR;
     OpacityFctCoeff          = 1;
     ColorFunction            = Fct.LINEAR;
     ColorFctCoeff            = 1;
     OutlineColorFunction     = Fct.LINEAR;
     OutlineColorFctCoeff     = 1;
     OutlineThicknessFunction = Fct.LINEAR;
     OutlineThicknessFctCoeff = 1;
     Opacity                  = 255;
     TextureTime              = null;
     reached                  = false;
 }
예제 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="animationFolder">The folder the animation, skeleton, and spritesheet data are found in.</param>
        /// <param name="skin">An optional skin to use in the animation, if supported.</param>
        public SpineAnimation(string animationFolder, string skin = null)
        {
            animationFolder.TrimEnd('/');
            var atlas        = new Atlas(new StringReader(Library.GetText(string.Format("{0}/skeleton.atlas", animationFolder))), ".", new PunkTextureLoader(animationFolder));
            var json         = new SkeletonJson(atlas);
            var skeletonData = json.ReadSkeletonData(string.Format("{0}/skeleton.json", animationFolder));

            var stateData = new AnimationStateData(skeletonData);

            Rate   = 1;
            Active = true;

            _vertexArray = new VertexArray(PrimitiveType.Quads, (uint)skeletonData.Bones.Count * 4);

            _skeleton = new Skeleton(skeletonData);
            _state    = new AnimationState(stateData);

            if (!string.IsNullOrEmpty(skin))
            {
                _skeleton.SetSkin(skin);
            }

            _skeleton.SetSlotsToSetupPose();
            _skeleton.SetToSetupPose();
            _skeleton.UpdateWorldTransform();

            _vertexPositions = new float[8];                    //	cache this for performance
            _transform       = new Transformable();
        }
예제 #4
0
        public void AddSprite(Sprite drawable, Transformable t)
        {
            var rect = drawable.GetGlobalBounds();

            _texture = drawable.Texture;

            _batch.Append(new Vertex()
            {
                Position  = t.Position,
                TexCoords = new Vector2f(),
                Color     = Color.White
            });
            _batch.Append(new Vertex()
            {
                Position  = new Vector2f(t.Position.X + rect.Width, t.Position.Y),
                TexCoords = new Vector2f(25, 0),
                Color     = Color.White
            });

            _batch.Append(new Vertex()
            {
                Position  = new Vector2f(t.Position.X + rect.Width, t.Position.Y + rect.Height),
                TexCoords = new Vector2f(25, 50),
                Color     = Color.White
            });
            _batch.Append(new Vertex()
            {
                Position  = t.Position,
                TexCoords = new Vector2f(t.Position.X, t.Position.Y + rect.Height),
                Color     = Color.White
            });
        }
예제 #5
0
 public BaseAnimation(float duration, Transformable target)
 {
     Clock           = new Clock();
     Duration        = duration;
     Target          = target;
     InitialPosition = target.Position;
 }
예제 #6
0
        public static void AnimateElasticMove(this Transformable target, Vector2f finalPosition, float duration)
        {
            var animation = new ElasticAnimation(duration, target, finalPosition);

            AnimationManager.Animations.Add(animation);
            animation.Play();
        }
예제 #7
0
        internal override void Draw(RenderTarget target, Vector2f decal)
        {
            Transformable tr = new Transformable();

            tr.Position = decal;
            target.Draw(Line, PrimitiveType.Lines, new RenderStates(tr.Transform));
        }
예제 #8
0
        public ModelAttachment Add(Transformable transformable)
        {
            var result = new ModelAttachment(transformable);

            Add(result);
            return(result);
        }
예제 #9
0
 public PointLight(ICanyonShooterGame game, Color color)
     : base(game as Game)
 {
     transformable = new Transformable(game, this, null);
     this.game     = game;
     this.color    = color;
 }
예제 #10
0
        public void Start(Transformable target)
        {
            state       = AnimState.Running;
            this.target = target;

            Started(this, EventArgs.Empty);
        }
예제 #11
0
        public void Emit(int count)
        {
            for (int i = 0; i < count; ++i)
            {
                ITransformable t;
                if (ttt == null)
                {
                    t = ttt = new Transformable(game);
                }
                else
                {
                    t = new Transformable(game);
                }
                t.ConnectedToXpa = true;

                float size = minSize + (maxSize - minSize) * (float)random.NextDouble();
                t.LocalScale = new Vector3(size, size, size);

                foreach (ShapeData shape in Model.CollisionShapes)
                {
                    t.AddShape(shape, ContactGroup);
                }

                t.Mass = Model.MassInDescription;

                type.Apply(t);

                if (instances[currentFreeInstance] != null)
                {
                    instances[currentFreeInstance].Dispose();
                }
                instances[currentFreeInstance] = t;
                currentFreeInstance            = (currentFreeInstance + 1) % instances.Length;
            }
        }
예제 #12
0
        public void Stop()
        {
            state  = AnimState.Stopped;
            target = null;

            Stopped(this, EventArgs.Empty);
        }
예제 #13
0
파일: Engine.cs 프로젝트: yCatDev/SimpleX
        public Engine(string title, int width = 1200, int height = 900, bool IsFullScreen = false)
        {
            logger = new Logger();
            logger.LogInfo("-Initializing framework");

            _settings.AntialiasingLevel = 8;

            _window = new RenderWindow(new VideoMode((uint)width, (uint)height), title, Styles.Close, _settings);
            _window.SetFramerateLimit(FPS);
            _window.SetVerticalSyncEnabled(true);
            _dt = new Clock();
            _dt.Restart();
            _window.Closed += (sender, e) => Quit();
            _instance       = this;


            World = new Transformable();

            World.Position = new Vector2f(0, 0);
            Camera         = new Camera(_window);
            _window.SetView(Camera.GetView());



            GameObjectManager = new GameObjectManager();
            TaskManager       = new TaskManager();
            SceneManager      = new SceneManager();
            AudioManager      = new AudioManager();
            InputManager.InitManager();
            WindowsPositions.Calcualte(_window, Camera);

            logger.LogInfo("-Initialized successful");
        }
예제 #14
0
        //------------------------------------------------------------------------------------------------------------------------
        //														DistanceTo()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the distance to another Transformable
        /// </summary>
        public float DistanceTo(Transformable other)
        {
            float dx = other.x - x;
            float dy = other.y - y;

            return(Mathf.Sqrt(dx * dx + dy * dy));
        }
예제 #15
0
 public void SetTargetInteractable(Interactable newTargetInteractable)
 {
     targetInteractable = newTargetInteractable;
     if (newTargetInteractable)
     {
         targetTransformable = newTargetInteractable.GetComponent <Transformable>();
     }
 }
예제 #16
0
 /// <summary>
 /// loads the effect ressources from files.
 /// </summary>
 /// <param name="type">The type of effect (i.e. explosion).</param>
 public Effect(ICanyonShooterGame game, EffectType type, ParticleSettings settings)
     : base(game as Game, game.Content)
 {
     transformable = new Transformable(game, this, null);
     this.game     = game;
     this.type     = type;
     this.settings = settings;
 }
    public override void update(float elapsedTime)
    {
        Transformable obj = mComponentOwner as Transformable;
        Vector3       dir = mFocusTarget.localToWorldDirection(mFocusOffset) + mFocusTarget.getWorldPosition() - obj.getWorldPosition();

        obj.setWorldRotation(getLookAtRotation(dir));
        base.update(elapsedTime);
    }
 public void setFocusTarget(Transformable obj)
 {
     mFocusTarget = obj;
     if (mFocusTarget == null)
     {
         setActive(false);
     }
 }
 public override void init()
 {
     base.init();
     mTarget           = null;
     mDoneCallback     = null;
     mTrackingCallback = null;
     mOffset           = Vector3.zero;
     mSpeed            = 0.0f;
 }
 public override void resetProperty()
 {
     base.resetProperty();
     mTarget        = null;
     mDoneCallback  = null;
     mDoingCallback = null;
     mOffset        = Vector3.zero;
     mSpeed         = 0.0f;
 }
예제 #21
0
        /// <summary>
        /// Creates a new GameObject and adds it to the world
        /// </summary>
        /// <param name="game"></param>
        public GameObject(ICanyonShooterGame game, string name)
            : base(game as Game)
        {
            this.game     = game;
            this.name     = name;
            transformable = new Transformable(game, this, this);

            DrawOrder = (int)DrawOrderType.Default;
        }
예제 #22
0
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            var transformable = new Transformable();

            transformable.Origin   = (Vector2f)info.GetValue("Origin", typeof(Vector2f));
            transformable.Position = (Vector2f)info.GetValue("Position", typeof(Vector2f));
            transformable.Rotation = (float)info.GetValue("Rotation", typeof(float));
            transformable.Scale    = (Vector2f)info.GetValue("Scale", typeof(Vector2f));
            return(transformable);
        }
예제 #23
0
		public void Start(Transformable target, Vector2f to, float speed)
		{
			this.to = to;
			this.speed = speed;

			initialDist = target.Position.Distance(to);
			time = 0;

			base.Start(target);
		}
        /// <summary>
        /// Generates a SFML transformable from a TVector2f position, scale and a angle in degrees.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="angle"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static Transformable TransformableFromPosRotScale(TVector2f position, float angle, TVector2f scale)
        {
            var t = new Transformable
            {
                Position = position,
                Rotation = angle,
                Scale    = scale
            };

            return(t);
        }
    public override void execute()
    {
        Transformable obj = mReceiver as Transformable;
        TransformableComponentLockPosition component = obj.getComponent(out component);

        // 停止其他移动组件
        obj.breakComponent <IComponentModifyPosition>(component.GetType());
        component.setActive(true);
        component.setLockPosition(mLockPosition);
        component.setLock(mLockX, mLockY, mLockZ);
    }
    public override void execute()
    {
        Transformable obj = mReceiver as Transformable;
        TransformableComponentRotateFocus component = obj.getComponent(out component);

        // 停止其他旋转组件
        obj.breakComponent <IComponentModifyRotation>(component.GetType());
        component.setActive(true);
        component.setFocusTarget(mTarget);
        component.setFocusOffset(mOffset);
    }
예제 #27
0
    public override void execute()
    {
        Transformable obj = mReceiver as Transformable;
        TransformableComponentRotateSpeed component = obj.getComponent(out component);

        // 停止其他旋转组件
        obj.breakComponent <IComponentModifyRotation>(component.GetType());
        component.setActive(true);
        component.startRotateSpeed(mStartAngle, mRotateSpeed, mRotateAcceleration);
        // 需要启用组件更新时,则开启组件拥有者的更新,后续也不会再关闭
        obj.setEnable(true);
    }
        public static TransformFollower CreateFollower(Transform parent, Vector3 position, Transformable target)
        {
            GameObject go = new GameObject("Follower:" + target, typeof(TransformFollower));
            TransformFollower loc = go.GetComponent<TransformFollower>();

            loc.target = target;

            go.transform.position = position;
            loc.SetParentInternal(parent);

            return loc;
        }
    public override void execute()
    {
        Transformable obj = mReceiver as Transformable;
        TransformableComponentRotateFixedPhysics component = obj.getComponent(out component);

        // 停止其他旋转组件
        obj.breakComponent <IComponentModifyRotation>(component.GetType());
        component.setActive(mActive);
        component.setFixedEuler(mFixedEuler);
        // 需要启用组件更新时,则开启组件拥有者的更新,后续也不会再关闭
        obj.setEnable(true);
    }
예제 #30
0
 public bool Remove(Transformable transformable)
 {
     for (int i = 0; i < Count; i++)
     {
         if (this[i].Transformable == transformable)
         {
             RemoveAt(i);
             return(true);
         }
     }
     return(false);
 }
    public override void execute()
    {
        Transformable obj = mReceiver as Transformable;
        TransformableComponentMovePhysics component = obj.getComponent(out component);

        // 停止其他移动组件
        obj.breakComponent <IComponentModifyPosition>(component.GetType());
        component.setTremblingCallback(mTremblingCallBack);
        component.setTrembleDoneCallback(mTrembleDoneCallBack);
        component.setActive(true);
        component.setTargetPos(mTargetPos);
        component.setStartPos(mStartPos);
        component.play(mName, mLoop, mOnceLength, mOffset, mFullOnce, mAmplitude);
    }
예제 #32
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Copy constructor
 /// </summary>
 ///
 /// <param name="copy">Instance to copy</param>
 ///
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public Transformable(Transformable copy)
 {
     m_Position = copy.m_Position;
 }
 public static TransformFollower CreateFollower(Vector3 position, Transformable target)
 {
     return CreateFollower(null, position, target);
 }
예제 #34
0
 //------------------------------------------------------------------------------------------------------------------------
 //                                                        DistanceTo()
 //------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Returns the distance to another Transformable
 /// </summary>
 public float DistanceTo(Transformable other)
 {
     float dx = other.x - x;
     float dy = other.y - y;
     return Mathf.Sqrt(dx * dx + dy * dy);
 }
예제 #35
0
 /** Applies the inverse of the camera transformation to a point. */
 public void worldToScreen(Transformable t)
 {
     t.rect.x -= mCornerX;
     t.rect.y -= mCornerY;
 }