Inheritance: MonoBehaviour
Example #1
0
        public static void Copy(UnturnedPlayer fromPlayer, UnturnedPlayer toPlayer, bool clothes)
        {
            PlayerClothing clothing    = fromPlayer.Player.clothing;
            Hat            hat         = new Hat(clothing.hat, clothing.hatQuality, clothing.hatState);
            Mask           mask        = new Mask(clothing.mask, clothing.maskQuality, clothing.maskState);
            Shirt          shirt       = new Shirt(clothing.shirt, clothing.shirtQuality, clothing.shirtState);
            Vest           vest        = new Vest(clothing.vest, clothing.vestQuality, clothing.vestState);
            Backpack       backpack    = new Backpack(clothing.backpack, clothing.backpackQuality, clothing.backpackState);
            Pants          pants       = new Pants(clothing.pants, clothing.pantsQuality, clothing.pantsState);
            Glasses        glasses     = new Glasses(clothing.glasses, clothing.glassesQuality, clothing.glassesState);
            Clothing       clothesList = new Clothing(hat, mask, shirt, vest, backpack, pants, glasses);

            List <Item> itemList       = ListItems(fromPlayer);
            int         inventoryCount = itemList.Count;

            Clear(toPlayer, clothes);

            if (clothes == true)
            {
                AddClothing(toPlayer, backpack, clothesList);
            }
            else
            {
                AddClothing(toPlayer, backpack);
            }

            for (int i = 0; i < itemList.Count; i++)
            {
                AddItem(toPlayer, itemList[i]);
            }
        }
Example #2
0
    public static string FindGlassKey(int iMID, int iPID, int iGID)
    {
        string strRet = "";

        for (int i = 0; i < manufacturers_list.ManufacturerList.Count; i++)
        {
            if (manufacturers_list.ManufacturerList[i].ID != iMID)
            {
                continue;
            }

            Products PL = MojingSDK.GetProducts(manufacturers_list.ManufacturerList[i].KEY, "zh");
            for (int j = 0; j < PL.ProductList.Count; j++)
            {
                if (PL.ProductList[j].ID != iPID)
                {
                    continue;
                }
                Glasses GL = MojingSDK.GetGlasses(PL.ProductList[j].KEY, "zh");
                for (int k = 0; k < GL.GlassList.Count; k++)
                {
                    if (GL.GlassList[k].ID == iGID)
                    {
                        return(GL.GlassList[k].KEY);
                    }
                }
            }
        }
        return(strRet);
    }
Example #3
0
        //Populate DetectionInfo with face recognition Attributes
        public DetectionInfo(Image <Bgr, byte> image, ICollection <Rectangle> rectangles, ICollection <Face> faces)
        {
            InitData();
            Image      = image;
            Rectangles = rectangles;
            Faces      = faces;

            if (faces.Any())
            {
                PersonCount = Faces.Count;
                //Gestion des genres
                Genders     = faces.Select(gender => gender.FaceAttributes.Gender).ToList();
                MaleCount   = Genders.Where(g => g == "male").Count();
                FemaleCount = Genders.Where(g => g == "female").Count();
                //Calcul de l'age moyen
                AgeAverage = faces.Select(age => age.FaceAttributes.Age).ToList().Average();
                //Calcul du nombre de sourire
                Smiles     = faces.Select(age => age.FaceAttributes.Smile).ToList();
                SmileCount = Smiles.Where(s => s >= 0.5).Count();
                //Calcul du nombre de "poilus" (moustache ou barbe)
                FacialHair = faces.Select(age => age.FaceAttributes.FacialHair).ToList();
                foreach (var f in FacialHair)
                {
                    if (f.Beard > 0.3 || f.Moustache > 0.3)
                    {
                        HearyCount++;
                    }
                }
                //calcul du nombre de porteur de lunettes de vue et solaire
                Glasses             = faces.Select(g => g.FaceAttributes.Glasses).ToList();
                SunGlassesCount     = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.Sunglasses).Count();
                ReadingGlassesCount = Glasses.Where(g => g == Microsoft.ProjectOxford.Face.Contract.Glasses.ReadingGlasses).Count();
                //Accessoires : non gérés
                Accessories = faces.Select(age => age.FaceAttributes.Accessories).ToList();
                //Ventilation des emotions selon les 4 grandes tendances
                Emotions = faces.Select(age => age.FaceAttributes.Emotion).ToList();
                foreach (var e in Emotions)
                {
                    if (GetEmotion(e) == "Happiness")
                    {
                        EmotionHappyCount++;
                    }
                    if (GetEmotion(e) == "Anger")
                    {
                        EmotionAngerCount++;
                    }
                    if (GetEmotion(e) == "Disgust")
                    {
                        EmotionDisgustCount++;
                    }
                    if (GetEmotion(e) == "Neutral")
                    {
                        EmotionNeutralCount++;
                    }
                }
                //Calcul du ratio de "happy" par rapport au nombre de personnes
                HappyRatio = Math.Round((((double)EmotionHappyCount / (double)faces.Count)) * 100, 2);
            }
        }
Example #4
0
 public Clothing(Hat hat, Mask mask, Shirt shirt, Vest vest, Backpack backpack, Pants pants, Glasses glasses)
 {
     this.hat      = hat;
     this.mask     = mask;
     this.shirt    = shirt;
     this.vest     = vest;
     this.backpack = backpack;
     this.pants    = pants;
     this.glasses  = glasses;
 }
Example #5
0
 private void Start()
 {
     _glasses    = GetComponent <Glasses>();
     _checkbox   = new Vector3(.35f, 0.3f, .35f);
     _animator   = GetComponent <Animator>();
     CharacContr = GetComponent <CharacterController>();
     if (PlayerPrefs.HasKey("PosX") && PlayerPrefs.HasKey("PosY") && PlayerPrefs.HasKey("PosZ"))
     {
         transform.position = new Vector3(PlayerPrefs.GetFloat("PosX"), PlayerPrefs.GetFloat("PosY"), PlayerPrefs.GetFloat("PosZ"));
     }
 }
 public FaceFormatter(Face face)
 {
     attributes = face.FaceAttributes;
     age        = attributes.Age;
     gender     = attributes.Gender;
     smile      = attributes.Smile;
     facialHair = attributes.FacialHair;
     headPose   = attributes.HeadPose;
     glasses    = attributes.Glasses;
     pos        = face.FaceRectangle.Left + face.FaceRectangle.Width / 2;
 }
Example #7
0
 private void GenerateItems()
 {
     for (int i = 0; i < glasses; i++)
     {
         Glasses.Enqueue(new Glass());
     }
     for (int i = 0; i < chairs; i++)
     {
         Chairs.Enqueue(new Chair());
     }
 }
Example #8
0
 void ResetCurrentValues()
 {
     ClearCurrentComboBoxValues();
     BtnsReenable();
     HideCurrentOrderElements();
     contactLenses  = null;
     glasses        = null;
     glassAdditions = null;
     orderList      = null;
     optionsST.Children.Clear();
     SaveRims.Click -= SaveRimsBtnClick;
 }
Example #9
0
    public void RandomiseFaceData(GrandData final)
    {
        final.Info.C_Hair = HairGrad.Evaluate(Random.value);        //RandomHair();
        final.Info.C_Skin = SkinGrad.Evaluate(Random.value);        //RandomSkin();
        final.Info.C_Eye  = RandomEye();

        RandomiseOffsetColours(final);

        final.Info.Base = Base.Randomise(final.Info.Gender, Simple2x2.zero, Simple2x2.zero, Simple2x2.zero);

        final.Info.Eye = Eye.Randomise(final.Info.Gender, new Simple2x2(0.0F, -0.5F, 0.0F, 0.9F),
                                       Simple2x2.zero,
                                       new Simple2x2(-0.2F, -0.2F, 0.1F, 0.1F));
        //	new Vector3(0,0.05F), 0.0F, new Vector3(0.1F, 0.1F));

        final.Info.Ear = Ear.Randomise(final.Info.Gender, new Simple2x2(0.0F, -1.5F, 0.0F, 1.5F),
                                       new Simple2x2(-4.0F, 0.0F, 4.0F, 0.0F),
                                       new Simple2x2(-0.3F, -0.3F, 0.05F, 0.25F));
        //new Vector3(0,0.3F), 4.0F,  new Vector3(0.3F, 0.3F));

        final.Info.Brow = Brow.Randomise(final.Info.Gender, new Simple2x2(0.0F, -0.1F, 0.0F, 0.15F),
                                         new Simple2x2(-5.0F, 0.0F, 7.0F, 0.0F),
                                         new Simple2x2(-0.2F, -0.15F, 0.35F, 0.35F));
        //new Vector3(0,0.1F), 6.0F,  new Vector3(0.3F, 0.2F));

        final.Info.Hair = Hair.Randomise(final.Info.Gender, Simple2x2.zero,
                                         Simple2x2.zero,
                                         new Simple2x2(0.0F, -0.1F, 0.0F, 0.1F));
        //Vector3.zero, 0.0F,  new Vector3(0.0F, 0.1F));

        final.Info.Jaw = Jaw.Randomise(final.Info.Gender, Simple2x2.zero,
                                       Simple2x2.zero,
                                       new Simple2x2(-0.15F, -0.15F, 0.13F, 0.2F));
        //Vector3.zero, 0.0F, new Vector3(0.35F, 0.25F));

        final.Info.Nose = Nose.Randomise(final.Info.Gender, new Simple2x2(0.0F, -0.7F, 0.0F, 0.7F),
                                         Simple2x2.zero,
                                         new Simple2x2(-0.2F, -0.15F, 0.2F, 0.35F));
        //new Vector3(0,0.1F), 0.0F,  new Vector3(0.1F, 0.3F));

        final.Info.Glasses = Random.value > (float)final.Age.Current / 100 ? null :
                             Glasses.Randomise(true, Simple2x2.zero,
                                               Simple2x2.zero,
                                               new Simple2x2(0.0F, 0.0F, 0.34F, 0.35F));
        if (final.Info.Glasses != null)
        {
            final.Info.Glasses._Scale   += (final.Info.Eye._Scale - Vector3.one);
            final.Info.Glasses._Position = final.Info.Eye._Position;
        }

        SetPupilInfo(final);
    }
Example #10
0
 public static Glasses GetGlasses(string strProductKey, string strLanguageCodeByISO963)
 {
     try
     {
         string  json = GetGlassList(strProductKey, strLanguageCodeByISO963);
         Glasses list = JsonMapper.ToObject <Glasses>(json);
         return(list);
     }
     catch (Exception e)
     {
         MojingLog.LogTrace(e.ToString());
     }
     return(null);
 }
Example #11
0
        public static void AddClothing(UnturnedPlayer player, Backpack backpack, Clothing clothing = null)
        {
            if (clothing != null)
            {
                Hat     hat     = clothing.hat;
                Mask    mask    = clothing.mask;
                Shirt   shirt   = clothing.shirt;
                Vest    vest    = clothing.vest;
                Pants   pants   = clothing.pants;
                Glasses glasses = clothing.glasses;

                if (hat != null)
                {
                    player.Player.clothing.askWearHat(hat.id, hat.quality, hat.state, true);
                }
                if (mask != null)
                {
                    player.Player.clothing.askWearMask(mask.id, mask.quality, mask.state, true);
                }
                if (shirt != null)
                {
                    player.Player.clothing.askWearShirt(shirt.id, shirt.quality, shirt.state, true);
                }
                if (vest != null)
                {
                    player.Player.clothing.askWearVest(vest.id, vest.quality, vest.state, true);
                }
                if (pants != null)
                {
                    player.Player.clothing.askWearPants(pants.id, pants.quality, pants.state, true);
                }
                if (glasses != null)
                {
                    player.Player.clothing.askWearGlasses(glasses.id, pants.quality, pants.state, true);
                }
            }

            if (backpack != null)
            {
                player.Player.clothing.askWearBackpack(backpack.id, backpack.quality, backpack.state, true);
            }
        }
Example #12
0
        void OkButtonGlassesClick(object sender, RoutedEventArgs e)
        {
            var selectedType = TypeComboBox.Text;

            if (!string.IsNullOrEmpty(selectedType))
            {
                OkButtonGlasses.IsEnabled = false;
                TypeComboBox.IsEnabled    = false;
                ShowHiddenGlassesElements();
                string        product       = "glasses";
                VisionExpress visionExpress = new VisionExpress();
                switch (selectedType)
                {
                case "Multifocal":
                    GlassProductBuilder builderMulti = new MultifocalBuilder(product);
                    visionExpress.ConstructGlasses(builderMulti);
                    glasses = builderMulti.Glasses;
                    break;

                case "Progressive":
                    GlassProductBuilder builderProg = new ProgressiveBuilder(product);
                    visionExpress.ConstructGlasses(builderProg);
                    glasses = builderProg.Glasses;
                    break;

                case "Antireflective":
                    GlassProductBuilder builderAnti = new AntireflectiveBuilder(product);
                    visionExpress.ConstructGlasses(builderAnti);
                    glasses = builderAnti.Glasses;
                    break;
                }
                glassAdditions        = new GlassProduct();
                glassAddDefectCommand = new GlassProductDefectCommand();
                RenderCheckBox();
                FillRimsOptions();
                RefreshCurrentOrderList();
            }
        }
Example #13
0
        private string GlassType(Glasses glasses)
        {
            var glassInformation = "Has: ";

            if (glasses == Microsoft.ProjectOxford.Face.Contract.Glasses.NoGlasses)
            {
                glassInformation += "No glasses ";
            }
            if (glasses == Microsoft.ProjectOxford.Face.Contract.Glasses.ReadingGlasses)
            {
                glassInformation += "Reading glasses ";
            }
            if (glasses == Microsoft.ProjectOxford.Face.Contract.Glasses.Sunglasses)
            {
                glassInformation += "Sunglasses ";
            }
            if (glasses == Microsoft.ProjectOxford.Face.Contract.Glasses.SwimmingGoggles)
            {
                glassInformation += "Swimming googgles";
            }

            return(glassInformation);
        }
Example #14
0
    void Awake()
    {
        m_bResetTextureId = true;
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_Init("C3845343263589043", "3908040197953231", "8b20789122bae89442edadf780250ad5", "www.mojing.cn");

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
            MojingSDK.Unity_SetGamePadAxisMode(0);

            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            CreateDummyCamera();
            Application.targetFrameRate = 60;
            //MojingRender.StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");
            foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList)
            {
                product_list = MojingSDK.GetProducts(MI.KEY, "zh");
                foreach (ProductInfo PI in product_list.ProductList)
                {
                    glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh");
                    foreach (GlassInfo GI in glasses_list.GlassList)
                    {
                        string GlassName = MI.Display + " " + PI.Display + " " + GI.Display;
                        string GlassKey  = GI.KEY;
                        glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }
        MojingLog.LogTrace("Leave Mojing.Awake");
    }
Example #15
0
        private void UpdateGlassesCount()
        {
            int availableGlasses = Glasses.Where(x => x.IsEmpty).Count();

            GlasOnShelf.Text = $"Det finns {availableGlasses} lediga glas.";
        }
Example #16
0
    // Update is called once per frame
    void Update()
    {
        gameObject.transform.localScale = new Vector3(-facing, 1, 1);

        if (gameObject.GetComponent<Rigidbody2D>().velocity.x > 0)
        {
            facing = 1;
        }
        if (gameObject.GetComponent<Rigidbody2D>().velocity.x < 0)
        {
            facing = -1;
        }

        //|| (Input.GetButtonDown("Throw_Y_Player2") && player == 2)
        if (((Input.GetButtonDown("Throw_Y_Player1") && player == 1) || (Input.GetButtonDown("Throw_Y_Player2") && player == 2)) && hat != Hats.none)
        {
            GameObject thrownHat = Instantiate(pickup, hatSprite.transform.position + new Vector3 (0, 1, 0), Quaternion.identity) as GameObject;
            thrownHat.GetComponent<Pickups>().itemSprite = hatSprite.GetComponent<SpriteRenderer>().sprite;
            thrownHat.GetComponent<Pickups>().itemType = "Hat";
            thrownHat.GetComponent<Pickups>().points = hatPoints;
            thrownHat.GetComponent<Rigidbody2D>().velocity = new Vector2(10 * facing, 3);
            thrownHat.GetComponent<SpriteRenderer>().sprite = hatSprite.GetComponent<SpriteRenderer>().sprite;
            hatSprite.GetComponent<SpriteRenderer>().sprite = new Sprite();
            if (player == 1)
            {
                female.GetComponent<GameManager>().player1Points -= hatPoints;
            }
            else
            {
                female.GetComponent<GameManager>().player2Points -= hatPoints;
            }
            hat = Hats.none;
            hatPoints = 0;
        }

        if (((Input.GetButtonDown("Throw_X_Player1") && player == 1) || (Input.GetButtonDown("Throw_X_Player2") && player == 2)) && glasses != Glasses.none)
        {
            GameObject thrownGlasses = Instantiate(pickup, hatSprite.transform.position + new Vector3(0, 1, 0), Quaternion.identity) as GameObject;
            thrownGlasses.GetComponent<Pickups>().itemSprite = glassesSprite.GetComponent<SpriteRenderer>().sprite;
            thrownGlasses.GetComponent<Pickups>().itemType = "Glasses";
            thrownGlasses.GetComponent<Pickups>().points = glassesPoints;
            thrownGlasses.GetComponent<Rigidbody2D>().velocity = new Vector2(10 * facing, 3);
            thrownGlasses.GetComponent<SpriteRenderer>().sprite = glassesSprite.GetComponent<SpriteRenderer>().sprite;
            glassesSprite.GetComponent<SpriteRenderer>().sprite = new Sprite();
            if (player == 1)
            {
                female.GetComponent<GameManager>().player1Points -= glassesPoints;
            }
            else
            {
                female.GetComponent<GameManager>().player2Points -= glassesPoints;
            }
            glasses = Glasses.none;
            glassesPoints = 0;
        }

        if (((Input.GetButtonDown("Throw_B_Player1") && player == 1) || (Input.GetButtonDown("Throw_B_Player2") && player == 2)) && scarf != Scarves.none)
        {
            GameObject thrownScarf = Instantiate(pickup, hatSprite.transform.position + new Vector3(0, 1, 0), Quaternion.identity) as GameObject;
            thrownScarf.GetComponent<Pickups>().itemSprite = scarfSprite.GetComponent<SpriteRenderer>().sprite;
            thrownScarf.GetComponent<Pickups>().itemType = "Scarf";
            thrownScarf.GetComponent<Pickups>().points = scarfPoints;
            thrownScarf.GetComponent<Rigidbody2D>().velocity = new Vector2(10 * facing, 3);
            thrownScarf.GetComponent<SpriteRenderer>().sprite = scarfSprite.GetComponent<SpriteRenderer>().sprite;
            scarfSprite.GetComponent<SpriteRenderer>().sprite = new Sprite();
            if (player == 1)
            {
                female.GetComponent<GameManager>().player1Points -= scarfPoints;
            }
            else
            {
                female.GetComponent<GameManager>().player2Points -= scarfPoints;
            }
            scarf = Scarves.none;
            scarfPoints = 0;
        }
    }
Example #17
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Pickup")
        {
            if (other.GetComponent<Pickups>().itemType == "Hat")
            {
                hat = Hats.hat;
                hatSprite.GetComponent<SpriteRenderer>().sprite = other.GetComponent<Pickups>().itemSprite;
                Destroy(other.gameObject);
                if (player == 1)
                {
                    female.GetComponent<GameManager>().player1Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player1Points -= hatPoints;
                    hatPoints = other.GetComponent<Pickups>().points;
                }
                if (player == 2)
                {
                    female.GetComponent<GameManager>().player2Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player2Points -= hatPoints;
                    hatPoints = other.GetComponent<Pickups>().points;
                }
            }

            if (other.GetComponent<Pickups>().itemType == "Scarf")
            {
                scarf = Scarves.scarf;
                scarfSprite.GetComponent<SpriteRenderer>().sprite = other.GetComponent<Pickups>().itemSprite;
                Destroy(other.gameObject);
                if (player == 1)
                {
                    female.GetComponent<GameManager>().player1Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player1Points -= scarfPoints;
                    scarfPoints = other.GetComponent<Pickups>().points;
                }
                if (player == 2)
                {
                    female.GetComponent<GameManager>().player2Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player2Points -= scarfPoints;
                    scarfPoints = other.GetComponent<Pickups>().points;
                }
            }

            if (other.GetComponent<Pickups>().itemType == "Glasses")
            {
                glasses = Glasses.glasses;
                glassesSprite.GetComponent<SpriteRenderer>().sprite = other.GetComponent<Pickups>().itemSprite;
                Destroy(other.gameObject);
                if (player == 1)
                {
                    female.GetComponent<GameManager>().player1Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player1Points -= glassesPoints;
                    glassesPoints = other.GetComponent<Pickups>().points;
                }
                if (player == 2)
                {
                    female.GetComponent<GameManager>().player2Points += other.GetComponent<Pickups>().points;
                    female.GetComponent<GameManager>().player2Points -= glassesPoints;
                    glassesPoints = other.GetComponent<Pickups>().points;
                }
            }
        }
    }
Example #18
0
    void Awake()
    {
        m_bResetTextureId = true;
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if  UNITY_EDITOR_OSX
#else
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            MojingSDK.Unity_Init("C3845343263589043", "3956931912082870", "def5833993bbb001554ac192a79c9727", "www.mojing.cn", GetProfilePath());
#elif UNITY_IOS
            MojingSDK.Unity_Init("C3845343263589043", "3961565540023130", "f34c9b49192c5e6026f99125bdbabd27", "www.mojing.cn");
#endif
            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_SetGamePadAxisMode(0);

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            CreateDummyCamera();
            Application.targetFrameRate = 60;
            //MojingRender.StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");
            foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList)
            {
                product_list = MojingSDK.GetProducts(MI.KEY, "zh");
                foreach (ProductInfo PI in product_list.ProductList)
                {
                    glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh");
                    foreach (GlassInfo GI in glasses_list.GlassList)
                    {
                        string GlassName = MI.Display + " " + PI.Display + " " + GI.Display;
                        string GlassKey  = GI.KEY;
                        glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }
        LCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Left").GetComponent <Camera>();
        RCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Right").GetComponent <Camera>();
        MojingLog.LogTrace("Leave Mojing.Awake");
    }
Example #19
0
    void Awake()
    {
        MojingLog.LogTrace("Enter Mojing.Awake");
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if  UNITY_EDITOR_OSX
#else
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS
            MojingSDK.Unity_Init("Unity " + Application.unityVersion,
                                 "C3845343263589043", "4117870080735505", "751db2db58cb82308d9c455c6d236a10", "http://fuwu.mojing.cn/api/appdownload",
                                 Screen.width, Screen.height, 320, 320,
                                 GetProfilePath(), IntPtr.Zero);
#elif UNITY_ANDROID
            DisplayMetricsAndroid.InitDisplayMetricsAndroid();
            AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            MojingSDK.Unity_Init("Unity " + Application.unityVersion,
                                 "C3845343263589043", "3908657356234505", "faadffa1383206111ae162969b340ad9", "www.mojing.cn",
                                 DisplayMetricsAndroid.WidthPixels, DisplayMetricsAndroid.HeightPixels, DisplayMetricsAndroid.XDPI, DisplayMetricsAndroid.YDPI,
                                 GetProfilePath(), activity.GetRawObject());
#endif
            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_SetGamePadAxisMode(0);

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            //CreateDummyCamera();
#if UNITY_IOS
            Application.targetFrameRate = 60;
#endif
            //StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");

            for (int i = 0; i < manufacturers_list.ManufacturerList.Count; i++)
            {
                product_list = MojingSDK.GetProducts(manufacturers_list.ManufacturerList[i].KEY, "zh");
                for (int j = 0; j < product_list.ProductList.Count; j++)
                {
                    glasses_list = MojingSDK.GetGlasses(product_list.ProductList[j].KEY, "zh");
                    for (int k = 0; k < glasses_list.GlassList.Count; k++)
                    {
                        string GlassName = manufacturers_list.ManufacturerList[i].Display + " " + product_list.ProductList[j].Display + " " + glasses_list.GlassList[k].Display;
                        string GlassKey  = glasses_list.GlassList[k].KEY;
                        string GlassID   = manufacturers_list.ManufacturerList[i].ID + "/" + product_list.ProductList[j].ID + "/" + glasses_list.GlassList[k].ID;
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                        glassesIDList.Add(GlassID);
                        glassesKey = FindGlassKey(manufacturers_list.ManufacturerList[i].ID, product_list.ProductList[j].ID, glasses_list.GlassList[k].ID);
                        //glassesKey = GlassKey;   //获取初始glassKey,mojingvrhead awake中用
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }

        MojingLog.LogTrace("Leave Mojing.Awake");
    }