public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/apiaryData.nut");
        ApiaryData      data = new ApiaryData();

        //<<<-------------SAVING DATA--------------->>>
        Dictionary <string, int> burs = new Dictionary <string, int>();

        foreach (GameObject obj in bees)
        {
            Bee bee = obj.GetComponentInChildren <Bee>();
            burs.Add(bee.type, bee.quantity);
        }
        data.beeQuants = burs;
        data.slotOne   = beeSlotOne.GetComponentInChildren <RawImage>().texture.name;
        data.slotTwo   = beeSlotTwo.GetComponentInChildren <RawImage>().texture.name;

        if (resultOne == null)
        {
            data.resOne = "HOCUSPOCUS";
        }
        else
        {
            if (justFinished == false || resultOne.enabled == false || resultTwo.enabled == false || resultThree.enabled == false)//should fix it but still isnt perfect
            {
                data.resOne = "HOCUSPOCUS";
            }
            else
            {
                data.resOne   = resultOne.GetComponentInChildren <RawImage>().texture.name;
                data.resTwo   = resultTwo.GetComponentInChildren <RawImage>().texture.name;
                data.resThree = resultThree.GetComponentInChildren <RawImage>().texture.name;
                data.honeyRes = breed.honeyNumberResult;
            }
        }

        if (breedTimer > 0)
        {
            data.turns = breedTimer;
        }
        else
        {
            data.turns = 0;
        }

        //<<<-------------END OF SAVING DATA--------------->>>

        //need a different file for each data
        bf.Serialize(file, data);
        file.Close();
    }
예제 #2
0
        public virtual void DoUpdate()
        {
            TextureExporter.ImageFile imageFile = m_Gallery.m_ImageFiles [m_CurrentImageId];

            // Update the texture image
            RawImage img = m_ImageContainer.GetComponentInChildren <RawImage> ();

            img.texture = imageFile.m_Texture;

            // Scale the texture to fit its parent size
            float parentRatio = m_ImageContainer.rect.width / m_ImageContainer.rect.height;
            float ratio       = (float)imageFile.m_Texture.width / (float)imageFile.m_Texture.height;
            float scaleCoeff  = ratio / parentRatio;

            if (scaleCoeff >= 1f)
            {
                img.GetComponentInChildren <RawImage> ().transform.localScale = new Vector3(1f, 1f / scaleCoeff, 1f);
            }
            else
            {
                img.GetComponentInChildren <RawImage> ().transform.localScale = new Vector3(scaleCoeff, 1f, 1f);
            }

            // Buttons
            if (m_CurrentImageId == 0)
            {
                m_PreviousButton.gameObject.SetActive(false);
            }
            else
            {
                m_PreviousButton.gameObject.SetActive(true);
            }

            if (m_CurrentImageId >= m_Gallery.m_ImageFiles.Count - 1)
            {
                m_NextButton.gameObject.SetActive(false);
            }
            else
            {
                m_NextButton.gameObject.SetActive(true);
            }

            m_FileName.text = imageFile.m_Name;
            m_PageText.text = (m_CurrentImageId + 1).ToString() + "/" + m_Gallery.m_ImageFiles.Count;
        }
예제 #3
0
    void positionSidebarPiece(RawImage button, clickSetter setter, int index, int count, float topBarHeight, float bottomBarHeight)
    {
        float t = index / (float)count;

        button.rectTransform.sizeDelta              = new Vector2(sidebarWidth, (topBarHeight - bottomBarHeight) / count);
        button.rectTransform.anchoredPosition       = new Vector2(width + sidebarWidth / 2f, topBarHeight * (1f - t) + bottomBarHeight * t - button.rectTransform.sizeDelta.y / 2);
        button.rectTransform.localScale             = Vector2.one;
        button.GetComponentInChildren <Text>().text = setter.label;
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        text  = GetComponentInChildren <Text> ();
        image = GetComponentInChildren <RawImage> ();
//		text.text = "YO";
        imageButton = image.GetComponentInChildren <Button>();

        imageButton.onClick.AddListener(onClick);
//		defaultImage = Resources.Load ("leafball") as Texture2D;
    }
예제 #5
0
        private void UpdatePlantOption()
        {
            //clear plant option
            while (plantOptImageList.Count > 0)
            {
                RawImage p = plantOptImageList[0];
                plantOptImageList.RemoveAt(0);
                for (int j = 0; j < p.transform.childCount; j++)
                {
                    Destroy(p.transform.GetChild(j).gameObject);
                }
                Destroy(p.gameObject);
                p = null;
            }
            plantOptImageList.Clear();

            if (plantOptionList.Count == 0)
            {
                attention.texture = attentionTexture[0];
                return;
            }
            else
            {
                attention.texture = attentionTexture[1];
            }

            int index = 0;

            plantPanel.GetComponent <PutBackOption>().Target = plantPanel.GetComponent <PlantPanel>().right;
            //generate plant option
            foreach (KeyValuePair <PlantProperty, List <Vector2Int> > item in plantOptionList)
            {
                RawImage plantOption = Instantiate(plantOptPrefab, transform.localPosition, transform.rotation);
                plantOption.texture = item.Key.texture;

                plantOption.GetComponent <PlantOption>().canvas = transform.GetComponent <RectTransform>();
                plantOption.transform.SetParent(transform.Find("PlantPanel/MyScrollView"));
                plantOption.transform.localPosition = new Vector3(optWidthOffset * (index + 1), optHeightPos, 0);
                plantOption.transform.localScale    = new Vector3(1, 1, 1);

                plantOption.GetComponent <PlantOption>().plantProperty = item.Key;
                plantOption.GetComponent <PlantOption>().position      = item.Value;
                plantOption.GetComponentInChildren <Text>().text       = item.Key.name;

                plantOptImageList.Add(plantOption);

                index++;
            }
            if (plantOptImageList.Count >= 4)
            {
                plantPanel.GetComponent <PlantPanel>().left.x = plantPanel.GetComponent <PlantPanel>().right.x - (plantOptImageList.Count - 3) * (plantOptImageList[0].rectTransform.rect.width + optWidthOffset);
            }

            //Debug.Log(plantPanel.GetComponent<PlantPanel>().right.x);
        }
예제 #6
0
 public void DisplayDescription(RawImage friendUIImage)
 {
     if (friendUIImage.enabled)
     {
         Text tempText = friendUIImage.GetComponentInChildren <Text>();
         if (friendUITooltipList.Contains(tempText))
         {
             tempText.enabled      = true;
             displayingDescription = true;
         }
     }
 }
예제 #7
0
    void Update()
    {
        screwdriverImage.enabled = playerController.hasScrewDriver;
        screwdriverImage.GetComponentInChildren <Text>().enabled = playerController.hasScrewDriver;

        keycardImage.enabled = playerController.hasFirstKeycard;
        keycardImage.GetComponentInChildren <Text>().enabled = playerController.hasFirstKeycard;

        passwordImage.enabled = playerController.hasPassword;
        passwordImage.GetComponentInChildren <Text>().enabled = playerController.hasPassword;

        eyeImage.enabled = playerController.hasEye;
        eyeImage.GetComponentInChildren <Text>().enabled = playerController.hasEye;
    }
    private void HitRegUI()
    {
        if (HitPlayer)
        {
            if (FatalHit)
            {
                HitRegRenderer.enabled = true;
                FatalHit = false;
            }

            HitRegRenderer.GetComponentInChildren <Text>().text = "-" + HitDamage;
            HitRegRenderer.GetComponentInChildren <Text>().GetComponent <Animation>().Rewind();
            HitRegRenderer.GetComponentInChildren <Text>().GetComponent <Animation>().Play();

            _preHitTime = Time.time;
            HitPlayer   = false;
        }
        else if (HitRegUITime <= (Time.time - _preHitTime))
        {
            HitRegRenderer.enabled = false;
            HitRegRenderer.GetComponentInChildren <Text>().text = "";
        }
    }
예제 #9
0
    /// <summary>
    /// shows
    /// </summary>
    private void UpdateIconsAndText()
    {
        //Debug.Log("Updating icons and text");
        int[] counts =
        {
            VRUILogic.Instance.GetAllErrors().Count,
            VRUILogic.Instance.GetAllWarnings().Count,
            VRUILogic.Instance.GetAllDebugs().Count,
            VRUILogic.Instance.GetAllInfos().Count
        };

        Texture[] textures =
        {
            VRUILogic.Instance.GetIconTexture(DummyStates.MessageType.ERROR),
            VRUILogic.Instance.GetIconTexture(DummyStates.MessageType.WARNING),
            VRUILogic.Instance.GetIconTexture(DummyStates.MessageType.DEBUG),
            VRUILogic.Instance.GetIconTexture(DummyStates.MessageType.INFO),
        };

        int slotIndex = 0; //index of the current slot to work with

        //update each slot with current info
        for (int i = 0; i < counts.Length; i++)
        {
            if (counts[i] > 0)
            {
                RawImage currentSlot = m_ImageSlots[slotIndex];
                if (!currentSlot.enabled)
                {
                    currentSlot.enabled = true;
                }
                if (!currentSlot.texture.Equals(textures[i]))
                {
                    currentSlot.texture = textures[i];
                }
                Text slotText = currentSlot.GetComponentInChildren <Text>();
                slotText.text = GetSlotText(counts[i]); //update displayed counts with respective number

                slotIndex++;                            //work with next slot, this one filled
            }
        }
        //clear rest of the slots
        for (; slotIndex < m_ImageSlots.Length; slotIndex++)
        {
            m_ImageSlots[slotIndex].enabled = false;
            m_ImageSlots[slotIndex].GetComponentInChildren <Text>().text = "";
        }
    }
예제 #10
0
    //manipulate text on Q&A User Interface
    void DisplayToScreen(string[] questAnswers)
    {
        //set the text for the answer blocks in the Q&A interface
        buttons = GetComponentsInChildren <Button>();
        for (int counter = 0; counter < 4; counter++)
        {
            Text buttonText = buttons[counter].GetComponentInChildren <Text>();
            buttonText.text = questAnswers[counter];
        }

        //set the text for the question block in the Q&A interface
        questionImage = GetComponentInChildren <RawImage>();
        Text question = questionImage.GetComponentInChildren <Text>();

        question.text = questAnswers[4];
    }
예제 #11
0
        private void Awake()
        {
            if (instance)
            {
                Destroy(gameObject);
            }
            else
            {
                instance = this;
            }

            bg          = transform.GetChild(0).GetChild(0).GetComponent <RawImage>();
            versionText = bg.GetComponentInChildren <TMP_Text>();

            DontDestroyOnLoad(this);
            UpdateText();
            UpdateColor(bgColor);
        }
예제 #12
0
    public GameObject Launch(GameObject missile, GameObject mount, Transform source, Transform target, MissileCameraUI missileCameraUI)
    {
        var missileGO = Instantiate(missile);

        missileGO.transform.position = mount.transform.position;
        missileGO.transform.rotation = mount.transform.rotation;

        var missileController = missileGO.GetComponent <HellfireMissileController>();

        missileController.Source           = source;
        missileController.Target           = target;
        missileController.HasMissileCamera = true;

        RawImage missileCameraRI = Instantiate(_missileCameraRI);

        missileCameraRI.transform.SetParent(missileCameraUI.MissileCameraRIs, false);
        missileCameraRI.enabled = true;
        missileCameraRI.gameObject.SetActive(true);

        CameraInfoUI cameraInfoUI = missileCameraRI.GetComponentInChildren <CameraInfoUI>();

        cameraInfoUI.MissileCompassController.gameObject.SetActive(true);
        cameraInfoUI.MissileCompassController.Source = source.gameObject;
        cameraInfoUI.MissileCompassController.Target = target.gameObject;
        //cameraInfoUI.TargetLock.gameObject.SetActive(true);
        //ameraInfoUI.TargetName.gameObject.SetActive(true);
        //cameraInfoUI.RangeToTarget.gameObject.SetActive(true);

        missileController.MissileCameraRI = missileCameraRI;
        missileController.MissileCameraUI = missileCameraUI;
        //missileController.MissileCameraUI.MissileCompassController.gameObject.SetActive(true);
        //missileController.MissileCameraUI.MissileCompassController.Target = target.gameObject;
        //missileController.MissileCameraUI.TargetLock.gameObject.SetActive(true);
        //missileController.MissileCameraUI.TargetName.gameObject.SetActive(true);
        //missileController.MissileCameraUI.RangeToTarget.gameObject.SetActive(true);

        missileController.IsLaunched = true;

        return(missileGO);
    }
예제 #13
0
    private void ShowConfiguration(int configuration)
    {
        switch (configuration)
        {
        case 0:             //Drifter
            activateDrifter();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite    = shotSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite   = driftSprite;
            hex_specialAbility.GetComponentInChildren <Image>().sprite = driftingSprite;
            setParametersBars("average", "high");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "130";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "-";
            hex_specialAbility.gameObject.SetActive(true);
            LblSpecialAbility.gameObject.SetActive(true);
            break;

        case 1:             //Miner
            activateMiner();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite  = mineSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite = bombSprite;
            setParametersBars("low", "average");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "10";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "12";
            hex_specialAbility.gameObject.SetActive(false);
            LblSpecialAbility.gameObject.SetActive(false);
            break;

        case 2:             //Camper
            activateCamper();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite    = bazookaSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite   = laserSprite;
            hex_specialAbility.GetComponentInChildren <Image>().sprite = camperSprite;
            setParametersBars("high", "low");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "8";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "10";
            hex_specialAbility.gameObject.SetActive(true);
            LblSpecialAbility.gameObject.SetActive(true);
            break;

        case 3:             //Medical
            activateFake();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite    = cureSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite   = poisonSprite;
            hex_specialAbility.GetComponentInChildren <Image>().sprite = medicalSprite;
            setParametersBars("high", "high");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "90";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "10";
            hex_specialAbility.gameObject.SetActive(true);
            LblSpecialAbility.gameObject.SetActive(true);
            break;

        case 4:             //Rammer
            activateFake();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite  = rotatingBladesSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite = flameThrowerSprite;
            setParametersBars("average", "low");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "-";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "90";
            hex_specialAbility.gameObject.SetActive(false);
            LblSpecialAbility.gameObject.SetActive(false);
            break;

        case 5:             //Chainer
            activateFake();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite  = chainSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite = needlesSprite;
            setParametersBars("average", "average");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "-";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "-";
            hex_specialAbility.gameObject.SetActive(false);
            LblSpecialAbility.gameObject.SetActive(false);
            break;

        case 6:             //Defender
            activateFake();
            hex_firstWeapon.GetComponentInChildren <Image>().sprite  = shieldSprite;
            hex_secondWeapon.GetComponentInChildren <Image>().sprite = bombSprite;
            setParametersBars("low", "high");
            hex_firstWeapon.GetComponentInChildren <Text>().text  = "-";
            hex_secondWeapon.GetComponentInChildren <Text>().text = "12";
            hex_specialAbility.gameObject.SetActive(false);
            LblSpecialAbility.gameObject.SetActive(false);
            break;
        }
        shortDescription.text = descriptions[configuration];
        classText.text        = classNames[configuration];
    }
예제 #14
0
    void Setup()
    {
        RectTransform rt = image.GetComponent <RectTransform>();

        txW      = (int)rt.sizeDelta.x;
        txH      = (int)rt.sizeDelta.y;
        easeH    = (int)(txH * 0.35f);
        txBorder = (int)((txH - easeH) * 0.5f);
        Color32[] colors = new Color32[txW * txH];
        for (int c = 0; c < colors.Length; ++c)
        {
            colors[c] = new Color(0.1f, 0.1f, 0.1f, 1);
        }
        int lineP = txBorder * txW;

        for (int c = lineP; c < lineP + txW; ++c)
        {
            colors[c] = new Color(0.25f, 0.25f, 0.25f, 1);
            colors[c + txW * easeH] = new Color(0.25f, 0.25f, 0.25f, 1);
        }

        // Create a tween for each easeType
        int     totTypes  = Enum.GetNames(typeof(Ease)).Length;
        int     distX     = txW;
        int     distY     = txH;
        int     totCols   = Screen.width / txW - 1;
        float   startX    = image.transform.position.x;
        float   startY    = image.transform.position.y;
        Vector2 gridCount = Vector2.zero;

        for (int i = 0; i < totTypes; ++i)
        {
            // Instantiate and position new Images
            Transform t = ((GameObject)Instantiate(image.gameObject)).transform;
            t.SetParent(image.transform.parent);
            t.position = new Vector3(startX + distX * gridCount.x + txDistance * gridCount.x, startY - distY * gridCount.y - txDistance * gridCount.y, 0);
            gridCount.x++;
            if (gridCount.x > totCols)
            {
                gridCount.y++;
                gridCount.x = 0;
            }
            // Set textures
            Texture2D tx = new Texture2D(txW, txH, TextureFormat.ARGB32, false);
            tx.filterMode = FilterMode.Point;
            tx.SetPixels32(colors);
            tx.Apply();
            RawImage img = t.GetComponent <RawImage>();
            img.texture = tx;
            // Set tween and text
            Ease easeType = (Ease)i;
            img.GetComponentInChildren <Text>().text = easeType.ToString();
            float val   = txBorder;
            Tween tween = DOTween.To(() => val, x => val = x, txBorder + easeH, duration).SetDelay(1);
            tween.OnUpdate(() => SetTextureEase(easeType, tx, tween.Elapsed(), (int)val));
            if (easeType == Ease.INTERNAL_Custom)
            {
                tween.SetEase(easeCurve);
            }
            else
            {
                tween.SetEase(easeType);
            }
        }
        // Disable original image
        image.gameObject.SetActive(false);
    }
예제 #15
0
 /// <summary>
 ///     Displays a dialog on the screen with a message
 /// </summary>
 /// <param name="message">The message to be displayed in the dialog</param>
 public void DisplayDialog(string message)
 {
     Dialog.gameObject.SetActive(true);
     Dialog.GetComponentInChildren <Text>().text = message;
 }
예제 #16
0
    public void HideDescription(RawImage friendUIImage)
    {
        Text tempText = friendUIImage.GetComponentInChildren <Text>();

        tempText.enabled = false;
    }
예제 #17
0
 void Start()
 {
     renderr  = GetComponentInChildren <RawImage>();
     distance = renderr.GetComponentInChildren <Text>();
 }
예제 #18
0
    protected override void HandleLaunch()
    {
        if (base.IsLaunched)
        {
            gameObject.transform.SetParent(null);

            if (!gameObject.GetComponent <Rigidbody>())
            {
                gameObject.AddComponent <Rigidbody>();
                base.Rb            = gameObject.GetComponent <Rigidbody>();
                base.Rb.useGravity = false;
            }

            if (base.Fuel > 0)
            {
                float distanceAtGround = Utils.GetDistanceToTargetAtGround(gameObject.transform, base.Target);

                if (base.Target)
                {
                    if (base.HasMissileCamera)
                    {
                        if (_missileCameraRI && _controller.Target)
                        {
                            CameraInfoUI cameraInfoUI = _missileCameraRI.GetComponentInChildren <CameraInfoUI>();
                            cameraInfoUI.TargetName.text = _controller.Target.name;
                            cameraInfoUI.Altitude.text   = Utils.GetDistanceToGround(gameObject.transform).ToString();
                            cameraInfoUI.Distance.text   = Utils.GetDistanceToTarget(gameObject.transform, _controller.Target).ToString();
                            cameraInfoUI.Fuel.text       = Mathf.Round((base.Fuel / base.MaxFuel) * 100).ToString() + "%";
                            //cameraInfoUI.RangeToTarget.text = Utils.GetDistanceToTarget(gameObject.transform, _controller.Target).ToString() + " ft / " + Utils.GetDistanceToGround(gameObject.transform) + " ft";
                        }
                        else
                        {
                            Debug.Log("NO _missileCameraRI");
                        }

                        if (_missileCamera)
                        {
                            Quaternion targetRotation = Quaternion.LookRotation(base.Target.position - _missileCamera.transform.position);

                            Quaternion cameraRotation = Quaternion.RotateTowards(_missileCamera.transform.rotation, targetRotation, _missileCameraSpeed * Time.deltaTime);

                            _missileCamera.transform.rotation = cameraRotation;
                        }
                    }

                    // Is Laser Guided
                    if (base.IsLaserGuided)
                    {
                        if (base.PeakHeight > 0f && base.PeakHeightDistance > 0f &&
                            distanceAtGround > base.PeakHeightDistance)
                        {
                            Vector3 aboveTarget = base.Target.position + new Vector3(0f, base.PeakHeight, 0f);

                            base.MissileRotation = Quaternion.LookRotation(aboveTarget - transform.position);
                        }
                        else
                        {
                            base.MissileRotation = Quaternion.LookRotation(base.Target.position - gameObject.transform.position);
                        }

                        base.Rb.MoveRotation(Quaternion.RotateTowards(gameObject.transform.rotation, base.MissileRotation, base.TurnSpeed));
                    }
                }
                else
                {
                    base.Rb.useGravity = true;
                }
            }
        }
        base.HandleLaunch();
    }