コード例 #1
0
    public void FillField()
    {
        field[FieldWidth / 2, FieldHeight / 2] = new PacmanHero(field);
        field[0, 0] = new Ghost(field);
        field[FieldWidth - 1, FieldHeight - 1] = new SmartGhost(field);
        int wallToCreate = FieldHeight * FieldWidth / 10;

        System.Random rnd = new System.Random();
        while (wallToCreate > 0)
        {
            int x = rnd.Next(0, FieldWidth);
            int y = rnd.Next(0, FieldHeight);
            if (field[x, y] == null)
            {
                field[x, y] = new Wall(field);
                --wallToCreate;
            }
        }
        for (int x = 0; x < FieldWidth; ++x)
        {
            for (int y = 0; y < FieldHeight; ++y)
            {
                if (field[x, y] == null)
                {
                    field[x, y] = new Berry(field);
                }
            }
        }
    }
コード例 #2
0
        public override void Init()
        {
            base.Init();

            this.NumLives = this.Scenario.MaxLives;

            //creates ghost elements
            this.SmartGhost = new SmartGhost
            {
                IdToken                = GHOST_ID,
                Description            = GHOST_ID,
                Visible                = true,
                Walkable               = true,
                HasSmell               = true,
                ImagePath              = GHOST1_IMG_PATH,
                WeakenedGhostImagePath = WEAKENED_GHOST_IMG_PATH,
                State = GhostState.Normal,
                Color = System.Drawing.Color.FromArgb(255, 0, 0).ToColorInfo()
            };

            this.KeeperGhost = new KeeperGhost(this.SmartGhost)
            {
                IdToken                = GHOST_ID,
                Description            = GHOST_ID,
                Visible                = true,
                Walkable               = true,
                HasSmell               = true,
                ImagePath              = GHOST2_IMG_PATH,
                WeakenedGhostImagePath = WEAKENED_GHOST_IMG_PATH,
                State = GhostState.Normal,
                Color = System.Drawing.Color.FromArgb(0, 0, 255).ToColorInfo()
            };

            //creates big dot element
            this.BigDot = new CellElement
            {
                IdToken     = BIG_DOT_ID,
                Description = BIG_DOT_ID,
                Visible     = true,
                Walkable    = true,
                HasSmell    = true,
                ImagePath   = BIG_DOT_IMG_PATH,
                Color       = System.Drawing.Color.FromArgb(255, 255, 102).ToColorInfo()
            };

            this.InitDots();
            this.InitDoors();
        }