示例#1
0
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            if (m_done)
            {
                return;
            }
            SimObject me   = dmView.AllObjects[m_thisID];
            SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation   = me.Location;
            LocationValue destLocation = dest.Location;
            VelocityValue myVelocity   = me.Velocity;


            if (ObjectMath.IsWithinRange(0.1, myLocation, destLocation))
            {
                m_done = true;
                return;
            }

            if (myVelocity.VX == 0 && myVelocity.VY == 0 && myVelocity.VZ == 0)
            {
                serverConnection.SendMoveObjectRequest(m_thisID, destLocation, 1);
            }
        }
示例#2
0
文件: Vec2D.cs 项目: xiangnanyue/DDD
        public VelocityValue ToVelocityValue()
        {
            VelocityValue v = new VelocityValue();

            v.VX = X;
            v.VY = Y;
            v.VZ = 0;
            return(v);
        }
示例#3
0
文件: Snake.cs 项目: ValerCheck/Snaky
        public Velocity(int hVelocity, int vVelocity) : this()
        {
            if (hVelocity == vVelocity && hVelocity != 0 && vVelocity != 0)
            {
                throw new ArgumentException("Horizontal and Vertical velocities cannot be the same");
            }

            Vertical   = (VelocityValue)vVelocity;
            Horizontal = (VelocityValue)hVelocity;
        }
示例#4
0
 /// <summary>
 /// The constructor for the SimObject.
 /// </summary>
 /// <param name="id"></param>
 public SimObject(String id)
 {
     m_id                = id;
     m_velocity          = new VelocityValue();
     m_location          = new LocationValue();
     m_destination       = new LocationValue();
     m_vulnerabilityList = new List <string>();
     m_capabilityList    = new List <string>();
     m_dockedObjects     = new List <string>();
     m_dockedWeapons     = new List <string>();
     m_childObjects      = new List <string>();
     m_agent             = new ObjectControlAgent();
     m_agent.simObject   = this;
     m_inActiveRegions   = new List <string>();
 }
示例#5
0
 static public bool VelocityIsEqual(VelocityValue vel1, VelocityValue vel2, Double threshhold)
 {
     if (Math.Abs(vel1.VX - vel2.VX) > threshhold)
     {
         return(false);
     }
     else if (Math.Abs(vel1.VY - vel2.VY) > threshhold)
     {
         return(false);
     }
     else if (Math.Abs(vel1.VZ - vel2.VZ) > threshhold)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#6
0
文件: Snake.cs 项目: ValerCheck/Snaky
        private void ChangeDirection(Direction dir, VelocityValue val)
        {
            if (dir == Direction.Horizontal)
            {
                if ((int)_velocity.Horizontal + (int)val == 0)
                {
                    throw new ArgumentException("Velocity cannot be changed with opposite value");
                }

                _velocity.Horizontal = val;
            }
            else if (dir == Direction.Vertical)
            {
                if ((int)_velocity.Vertical + (int)val == 0)
                {
                    throw new ArgumentException("Velocity cannot be changed with opposite value");
                }
                _velocity.Vertical = val;
            }
        }
        public void Update(DDDServerConnection serverConnection, DMView dmView)
        {
            //Console.Out.WriteLine(String.Format("MoveWithAvoidanceBehavior.Update() {0}", m_thisID));
            if (m_done)
            {
                return;
            }
            SimObject me = dmView.AllObjects[m_thisID];
            //SimObject dest = dmView.AllObjects[m_destID];

            LocationValue myLocation = me.Location;

            VelocityValue myVelocity = me.Velocity;


            if (ObjectMath.IsWithinRange(0.1, myLocation, m_destLocation))
            {
                m_done = true;
                return;
            }

            if (!IsBlocked2())
            {
                if (m_wasBlocked)
                {
                    m_wasBlocked = false;
                    serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, m_destLocation, m_throttle);
                }
                else if (myVelocity.VX == 0 && myVelocity.VY == 0 && myVelocity.VZ == 0)
                {
                    serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, m_destLocation, m_throttle);
                }
            }
            else
            {
                m_wasBlocked = true;
                serverConnection.SendMoveObjectRequest(m_thisID, me.Owner, myLocation, 0);
            }
        }
示例#8
0
        private static SimulationEvent populateQueue3()
        {
            SimulationEvent ee = new SimulationEvent();
            Dictionary <string, DataValue> myAtt = new Dictionary <string, DataValue>();

            ee.eventType = "NewObject";
            DataValue myDV = new StringValue();

            ((StringValue)(myDV)).value = "PhysicalObject";
            ee.parameters.Add("ObjectType", myDV);


            // START OF ATTRIBUTE DEFINITIONS //
            myDV = new IntegerValue();
            ((IntegerValue)(myDV)).value = 1;
            myAtt.Add("ID", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "Second Object";
            myAtt.Add("ObjectName", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "flying";
            myAtt.Add("ObjectState", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "NoClassesYet";
            myAtt.Add("ClassName", myDV);

            myDV = new LocationValue();
            ((LocationValue)(myDV)).X = 100;
            ((LocationValue)(myDV)).Y = 100;
            ((LocationValue)(myDV)).Z = 0;
            myAtt.Add("Location", myDV);

            myDV = new VelocityValue();
            ((VelocityValue)(myDV)).VX = 0;
            ((VelocityValue)(myDV)).VY = 0;
            ((VelocityValue)(myDV)).VZ = 0;
            myAtt.Add("Velocity", myDV);

            myDV = new DoubleValue();
            ((DoubleValue)(myDV)).value = 1;
            myAtt.Add("MaximumSpeed", myDV);

            myDV = new DoubleValue();
            ((DoubleValue)(myDV)).value = 0.0;
            myAtt.Add("Throttle", myDV);

            myDV = new LocationValue();
            ((LocationValue)(myDV)).X = 0;
            ((LocationValue)(myDV)).Y = 0;
            ((LocationValue)(myDV)).Z = 0;
            myAtt.Add("DestinationLocation", myDV);

            // END OF ATTRIBUTE DEFINITIONS //

            myDV = new AttributeCollectionValue();
            ((AttributeCollectionValue)(myDV)).attributes = myAtt;
            ee.parameters.Add("Attributes", myDV);

            myDV = new IntegerValue();
            ((IntegerValue)(myDV)).value = 5000;
            ee.parameters.Add("Time", myDV);

            return(ee);
        }
示例#9
0
文件: Vec2D.cs 项目: xiangnanyue/DDD
 public void Set(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
 }
示例#10
0
文件: Vec2D.cs 项目: xiangnanyue/DDD
 public Vec2D(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
 }
示例#11
0
 static public bool VelocityIsEqual(VelocityValue vel1, VelocityValue vel2)
 {
     return(VelocityIsEqual(vel1, vel2, 0.1));
 }
示例#12
0
 public Vec3D(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
     Z = v.VZ;
 }