Пример #1
0
 /// <summary>
 /// 修改船员
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="protoModel"></param>
 /// <returns>0:成功 1:失败 2:数据重复</returns>
 public static int CrewUpdate(CrewInfo protoModel)
 {
     using (var _context = new MyContext())
     {
         if (protoModel != null)
         {
             int uid   = Convert.ToInt32(protoModel.uid);
             var model = _context.Crew.FirstOrDefault(c => c.Id == uid);
             if (model != null)
             {
                 var dbmodel = _context.Crew.FirstOrDefault(c => c.Name == protoModel.name);
                 if (dbmodel != null && model.Name != protoModel.name)
                 {
                     return(2);
                 }
                 model.Job  = protoModel.job;
                 model.Name = protoModel.name;
                 _context.Crew.Update(model);
                 _context.SaveChanges();
                 AddCrewPicture(protoModel.pictures, uid);
                 return(0);
             }
             return(1);
         }
         return(1);
     }
 }
Пример #2
0
 /// <summary>
 /// 添加船员
 /// </summary>
 /// <param name="protoModel"></param>
 /// <returns>0:成功 1:失败 2:数据重复</returns>
 public static int CrewAdd(ref CrewInfo protoModel)
 {
     using (var _context = new MyContext())
     {
         var shipId = "";// _context.Ship.FirstOrDefault().Id;
         if (protoModel != null)
         {
             string name  = protoModel.name;
             var    dbemp = _context.Crew.FirstOrDefault(c => c.Name == name);
             if (dbemp != null)
             {
                 return(2);
             }
             int uid = Convert.ToInt32(protoModel.uid);
             dbemp = _context.Crew.FirstOrDefault(c => c.Id == uid);
             if (dbemp == null)
             {
                 SmartWeb.Models.Crew employee = new SmartWeb.Models.Crew()
                 {
                     Id   = uid,
                     Job  = protoModel.job,
                     Name = protoModel.name
                 };
                 _context.Crew.Add(employee);
                 _context.SaveChanges();
                 protoModel.uid = employee.Id.ToString();
                 AddCrewPicture(protoModel.pictures, employee.Id);
             }
             return(0);
         }
         return(1);
     }
 }
Пример #3
0
 /// <summary>
 /// 查询船员信息
 /// </summary>
 /// <param name="uid"></param>
 /// <returns></returns>
 public static List <CrewInfo> CrewQuery(int uid = 0)
 {
     using (var _context = new MyContext())
     {
         List <CrewInfo> list = new List <CrewInfo>();
         //获取船员信息
         var dbempl = _context.Crew.Where(c => (uid > 0 ? c.Id == uid : 1 == 1)).ToList();
         //获取船员图片
         var pics = _context.CrewPicture.ToList();
         foreach (var item in dbempl)
         {
             CrewInfo em = new CrewInfo()
             {
                 job      = item.Job,
                 name     = item.Name,
                 uid      = item.Id.ToString(),
                 pictures = new List <string>()
             };
             var picList = pics.Where(c => c.CrewId == item.Id);
             foreach (var itpic in picList)
             {
                 string pic = Convert.ToBase64String(itpic.Picture);
                 em.pictures.Add(pic);
             }
             list.Add(em);
         }
         return(list);
     }
 }
Пример #4
0
    protected override void Refresh()
    {
        CrewInfo info = CrewLibrary.instance.GetRandomInfo();

        _crewType  = info.model.type;
        _crewName  = info.name;
        _crewPrice = info.GetRandomPrice();
        _crewIcon  = info.icon;
        _flagRenderer.material.SetTexture("Texture2D_D003A093", info.flagIcon);
    }
Пример #5
0
    protected override void SetInformation(IShipLocation location)
    {
        Crew crew = crewLocation.current;

        CrewInfo info = CrewLibrary.instance.GetInfo(crew.type);

        _background.color  = info.backgroundColor;
        _filled.color      = info.frontColor;
        _filled.fillAmount = crew.progress01;
        _icon.sprite       = info.icon;
    }
Пример #6
0
    public static CrewInfo GetCrewInfo(Dictionary <string, System.Object> CrewDictionary)
    {
        CrewInfo Temp = NewCrewInfo();

        if (CrewDictionary != null)
        {
            if (CrewDictionary.ContainsKey("GunnerProficiency"))
            {
                Temp.GunnerProficiency = float.Parse(CrewDictionary["GunnerProficiency"].ToString());
            }
            if (CrewDictionary.ContainsKey("ReloaderProficiency"))
            {
                Temp.ReloaderProficiency = float.Parse(CrewDictionary["ReloaderProficiency"].ToString());
            }
            if (CrewDictionary.ContainsKey("ChiefProficiency"))
            {
                Temp.ChiefProficiency = float.Parse(CrewDictionary["ChiefProficiency"].ToString());
            }
            if (CrewDictionary.ContainsKey("DriverProficiency"))
            {
                Temp.DriverProficiency = float.Parse(CrewDictionary["DriverProficiency"].ToString());
            }
            if (CrewDictionary.ContainsKey("RedioProficiency"))
            {
                Temp.RedioProficiency = float.Parse(CrewDictionary["RedioProficiency"].ToString());
            }
            if (CrewDictionary.ContainsKey("RepairMent"))
            {
                Temp.RepairMent = float.Parse(CrewDictionary["RepairMent"].ToString());
            }
            if (CrewDictionary.ContainsKey("Snow"))
            {
                Temp.Snow = CrewDictionary["Snow"].ToString();
            }
            if (CrewDictionary.ContainsKey("Grass"))
            {
                Temp.Grass = CrewDictionary["Grass"].ToString();
            }
            if (CrewDictionary.ContainsKey("Sand"))
            {
                Temp.Sand = CrewDictionary["Sand"].ToString();
            }
            if (CrewDictionary.ContainsKey("Exp"))
            {
                Temp.Exp = int.Parse(CrewDictionary["Exp"].ToString());
            }
        }
        return(Temp);
    }
Пример #7
0
    public static Dictionary <string, System.Object> GetCrewInfo(CrewInfo MyCrew)
    {
        Dictionary <string, System.Object> Temp = new Dictionary <string, System.Object>();

        Temp.Add("GunnerProficiency", MyCrew.GunnerProficiency);
        Temp.Add("ReloaderProficiency", MyCrew.ReloaderProficiency);
        Temp.Add("ChiefProficiency", MyCrew.ChiefProficiency);
        Temp.Add("DriverProficiency", MyCrew.DriverProficiency);
        Temp.Add("RedioProficiency", MyCrew.RedioProficiency);
        Temp.Add("RepairMent", MyCrew.RepairMent);
        Temp.Add("Snow", MyCrew.Snow);
        Temp.Add("Sand", MyCrew.Sand);
        Temp.Add("Grass", MyCrew.Grass);
        Temp.Add("Exp", MyCrew.Exp);
        return(Temp);
    }
Пример #8
0
    public static CrewInfo NewCrewInfo()
    {
        CrewInfo temp = new CrewInfo();

        temp.GunnerProficiency   = 0.0f;
        temp.ReloaderProficiency = 0.0f;
        temp.ChiefProficiency    = 0.0f;
        temp.DriverProficiency   = 0.0f;
        temp.RedioProficiency    = 0.0f;
        temp.RepairMent          = 0.0f;
        temp.Snow  = "null";
        temp.Grass = "null";
        temp.Sand  = "null";
        temp.Exp   = 0;
        return(temp);
    }
Пример #9
0
        /// <summary>
        /// 修改船员
        /// </summary>
        /// <param name="nextIdentity"></param>
        /// <param name="crewInfo"></param>
        public void SendCrewUpdate(CrewInfo crewInfo, string nextIdentity = "")
        {
            MSG msg = new MSG()
            {
                type      = MSG.Type.CREW,
                sequence  = 3,
                timestamp = ProtoBufHelp.TimeSpan(),
                crew      = new Models.Crew()
                {
                    command     = Models.Crew.Command.MODIFY_REQ,
                    crewrequest = new CrewRequest()
                    {
                        crewinfo = crewInfo
                    }
                }
            };

            dealer.Send(msg, nextIdentity);
        }