Beispiel #1
0
        public void GivePassivesPositions()
        {
            if (PassiveNPCs.GetType() != null)
            {
                for (int i = 0; i < PassiveNPCs.Count; i++)
                {
                    bool passable = false;
                    bool occupied = false;

                    do
                    {
                        int sampleX = Gamestate.RandObj.Next(0, C.TilesPerRow);
                        int sampleY = Gamestate.RandObj.Next(0, C.TilesPerRow);

                        if (MapGrid[sampleX, sampleY].Passable == true)
                        {
                            if (MapGrid[sampleX, sampleY].ID != 3 && MapGrid[sampleX, sampleY].ID != 4)
                            {
                                if (i == 0)
                                {
                                    PassivePosX.Add(sampleX);
                                    PassivePosY.Add(sampleY);
                                    passable = true;
                                }
                                else
                                {
                                    for (int e = 0; e < EnemyPosX.Count; e++)
                                    {
                                        if (EnemyPosX[e] == sampleX && EnemyPosY[e] == sampleY)
                                        {
                                            occupied = true;
                                        }
                                    }

                                    if (occupied == false)
                                    {
                                        PassivePosX.Add(sampleX);
                                        PassivePosY.Add(sampleY);
                                        passable = true;
                                    }

                                    occupied = false;
                                }
                            }
                        }
                    } while (passable == false);
                }
            }
        }
Beispiel #2
0
        public bool IsPassiveThere(int x, int y)
        {
            bool isOccupied = false;

            if (PassiveNPCs.GetType() != null)
            {
                for (int i = 0; i < PassiveNPCs.Count; i++)
                {
                    if (PassivePosX[i] == x && PassivePosY[i] == y)
                    {
                        isOccupied = true;
                    }
                }
            }

            return(isOccupied);
        }