コード例 #1
0
 void CalcAbroad()
 {
     for (int i = 0; i < engineModelsList.Count; i++)
     {
         EngineModel engMd = engineModelsList[i];
         if (engMd.GetX() < 0 ||
             engMd.GetY() < 0 ||
             engMd.GetX() + engMd.GetFixture().GetLength(0) > width ||
             engMd.GetY() + engMd.GetFixture().GetLength(0) > height)
         {
             engMd.OnAbroad();
         }
     }
 }
コード例 #2
0
        public void NextTick()
        {
            List <EngineModel> buf = new List <EngineModel>();

            for (int i = 0; i < engineModelsList.Count; i++)
            {
                EngineModel engMd = engineModelsList[i];
                if (!(engMd == null || engMd.IsDisposed()))
                {
                    buf.Add(engMd);
                }
            }
            engineModelsList = buf;
            CalcAbroad();
            CalcColisions();
            MoveByAcceleration();
            CallLoopEvents();
        }
コード例 #3
0
 void CalcColisions()
 {
     int[,] colisionMap = GetColisionMap();
     for (int i = 0; i < engineModelsList.Count; i++)
     {
         EngineModel engMd        = engineModelsList[i];
         bool        haveColision = CheckColision(
             colisionMap,
             engMd.GetFixture(),
             (int)engMd.GetX(),
             (int)engMd.GetY()
             );
         if (haveColision)
         {
             engMd.OnColision();
         }
     }
 }
コード例 #4
0
 public char[,] GetRendered()
 {
     char[,] renderMap = new char[width, height];
     for (int i = 0; i < renderMap.GetLength(0); i++)
     {
         for (int j = 0; j < renderMap.GetLength(1); j++)
         {
             renderMap[i, j] = ' ';
         }
     }
     for (int i = 0; i < engineModelsList.Count; i++)
     {
         EngineModel engMd = engineModelsList[i];
         ImposeTexture(
             renderMap,
             engMd.GetTexture(),
             (int)engMd.GetX(),
             (int)engMd.GetY()
             );
     }
     return(renderMap);
 }
コード例 #5
0
        public int[,] GetColisionMap()
        {
            int[,] colisionMap = new int[width, height];
            for (int i = 0; i < colisionMap.GetLength(0); i++)
            {
                for (int j = 0; j < colisionMap.GetLength(1); j++)
                {
                    colisionMap[i, j] = 0;
                }
            }

            for (int i = 0; i < engineModelsList.Count; i++)
            {
                EngineModel engMd = engineModelsList[i];
                ImposeFixture(
                    colisionMap,
                    engMd.GetFixture(),
                    (int)engMd.GetX(),
                    (int)engMd.GetY()
                    );
            }
            return(colisionMap);
        }
コード例 #6
0
        void MoveByAcceleration()
        {
            for (int i = 0; i < engineModelsList.Count; i++)
            {
                EngineModel  engMd = engineModelsList[i];
                Acceleration ac    = engMd?.GetAcceleration();
                if (ac == null)
                {
                    continue;
                }
                double xModification = 0, yModification = 0;
                double distance = speedModificator * ac.Speed;
                switch (ac.MoveDirection)
                {
                case MoveDirection.up:
                    yModification -= distance;
                    break;

                case MoveDirection.down:
                    yModification += distance;
                    break;

                case MoveDirection.left:
                    xModification -= distance;
                    break;

                case MoveDirection.right:
                    xModification += distance;
                    break;
                }
                engMd.SetPosition(
                    engMd.GetX() + xModification,
                    engMd.GetY() + yModification
                    );
            }
        }
コード例 #7
0
 public void AddEngineModel(EngineModel engineModel)
 {
     engineModelsList.Add(engineModel);
 }