Ejemplo n.º 1
0
        public void Initialise(Tile sideA, Direction wallLocation, Tile sideB)
        {
            this.wallLocation = wallLocation;
            this.sideA = sideA;
            this.sideB = sideB;
            makesVisible = new List<Room>();

            // Get correct image files for door, due to the wall it is located on.
            switch(wallLocation)
            {
                case Direction.North:
                    this.imageRefSideA = "door_n_closed";
                    this.imageRefSideB = "door_s_back";
                    break;
                case Direction.East:
                    this.imageRefSideA = "door_e_closed";
                    this.imageRefSideB = "door_w_back";
                    break;
                case Direction.South:
                    this.imageRefSideA = "door_s_closed";
                    this.imageRefSideB = "door_n_back";
                    break;
                case Direction.West:
                    this.imageRefSideA = "door_w_closed";
                    this.imageRefSideB = "door_e_back";
                    break;
            }

            // Update Tile adjacencies to reference Door.
            sideA.adjacencies[wallLocation] = this;
            sideB.adjacencies[Opposite(wallLocation)] = this;
        }
Ejemplo n.º 2
0
        public void Initialse(Tile sideA, Direction wallLocation, Tile sideB)
        {
            this.sideA = sideA;
            this.sideB = sideB;
            this.wallLocation = wallLocation;

            // Update Tile adjacencies to reference TileConnector.
            sideA.adjacencies[wallLocation] = this;
            sideB.adjacencies[Opposite(wallLocation)] = this;
        }
Ejemplo n.º 3
0
 public Character(Tile location, Direction facing, int ws, int bs, int s, int t, int w)
 {
     this.location = location;
     this.facing = facing;
     this.stats.Add(Stats.WS, ws);
     this.stats.Add(Stats.BS, bs);
     this.stats.Add(Stats.S, s);
     this.stats.Add(Stats.T, t);
     this.stats.Add(Stats.W, w);
     this.damageTaken = 0;
 }
Ejemplo n.º 4
0
        void SpellExplodeButtonClick(object sender, EventArgs e)
        {
            // Only cast spell if wizard has some spell uses left!
            // TODO make this a high strength attack.

            if((activeHero as Wizard).spellExplodeRemaining != 0)
                {

                // See if there is an adjacent Tile in activeHero.facing direction, next to activeHero.location
                //   if (adjacent = null), fail shot
                //	 if (adjacent != null) see who is in location
                //   	if(nobody) continue shot
                //		if baddie, add to hit list
                //		add any other adjacent baddies to hit list
                //		resolve damage on hit list characters
                //	TODO when Heroes are damageable, add Heroes to hit list
                //	TODO add diagonals

                shotLocation = activeHero.location;
                Boolean shotOver = false;
                activeBaddie = null;
                shotVictim = null;
                everybody = heroes.Concat(visibleBaddies);
                spellVictims = new List<Baddie>();

                // Shoot in straight line until hit wall or other Character. If Character encountered, decide outcome based on Type.

                while (!shotOver){
                    if(shotLocation.Adjacent(activeHero.facing) == null) shotOver = true;
                    else
                    {
                        shotLocation = shotLocation.Adjacent(activeHero.facing);
                        foreach(Character potentialVictim in everybody)
                        {
                            if(potentialVictim.location == shotLocation)
                            {
                                shotVictim = potentialVictim;
                                shotOver = true;
                                break;
                            }
                        }
                        // Draw a square round the location to show it is the shot path, and add to redraw list
                        g.DrawImage((Bitmap) resources.GetObject("square_blue"),
                                new Rectangle((shotLocation.tileLocation.X*scale)+origin.X, (shotLocation.tileLocation.Y*scale)+origin.Y, scale, scale));
                        tilesForRedraw.Add(shotLocation);
                    }
                }

                // If there is a shotVictim, check its type. If it is a Baddie, add it to hitlist! If it is a Hero, shot does nothing.
                if(shotVictim != null)
                {
                    if (shotVictim is Baddie)
                    {
                        spellVictims.Add((Baddie) shotVictim);
                        // Get adjacent baddies (if any)

                        if(shotVictim.location.Adjacent(Direction.North) != null)
                        {
                            foreach(Character potentialVictim in everybody)
                            {
                                if(potentialVictim.location == shotVictim.location.Adjacent(Direction.North))
                                {
                                    if (potentialVictim is Baddie)
                                    {
                                        spellVictims.Add((Baddie) potentialVictim);
                                    }
                                }
                            }
                        }
                        if(shotVictim.location.Adjacent(Direction.East) != null)
                        {
                            foreach(Character potentialVictim in everybody)
                            {
                                if(potentialVictim.location == shotVictim.location.Adjacent(Direction.East))
                                {
                                    if (potentialVictim is Baddie)
                                    {
                                        spellVictims.Add((Baddie) potentialVictim);
                                    }
                                }
                            }
                        }
                        if(shotVictim.location.Adjacent(Direction.South) != null)
                        {
                            foreach(Character potentialVictim in everybody)
                            {
                                if(potentialVictim.location == shotVictim.location.Adjacent(Direction.South))
                                {
                                    if (potentialVictim is Baddie)
                                    {
                                        spellVictims.Add((Baddie) potentialVictim);
                                    }
                                }
                            }
                        }
                        if(shotVictim.location.Adjacent(Direction.West) != null)
                        {
                            foreach(Character potentialVictim in everybody)
                            {
                                if(potentialVictim.location == shotVictim.location.Adjacent(Direction.West))
                                {
                                    if (potentialVictim is Baddie)
                                    {
                                        spellVictims.Add((Baddie) potentialVictim);
                                    }
                                }
                            }
                        }

                        // Hit all baddies in spellVictims list!
                        foreach(Baddie victim in spellVictims)
                            {
                                activeBaddie = victim;
                                charactersForRedraw.Add(shotVictim);
                                HitBaddie();
                            }
                    }
                    else
                    {
                        // shotVictim is a Hero, so add to redraw list.
                        charactersForRedraw.Add(shotVictim);
                        FailShot();
                    }
                }
                else FailShot();

                // Deplete wizard remaining uses and update spell action button if appropriate.
                (activeHero as Wizard).spellExplodeRemaining--;
                if((activeHero as Wizard).spellExplodeRemaining == 0)
                {
                    spellExplodeButton.Image = Dungeons.Images.spell_explode_used;
                    DrawActionButtons();
                }
            }
        }
Ejemplo n.º 5
0
        void RangedCombatButtonClick(object sender, EventArgs e)
        {
            // See if there is an adjacent Tile in activeHero.facing direction, next to activeHero.location
            //   if (adjacent = null), fail shot
            //	 if (adjacent != null) see who is in location
            //   	if(nobody) continue shot
            //		if baddie, kill it
            //		if hero, fail shot

            shotLocation = activeHero.location;
            Boolean shotOver = false;
            activeBaddie = null;
            shotVictim = null;
            everybody = heroes.Concat(visibleBaddies);

            // Shoot in straight line until hit wall or other Character. If Character encountered, decide outcome based on Type.

            while (!shotOver){
                if(shotLocation.Adjacent(activeHero.facing) == null) shotOver = true;
                else
                {
                    shotLocation = shotLocation.Adjacent(activeHero.facing);
                    foreach(Character potentialVictim in everybody)
                    {
                        if(potentialVictim.location == shotLocation)
                        {
                            shotVictim = potentialVictim;
                            shotOver = true;
                            break;
                        }
                    }
                    // Draw a square round the location to show it is the shot path, and add to redraw list
                    g.DrawImage((Bitmap) resources.GetObject("square_blue"),
                            new Rectangle((shotLocation.tileLocation.X*scale)+origin.X, (shotLocation.tileLocation.Y*scale)+origin.Y, scale, scale));
                    tilesForRedraw.Add(shotLocation);
                }
            }

            // If there is a shotVictim, check its type. If it is a Baddie, kill it! If it is a Hero, shot does nothing.
            if(shotVictim != null)
            {
                if (shotVictim.GetType() != activeHero.GetType())
                {
                    activeBaddie = (Baddie) shotVictim;
                    HitBaddie();
                }
                else
                {
                    // shotVictim is a Hero, so add to redraw list.
                    charactersForRedraw.Add(shotVictim);
                    FailShot();
                }
            }
            else FailShot();
        }
Ejemplo n.º 6
0
 public Tile OtherSide(Tile viewer)
 {
     if (viewer == sideA) return sideB;
     else return sideA;
 }
Ejemplo n.º 7
0
 public Wizard(Tile location, Direction facing, int ws, int bs, int s, int t, int w, HeroType type)
     : base(location, facing, ws, bs, s, t, w, type)
 {
     this.spellAffectAllRemaining = 2;
     this.spellExplodeRemaining = 2;
 }
Ejemplo n.º 8
0
 public Hero(Tile location, Direction facing, int ws, int bs, int s, int t, int w, HeroType type)
     : base(location, facing, ws, bs, s, t, w)
 {
     this.type = type;
     UpdateImageRef();
 }
Ejemplo n.º 9
0
 public void MoveTo(Tile location)
 {
     // N.B. Does not have to be adjacent to current location!
     this.location = location;
 }
Ejemplo n.º 10
0
 public Baddie(Tile location, Direction facing, int ws, int bs, int s, int t, int w)
     : base(location, facing, ws, bs, s, t, w)
 {
     this.imageRef = "baddie";
 }