public void AddItem(ThrowItem item) { item.transform.SetParent(transform); item.transform.localScale = Vector3.one; list.Add(item); GameObjectPosition(); }
private void ThrowTrash() { // PhotonNetwork.Instantiate() บน Client คนไหน คนนั้นคือ ผู้ควบคุมวัตถุนั้น CheckActiveTrashIconsForDeActive(); GameObject thisTrash = PhotonNetwork.Instantiate(trashInHand[0].name, throwRoot.transform.localPosition, throwRoot.transform.localRotation, 0); Rigidbody2D trashRigid = thisTrash.transform.GetComponent <Rigidbody2D>(); ThrowItem throwItem = thisTrash.transform.GetComponent <ThrowItem>(); throwItem.photonPlayer = this.photonPlayer; thisTrash.transform.SetParent(throwRoot.transform); thisTrash.transform.localPosition = new Vector3(0, 0, 50); thisTrash.transform.localScale = trashPrefabs[trashInHandIndex[0]].transform.localScale; thisTrash.transform.SetParent(GameObject.Find("Canvas").transform); thisTrash.transform.TransformPoint(Vector3.right * 2); thisTrash.transform.localScale = trashPrefabs[trashInHandIndex[0]].transform.localScale; photonView.RPC("SetThrowTrash", PhotonTargets.OthersBuffered, thisTrash.transform.name, throwRoot.name, this.name); if (!isFacingRight) { trashRigid.AddForce(new Vector2(-210, 210), ForceMode2D.Force); } else { trashRigid.AddForce(new Vector2(210, 210), ForceMode2D.Force); } trashInHandIndex.RemoveAt(0); trashInHandIndex.Clear(); trashInHand.Remove(thisTrash); trashInHand.Clear(); }
//throwing an item is determined by where the mouse is public void ThrowItem() { Vector3 mousePos = control.MousePos(); //get mouse position int targetLayer = control.ThrowingTarget(mousePos); //get what is at the mouse position //note, mousePos isn't actually used yet. I thought about teaching buddies to throw to a specific position throw RELATIVE to the cow for example //but unnecessary ThrowItem throwItem = new ThrowItem(mousePos, HeldItem.layer, control.ThrowingTarget(mousePos)); CurrentAction = throwItem; if (CurrentAction.PerformEvent(this)) { if (teaching) { OnTeach(); } } }
/// <summary> /// 범위 이미지 활성/비활성 처리 /// </summary> /// <param name="value">활성/비활성 여부</param> //public void SetActivatedThrowImage(bool value) //{ // if (throwRange == null) // return; // throwRange.gameObject.SetActive(value); //} /// <summary> /// 던지기 처리 /// </summary> /// <param name="endPoint">이동 지점</param> /// <param name="generatePosition">생성 지점</param> /// <param name="throwItemIndex">생성할 아이템 인덱스</param> /// <param name="attacker">공격자 객체</param> public void GenerateThrowItem(Vector3 endPoint, Vector3 generatePosition, int throwItemIndex, Actor attacker) { //Debug.Log(throwItemType + ": Throw"); // 던질 아이템 생성 GameObject go = Generate(cacheDatas[throwItemIndex - 1].filePath, generatePosition); if (go != null) { ThrowItem throwItem = go.GetComponent <ThrowItem>(); if (throwItem != null) { // 데미지 세팅 BuffData buffData = GameManager.Instance.BuffManager.GetBuffData(WeaponStyle.GRENADE, BuffType.GrenadeDamage); // 레벨을 올렸는지 검사 if (buffData.currentLevel > 0) { Debug.Log("throwItem.OriginValue: " + throwItem.OriginValue); float factor = buffData.currentValue * 0.01f; int value = (int)(throwItem.OriginValue * factor); throwItem.Value = throwItem.OriginValue; throwItem.Value += value; } // 범위 세팅 buffData = GameManager.Instance.BuffManager.GetBuffData(WeaponStyle.GRENADE, BuffType.GrenadeRange); // 레벨을 올렸는지 검사 if (buffData.currentLevel > 0) { float factor = buffData.currentValue * 0.01f; float value = throwItem.OriginRange * factor; throwItem.Range = throwItem.OriginRange; throwItem.Range += value; } // 던질 아이템 투척 throwItem.Throw(endPoint, attacker); } } }
// Start is called before the first frame update private void Awake() { image.GetComponent <Rigidbody2D>(); itemcheck = GameObject.FindGameObjectWithTag("Player").GetComponent <ThrowItem>(); }
public override GOAPAct Clone() { ThrowItem clone = new ThrowItem(Vector3.zero, this.ActionLayer, this.ActionLayer2);//Vector3.zero = where player threw (currently not tracked) return(clone); }