private void Awake() { iA = GetComponent <InimigoAndar>(); canShoot = GetComponentInChildren <CanShoot>(); tSpawn = transform.Find(nameSpawn); m_Animator = GetComponent <Animator>(); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D> (); jumper = GetComponent <CanJump> (); shooter = GetComponent <CanShoot> (); }
public void AddDamageMultiplierIfOnDamageBooster() { if (GetComponent<LocalizableOnMap>().cell.tile.tileType == Tile.TileType.DAMAGE_BOOSTER) { canShoot = GetComponent<CanShoot>(); canShoot.damageMultipliers.Add(CELL_DAMAGE_BONUS_STRING, 50f); } }
private void OnTriggerEnter(Collider other) { // Find all the tanks in an area around the shell and damage them. Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_Mask); for (int i = 0; i < colliders.Length; i++) { Rigidbody targetRidgetbody = colliders[i].GetComponent <Rigidbody> (); if (!targetRidgetbody) { continue; } targetRidgetbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius); CanShoot targetHealth = targetRidgetbody.GetComponent <CanShoot>(); if (!targetHealth) { continue; } float damage = CalculateDamage(targetRidgetbody.position); //targetHealth.TakeDamage(gunhit); } //Remove child from parent when the object is destroied m_ExplosionParticles.transform.parent = null; m_ExplosionParticles.Play(); m_ExplosionAudio.Play(); //Wait the particle systems duration, then destory the system Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.duration); //Destory Rocket Destroy(gameObject); }
public Missile(CanShoot owner, float x, float y, int direction, int missileVelocity, Color colour) : base(x, y, direction, colour) { _owner = owner; double directionInRadians = (Math.PI * direction) / 180; _xVel = (missileVelocity * (float)Math.Sin(directionInRadians)); _yVel = -(missileVelocity * (float)Math.Cos(directionInRadians)); _timer = 0; _active = true; }
public void AddBooster(PlasmaBooster plasmaBooster) { //Start executes after AddBooster happens so we eed to initialize here for now if (activePlasmaBoosters == null){ canShoot = GetComponent<CanShoot>(); activePlasmaBoosters = new List<PlasmaBooster>(); } if (!activePlasmaBoosters.Contains(plasmaBooster)){ activePlasmaBoosters.Add(plasmaBooster); } }
public void AddMissile(CanShoot owner, float x, float y, int direction, Color colour) { /* Will only add a missile if: * 1. The cooldown timer is not currently active * 2. The maximum number of missiles on-screen has not been reached */ if ((_cooldown <= 0) && (_missles.Count < _maxMissiles)) { SwinGame.PlaySoundEffect(SwinGame.SoundEffectNamed("shoot")); _missles.Add(new Missile(owner, x, y, direction, _missileVelocity, colour)); _cooldown = _cooldownLength; } }
public void LauTestHalloj() { GameObject playergameobject = new GameObject(); GameObject enemygameobject = new GameObject(); SpriteRenderer spriteRenderer = new SpriteRenderer(SpriteContainer.Instant.playerSprite); Player player = new Player(); CanShoot canShoot = new CanShoot(); playergameobject.AddComponent(spriteRenderer); playergameobject.AddComponent(player); playergameobject.AddComponent(canShoot); enemygameobject.AddComponent(canShoot); Instantiate(playergameobject); }
// Update is called once per frame void Update() { if (isActiveAndEnabled) { Ammo current = GetComponent <Ammo>(); Ammo.currentWeapon = "Shotgun"; hasammo = Ammo.shells; } if (Input.GetButton("Fire1") && Time.time > nextFire && isActiveAndEnabled && hasammo > 0) { nextFire = Time.time + fireRate; Ammo getammo = (Ammo)this.GetComponentInParent(typeof(Ammo)); myGun = Ammo.currentWeapon = "Shotgun"; getammo.UseAmmo(myGun); for (int i = 0; i < shellFragments; i++) { StartCoroutine(ShotEffect()); Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; Vector3 fireDirection = fpsCam.transform.forward; Quaternion fireRotation = Quaternion.LookRotation(fireDirection); Quaternion randomrotation = Random.rotation; fireRotation = Quaternion.RotateTowards(fireRotation, randomrotation, Random.Range(0.0f, spreadAngle)); if (Physics.Raycast(rayOrigin, fireRotation * Vector3.forward, out hit, weaponRange)) { GunHit gunHit = new GunHit(); gunHit.damage = Damage; gunHit.raycastHit = hit; CanShoot health = hit.collider.GetComponent <CanShoot>(); if (health == true) { } else { Instantiate(objectToSpawn, gunHit.raycastHit.point, Quaternion.LookRotation(gunHit.raycastHit.normal)); } if (health != null) { health.TakeDamage(gunHit); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * hitForce); } } else { //laserLine.SetPosition (1, rayOrigin + (fpsCam.transform.forward * weaponRange)); } } } }
public SniperRifle(string brand, int ammo = 5, int clip = 1) : base(brand, ammo, clip) { weaponType = new CanShoot(); weaponType = new CanReload(); }
public override void Awake() { canshoot = GameObject.GetComponent <CanShoot>(); base.Awake(); }
public RocketLauncher(string brand = "RocketLauncher", int ammo = 2, int clip = 2) : base(brand, ammo, clip) { weaponType = new CanReload(); weaponType = new CanShoot(); }
public void removeTargetingTower(CanShoot tower) { TargetedBy.Remove(tower); }
public void addTargetingTower(CanShoot tower) { TargetedBy.Add(tower); }
// Use this for initialization void Start () { rb = GetComponent<Rigidbody2D> (); jumper = GetComponent<CanJump> (); shooter = GetComponent<CanShoot> (); }