Beispiel #1
0
        public void Get(ICreature getter)
        {
            _getStrategy.Get(this, _world, getter);

            if (GotItem != null)
                GotItem(this, getter);
        }
 public Arena(string name, FightRules fightRules, IHero hero, ICreature creature)
     : base(name)
 {
     this.fightRules = fightRules;
     this.creature = creature;
     this.hero = hero;
 }
 public void Use(IItem item, World world, ICreature user)
 {
     Announcer.Instance.Announce(user.Name + " feels different. ", MessageTypes.Other);
     Announcer.Instance.Announce(user.Name + " is under the affect of " + _effect.Name + "!", MessageTypes.Other);
     user.AddTemporaryEffect(_effect);
     user.Inventory.Remove(item);
 }
        public void TakeTurn(ICreature creature, World world)
        {
            _countdownToNextTurn -= 1;
            if (_countdownToNextTurn <= 0)
            {
                _countdownToNextTurn = _speed;
                bool turnOver = false;

                if (world.CanPlayerSeeWorldIndex(creature.WorldIndex) && RandomNumberProvider.CheckIfChanceOccurs(25) && world.GetStraightLineDistance(creature.WorldIndex, world.Player.WorldIndex) <= 5)
                {
                    _spell.CastSpell(creature, world.Player.WorldIndex);
                }
                else
                {
                    while (turnOver != true)
                    {
                        int roll = RandomNumberProvider.GetRandomNumber(1, 4);
                        if (roll == 1)
                            turnOver = world.MoveCreatureInDirectionSuccessful(Direction.North, creature);
                        else if (roll == 2)
                            turnOver = world.MoveCreatureInDirectionSuccessful(Direction.South, creature);
                        else if (roll == 3)
                            turnOver = world.MoveCreatureInDirectionSuccessful(Direction.East, creature);
                        else if (roll == 4)
                            turnOver = world.MoveCreatureInDirectionSuccessful(Direction.West, creature);
                    }
                }
            }
        }
 public KillCreatureStrategy(ICreature target)
 {
     _targetKilled = false;
     _targetSpotted = false;
     _target = target;
     target.Death += new CreatureEvent(target_Death);
 }
 public void EffectCompleted(ICreature creature, World world)
 {
     creature.MovementType = _creaturesOriginalMovementType;
     Announcer.Instance.Announce(creature.Name + "'s movement returned to normal.", MessageTypes.Other);
     if (Completed != null)
         Completed(this);
 }
        public void Get(IItem item, World world, ICreature getter)
        {
            Announcer.Instance.Announce(getter.Name + " feels different. ", MessageTypes.Other);
            Announcer.Instance.Announce(getter.Name + " is under the affect of " + _effect.Name + "!", MessageTypes.Other);
            getter.AddTemporaryEffect(_effect);

            _standardGet.Get(item, world, getter);
        }
 public void Use(IItem item, World world, ICreature user)
 {
     if (item.ItemCategory == ItemCategories.Weapon)
     {
         user.Weapon = (IWeapon)item;
         Announcer.Instance.Announce(user.Name + " is now using " + item.Name + ".", MessageTypes.GetItem);
     }
 }
Beispiel #9
0
 public void CollectPony(ICreature pony)
 {
     Fermer.Ponies.Remove(pony);
     if (Fermer.Ponies.Count == 0) {
         GameStarted = false;
         DestroyObjects();
         Time.timeScale = 0;// pause game
     }
 }
 public void TakeTurn(ICreature creature, World world)
 {
     List<Vector2> surroungingPoints = world.GetSurroundingWorldIndexPositions(creature.WorldIndex);
     if(surroungingPoints.Contains(world.Player.WorldIndex))
     {
         ICreature target = world.Player;
         creature.AttackCreature(ref target);
     }
 }
        public void Draw(GameTime gameTime, ICreature creature, World world)
        {
            if (world.PlayerCanSeeWorldIndex(creature.WorldIndex))
            {
                Vector2 worldPosition = world.ConvertTileIndexToWorldPosition(creature.WorldIndex.X, creature.WorldIndex.Y);
                Vector2 screenPosition = Camera.GetScreenPosition(worldPosition);

                GraphicsHelper.spriteBatch.Draw(_image, screenPosition, null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0.7f);
            }
        }
 public void Give(IItem item, World world, ICreature giver)
 {
     for (int i = giver.TemporaryEffects.Count - 1; i >= 0; i--)
         if (giver.TemporaryEffects[i].Id == _id)
         {
             giver.TemporaryEffects[i].TurnsRemaining = 0;
             break;
         }
     _standardGive.Give(item, world, giver);
 }
Beispiel #13
0
 public bool CastSpell(ICreature caster, Vector2 targetWorldIndex)
 {
     if (caster.Mana.Current - ManaCost < 0)
     {
         Announcer.Instance.Announce("Not enough mana to cast " + Name + ".", MessageTypes.Spell);
         return false;
     }
     else
     {
         Announcer.Instance.Announce(caster.Name + " casts " + Name + ".", MessageTypes.Spell);
         caster.Mana.Current -= ManaCost;
         return _castStrategy.CastSpell(caster, targetWorldIndex, AffectedArea, _world);
     }
 }
Beispiel #14
0
 public GameCreature(ICreature c)
 {
     creature = c;
     foreach(string s in c.getTypes())
     {
         if(s.ToLower() == "hostile")
         {
             bIsHostile = true;
         }
     }
     health = ((StoryGenerationClass.Instance.getRandomNumber(creature.getValue()) + 1) * creature.getValue());
     attackDamage = StoryGenerationClass.Instance.getRandomNumber(creature.getValue()) + creature.getValue() / 2;
     defence = creature.getValue();
 }
Beispiel #15
0
        public void AddCreaturesToMap(IMap map, IDictionary <CreatureTypes, int> creatureTypeAndTotalAmountGenerated)
        {
            CreatureGenerator creatureGenerator = new CreatureGenerator();

            foreach (KeyValuePair <CreatureTypes, int> creatureTypeAndGeneratedAmount in creatureTypeAndTotalAmountGenerated)
            {
                ITile[] validCreatureTiles = GetValidCreatureTypes(map, creatureTypeAndGeneratedAmount.Key);
                for (int generatedCreatures = 0; generatedCreatures < creatureTypeAndGeneratedAmount.Value; ++generatedCreatures)
                {
                    ITile     tile     = validCreatureTiles[rand.Next(0, validCreatureTiles.Length)];
                    ICreature creature = creatureGenerator.GenerateCreature(creatureTypeAndGeneratedAmount.Key);
                    tile.CreatureList.Add(creature);
                }
            }
        }
        public void Use(IItem item, World world, ICreature user)
        {
            if (user.Health.Current + _healthToRecover >= user.Health.Maximum)
            {
                user.Health.Current = user.Health.Maximum;
                Announcer.Instance.Announce(user.Name + " returned to full health!", MessageTypes.Other);
            }
            else
            {
                user.Health.Current += _healthToRecover;
                Announcer.Instance.Announce(user.Name + " recovered " + _healthToRecover + " health.", MessageTypes.Other);
            }

            user.Inventory.Remove(item);
        }
Beispiel #17
0
        public void DrawCreature(Rectangle bitmapRectangle, ICreature creature)
        {
            var graphics = Graphics.FromImage(field);

            if (creature == null)
            {
                graphics.FillRectangle(Brushes.White, bitmapRectangle);
            }
            else
            {
                var image = Image.FromFile(creature.GetFolderName() + "\\Texture.png");
                graphics.DrawImage(image, bitmapRectangle);
            }
            Invalidate();
        }
        public void Use(IItem item, World world, ICreature user)
        {
            if (user.Mana.Current + _manaToRecover >= user.Mana.Maximum)
            {
                user.Mana.Current = user.Mana.Maximum;
                Announcer.Instance.Announce(user.Name + " regained all mana!", MessageTypes.Other);
            }
            else
            {
                user.Mana.Current += _manaToRecover;
                Announcer.Instance.Announce(user.Name + " recovered " + _manaToRecover + " mana.", MessageTypes.Other);
            }

            user.Inventory.Remove(item);
        }
 public void UpdateEffect(ICreature creature, World world)
 {
     if (EffectComplete == false)
     {
         if (TurnsRemaining <= 0)
         {
             EffectCompleted(creature, world);
             EffectComplete = true;
         }
         else
         {
             TurnsRemaining -= 1;
         }
     }
 }
Beispiel #20
0
 public bool DeadInConflict(ICreature conflictedObject)
 {
     if (!(conflictedObject is Sack))
     {
         if (conflictedObject is Player)
         {
             Game.Scores += 10;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public DamageModListForm(ICreature creature)
 {
     this.InitializeComponent();
     Application.Idle += new EventHandler(this.Application_Idle);
     this.fCreature    = creature;
     this.fModifiers   = new List <DamageModifier>();
     foreach (DamageModifier damageModifier in this.fCreature.DamageModifiers)
     {
         this.fModifiers.Add(damageModifier.Copy());
     }
     this.update_damage_list();
     this.ResistBox.Text     = this.fCreature.Resist;
     this.VulnerableBox.Text = this.fCreature.Vulnerable;
     this.ImmuneBox.Text     = this.fCreature.Immune;
 }
        public void Use(IItem item, World world, ICreature user)
        {
            if (user.Health.Current + _healthToRecover >= user.Health.Maximum)
            {
                user.Health.Current = user.Health.Maximum;
                Announcer.Instance.Announce(user.Name + " returned to full health!", MessageTypes.Other);
            }
            else
            {
                user.Health.Current += _healthToRecover;
                Announcer.Instance.Announce(user.Name + " recovered " + _healthToRecover + " health.", MessageTypes.Other);
            }

            user.Inventory.Remove(item);
        }
Beispiel #23
0
        public bool DeadInConflict(ICreature conflictedObject)
        {
            var neighbor = conflictedObject.ToString();

            if (neighbor == "Digger.Gold")
            {
                Game.Scores += 10;
            }
            if (neighbor == "Digger.Sack" ||
                neighbor == "Digger.Monster")
            {
                return(true);
            }
            return(false);
        }
Beispiel #24
0
        private bool MovingToSpaceIsSuccessful(Vector2 movePosition, ICreature creature)
        {
            if (Tiles[(int)movePosition.X, (int)movePosition.Y].CanCreatureEnter(creature))
            {
                IContainer containerAtPosition = GetContainerAtIndex(movePosition);
                if (containerAtPosition == null)
                {
                    creature.WorldIndex = movePosition;

                    return(true);
                }
            }

            return(false);
        }
Beispiel #25
0
        public bool IsWorldIndexFreeOfObstacles(Vector2 index)
        {
            IContainer containerAtIndex = GetContainerAtIndex(index);
            Door       doorAtIndex      = GetDoorAtIndex(index);
            ICreature  creatureAtIndex  = GetCreatureAtIndex(index);

            if (containerAtIndex == null && doorAtIndex == null && creatureAtIndex == null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #26
0
        private ListViewItem add_card(EncounterCard card)
        {
            ListViewItem listViewItem = new ListViewItem(card.Title);

            listViewItem.SubItems.Add(card.Info);
            listViewItem.Tag = card;
            if (card.Drawn)
            {
                listViewItem.ForeColor = SystemColors.GrayText;
            }
            ICreature creature = Session.FindCreature(card.CreatureID, SearchType.Global);

            listViewItem.Group = this.CardList.Groups[(creature.Category != "" ? creature.Category : "Miscellaneous Creatures")];
            return(listViewItem);
        }
Beispiel #27
0
        public CNS(ICreature cr)
        {
            myCr = cr;

              //формировать секции
              int seCount = cr.SectionsCount();
              for (int seIndex = 0; seIndex < seCount; ++seIndex)
              {
            ISection sec = cr.GetSection(seIndex);
            Section section = new Section(sec, this);
            sections.Add(section);
              }

              reactAlg = new ReactAlg(sections);
        }
        public void Use(IItem item, World world, ICreature user)
        {
            if (user.Mana.Current + _manaToRecover >= user.Mana.Maximum)
            {
                user.Mana.Current = user.Mana.Maximum;
                Announcer.Instance.Announce(user.Name + " regained all mana!", MessageTypes.Other);
            }
            else
            {
                user.Mana.Current += _manaToRecover;
                Announcer.Instance.Announce(user.Name + " recovered " + _manaToRecover + " mana.", MessageTypes.Other);
            }

            user.Inventory.Remove(item);
        }
Beispiel #29
0
        /// <summary>
        /// Flags a creature as no longed being sensed.
        /// </summary>
        /// <param name="creature">The creature that is lost.</param>
        public void StopSensingCreature(ICreature creature)
        {
            creature.ThrowIfNull(nameof(creature));

            // We don't track self anyways.
            if (creature == this)
            {
                return;
            }

            if (this.creatureAwarenessMap.Remove(creature))
            {
                this.CreatureLost?.Invoke(this, creature);
            }
        }
Beispiel #30
0
        public void ThrowNullReferenceExceptionWhenPassedArgumentIsNull()
        {
            // Arrange
            var mockedDbContext = new Mock <IAquaWorldDbContext>();
            var mockedSet       = new Mock <DbSet <ICreature> >();

            // Act
            mockedDbContext.Setup(set => set.Set <ICreature>()).Returns(mockedSet.Object);
            var       dataProvider = new EfAquaWorldDataProvider <ICreature>(mockedDbContext.Object);
            ICreature entity       = null;

            // Assert
            Assert.That(() => dataProvider.Update(entity),
                        Throws.InstanceOf <NullReferenceException>());
        }
        private void update_list()
        {
            this.CreatureList.Groups.Clear();
            this.CreatureList.Items.Clear();
            List <EncounterCard> encounterCards = null;

            if (this.fCreatures == null)
            {
                encounterCards = EncounterBuilder.FindCreatures(this.fTemplateSlot, this.fLevel, this.NameBox.Text);
            }
            else
            {
                encounterCards = new List <EncounterCard>();
                foreach (Masterplan.Data.Creature fCreature in this.fCreatures)
                {
                    encounterCards.Add(new EncounterCard(fCreature.ID));
                }
            }
            BinarySearchTree <string> binarySearchTree = new BinarySearchTree <string>();

            foreach (EncounterCard encounterCard in encounterCards)
            {
                ICreature creature = Session.FindCreature(encounterCard.CreatureID, SearchType.Global);
                binarySearchTree.Add(creature.Category);
            }
            List <string> sortedList = binarySearchTree.SortedList;

            sortedList.Add("Miscellaneous Creatures");
            foreach (string str in sortedList)
            {
                this.CreatureList.Groups.Add(str, str);
            }
            foreach (EncounterCard encounterCard1 in encounterCards)
            {
                ICreature    creature1 = Session.FindCreature(encounterCard1.CreatureID, SearchType.Global);
                ListViewItem item      = this.CreatureList.Items.Add(encounterCard1.Title);
                item.SubItems.Add(encounterCard1.Info);
                item.Tag = encounterCard1;
                if (creature1.Category == null || !(creature1.Category != ""))
                {
                    item.Group = this.CreatureList.Groups["Miscellaneous Creatures"];
                }
                else
                {
                    item.Group = this.CreatureList.Groups[creature1.Category];
                }
            }
        }
        public CreatureCommand Act(int x, int y)
        {
            CreatureCommand movement    = new CreatureCommand();
            Point?          playerPoint = FindPlayer();

            if (playerPoint != null)
            {
                int distanceX = playerPoint.Value.X - x;
                int distanceY = playerPoint.Value.Y - y;

                if (x == playerPoint.Value.X)
                {
                    if (distanceY > 0)
                    {
                        movement.DeltaY = 1;
                    }
                    else
                    {
                        movement.DeltaY = -1;
                    }
                }
                else
                {
                    if (distanceX > 0)
                    {
                        movement.DeltaX = 1;
                    }
                    else
                    {
                        movement.DeltaX = -1;
                    }
                }

                ICreature creatureX = Game.Map[x + movement.DeltaX, y];
                ICreature creatureY = Game.Map[x, y + movement.DeltaY];
                if (creatureX is Sack || creatureX is Terrain || creatureX is Monster)
                {
                    movement.DeltaX = 0;
                }

                if (creatureY is Sack || creatureY is Terrain || creatureY is Monster)
                {
                    movement.DeltaY = 0;
                }
            }

            return(movement);
        }
Beispiel #33
0
        /// <summary>
        /// Calculates the step duration of a creature moving from a given tile in the given direction.
        /// </summary>
        /// <param name="creature">The creature that's moving.</param>
        /// <param name="fromTile">The tile which the creature is moving from.</param>
        /// <returns>The duration time of the step.</returns>
        public static TimeSpan CalculateStepDuration(this ICreature creature, ITile fromTile = null)
        {
            if (creature == null)
            {
                return(TimeSpan.Zero);
            }

            var tilePenalty = fromTile?.Ground?.MovementPenalty ?? MechanicsConstants.DefaultGroundMovementPenaltyInMs;

            decimal totalPenalty = 1000 * tilePenalty;
            decimal stepSpeed    = Math.Max(1u, creature.Speed);

            var durationInMs = (uint)(Math.Round(totalPenalty / stepSpeed, MidpointRounding.ToEven) * creature.LastMovementCostModifier);

            return(TimeSpan.FromMilliseconds(durationInMs));
        }
Beispiel #34
0
        private int AttackPowerModifier(ICreature attacker)
        {
            Hit hit    = attacker.Attack();
            int damage = new int();

            if (hit.Type == PowerEnum.ForcePower)
            {
                damage = (int)(hit.Power * this.fightRules.ForceAttackCoefficient);
            }
            else if (hit.Type == PowerEnum.MentalPower)
            {
                damage = (int)(hit.Power * this.fightRules.MindAttackCoefficient);
            }

            return(damage);
        }
Beispiel #35
0
 /// <summary>
 /// Use this potion to heal a Creature.
 /// </summary>
 /// <param name="target">target must be of type Creature.</param>
 public void Use(object target)
 {
     if (target is ICreature)
     {
         ICreature creature = (ICreature)target;
         creature.Stats.HPs += HealValue;
         if (--UseCount <= 0)
         {
             throw new ItemDepletedException(string.Format("Your {0} has run out.", this.Name), this);
         }
     }
     else
     {
         throw new WorldException(string.Format("You can't use this item on {0}...", this.Name), target);
     }
 }
 public bool CastSpell(ICreature caster, Vector2 targetWorldIndex, AreaOfEffect affectedArea, World world)
 {
     int healthRestored = RandomNumberProvider.GetRandomNumber(_minimumHealthToRestore, _maximumHealthToRestore);
     if (caster.Health.Current + healthRestored >= caster.Health.Maximum)
     {
         caster.Health.Current = caster.Health.Maximum;
         Announcer.Instance.Announce(caster.Name + " returned to full health!", MessageTypes.Spell);
     }
     else
     {
         caster.Health.Current += healthRestored;
         Announcer.Instance.Announce(caster.Name + " recovered " + healthRestored + " health.", MessageTypes.Spell);
     }
     world.AddSpecialEffectToWorld(new Heal(caster.WorldIndex, caster.WorldIndex, world));
     return true;
 }
Beispiel #37
0
        public void AddDemonForm()
        {
            Random          rand   = new Random();
            CreautureStates state  = new CreautureStates();
            string          sDemon = "Demon";

            foreach (var c in CreatureList)
            {
                if (c.Description == "Demon")
                {
                    ICreature demon = state.SPawnDemon(rand.Next(0, 9), rand.Next(0, 9));
                    CreatureList.Add(demon);
                }
                throw new ArgumentException("No demons");
            }
        }
Beispiel #38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CanThrowBetweenEventCondition"/> class.
        /// </summary>
        /// <param name="game">A reference to the game instance.</param>
        /// <param name="requestor">The creature requesting the throw.</param>
        /// <param name="determineSourceLocationFunc">A function delegate to determine the source location of the throw.</param>
        /// <param name="determineDestinationLocationFunc">A function delegate to determine the destination location of the throw.</param>
        /// <param name="checkLineOfSight">Whether or not to check the line of sight.</param>
        public CanThrowBetweenEventCondition(
            IGame game,
            ICreature requestor,
            Func <Location> determineSourceLocationFunc,
            Func <Location> determineDestinationLocationFunc,
            bool checkLineOfSight = true)
        {
            determineSourceLocationFunc.ThrowIfNull(nameof(determineSourceLocationFunc));
            determineDestinationLocationFunc.ThrowIfNull(nameof(determineDestinationLocationFunc));

            this.Game                   = game;
            this.Requestor              = requestor;
            this.GetSourceLocation      = determineSourceLocationFunc;
            this.GetDestinationLocation = determineDestinationLocationFunc;
            this.CheckLineOfSight       = checkLineOfSight;
        }
Beispiel #39
0
 public bool DeadInConflict(ICreature conflictedObject)
 {
     if (conflictedObject is Player)
     {
         Game.Scores += 10;
         return(true);
     }
     else if (conflictedObject is Monster)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #40
0
 public bool DeadInConflict(ICreature conflictedObject)
 {
     if (conflictedObject is TNT)
     {
         return(true);
     }
     if (conflictedObject is SackOfGold)
     {
         return(true);
     }
     if (conflictedObject is Gold)
     {
         game.Scores += 100;
     }
     return(false);
 }
Beispiel #41
0
        private void BtnSchoolFightClick(object sender, EventArgs e)
        {
            this.academy       = Academy.Instance;
            this.arena         = academy.Practice(ninja);
            this.evil          = arena.Creature;
            this.isSchoolFight = true;
            this.InitializeFight();

            this.pnlSchool.Visible = false;
            this.pnlFight.Visible  = true;
            this.DeclareFightButtons();
            this.LoadButtons();
            this.temporaryBag       = new List <IUsable>(this.ninja.BagOfItems);
            this.temporaryForceBag  = new List <IUsable>(this.ninja.ListOfFightingSkills);
            this.temporaryMentalBag = new List <IUsable>(this.ninja.ListOfMentalSkills);
        }
Beispiel #42
0
        private double FitnessFunction(ICreature creature)
        {
            var fitness        = 0;
            var interpretation = GetInterpretation(creature);

            if (interpretation["X1"] || interpretation["Y1"] || interpretation["Z1"])
            {
                fitness++;
            }
            if (interpretation["X2"] || interpretation["Y2"] || interpretation["Z2"])
            {
                fitness++;
            }
            if (interpretation["X3"] || interpretation["Y3"] || interpretation["Z3"])
            {
                fitness++;
            }

            if (!interpretation["X1"] || !interpretation["X2"] || interpretation["X3"])
            {
                fitness++;
            }
            if (!interpretation["X1"] || interpretation["X2"] || !interpretation["X3"])
            {
                fitness++;
            }

            if (!interpretation["Y1"] || !interpretation["Y2"] || interpretation["Y3"])
            {
                fitness++;
            }
            if (interpretation["Y1"] || !interpretation["Y2"] || !interpretation["Y3"])
            {
                fitness++;
            }

            if (!interpretation["Z1"] || interpretation["Z2"] || !interpretation["Z3"])
            {
                fitness++;
            }
            if (interpretation["Z1"] || !interpretation["Z2"] || !interpretation["Z3"])
            {
                fitness++;
            }

            return(fitness);
        }
Beispiel #43
0
        public static void UpdatePowerRange(ICreature c, CreaturePower power)
        {
            if ((power.Range != null) && (power.Range != ""))
            {
                return;
            }

            List <string> ranges = new List <string>();

            ranges.Add("close blast");
            ranges.Add("close burst");
            ranges.Add("area burst");
            ranges.Add("melee");
            ranges.Add("ranged");

            string details = "";

            string[] clauses = power.Details.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string clause in clauses)
            {
                bool is_range_clause = false;
                foreach (string range in ranges)
                {
                    if (clause.ToLower().Contains(range))
                    {
                        is_range_clause = true;
                        break;
                    }
                }

                if (is_range_clause)
                {
                    power.Range = clause;
                }
                else
                {
                    if (details != "")
                    {
                        details += "; ";
                    }

                    details += clause;
                }
            }

            power.Details = details;
        }
Beispiel #44
0
        public static void UpdatePowerRange(ICreature c, CreaturePower power)
        {
            if (power.Range != null && power.Range != "")
            {
                return;
            }
            List <string> strs = new List <string>()
            {
                "close blast",
                "close burst",
                "area burst",
                "melee",
                "ranged"
            };
            string str     = "";
            string details = power.Details;

            string[] strArrays  = new string[] { ";" };
            string[] strArrays1 = details.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < (int)strArrays1.Length; i++)
            {
                string str1 = strArrays1[i];
                bool   flag = false;
                foreach (string str2 in strs)
                {
                    if (!str1.ToLower().Contains(str2))
                    {
                        continue;
                    }
                    flag = true;
                    break;
                }
                if (!flag)
                {
                    if (str != "")
                    {
                        str = string.Concat(str, "; ");
                    }
                    str = string.Concat(str, str1);
                }
                else
                {
                    power.Range = str1;
                }
            }
            power.Details = str;
        }
Beispiel #45
0
    public float originalCreatureSpeed; // to reassign it on trigger exit. That happend on creatures script method

    // Slows enemies' movement speed AND attack speed

    void OnTriggerEnter2D(Collider2D creature)
    {
        creatureMovement = creature.gameObject.GetComponent <MonsterMovement>();

        slowEffect = gameObject.GetComponentInParent <Salt>();

        creatureStats = creature.gameObject.GetComponent <ICreature>();


        if (creature.tag == "Enemy")
        {
            creatureMovement.speed    -= creatureMovement.speed * slowEffect.SlowEffect;
            creatureStats.currentState = ICreature.CreatureState.SLOWED;

            Debug.Log("SLOWED SPEED: " + creatureMovement.speed);
        }
    }
        public bool CastSpell(ICreature caster, Vector2 targetWorldIndex, AreaOfEffect affectedArea, World world)
        {
            ITerrain targetTile = world.Tiles[(int)targetWorldIndex.X, (int)targetWorldIndex.Y];

            if (targetTile.IsExploredByPlayer && targetTile.CanCreatureEnter(caster) && world.IsWorldIndexFreeOfObstacles(targetWorldIndex))
            {
                caster.WorldIndex = targetWorldIndex;
                world.CenterCameraOnPlayer();
                world.DiscoverTerrainAroundPlayer();
            }
            else
            {
                Announcer.Instance.Announce(caster.Name + " tried to teleport, but could not.", MessageTypes.SpellFailure);
            }

            return true;
        }
        public bool Match(EncounterCard card, int encounter_level)
        {
            ICreature creature       = Session.FindCreature(card.CreatureID, SearchType.Global);
            int       encounterLevel = encounter_level + this.fLevelAdjustment;

            if (encounterLevel < 1)
            {
                encounterLevel = 1;
            }
            if (creature.Level != encounterLevel)
            {
                return(false);
            }
            if (creature.Role is Minion != this.fMinions)
            {
                return(false);
            }
            bool flag = false;

            if (this.fRoles.Count != 0)
            {
                ComplexRole role = creature.Role as ComplexRole;
                foreach (RoleType roleType in card.Roles)
                {
                    if (!this.fRoles.Contains(role.Type))
                    {
                        continue;
                    }
                    flag = true;
                    break;
                }
            }
            else
            {
                flag = true;
            }
            if (!flag)
            {
                return(false);
            }
            if (this.fFlag != card.Flag)
            {
                return(false);
            }
            return(true);
        }
Beispiel #48
0
        public void GenerateCreatureTest_GenerateHuman()
        {
            const int           StartingGold = 10;
            const CreatureTypes TypeCreature = CreatureTypes.Human;

            ICreature creature = GetCreature(TypeCreature);

            AssertCreatureIsCorrect(creature, TypeCreature);

            Assert.IsTrue(creature is IHero);

            if (creature is IHero hero)
            {
                Assert.IsNotNull(hero.Inventory);
                Assert.AreEqual(StartingGold, hero.Inventory.Gold);
            }
        }
        private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (e.Url.Scheme == "remove")
            {
                Guid      id       = new Guid(e.Url.LocalPath);
                ICreature creature = find_creature(id);
                if (creature != null)
                {
                    e.Cancel = true;

                    fCreatures.Remove(creature);

                    update_list();
                    update_stats();
                }
            }
        }
        public void EffectCompleted(ICreature creature, World world)
        {
            if (creature.ViewDistance.Current + _amountToReduceVisionBy >= creature.ViewDistance.Maximum)
            {
                creature.ViewDistance.Current = creature.ViewDistance.Maximum;
                Announcer.Instance.Announce(creature.Name + "'s vision returned to normal!", MessageTypes.Other);
            }
            else
            {
                creature.ViewDistance.Current += _amountToReduceVisionBy;
                Announcer.Instance.Announce(creature.Name + "'s vision improved.", MessageTypes.Other);
            }

            world.DiscoverTerrainAroundPlayer();

            if (Completed != null)
                Completed(this);
        }
Beispiel #51
0
        public bool CastSpell(ICreature caster, Vector2 targetWorldIndex, AreaOfEffect affectedArea, World world)
        {
            affectedWorldIndicies = affectedArea.GetAffectedWorldIndices(targetWorldIndex);
            damage = RandomNumberProvider.GetRandomNumber(_minimumDamage, _maximumDamage);

            foreach (KeyValuePair<Vector2, double> affectedWorldIndex in affectedWorldIndicies)
            {
                ICreature target = world.GetCreatureAtIndex(affectedWorldIndex.Key);
                if (target != null)
                {
                    int actualDamage = (int)(damage * affectedWorldIndex.Value);
                    Announcer.Instance.Announce(target.Name + " was hit by a fireball for " + actualDamage + " damage!", MessageTypes.Spell);
                    target.Health.Current -= actualDamage;
                }
            }
            world.AddSpecialEffectToWorld(new Inferno(targetWorldIndex, world, affectedArea));

            return true;
        }
 public void UpdateEffect(ICreature creature, World world)
 {
     if (EffectComplete == false)
     {
         if (TurnsRemaining <= 0)
         {
             EffectCompleted(creature, world);
             EffectComplete = true;
         }
         else
         {
             if (TurnsRemaining == 5)
                 Announcer.Instance.Announce(creature.Name + " feels the potion wearing off.", MessageTypes.Other);
             else if (TurnsRemaining == 10)
                 Announcer.Instance.Announce(creature.Name + " feels his movement returning to normal.", MessageTypes.Other);
             TurnsRemaining -= 1;
         }
     }
 }
Beispiel #53
0
        public void Attack(IWeapon weapon, ICreature attacker, ICreature target, World world)
        {
            MessageTypes messageTypeToUse;
            bool attackHits = RandomNumberProvider.CheckIfChanceOccurs(_chanceOfHit);
            int amountOfDamage = RandomNumberProvider.GetRandomNumber(_minimumDamage, _maximumDamage);

            if (attacker.IsPlayer())
                messageTypeToUse = MessageTypes.PlayerAttack;
            else
                messageTypeToUse = MessageTypes.CreatureAttack;

            if (attackHits)
            {
                target.Health.Current -= amountOfDamage;
                Announcer.Instance.Announce(attacker.Name + " hits " + target.Name + " for " + amountOfDamage + " damage!", MessageTypes.CreatureAttack);
            }
            else
            {
                Announcer.Instance.Announce(attacker.Name + " misses " + target.Name + "!", MessageTypes.CreatureAttack);
            }
        }
 public void TakeTurn(ICreature creature, World world)
 {
     _countdownToNextTurn -= 1;
     if (_countdownToNextTurn <= 0)
     {
         _countdownToNextTurn = _speed;
         bool turnOver = false;
         while (turnOver != true)
         {
             int roll = RandomNumberProvider.GetRandomNumber(1, 4);
             if (roll == 1)
                 turnOver = world.MoveCreatureInDirectionSuccessful(Direction.North, creature);
             else if (roll == 2)
                 turnOver = world.MoveCreatureInDirectionSuccessful(Direction.South, creature);
             else if (roll == 3)
                 turnOver = world.MoveCreatureInDirectionSuccessful(Direction.East, creature);
             else if (roll == 4)
                 turnOver = world.MoveCreatureInDirectionSuccessful(Direction.West, creature);
            }
     }
 }
Beispiel #55
0
 public void ResolveCommand(ECommands commands, params object[] list)
 {
     switch(commands) {
         case ECommands.Link: {
             FollowTarget = ((Dog)list[0]).transform;
             Head = (ICreature)list[0];
             break;
         }
         case ECommands.Select: {
             Debug.Log("Cant select pony");
             break;
         }
         case ECommands.BreakLink: {
             FollowTarget = null;
             Head = null;
             if(Game.Instance != null) { // spike for pass test (BreakLinkTest)
                 Game.Instance.CollectPony(this);
                 Destroy(gameObject);
             }
             break;
         }
     }
 }
Beispiel #56
0
 public bool DeadInConflict(ICreature conflictedObject)
 {
     return false;
 }
Beispiel #57
0
 public void addCreature(ICreature c)
 {
     IGameCreature newCreature = new GameCreature(c);
     creatures.Add(newCreature);
 }
Beispiel #58
0
 public void AttackCreature(ref ICreature creature)
 {
     Weapon.Attack(this, creature);
 }
Beispiel #59
0
 private bool MovingToSpaceOpensDoor(Vector2 movePosition, ICreature creature)
 {
     Door doorAtPosition = GetDoorAtIndex(movePosition);
     if (doorAtPosition != null)
     {
         if (doorAtPosition.IsOpen == false)
         {
             doorAtPosition.Open();
             return true;
         }
         else
         {
             return false;
         }
     }
     else
         return false;
 }
 public void AttackCreature(ICreature attacker, ref ICreature creature)
 {
     int damage = RandomNumberProvider.GetRandomNumber(1, 2);
     Announcer.Instance.Announce(attacker.Name + " inflicted " + damage + " damage to " + creature.Name, MessageTypes.CreatureAttack);
     creature.Health.Current -= damage;
 }