Ejemplo n.º 1
0
 /// <summary>
 /// Fires the current weapon
 /// </summary>
 public void Fire()
 {
     // If the weapon has not been fired yet
     if (!CurrentWeapon.Fired)
     {
         CurrentWeapon.FireWeapon();
         Shot.Update(position, 1280, Assets.MapData.TileMap, Assets.MapData.MapArea, rotation);
         Vector2 direction = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
         //debrisEmitter.Launch(Shot.CollisionPos, rotation);
     }
 }
    void Update()
    {
        var x = Input.GetAxis("FireHorizontal");
        var y = Input.GetAxis("FireVertical");

        var vec = new Vector3(x, 0, y);

        if (vec.sqrMagnitude <= 0)
        {
            return;                        // Player did not fire
        }
        var quat       = Quaternion.LookRotation(vec.normalized, Vector3.up);
        var spawnPoint = transform.position + vec.normalized * _spawnDistance;

        _weapon.FireWeapon(spawnPoint, quat);
    }