public void SetHP(float hitPoint) { this.hitPoint = hitPoint; GameObject hp = null; for (int i = 0; i < hitPoint; i++) { hp = Instantiate(hpObj); hpObjects.Add(hp); SizeFitter.FittingContent(hp, gameObject); SizeFitter.FittingSize(hp); } float residualPoint = hitPoint - (float)Math.Truncate(hitPoint); if (residualPoint > 0) { hp = Instantiate(hpObj); hp.GetComponent <Image>().fillAmount = residualPoint; hpObjects.Add(hp); SizeFitter.FittingContent(hp, gameObject); SizeFitter.FittingSize(hp); } }
protected virtual void AddPanel(IListObjectInfo info) { Debug.Log("AddPanel"); GameObject panel = Instantiate(this.listObject); ControlPanel containePanel; containePanel = panel.GetComponent <ControlPanel>(); if (info.GetOption().Title) { Debug.Log(info.GetTitle()); containePanel.SetText(info.GetTitle()); } if (info.GetOption().SubTitle) { Debug.Log(info.GetSubTitle()); containePanel.SetSubText(info.GetSubTitle()); } if (info.GetOption().Sprite) { containePanel.SetSprite(info.GetSprite()); } panel.transform.SetParent(content.transform); SizeFitter.FittingSize(panel); }
public void ReciveMessage(string message) { JObject chatMessage = JObject.Parse(message); try { ChatObject chat = Instantiate(chatObject); chat.outputText.text = chatMessage[ChatHelper.Message.ToString()].ToString(); chat.client.text = chatMessage[ChatHelper.Client.ToString()].ToString(); try { chat.profile.sprite = Resources.Load <Sprite>(chatMessage[ChatHelper.Profile.ToString()].ToString()); } catch (Exception e) { } SizeFitter.FittingContent(chat.gameObject, contentPanel); } catch (Exception e) { Debug.Log("Chat에러" + e); } }
private Vector3 GetDynamicVector() { SizeFitter sizeFitter = dynamicSize.GetComponent <SizeFitter>(); if (sizeFitter) { sizeFitter.AdjustSize(true); } return(dynamicSize.rect.height * TranslateVector.normalized); }
public void SideEffect(float time, AttackType type, CrowdControlEffect effect, FollowUpEffect followUpEffect = null) { if (!crowdControls.ContainsKey(type.ofensiveType)) { GameObject crowd = Instantiate(crowdControl); SizeFitter.FittingContent(crowd, gameObject); crowdControls.Add(type.ofensiveType, crowd.GetComponent <CrowdControl>()); crowdControls[type.ofensiveType].controler = this; } crowdControls[type.ofensiveType].SetCrowdControl(time, type.effect, effect, followUpEffect); // subSprites[0].sprite = sprite; // IEnumerator coroutine =CrowdControl(time, effect); }
public void Start() { diceSlots = new Dictionary <Vector2, GameObject>(); for (int y = 0; y < ySize; y++) { for (int x = 0; x < xSize; x++) { GameObject dice_slot = Instantiate(diceSlot); dice_slot.name = x + "," + y; dice_slot.transform.SetParent(transform); SizeFitter.FittingSize(dice_slot); diceSlots.Add(new Vector2(x, y), dice_slot); dice_slot.transform.Rotate(new Vector3(0, 0, RotateZ)); } } }
public virtual void NotifyChangeList() { Destroy(content); Debug.Log("노티파잉"); content = Instantiate(container); SizeFitter.FittingContent(content, parent); SizeFitter.FittingSize(content); if (this.GetComponentInChildren <ScrollRect>() != null) { this.GetComponentInChildren <ScrollRect>().content = content.GetComponent <RectTransform>(); } foreach (IListObjectInfo info in infos) { AddPanel(info); } }
public void MakeEye(int eye) { GameObject eyeObject = Instantiate(this.eye); DiceEye diceEye = eyeObject.GetComponent <DiceEye>(); SizeFitter.FittingContent(eyeObject, gameObject); diceEye.Init(this); foreach (DiceEye eyeObj in eyes) { eyeObj.ChangeSprite(diceStatus.dotSprite); } eyes.Add(diceEye); //여기 이후론 눈 숫자에 따라서 위치 조정 switch (eye) { case 2: eyes[0].transform.localPosition = new Vector3(-0.25f, 0); eyes[1].transform.localPosition = new Vector3(0.25f, 0); break; case 3: eyes[0].transform.localPosition = new Vector3(-0.25f, 0.25f); eyes[1].transform.localPosition = new Vector3(0, 0); eyes[2].transform.localPosition = new Vector3(0.25f, -0.25f); break; case 4: eyes[0].transform.localPosition = new Vector3(-0.25f, 0.25f); eyes[1].transform.localPosition = new Vector3(0.25f, 0.25f); eyes[2].transform.localPosition = new Vector3(-0.25f, -0.25f); eyes[3].transform.localPosition = new Vector3(0.25f, -0.25f); break; } }
public void OnBeginDrag(PointerEventData eventData) { gameManager.isDraging = true; oldParent = transform.parent; childList = new List <Transform>(); // Create new BlockGrid to drag Transform newParent = Instantiate(blockGridPrefab, transform.parent).GetComponent <Transform>(); newParent.position = transform.position; newParent.SetParent(gameManager.gameBoard); if (onHoldTimer > 0.25f) // Single Block { childList.Add(transform); } else // Mutiple Block { for (int i = transform.GetSiblingIndex(); i < oldParent.childCount; i++) { childList.Add(oldParent.GetChild(i)); } } // Create PlaceHolder placeHolder = Instantiate(placeHolderPrefab); placeHolder.transform.SetSiblingIndex(transform.GetSiblingIndex()); float height = GameUtility.CONNECTOR_HEIGHT; // Transfer All block to the new BlockGrid for (int i = 0; i < childList.Count; i++) { childList[i].SetParent(newParent.transform); childList[i].SetSiblingIndex(i); height += childList[i].GetComponent <RectTransform>().sizeDelta.y - GameUtility.CONNECTOR_HEIGHT; Transform phc = Instantiate(childList[i]); phc.SetParent(placeHolder.transform); phc.GetComponent <CanvasGroup>().blocksRaycasts = false; } //placeHolder.GetComponent<RectTransform>().sizeDelta = new Vector2( GameUtility.BLOCK_WIDTH, height ); SizeFitter.CheckForChanges(placeHolder.transform); // PlaceHolder's transparent effect && turn off raycast Color newColor = new Color(1.0f, 1.0f, 1.0f, 0.2f); foreach (Image img in placeHolder.GetComponentsInChildren <Image>()) { img.color = newColor; img.raycastTarget = false; } foreach (CanvasGroup cg in placeHolder.GetComponentsInChildren <CanvasGroup>()) { cg.blocksRaycasts = false; cg.interactable = false; } foreach (BlockGridInfo phbi in placeHolder.GetComponentsInChildren <BlockGridInfo>()) { phbi.priority = -1; } // Turning blocksRaycasts off to not disturb OnDrop Event gameManager.BlockBlockRaycast(false); gameManager.targetBlock = newParent; BlockRaycastWithChildGrid(gameManager.targetBlock, false); foreach (BlockGridDropZone cbg in GetComponentsInChildren <BlockGridDropZone>()) { gameManager.blockGridsUnderPointer.Remove(cbg.transform); } // if the original BlockGrid doesn't have Block anymore, there is no reason to return back // Prevent snapping to an seemingly empty space if (oldParent.childCount == 0 && oldParent.GetComponent <BlockGridInfo>().blockGridType == BlockGridType.Block && oldParent.parent == gameManager.gameContent) { oldParent.gameObject.GetComponent <CanvasGroup>().blocksRaycasts = false; gameManager.blockGridsUnderPointer.Remove(oldParent); foreach (BlockGridDropZone opc in oldParent.GetComponentsInChildren <BlockGridDropZone>()) { gameManager.blockGridsUnderPointer.Remove(opc.transform); } gameManager.blockGridsUnderPointer.Remove(transform.parent); } gameManager.blockGridsUnderPointer.Clear(); gameManager.ResetAll(); }