/// <summary>
        /// Cast confuse
        /// </summary>
        /// <param name="resultSet">Result set</param>
        /// <param name="caster">Caster</param>
        /// <param name="targetPos">Target position</param>
        /// <returns>True if successful</returns>
        public static bool CastConfuse(ResultSet resultSet, EntityID caster, Vector2i targetPos)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            if (!CheckTargetPosValid(resultSet, targetPos, caster))
            {
                return(false);
            }

            EntityID target = EntityID.empty;

            for (int i = 0; i < EntityStore.entities.Count; i++)
            {
                var eid = EntityStore.entities[i];
                var e   = eid.e;

                if (e.pos == targetPos)
                {
                    target = eid;
                    break;
                }
            }

            if (!target.isEmpty)
            {
                var confusedAi = new ConfusedMonster();
                confusedAi.previousAi    = target.e.ai;
                confusedAi.numberOfTurns = 10;

                target.e.ai = confusedAi;

                resultSet.AddMessage(
                    C.FSTR.Set("The eyes of the ").Append(C.STR_COLOR_NAME).Append(target.e.name).Append("@- look vacant, as it starts to stumble around!"));

                EffectManager.Instance.AddEffect(new EffectConfuse(target));

                RB.SoundPlay(game.assets.soundConfuse);

                return(true);
            }
            else
            {
                resultSet.AddMessage(
                    C.FSTR.Set("There is no targetable enemy at that location."));
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Read component
        /// </summary>
        /// <param name="reader">Reader instance</param>
        /// <returns>Entity component</returns>
        public static EntityComponent ReadComponent(this BinaryReader reader)
        {
            bool exists = reader.ReadBoolean();

            if (!exists)
            {
                return(null);
            }

            EntityComponent component = null;

            var componentType = (ComponentType)reader.ReadInt32();

            switch (componentType)
            {
            case ComponentType.Fighter:
                component = new Fighter(reader);
                break;

            case ComponentType.BasicMonster:
                component = new BasicMonster(reader);
                break;

            case ComponentType.ConfusedMonster:
                component = new ConfusedMonster(reader);
                break;

            case ComponentType.GolemMonster:
                component = new GolemMonster(reader);
                break;

            case ComponentType.SlimeMonster:
                component = new SlimeMonster(reader);
                break;

            case ComponentType.Inventory:
                component = new Inventory(reader);
                break;

            case ComponentType.Item:
                component = new Item(reader);
                break;

            case ComponentType.Stairs:
                component = new Stairs(reader);
                break;

            case ComponentType.Level:
                component = new Level(reader);
                break;

            case ComponentType.Equipment:
                component = new Equipment(reader);
                break;

            case ComponentType.Equippable:
                component = new Equippable(reader);
                break;

            case ComponentType.GroundTrigger:
                component = new GroundTrigger(reader);
                break;

            case ComponentType.MoveTrail:
                component = new MoveTrail(reader);
                break;

            default:
                throw new System.Exception("Unknown component type " + (int)componentType);
            }

            return(component);
        }