예제 #1
0
파일: XAMLEntity.cs 프로젝트: JJOL/xgame
 public bool intersect(XAMLEntity other)
 {
     // Do AABB box intersection
     return(pX < (other.pX + other.size) &&
            (pX + size) > other.pX &&
            pY < (other.pY + other.size) &&
            (pY + size) > other.pY);
 }
예제 #2
0
        public void spawnEnemy(XAMLEntity player, float gameWidth, float gameHeight)
        {
            Random r = new Random();

            foreach (var e in enemies)
            {
                if (!enemySpawnMap[e])
                {
                    float nx, ny;
                    do
                    {
                        nx = (float)(r.NextDouble() * (gameWidth - 30));
                        ny = (float)(r.NextDouble() * (gameHeight - 30));
                    } while (dist(nx, ny, player.pX, player.pY) < 50);

                    e.pX             = nx;
                    e.pY             = ny;
                    enemySpawnMap[e] = true;

                    break;
                }
            }
        }
예제 #3
0
        public MainPage()
        {
            InitializeComponent();

            // Calculate Canvas Width and Height

            // Setup Enemy Spawners
            player  = new XAMLEntity(PlayerBox, 30, 50, 50);
            spawner = new EnemySpawner(new View[] { EnemyBox1, EnemyBox2, EnemyBox3, EnemyBox4, EnemyBox5 });

            // Mount Spawning Thread
            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    await Task.Delay(3000);
                    MainThread.BeginInvokeOnMainThread(() =>
                    {
                        spawner.spawnEnemy(player, gameWidth, gameHeight);
                    });
                }
            });
        }
예제 #4
0
 public void despawn(XAMLEntity enemy)
 {
     enemy.pX             = -100;
     enemy.pY             = -100;
     enemySpawnMap[enemy] = false;
 }