Exemple #1
0
 public Human(HumanType HumanType, Vec2 Position, Vec2 Node)
 {
     this.HumanType = HumanType;
     this.Position = Position;
     this.Node = Node;
     this.MovementBehaviour = new UsualMovementBehaviour();
     this.DecisionBehaviour = new UsualDecisionBehaviour();
 }
Exemple #2
0
        public List<Human> GetNearestNeighbour(Vec2 FieldIndex, Vec2 Position)
        {
            int[,] leftUp = {{0, -1}, {-1, -1}, {-1, 0}};
            int[,] leftDown = {{-1, 0}, {-1, 1}, {0, 1}};
            int[,] rightUp = {{0, -1}, {1, -1}, {1, 0}};
            int[,] rightDown = {{1, 0}, {1, 1}, {0, 1}};

            var leftRight = 0;
            var upDown = 0;

            var neighbour = new List<Human>();

            if((Position.Xi % this.xTile) > (this.xTile / 2))
            {
                leftRight = 1;
            }

            if ((Position.Yi % this.yTile) > (this.yTile / 2))
            {
                upDown = 1;
            }

            switch (leftRight)
            {
                case 0:
                {
                    switch (upDown)
                    {
                        case 0:
                        {
                            neighbour.AddRange(this.GetFields(FieldIndex, leftUp));
                        } break;

                        case 1:
                        {
                            neighbour.AddRange(this.GetFields(FieldIndex, leftDown));
                        } break;
                    }
                }break;

                case 1:
                {
                    switch (upDown)
                    {
                        case 0:
                        {
                            neighbour.AddRange(this.GetFields(FieldIndex, rightUp));
                        } break;

                        case 1:
                        {
                            neighbour.AddRange(this.GetFields(FieldIndex, rightDown));
                        } break;
                    }
                }break;
            }

            neighbour.AddRange(this.humans[FieldIndex.Xi, FieldIndex.Yi]);

            return neighbour;
        }
Exemple #3
0
        private IEnumerable<Human> GetFields(Vec2 Field, int[,] Offsets)
        {
            var neightbour = new List<Human>();

            for (int i = 0; i < (Offsets.GetLength(0) - 1); i++)
            {
                int x = Field.Xi + Offsets[i, 0];
                int y = Field.Yi + Offsets[i, 1];

                if (!(x >= 0 && x < XFields))
                {
                    continue;
                }

                if (!(y >= 0 && y < YFields))
                {
                    continue;
                }

                neightbour.AddRange(this.humans[x, y]);
            }

            return neightbour;
        }
Exemple #4
0
 public static float Dot(Vec2 a, Vec2 b)
 {
     return a.X * b.X + a.Y * b.y;
 }