void Awake() { _boxCollider = GetComponent <BoxCollider2D>(); _circleCollider = GetComponent <CircleCollider2D>(); _myShooter = GetComponent <WeaponShooter>(); _myRidigbody2D = GetComponent <Rigidbody2D>(); _myHealth = GetComponent <HealthHaver>(); _myHealth.Died += HandleDied; }
// Use this for initialization void Start() { init(); gameObject.tag = "Enemy"; animator = this.gameObject.GetComponent <Animator>(); setAnimatorFalse(); weapon = GetComponentInChildren <WeaponShooter>(); agent = GetComponent <NavMeshAgent>(); }
void Start() { _health = GetComponent <HealthHaver>(); _damageTaker = GetComponent <PlayerDamageTaker>(); _mover = GetComponent <PlayerMover>(); _shooter = GetComponent <WeaponShooter>(); _health.Died += StartSpawnEffect; StartSpawnEffect(); }
void weapondrop() { if (leftWeapon && OVRInput.Get(OVRInput.Button.Two, OVRInput.Controller.LTouch)) { leftWeapon = null; } if (rightWeapon && OVRInput.Get(OVRInput.Button.Two, OVRInput.Controller.RTouch)) { rightWeapon = null; } }
public void childTrigger(Collider other) { if (other.gameObject.tag == "Weapon") { float leftDist = Vector3.Distance(leftHandAnchor.position, other.transform.position); float rightDist = Vector3.Distance(rightHandAnchor.position, other.transform.position); if ((!leftWeapon) && OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.LTouch) && leftDist < 0.3) { if ((!rightWeapon) || (other.gameObject != rightWeapon.gameObject)) { leftWeapon = other.gameObject.GetComponent <WeaponShooter>(); } } else if ((!rightWeapon) && OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.RTouch) && rightDist < 0.3) { if ((!leftWeapon) || (other.gameObject != leftWeapon.gameObject)) { rightWeapon = other.gameObject.GetComponent <WeaponShooter>(); } } } }
// Use this for initialization void Start() { weapon = GetComponent <WeaponShooter>(); //muzzle = this.transform.Find("turret_muzzle").gameObject; }
public void SetCombatWeapon(Weapon weapon) { _weapon = weapon; _weaponShooter = weapon.WeaponShooter; UIController.instance.UpdateAmmoUI(_weaponShooter.CurrentAmmoInStore, _weaponShooter.CurrentAmmoAmmount); }
/// <summary> /// simulates a melee swing by carrying out a sequence of /// timers, state changes and soft forces on the weapon springs /// </summary> protected void UpdateAttack() { if (!Player.Attack.Active) { return; } if (Player.SetWeapon.Active) { return; } if (FPWeapon == null) { return; } if (!FPWeapon.Wielded) { return; } if (Time.time < m_NextAllowedSwingTime) { return; } m_NextAllowedSwingTime = Time.time + SwingRate; // enable random attack states on the melee and weapon components if (AttackPickRandomState) { PickAttack(); } // set 'raise' state (of the chosen attack state) on the weapon component FPWeapon.SetState(WeaponStatePull); FPWeapon.Refresh(); // after a short delay, swing the weapon vp_Timer.In(SwingDelay, delegate() { // play a random swing sound if (SoundSwing.Count > 0) { Audio.pitch = Random.Range(SoundSwingPitch.x, SoundSwingPitch.y) * Time.timeScale; Audio.clip = (AudioClip)SoundSwing[(int)Random.Range(0, (SoundSwing.Count))]; if (vp_Utility.IsActive(gameObject)) { Audio.Play(); } } // switch to the swing state FPWeapon.SetState(WeaponStatePull, false); FPWeapon.SetState(WeaponStateSwing); FPWeapon.Refresh(); // apply soft forces of the current attack FPWeapon.AddSoftForce(SwingPositionSoftForce, SwingRotationSoftForce, SwingSoftForceFrames); // check for target impact after a predetermined duration vp_Timer.In(ImpactTime, delegate() { // perform a sphere cast ray from center of controller, at height // of camera and along camera angle RaycastHit hit; Ray ray = new Ray(new Vector3(FPController.Transform.position.x, FPCamera.Transform.position.y, FPController.Transform.position.z), FPCamera.Transform.forward); Physics.Raycast(ray, out hit, (Bullet != null ? Bullet.Range : 2), vp_Layer.Mask.BulletBlockers); // hit something: perform impact functionality if (hit.collider != null) { if (WeaponShooter != null) { WeaponShooter.FirePosition = Camera.main.transform.position; WeaponShooter.TryFire(); } ApplyRecoil(); } else { // didn't hit anything: carry on swinging until time is up vp_Timer.In(SwingDuration - ImpactTime, delegate() { FPWeapon.StopSprings(); Reset(); }, SwingDurationTimer); } }, ImpactTimer); }, SwingDelayTimer); }