コード例 #1
0
ファイル: BotPolygon.cs プロジェクト: funkjunky/Raven
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _botEntity = entity as BotEntity;

            switch (_team)
            {
                case GameManager.GameManager.Teams.Blue:
                    Color = Microsoft.Xna.Framework.Graphics.Color.Blue.ToVector4();
                    break;
                case GameManager.GameManager.Teams.Red:
                    Color = Microsoft.Xna.Framework.Graphics.Color.Red.ToVector4();
                    break;
                case GameManager.GameManager.Teams.Green:
                    Color = Microsoft.Xna.Framework.Graphics.Color.Green.ToVector4();
                    break;
                case GameManager.GameManager.Teams.Yellow:
                    Color = Microsoft.Xna.Framework.Graphics.Color.Yellow.ToVector4();
                    break;
            }

            Primitive = 6;

            //set the layer
            Layer = 0;
            Size = new Vector2(32, 32);

            T2DPhysicsComponent physics = new T2DPhysicsComponent();
            physics.InverseMass = 0.1f;
            Components.AddComponent(physics);

            if (null == _minimapComponent)
                return;

            _minimapComponent.MiniCam.Mount(this, "", false);
            _minimapComponent.MiniCam.TrackMountRotation = false;
            switch (_team)
            {
                case GameManager.GameManager.Teams.Blue:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Blue;
                    break;
                case GameManager.GameManager.Teams.Red:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Red;
                    break;
                case GameManager.GameManager.Teams.Green:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Green;
                    break;
                case GameManager.GameManager.Teams.Yellow:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Yellow;
                    break;
                default:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Black;
                    break;
            }
            Components.AddComponent(_minimapComponent);
        }
コード例 #2
0
ファイル: BotAnimatedSprite.cs プロジェクト: funkjunky/Raven
        ///<summary>
        ///initialize using associated entity
        ///</summary>
        ///<param name="entity">associated entity</param>
        public void Initialize(Entity entity)
        {
            _botEntity = entity as BotEntity;

            //switch (_team)
            //{
            //    case GameManager.Teams.Blue:
            AnimationData =
                Manager.FindObject<T2DAnimationData>("microbeAnimation");
            //        break;
            //    case GameManager.Teams.Red:
            //        AnimationData =
            //            Manager.FindObject<T2DAnimationData>("microbeAnimation");
            //        break;
            //    case GameManager.Teams.Green:
            //        AnimationData =
            //            Manager.FindObject<T2DAnimationData>("microbeAnimation");
            //        break;
            //    case GameManager.Teams.Yellow:
            //        AnimationData =
            //            Manager.FindObject<T2DAnimationData>("microbeAnimation");
            //        break;
            //}

            //set the layer
            Layer = 0;
            Size = new Vector2(24, 24);

            T2DPhysicsComponent physics = new T2DPhysicsComponent();
            physics.InverseMass = 0.1f;
            Components.AddComponent(physics);

            if (null == _minimapComponent)
                return;

            _minimapComponent.MiniCam.Mount(this, "", false);
            _minimapComponent.MiniCam.TrackMountRotation = false;
            switch (_team)
            {
                case GameManager.GameManager.Teams.Blue:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Blue;
                    break;
                case GameManager.GameManager.Teams.Red:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Red;
                    break;
                case GameManager.GameManager.Teams.Green:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Green;
                    break;
                case GameManager.GameManager.Teams.Yellow:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Yellow;
                    break;
                default:
                    _minimapComponent.BorderColor =
                        MinimapComponent.BorderColors.Black;
                    break;
            }
            Components.AddComponent(_minimapComponent);
        }
コード例 #3
0
 public override void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
 {
     strength = strength * (MaxStrength - MinStrength) + MinStrength;
     if (offset.LengthSquared() < 0.0001f || physics.Immovable)
         // skip the mass route -- will work on immovable
         physics.Velocity -= direction * strength * dt;
     else
         // have to use real impulse, multiply by mass
         physics.ApplyImpulse(-direction * strength * physics.Mass * dt, offset);
 }
コード例 #4
0
 public virtual void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
 {
     strength = strength * (MaxStrength - MinStrength) + MinStrength;
     // will be modified by inverse mass (and inverse rot inertia)
     physics.ApplyImpulse(-direction * strength * dt, offset);
 }
コード例 #5
0
            public override void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
            {
                float rotStrength = strength * (MaximumRotationDrag - MinimumRotationDrag) + MinimumRotationDrag;
                strength = strength * (MaxStrength - MinStrength) + MinStrength;

                // figure velocity due to rotation
                Vector2 vel = new Vector2(-offset.Y, offset.X);
                vel *= 6.28f * physics.AngularVelocity / 360.0f;

                // add in linear velocity
                vel += physics.Velocity;

                float dot = Vector2.Dot(vel, direction);
                if (dot < 0.0f)
                    _ApplyDrag(dot * direction, physics, strength, rotStrength, offset, direction, dt);
            }
コード例 #6
0
            protected void _ApplyDrag(Vector2 vel, T2DPhysicsComponent physics, float strength, float rotStrength, Vector2 offset, Vector2 direction, float dt)
            {
                // adjust rotation velocity based on rotation drag
                if (rotStrength < 0.0f)
                    // handle case where negative force is set
                    rotStrength = 0.0f;
                if (!ConstantDrag)
                    rotStrength *= Math.Abs(physics.AngularVelocity);
                if (rotStrength > AbsoluteDragRotationCap)
                    rotStrength = AbsoluteDragFactor * AbsoluteDragRotationCap;
                rotStrength *= dt;
                if (rotStrength > Math.Abs(physics.AngularVelocity))
                    physics.AngularVelocity = 0.0f;
                else if (physics.AngularVelocity > 0.0f)
                    physics.AngularVelocity -= rotStrength;
                else
                    physics.AngularVelocity += rotStrength;

                float velLen = vel.Length();
                if (velLen > Epsilon.Value)
                    vel.Normalize();

                // adjust by velocity and update interval
                if (!ConstantDrag)
                    strength *= velLen;
                if (strength > AbsoluteDragCap)
                    strength = AbsoluteDragFactor * AbsoluteDragCap;
                strength *= dt;

                // make sure we don't overshoot
                if (strength > velLen)
                    strength = velLen;

                if (!physics.Immovable)
                    physics.ApplyImpulse(-strength * vel * physics.Mass, offset);
                else
                    physics.Velocity -= strength * vel;
            }
コード例 #7
0
            public override void UpdateForce(T2DPhysicsComponent physics, float strength, Vector2 offset, Vector2 direction, float dt)
            {
                float rotStrength = strength * (MaximumRotationDrag - MinimumRotationDrag) + MinimumRotationDrag;
                strength = strength * (MaxStrength - MinStrength) + MinStrength;

                _ApplyDrag(physics.Velocity, physics, strength, rotStrength, offset, direction, dt);
            }