Esempio n. 1
0
    public override void Awake()
    {
        base.Awake();
        gameObject.SetActive(false);
        contentPanel = (RectTransform)transform.Find("ContentPanel");
        scroller = transform.Find("Scrollbar").GetComponent<Scrollbar>();
        messageBox = new MessageBox(transform.Find("MessageBox"));

        scroller.onValueChanged.AddListener(delegate(float value)
        {
            float screenHeight = Screen.height;
            float screenWidth = Screen.width;
            float allHeight = contentPanel.rect.height - screenHeight + 50f;
            float allWidth = contentPanel.rect.width;
            float yPos = value * -allHeight + allHeight / 2f + screenHeight / 2f;
            float xPos = (screenWidth - allWidth) / 2f + allWidth / 2;
            contentPanel.position = new UnityEngine.Vector2(xPos, yPos);
        });

        RectTransform userInfoPanel = (RectTransform)contentPanel.Find("UserInfoPanel");
        firstNameText = userInfoPanel.Find("UserNameText").GetComponent<Text>();
        secondNameText = userInfoPanel.Find("UserLavelText").GetComponent<Text>();
        userIconImage = userInfoPanel.Find("UserIcon").GetComponent<Image>();

        avalableGamesPanel = (RectTransform)contentPanel.Find("AvalableGamesPanel");
    }
Esempio n. 2
0
 private void Init()
 {
     _mRectTransform = this.transform as RectTransform;
     _imgBall1 = _mRectTransform.Find("Image_ball/ball1").GetComponent<Image>();
     _imgBall2 = _mRectTransform.Find("Image_ball/ball2").GetComponent<Image>();
     _imgBall3 = _mRectTransform.Find("Image_ball/ball3").GetComponent<Image>();
     ResetBall();
 }
 private void Awake()
 {
     Delegates.CurrentTeamColorChanged += RefreshColor;
     Delegates.ScreenSizeChanged += RefreshEntryRect;
     (entry = GetComponent<RectTransform>()).SetParent(GameObject.Find("ProductionLists").transform);
     description = entry.Find("Description").GetComponent<Text>();
     tintedIcon = entry.Find("TintedIcon").GetComponent<Image>();
     underlay = entry.Find("Underlay").GetComponent<Image>();
 }
Esempio n. 4
0
    public void Start() {
        // get components
        canvas = GameObject.Find("StatUI").GetComponent<RectTransform>();
        game = canvas.GetComponent<Game>();
        model = transform.Find("Model").transform;
        player = GameObject.Find("Player").transform;
        nav = GetComponent<NavMeshAgent>();
        nav.speed = Random.Range(2.0f, 5.5f);

        // build healthbar
        GameObject backGO = new GameObject("healthbarback");
        backGO.transform.parent = canvas.Find("HealthBars").transform;
        GameObject healthGO = new GameObject("healthbar");
        healthGO.transform.parent = canvas.Find("HealthBars").transform;

        healthBar = healthGO.AddComponent<Image>();
        backBar = backGO.AddComponent<Image>();

        healthBar.color = Color.red;
        backBar.color = new Color(0.2f, 0.0f, 0.0f);

        healthBar.rectTransform.sizeDelta = new Vector2(100, 5);
        backBar.rectTransform.sizeDelta = new Vector2(100, 5);

        backBar.rectTransform.pivot = Vector2.zero;
        healthBar.rectTransform.pivot = Vector2.zero;

        switch (type) {
            case EnemyType.ORC:
                hp = 2.0f + game.level;
                damage = 2.0f + game.level;
                break;
            case EnemyType.SKELETON:
                hp = 0.5f + game.level / 3.0f;
                damage = 1.0f + (game.level) / 3.0f;
                break;
            case EnemyType.MAGE:
                hp = 1.0f + game.level / 3.0f;
                damage = 2.5f + game.level / 2.0f;
                break;
            case EnemyType.RANGER:
                hp = 1.0f + game.level / 2.0f;
                damage = 1.0f + game.level / 2.0f;
                break;
            case EnemyType.CROSSBOW:
                hp = 1.0f + game.level / 1.5f;
                damage = 1.0f + game.level / 2.0f;
                break;
            default:
                hp = 1.0f + game.level / 2.0f;
                damage = 1.0f + game.level / 2.0f;
                break;
        }

        maxhp = hp;
    }
Esempio n. 5
0
 private void Init()
 {
     _mRectTransform = this.transform as RectTransform;
     _bar = _mRectTransform.Find("bar").GetComponent<Image>();
     _count = _mRectTransform.Find("count");
     //gameObject.SetActive(false);
     //StartCombo();
     /*Type T = Type.GetType("Game.EnityData");
     MemberInfo[] _a = T.GetMember("DictActionTime");*/
 }
Esempio n. 6
0
	// Use this for initialization
	void Start () {
		//Enemy killed counter initialisation
		text = GetComponentInChildren<Text>();
		text.text = ("Enemies killed : " + enemiesKilled);
		GameObject player = GameObject.FindGameObjectWithTag("Player");
		health = player.GetComponent<HealthScript>();
		playerHealth = health.health;
		totalHealth = playerHealth;
		weapon = player.GetComponent<WeaponController>();
		skill = player.GetComponent<SkillController>();

		GameObject skills = GameObject.Find("Skills");
		//skills.gameObject.
		GameObject bullet = GameObject.Find("Bullet");
		bulletCooldownBar = bullet.GetComponentInChildren<RectTransform>();
		bulletCooldownBar = bulletCooldownBar.FindChild("Cooldown") as RectTransform;
		GameObject secondary = GameObject.Find("Secondary");
		secondaryCooldownBar = secondary.GetComponentInChildren<RectTransform>();
		secondaryCooldownBar = secondaryCooldownBar.FindChild("Cooldown") as RectTransform;
		GameObject dodge = GameObject.Find("Dodge");
		dodgeCooldownBar = dodge.GetComponentInChildren<RectTransform>();
		dodgeCooldownBar = dodgeCooldownBar.Find("Cooldown") as RectTransform;

		Image healthBarImage = GetComponentInChildren<Image>();
		healthBar = healthBarImage.gameObject.GetComponent<RectTransform>();
	}
Esempio n. 7
0
    private void Init()
    {
        m_transform = this.transform as RectTransform;
        img_word1 = m_transform.Find("img_word1").GetComponent<Image>();
        img_word2 = m_transform.Find("img_word2").GetComponent<Image>();
        img_top = m_transform.Find("img_top").GetComponent<Image>();
        img_bottom = m_transform.Find("img_bottom").GetComponent<Image>();

        img_top.rectTransform.anchoredPosition = new Vector2(0, 0);
        img_bottom.rectTransform.anchoredPosition = new Vector2(0, 0);
        img_word1.rectTransform.anchoredPosition = new Vector2(-180, 0);
        img_word2.rectTransform.anchoredPosition = new Vector2(180, 0);
        m_transform.sizeDelta = new Vector2(400, 0);
        m_transform.anchoredPosition = new Vector2(0, 200);
        gameObject.SetActive(false);
        this.Invoke("PlayEffect", 1f);
    }
Esempio n. 8
0
 void Start()
 {
     mRectTransform = this.transform as RectTransform;
     _btn = mRectTransform.GetComponent<Button>();
     _mask = mRectTransform.Find("mask").GetComponent<Image>();
     _mask.transform.localPosition = Vector3.zero;
     _mask.enabled = false;
 }
Esempio n. 9
0
 private void Init()
 {
     m_transfrom = this.transform as RectTransform;
     Transform _btns = m_transfrom.Find("btn_container");
     btn_atk = _btns.Find("btn_atk").GetComponent<Button>();
     btn_skill1 = _btns.Find("btn_skill1").GetComponent<Button>();
     btn_skill2 = _btns.Find("btn_skill2").GetComponent<Button>();
     btn_skill3 = _btns.Find("btn_skill3").GetComponent<Button>();
     btn_skill4 = _btns.Find("btn_skill4").GetComponent<Button>();
     _arrBtns = new Button[5] { btn_atk, btn_skill1, btn_skill2, btn_skill3, btn_skill4 };
 }
Esempio n. 10
0
    private void PutInInventory(RectTransform panel, Toggle sender)
    {
        string selectedID = panel.Find("Panel/ItemStaticID").GetComponentInChildren<Text>().text;

        Destroy(panel.gameObject);

        Equipment e = itemDatabase.GetCopyEquipment(selectedID);

        CurrentPlayer.currentPlayer.PlayerInventory.AddEquipment(e);

        Destroy(GameObject.Find("ItemTooltip(Clone)").gameObject);
    }
Esempio n. 11
0
    private void PutInInventory(RectTransform panel, Toggle sender)
    {
        string staticID = panel.Find("Panel/ItemStaticID").GetComponentInChildren<Text>().text;

        Destroy(panel.gameObject);

        Equipment e = itemDatabase.GetCopyEquipment(staticID);

        CurrentPlayer.currentPlayer.PlayerInventory.AddEquipment(e);
        information.RemoveFromDropLoot(staticID);

        Destroy(GameObject.Find("ItemTooltip(Clone)").gameObject);
        numberOfLoot--;
        if (numberOfLoot == 0)  //ako vise nema nicega za lootanje, disable skriptu
        {
            Destroy(gameObject.transform.parent.gameObject);
        }
    }
Esempio n. 12
0
 public void loadAssets()
 {
     if (m_rect == null ||
         m_title == null ||
         m_parameters == null ||
         m_viewport == null ||
         m_content == null
     )
     {
         m_layoutElem = GetComponent<LayoutElement>();
         m_rect = (RectTransform)transform;
         m_title = transform.Find("title_panel").GetComponent<RectTransform>();
         m_parameters = transform.Find("parameters").GetComponent<RectTransform>();
         m_viewport = m_parameters.Find("viewport").GetComponent<RectTransform>();
         m_content = m_viewport.Find("content").GetComponent<RectTransform>();
         m_upScroll = transform.Find("scroll_up").GetComponent<RectTransform>();
         m_downScroll = transform.Find("scroll_down").GetComponent<RectTransform>();
     }
 }
Esempio n. 13
0
    void Awake()
    {
        if (instance == null)
            instance = this;
        else if (instance != this)
            Destroy (gameObject);

            cam = Camera.main;
            player=GameObject.Find("Player").GetComponent<Player>();
            scorePanel=GameObject.Find("Panel_Score").GetComponent<RectTransform>();

        boardScript=GetComponent<BoardManager>();
        inputHandler=GetComponent<InputHandler>();
        dataFetcher=GetComponent<DataFetcher>();

        scoreSlider = scorePanel.Find("Slider_Score").GetComponent<Slider>();
        livesSlider = scorePanel.Find("Slider_lives").GetComponent<Slider>();
        levelText=GameObject.Find("level").GetComponent<Text>();
        levelDesc=GameObject.Find("level_desc").GetComponent<Text>();

        scoreText = scorePanel.Find("Text_Score").GetComponent<Text>();
        sceneEnd = GameObject.Find ("scene_end").GetComponent<Image>();
        bRestart= GameObject.FindWithTag ("Respawn").GetComponent<Button>();
        bRestart.gameObject.SetActive (false);
        bResume= GameObject.FindWithTag ("Resume").GetComponent<Button>();
        bResume.gameObject.SetActive (false);
        bPause= GameObject.FindWithTag ("Pause").GetComponent<Button>();
        //bPause.gameObject.SetActive (false);
        bExit= GameObject.FindWithTag ("Finish").GetComponent<Button>();
        bExit.gameObject.SetActive (false);
        bSoundOn= GameObject.Find ("sound_on").GetComponent<Button>();
        bSoundOn.gameObject.SetActive (false);
        bSoundOff= GameObject.Find ("sound_off").GetComponent<Button>();
        bSoundOff.gameObject.SetActive (false);
        debug=GameObject.Find("debug").GetComponent<Text>();
        sound= GetComponent<AudioSource>();

        initGame ();
        if (Screen.width > Screen.height)
            camerazoom = 8;
        StartCoroutine("cameraZoomIn");
        highS = PlayerPrefs.GetInt ("high_score");
    }
Esempio n. 14
0
 private void _InitRoomUI( )
 {
     m_tf = transform.rectTransform();
     m_menuTf = m_tf.Find("menu").GetChild(0);
     m_menuButtonTf = m_tf.Find("menu").GetChild(1);
     m_menuCanvasGroup = m_menuTf.GetComponent<CanvasGroup>();
 }
Esempio n. 15
0
    public override void Awake()
    {
        base.Awake();

        gameObject.SetActive(true);
        myInfoWindiow = (RectTransform)transform.Find("MyWindow");
        usersWindow = (RectTransform)transform.Find("UsersWindow");

        RectTransform dataWindow = (RectTransform)transform.Find("DataWindow");

        messagesWindow = (RectTransform)dataWindow.Find("MessagesPanel");
        sendControlsPanel = (RectTransform)dataWindow.Find("ControlsPanel");

        messagesList = (RectTransform)messagesWindow.Find("MessagesList");
        messagesListScroller = messagesWindow.Find("MessagesScrollbar").GetComponent<Scrollbar>();
        messagesListScroller.onValueChanged.AddListener(delegate(float value)
        {
            float listHeight = messagesList.rect.height;
            float windowHeight = ((RectTransform)messagesListScroller.transform).rect.height;
            if (listHeight > windowHeight)
            {
                float yPos = (listHeight / -2f) + value * (listHeight - windowHeight);
                messagesList.anchoredPosition = new UnityEngine.Vector2(usersList.anchoredPosition.x, yPos);
            }
        });

        sendMessageButton = sendControlsPanel.Find("SendButton").GetComponent<Button>();
        sendMessageButton.onClick.AddListener(onSendMessageClick);
        sendMessageInputField = sendControlsPanel.Find("InputField").GetComponent<InputField>();

        usersList = (RectTransform)usersWindow.Find("UsersList");
        usersListScroller = usersWindow.Find("UsersListScroller").GetComponent<Scrollbar>();
        usersListScroller.onValueChanged.AddListener(delegate(float value)
        {
            float listHeight = usersList.rect.height;
            float windowHeight = ((RectTransform)usersListScroller.transform).rect.height;
            if (listHeight > windowHeight)
            {
                float yPos = (listHeight / -2f) + value * (listHeight - windowHeight);
                usersList.anchoredPosition = new UnityEngine.Vector2(usersList.anchoredPosition.x, yPos);
            }
        });

        startWait();
    }
Esempio n. 16
0
    private void UnequipEquip(RectTransform panel, Toggle sender)
    {
        int itemID = int.Parse(panel.Find("Panel/ItemID").GetComponentInChildren<Text>().text);

        Equipment newEquip = null;  //equipment koji se zeli obuci
        foreach (Equipment e in CurrentPlayer.currentPlayer.PlayerInventory.PlayerInventory)
        {
            if (e.IDEquipment == itemID)
            {
                newEquip = e;
            }
        }

        string slot = "";
        int id;

        foreach (Transform child in InventoryItemList)   //za svaki equipment u izborniku
        {
            slot = child.Find("Panel/ItemSlot").GetComponentInChildren<Text>().text;    //nadi gdje se nalazi
            id = int.Parse(child.Find("Panel/ItemID").GetComponentInChildren<Text>().text);    //id equipmenta u izborniku

            if (slot == newEquip.Slot.ToString())   //ako se slotovi podudaraju
            {
                if (id != newEquip.IDEquipment)  //i to nije ista instanca objekta
                {
                    if (child.Find("Panel/Equip").GetComponent<Toggle>().isOn == true && sender.isOn == true)
                    {
                        child.Find("Panel/Equip").GetComponent<Toggle>().isOn = false;    //promjeni ga u false, tj skini ga
                    }
                }
            }
        }

        CurrentPlayer.currentPlayer.PlayerInventory.ChangeEquip(sender.isOn, newEquip);
    }
Esempio n. 17
0
 private void Awake()
 {
     m_RectTransform = this.transform as RectTransform;
     bar = m_RectTransform.Find("Bar").GetComponent<Image>();
 }
Esempio n. 18
0
 private void Init()
 {
     _rectTransform = this.transform as RectTransform;
     _imgPoint = _rectTransform.Find("Image_point").GetComponent<Image>();
     _imgPoint.transform.DOScale(new Vector3(1.2f, 1.2f, 1), 0.3f).SetLoops(-1, LoopType.Yoyo);
 }
Esempio n. 19
0
 protected override void Awake()
 {
     base.Awake();
     (hbCanvas = (Instantiate(Resources.Load("HealthBar")) as GameObject).GetComponent<Canvas>()).worldCamera = Camera.main;
     hbRect = hbCanvas.transform.Find("HBRect").GetComponent<RectTransform>();
     hbImage = hbRect.Find("HBImage").GetComponent<RawImage>();
     hbText = hbRect.Find("HBText").GetComponent<Text>();
     hbHorizontalPixelNumber = Mathf.RoundToInt(Mathf.Pow(MaxHP(), 0.25f) * 10);
     gameObject.AddComponent<Rigidbody>().isKinematic = true;
 }