Exemple #1
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();
                }
            }
        }
Exemple #2
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();
        }
Exemple #3
0
        void SpellAffectAllButtonClick(object sender, EventArgs e)
        {
            // Only cast spell if wizard has some spell uses left!
            // TODO make this a low-mid strength attack.

            if((activeHero as Wizard).spellAffectAllRemaining != 0)
            {
                // Find Room wizard is in.
                Room affected = null;

                foreach (Room potentialRoom in board.rooms)
                {
                    foreach(Tile potentialTile in potentialRoom.tiles)
                    {
                        if(activeHero.location == potentialTile)
                        {
                            affected = potentialRoom;
                        }
                    }
                }

                // Make list of affeted Baddies.
                List<Baddie> hitBySpell = new List<Baddie>();

                // Populate list with baddies affected i.e. the ones in the same room as the wizard.
                foreach (Baddie baddie in visibleBaddies)
                {
                    foreach(Tile potentialTile in affected.tiles)
                    {
                        if(baddie.location == potentialTile)
                        {
                            hitBySpell.Add(baddie);
                        }
                    }
                }

                // Apply spell affect to each baddie in list.
                foreach (Baddie baddie in hitBySpell)
                {
                    activeBaddie = baddie;
                    tilesForRedraw.Add(activeBaddie.location);
                    charactersForRedraw.Add(activeBaddie);
                    HitBaddie();
                }

                // Clear affected list.
                hitBySpell.Clear();

                // Deplete wizard remaining uses and update spell action button if appropriate.
                (activeHero as Wizard).spellAffectAllRemaining--;
                if((activeHero as Wizard).spellAffectAllRemaining == 0)
                {
                    spellAffectAllButton.Image = Dungeons.Images.spell_affectAll_used;
                    DrawActionButtons();
                }
            }
        }
Exemple #4
0
        void FightButtonClick(object sender, System.EventArgs e)
        {
            controlsGroupBox.Enabled = false;

            // Find if there is a baddie adjacent to activeHero, and if so set activeBaddie to it.
            activeBaddie = null;
            Tile attackLocation = null;

            // If there is an adjacent Tile set attackLocation to it.
            switch(activeHero.facing){
                case Direction.North: if(activeHero.location.Adjacent(Direction.North) != null){
                        attackLocation = activeHero.location.Adjacent(Direction.North);
                    } break;
                case Direction.East : if(activeHero.location.Adjacent(Direction.East) != null){
                        attackLocation = activeHero.location.Adjacent(Direction.East);
                    } break;
                case Direction.South : if(activeHero.location.Adjacent(Direction.South) != null){
                        attackLocation = activeHero.location.Adjacent(Direction.South);
                    } break;
                case Direction.West : if(activeHero.location.Adjacent(Direction.West) != null){
                        attackLocation = activeHero.location.Adjacent(Direction.West);
                    } break;
            }

            // If attackLocation exists see who is in it. If nobody, fight is over.
            if (attackLocation !=null){
                foreach (Baddie baddie in visibleBaddies){
                    if(baddie.location == attackLocation){
                        activeBaddie = baddie;
                        break;
                    }
                }
            } else failedFightButton.Visible = true;

            // If there is a baddie infront of activeHero, kill it
            if (activeBaddie !=null) HitBaddie();
            else failedFightButton.Visible = true;
        }