コード例 #1
0
        private void AddNewCreature(string selectedHerd, CreatureBuffer newCreature)
        {
            var newEntity = new CreatureEntity
            {
                Id                     = CreatureEntity.GenerateNewCreatureId(context),
                Name                   = newCreature.Name,
                Herd                   = selectedHerd,
                Age                    = newCreature.Age,
                TakenCareOfBy          = newCreature.CaredBy,
                BrandedFor             = newCreature.BrandedBy,
                FatherName             = newCreature.FatherName,
                MotherName             = newCreature.MotherName,
                Traits                 = newCreature.Traits,
                TraitsInspectedAtSkill = newCreature.InspectSkill,
                IsMale                 = newCreature.IsMale,
                PregnantUntil          = newCreature.PregnantUntil,
                SecondaryInfoTagSetter = newCreature.SecondaryInfo,
                ServerName             = newCreature.Server != null ? newCreature.Server.ServerName.Original : string.Empty,
                SmilexamineLastDate    = DateTime.Now,
                CreatureColorId        = newCreature.HasColorWurmLogText
                    ? creatureColorDefinitions.GetColorIdByWurmLogText(newCreature.ColorWurmLogText)
                    : CreatureColor.GetDefaultColor().CreatureColorId
            };

            newEntity.EpicCurve = newCreature.Server != null &&
                                  newCreature.Server.ServerGroup.ServerGroupId == ServerGroup.EpicId;

            context.InsertCreature(newEntity);
            debugLogger.Log("successfully inserted creature to db");
            trayPopups.Schedule(String.Format("Added new creature to herd {0}: {1}", selectedHerd, newEntity), "CREATURE ADDED");
        }
コード例 #2
0
    public static Color GetCreatureColorValue(CreatureColor color)
    {
        switch (color)
        {
        case CreatureColor.White:
            return(Color.white);

        case CreatureColor.Red:
            return(new Color(0.9f, 0.1f, 0.2f));

        case CreatureColor.Blue:
            return(new Color(0.1f, 0.1f, 0.9f));

        case CreatureColor.Orange:
            return(new Color(1.0f, 0.7f, 0.3f));

        case CreatureColor.Green:
            return(new Color(0.1f, 0.9f, 0.1f));

        case CreatureColor.Yellow:
            return(new Color(1.0f, 0.8f, 0.1f));

        case CreatureColor.Purple:
            return(new Color(0.8f, 0.1f, 0.5f));
        }

        return(Color.white);
    }
コード例 #3
0
    public static string GetCreatureColorDisplayString(CreatureColor color)
    {
        switch (color)
        {
        case CreatureColor.White:
            return("White");

        case CreatureColor.Red:
            return("Red");

        case CreatureColor.Blue:
            return("Blue");

        case CreatureColor.Orange:
            return("Orange");

        case CreatureColor.Green:
            return("Green");

        case CreatureColor.Yellow:
            return("Yellow");

        case CreatureColor.Purple:
            return("Purple");
        }

        return("INVALID");
    }
コード例 #4
0
        public FormCreatureViewEdit(
            [NotNull] FormGrangerMain mainForm,
            [NotNull] GrangerContext context,
            [NotNull] ILogger logger,
            [NotNull] IWurmApi wurmApi,
            [CanBeNull] Creature creature,
            CreatureViewEditOpType optype,
            string herdId,
            [NotNull] CreatureColorDefinitions creatureColorDefinitions)
        {
            if (mainForm == null)
            {
                throw new ArgumentNullException(nameof(mainForm));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmApi == null)
            {
                throw new ArgumentNullException(nameof(wurmApi));
            }
            if (creatureColorDefinitions == null)
            {
                throw new ArgumentNullException(nameof(creatureColorDefinitions));
            }
            this.mainForm = mainForm;
            this.creature = creature;
            this.context  = context;
            this.herdId   = herdId;
            this.creatureColorDefinitions = creatureColorDefinitions;
            this.logger  = logger;
            this.wurmApi = wurmApi;
            InitializeComponent();

            DisableAllFields();

            comboBoxServerName.Items.AddRange(
                wurmApi.Servers.All.Select(server => server.ServerName.Original).Cast <object>().ToArray());

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

            list.AddRange(this.context.Creatures.Select(x => x.Name));
            list.AddRange(this.context.Creatures.Select(x => x.MotherName));
            list.AddRange(this.context.Creatures.Select(x => x.FatherName));

            var allCreatureNamesInDatabase = list.Distinct().Where(x => x != null).Cast <object>().ToArray();

            comboBoxFather.Items.AddRange(allCreatureNamesInDatabase);
            comboBoxMother.Items.AddRange(allCreatureNamesInDatabase);
            ;
            comboBoxColor.Items.AddRange(
                creatureColorDefinitions.GetColors().Select(color => color.CreatureColorId).Cast <object>().ToArray());
            comboBoxColor.Text = CreatureColor.GetDefaultColor().CreatureColorId;
            comboBoxAge.Items.AddRange(CreatureAge.GetColorsEnumStrArray().Cast <object>().ToArray());
            comboBoxAge.Text = CreatureAge.GetDefaultAgeStr();

            this.OpMode = optype;
        }
コード例 #5
0
 public ColorWeight(CreatureColor color, float weight)
 {
     Color  = color;
     Weight = weight;
 }