private void GrabObject(ControllerInformation info) { GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation)); grabObjInfo.objectInHand = grabObjInfo.collidingObject; grabObjInfo.collidingObject = null; //objectInHand.transform.position = Vector3.Lerp(transform.position,objectInHand.transform.position, 0.8f); if (!info.trackedObj.GetComponent <FixedJoint>()) { var joint = AddFixedJoint(info); joint.connectedBody = grabObjInfo.objectInHand.GetComponent <Rigidbody>(); } if (grabObjInfo.objectInHand.gameObject.name == "Cube") { Cube = grabObjInfo.objectInHand.GetComponent <ThrowObject>(); if (Cube) { if (Cube.taskCompleted[0] != null) { { Cube.taskCompleted[0].Invoke(); } } } } }
public override void Use() { if (objectToShoot == null) { return; } if (shootLocations.Count <= 0) { return; } //logic for (int i = 0; i < shootLocations.Count; i++) { //for all the locations we want to instantiate a slash. GameObject obj = Instantiate(objectToShoot); Transform trans = shootLocations[i].transform; obj.transform.position = trans.position; ThrowObject throwObjectComponent = obj.AddComponent <ThrowObject>(); throwObjectComponent.Instantiate(Random.Range(minDamage, maxDamage), true, null); TweenBuild tweenBuild = new TweenBuild(obj); Tween tweenPosition = tweenBuild.SetTweenPosition(shootLocations[i].position + (shootLocations[i].forward * maxDistance), .4f, EasingType.Linear); tweenBuild.DestroyOnFinish = true; tweenBuild.StartTween(); } }
void OnCollisionEnter(Collision collision) { if (Player.instance.CheckIfAPlayer(collision.transform)) { Player.instance.OnHitThrowObj(GetComponent <ThrowObject> ()); } else { otherObj = collision.transform.GetComponent <ThrowObject>(); //if hit by another throw obj if (otherObj != null) { if (Player.instance.currentLife > 0) { AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.bup, transform.position); } } else { if (collision.transform.name == "Floor") { if (Player.instance.currentLife > 0) { switch (transform.name) { case "SandalA(Clone)": AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.Sandal, transform.position); break; case "SandalB(Clone)": AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.Sandal, transform.position); break; case "Hammer(Clone)": AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.bup, transform.position); break; case "Pot(Clone)": AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.Pot, transform.position); break; case "Bread(Clone)": AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.bup, transform.position); break; default: AudioManager_RB.instance.PlayClip(AudioManager_RB.SoundFX.bup, transform.position); break; } } isKillPlayer = false; trailRenderer.enabled = false; StartCoroutine(StartPoofEffect()); } } } }
private void CreateRock() { Rock = Instantiate(_rock, _hand.transform.position, Quaternion.identity) as GameObject; RockScript = Rock.GetComponent <ThrowObject>(); RockScript.Target = _player.transform; RockScript.Projectile = Rock.transform; RockScript._myTransform = _hand.transform; }
private ThrowObject createThrowObject(MovableObject objectType) { ThrowObject throwObject = new ThrowObject(); throwObject.SetThrower(objectType); throwObject.Initialize(); return throwObject; }
protected virtual void OnCollisionEnter(Collision collision) { throwObj = collision.gameObject.GetComponent <ThrowObject> (); // If player indeed hit the enemy if (throwObj != null) { throwObj.Bounce(); } }
public void OnHitThrowObj(ThrowObject throwObj) { if (currentLife <= 0 || !throwObj.isKillPlayer) { return; } Killed(); throwObj.CFXM_Hit_Effect(throwObj.transform); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.name == "Screen") { Cube = GetComponent <ThrowObject>(); if (Cube.taskCompleted[1] != null) { Cube.taskCompleted[1].Invoke(); } } }
private void CheckIfThrowRock(GameObject rockGO) { rock = rockGO.GetComponent <ThrowObject> (); // If player indeed hit the enemy if (rock != null) { rock.Bounce(); AudioManager.instance.PlayClip(AudioManager.SoundFX.Impact, transform.position); //VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, .5f, 0.5f, 0.01f); } }
void StartThrow() { ThrowObject obj = ObjectPool.instance.GetRockThrow(); if (stateController.playerReference != null) { obj.Live(); obj.transform.position = transform.position; obj.Launch(stateController.playerReference.transform.position, transform); } else { isThrowing = false; } }
public void Atirar() { if (tiroScript == null) { tiroScript = GetComponent <ThrowObject>(); } if (dogScript.state.Equals(DogController.State.Idle)) { dogScript.ChangeState("TiroState"); tiroScript.Atirou(); } else { return; } }
//public Transform targ; // Use this for initialization IEnumerator Start() { while (true) { if (Player.instance != null) { ThrowObject obj = ObjectPool.instance.GetRockThrow(); obj.transform.position = transform.position; //obj.transform.position = transform.position + Random.insideUnitSphere * 15; //obj.transform.position = new Vector3 (obj.transform.position.x,8.5f,obj.transform.position.z); obj.Launch(Player.instance.transform.position, transform); } yield return(new WaitForSeconds(5)); } }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ThrowObject to = animator.GetComponent <ThrowObject>(); if (stateInfo.normalizedTime > to.MomentToThrow) { if (!eventThrowDone) { animator.GetComponent <ThrowObject>().ThrowTheObject(); } eventThrowDone = true; } else { eventThrowDone = false; } }
void OnTriggerStay(Collider other) { if (currentLife <= 0) { return; } throwObj = other.GetComponent <ThrowObject>(); if (throwObj != null) { if (!throwObj.isKillPlayer) { throwObj.PickedUp(); Score++; } } }
public void Update() { if (clone != null) { float sliderValue = slider.value; float sliderValueNormalized = slider.normalizedValue; ThrowObject throwObject = clone.GetComponent <ThrowObject>(); if (SwipeControls.SwipeUp) { Debug.Log("Player swipes up."); throwObject.ApplyForwardInertia(sliderValue, sliderValueNormalized); ReadyToThrow = false; } if (SwipeControls.SwipeUpLeft) { Debug.Log("Player swipes up to the left"); throwObject.ApplyLeftInertia(sliderValue, sliderValueNormalized); ReadyToThrow = false; } if (SwipeControls.SwipeUpRight) { Debug.Log("Player swipes up to the right."); throwObject.ApplyRightInertia(sliderValue, sliderValueNormalized); ReadyToThrow = false; } if (SwipeControls.SwipeLeft) { Debug.Log("Player swipe to the left."); desiredPosition += new Vector3(-0.5f, 0, 0); } if (SwipeControls.SwipeRight) { Debug.Log("Player swipe to the right."); desiredPosition += new Vector3(0.5f, 0, 0); } if (ReadyToThrow) { clone.transform.position = Vector3.MoveTowards(clone.transform.position, desiredPosition, 5.0f * Time.deltaTime); } } }
public override void Use() { if (throwObject == null) { return; } GameObject obj = Instantiate(throwObject); Transform trans = throwFromLocation.transform; obj.transform.position = trans.position + (trans.forward * forwardOffset); //FIX OBJECT SCRIPT ThrowObject throwObjectComponent = obj.AddComponent <ThrowObject>(); throwObjectComponent.Instantiate(Random.Range(minDamage, maxDamage), true, null); TweenBuild tweenBuild = new TweenBuild(obj); Tween tweenPosition = tweenBuild.SetTweenPosition(throwFromLocation.position + (throwFromLocation.forward * maxDistance), speed, EasingType.Linear); tweenBuild.DestroyOnFinish = true; tweenBuild.StartTween(); }
public TrackedThrowObject(ThrowObject throwObject, AbilityInfo data) { ThrowObject = throwObject; Data = data; Update(); }
public void DeleteThrowObject(ThrowObject throwObject) { _level.ThrownObjects.Remove(throwObject); }
public void ThrownObjectHasCollidedWithEnemy(Enemy enemy, ThrowObject throwObject) { enemy.Hit(throwObject.getDamage()); DeleteThrowObject(throwObject); }
public static AbilityInfo Data(this ThrowObject throwObject) { return(AbilityDatabase.Get(throwObject.GameObject.ObjectName)); }
public void ThrownObjectHasCollidedWithPlayer(Player player, ThrowObject throwObject) { player.Hit(throwObject.getDamage()); DeleteThrowObject(throwObject); }