Server.GameObject.calculateGravity C# (CSharp) Méthode

calculateGravity() public méthode

calculateGravity() modifies acceleration rates of game objects based on gravity effect
public calculateGravity ( ) : void
Résultat void
        public virtual void calculateGravity()
        {
            List<GameObject> objectsG = new List<GameObject>(); //MatchConfig.getGravityObjects();
            float G = MatchConfig.gravityConstant;

            foreach (GameObject ob in objectsG)
            {
                if(!ob.Equals(this))
                {
                    double distance = Math.Sqrt((Math.Pow(this.x - ob.x, 2) + Math.Pow(this.y - ob.y, 2)));
                    double speedVector = (float)((G * ob.mass) / Math.Pow(distance, 2));
                    double deltaY = (this.y - ob.y);
                    double deltaX = (this.x - ob.x);
                    double angleDegree = Math.Atan(deltaY / deltaX);// * 180 / Math.PI;
                    //float rad = (float)(Math.PI / 180) * o.angle;
                    if (this.x != ob.x)
                    {
                        //speedX += (float)(Math.Cos(angleDegree) * speedVector);
                        if (this.x > ob.x)
                            speedX -= (float)Math.Abs((Math.Cos(angleDegree) * speedVector));
                        else
                            speedX += (float)Math.Abs((Math.Cos(angleDegree) * speedVector));
                    }
                    if (this.y != ob.y)
                    {
                        //speedY += (float)(Math.Sin(angleDegree) * speedVector);
                        if (this.y < ob.y)
                            speedY += (float)Math.Abs((Math.Sin(angleDegree) * speedVector));
                        else
                            speedY -= (float)Math.Abs((Math.Sin(angleDegree) * speedVector));
                    }
                }
            }
        }