public GameObject GetHumanOfSex(int id, enumSex sex)
 {
     foreach (PrefabDataHumain prefabD in lHumains)
     {
         if (prefabD.id == id)
         {
             if (sex == enumSex.Female)
             {
                 return(prefabD.prefabF);
             }
             else
             {
                 return(prefabD.prefabM);
             }
         }
     }
     return(null);
 }
Esempio n. 2
0
        public IdCardInfo Parse18(out string errMsg)
        {
            string Id = IdcardNo;
            errMsg = string.Empty;
            long n = 0;

            //长度和数值特性
            if (long.TryParse(Id.Remove(17), out n) == false  //  前17位是数字
                || n < Math.Pow(10, 16)   //前17位的数字值大于 10的16次方
                || long.TryParse(Id.Replace('x', '0').Replace('X', '0'), out n) == false)//将最后一位的x替换成0
            {
                errMsg = "身份证号码格式有误";
            }
            //地址
            // 1-2位省、自治区、直辖市代码;
            int provinceCode = Convert.ToInt32(Id.Remove(2));
            int cityCode = Convert.ToInt32(Id.Remove(4)+"00");

            int countryCode = Convert.ToInt32(Id.Remove(6));
            if (!ProvinceDict.ContainsKey(provinceCode))
            {
                errMsg = "身份证号码省份不正确";
                //省份验证
                return null;
            }
            this.ProvinceCode = provinceCode;
            if (!CityDict.ContainsKey(cityCode))
            {

                errMsg = "身份证号码城市代码不正确";
                //城市
                return null;
            }
            if (!CityDict.ContainsKey(countryCode))
            {
                errMsg = "身份证号码城市代码不正确";
                //城市
                return null;
            }

            this.CityCode = cityCode;
            this.CountryCode = countryCode;

            string birth = Id.Substring(6, 8).Insert(6, "-").Insert(4, "-");
            DateTime birthday;
            if (DateTime.TryParse(birth, out birthday) == false)
            {
                errMsg = "身份证号码生日不正确";
                return null;
            }
            this.Age = DateTime.Now.Year - birthday.Year+1;
            //性别
            int sexCode = Convert.ToInt32(Id.Substring(16, 1)) % 2;
            this.Sex = sexCode == 0 ? enumSex.女 : enumSex.男;
            //---校验码验证
            string[] arrVarifyCode = ("1,0,x,9,8,7,6,5,4,3,2").Split(',');
            string[] Wi = ("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2").Split(',');
            char[] Ai = Id.Remove(17).ToCharArray();
            int sum = 0;
            for (int i = 0; i < 17; i++)
            {
                sum += int.Parse(Wi[i]) * int.Parse(Ai[i].ToString());
            }
            int y = -1;
            Math.DivRem(sum, 11, out y);
            if (arrVarifyCode[y] != Id.Substring(17, 1).ToLower())
            {
                errMsg = "身份证号码校验码不正确";
                return null;
            }
            return this;
        }
Esempio n. 3
0
    void InstantiateHuman()
    {
        GameObject   prefab = prefabHuman;
        Fighter      fighter;
        CreatureType creatureType = CreatureType.Human;

        GameObject       humansPositionParent = GameObject.FindGameObjectWithTag("HumansPosition");
        List <Transform> humansPosition       = new List <Transform>();

        foreach (Transform child in humansPositionParent.transform)
        {
            humansPosition.Add(child);
        }

        if (!bSpecialFight)
        {
            humanGroupFighter = new GroupHumanFighter();


            if (protoScript == null && !isBossCombat)
            {
                currentNbHuman = Random.Range(2, nbCreaturePerGroup + 1);
                //currentNbHuman = 2;
            }



            for (int i = 0; i < currentNbHuman; i++)
            {
                int        idModel = creaturePrefabManager.GetRandomHumanID();
                GameObject model   = creaturePrefabManager.GetHuman(idModel);
                Human      humain  = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().GetFighterOfID <Human>(creatureType, idModel);
                humain.sexe = enumSex.None;

                enumSex sexCurrent = creaturePrefabManager.GetSexPrefabId(model, idModel);
                humain.sexe = sexCurrent;

                ModelHumainUI modelUI = model.GetComponent <ModelHumainUI>();
                if (modelUI != null)
                {
                    modelUI.RandomCheveux();
                }

                if (humain == null)
                {
                    humain = new Human();
                    humain.CopyHuman(defaultHuman);
                    humain.nID = idModel;
                    //humain.sName = model.name;
                }

                GameObject g = Instantiate(prefab, humansPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject;

                GameObject mo = Instantiate(model, humansPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject;
                mo.transform.parent        = g.transform;
                mo.transform.localPosition = Vector3.zero;
                mo.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);

                mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

                MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
                mouseOver.fighterUI = g.GetComponent <FighterUI>();

                g.GetComponent <FighterUI>().fighter = humain;
                humanGroupFighter.lFighters.Add(humain);
                g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform;
                g.name             = humain.sName;

                g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
            }
        }
        else
        {
            if (specialType == SpecialType.Ed)
            {
                humanGroupFighter = new GroupEd();

                int        idModel = 30;
                GameObject model   = creaturePrefabManager.GetSpecial(idModel);
                //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel);
                Human humain = new Human();
                humain.CopyHuman(defaultHuman);
                humain.nID    = idModel;
                humain.sName  = "Ed";
                humain.nPower = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultHuman.nPower;

                GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;

                GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;
                mo.transform.parent        = g.transform;
                mo.transform.localPosition = Vector3.zero;
                mo.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);

                mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

                MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
                mouseOver.fighterUI = g.GetComponent <FighterUI>();

                g.GetComponent <FighterUI>().fighter = humain;
                humanGroupFighter.lFighters.Add(humain);
                g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform;
                g.name             = humain.sName;

                g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
            }
            if (specialType == SpecialType.Bard)
            {
                humanGroupFighter = new GroupBard();
                int        idModel = 31;
                GameObject model   = creaturePrefabManager.GetSpecial(idModel);
                //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel);
                Human humain = new Human();
                humain.CopyHuman(defaultHuman);
                humain.nID   = idModel;
                humain.sName = "Bard";

                GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;

                GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;
                mo.transform.parent        = g.transform;
                mo.transform.localPosition = Vector3.zero;
                mo.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);

                mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

                MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
                mouseOver.fighterUI = g.GetComponent <FighterUI>();

                g.GetComponent <FighterUI>().fighter = humain;
                humanGroupFighter.lFighters.Add(humain);
                g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform;
                g.name             = humain.sName;

                g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
            }
            if (specialType == SpecialType.Slip)
            {
                humanGroupFighter = new GroupSlip();
                int        idModel = 32;
                GameObject model   = creaturePrefabManager.GetSpecial(idModel);
                //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel);
                Human humain = new Human();
                humain.CopyHuman(defaultHuman);
                humain.nPower = 0;
                humain.nID    = idModel;
                humain.sName  = "MecEnSlip";

                GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;

                GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject;
                mo.transform.parent        = g.transform;
                mo.transform.localPosition = Vector3.zero;
                mo.transform.localScale    = new Vector3(0.3f, 0.3f, 0.3f);

                mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

                MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>();
                mouseOver.fighterUI = g.GetComponent <FighterUI>();

                g.GetComponent <FighterUI>().fighter = humain;
                humanGroupFighter.lFighters.Add(humain);
                g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform;
                g.name             = humain.sName;

                g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>();
            }
        }
    }