Inheritance: Ammunition
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Revolver revolver = new Revolver();
            Rifle    rifle    = new Rifle();
            Shotgun  shotgun  = new Shotgun();
            Gatling  gatling  = new Gatling();

            IWeapon[] soldierWeapons = { revolver, rifle, shotgun, gatling };

            Soldier soldier = new Soldier(soldierWeapons);

            Console.WriteLine("The soldier is trying his weapons: ");
            for (int i = 0; i < soldierWeapons.Length; i++)
            {
                Console.WriteLine(soldier.Shoot(soldierWeapons[i]));
            }

            Console.WriteLine();

            Console.WriteLine("The tank operators are doing some weapon tests: ");

            TankGun    tankGun    = new TankGun();
            MachineGun machineGun = new MachineGun();
            Missile    missile    = new Missile();

            IWeapon[] tankWeapons = { tankGun, machineGun, missile };

            Tank tank = new Tank(tankWeapons);

            for (int i = 0; i < tankWeapons.Length; i++)
            {
                Console.WriteLine(tank.Shoot(tankWeapons[i]));
            }
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     machineGun = GetComponent<MachineGun>();
     rocketLauncher = GetComponent<RocketLauncher>();
     gun = GetComponent<Gun>();
     shotgun = GetComponent<Shotgun>();
 }
Exemplo n.º 3
0
    public MachineGun(MachineGun copy)
    {
        this.m_sWeaponName = copy.m_sWeaponName;
        this.WeaponID      = copy.WeaponID;
        this.Default       = copy.Default;

        this.m_iAmmoMaxInAClip = copy.m_iAmmoMaxInAClip;
        this.m_iMaxClip        = copy.m_iMaxClip;
        this.m_iPrice          = copy.m_iPrice;
        this.m_fReloadTime     = copy.m_fReloadTime;


        //inherited members
        m_sCrossHair.Initalize(copy.m_sCrossHair.CrossHairBasicOffSet, copy.m_sCrossHair.CrossHairOffSetModifier,
                               copy.m_sCrossHair.CrossHairStability, copy.m_sCrossHair.CrossHairMaxOffSet);

        m_sStats.Initialize(copy.m_sStats.FireRate, copy.m_sStats.WeaponDamage, copy.m_sStats.Force, copy.m_sStats.Range);

        this.m_tIconTexture = copy.m_tIconTexture;

        ammoLeft  = m_iAmmoMaxInAClip;
        clipsLeft = m_iMaxClip;

        recoils = copy.recoils;
    }
Exemplo n.º 4
0
 void Start()
 {
     if (WeaponManager.Instance)
     {
         MachineGun machineGun    = WeaponManager.Instance.GetComponentInChildren <MachineGun>();
         LaserGun   laserGun      = WeaponManager.Instance.GetComponentInChildren <LaserGun>();
         SingleShot singleShotGun = WeaponManager.Instance.GetComponentInChildren <SingleShot>();
         ForkGun    forkGun       = WeaponManager.Instance.GetComponentInChildren <ForkGun>();
         SideShot   sideGun       = WeaponManager.Instance.GetComponentInChildren <SideShot>();
         RadialGun  radialGun     = WeaponManager.Instance.GetComponentInChildren <RadialGun>();
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node24>(laserGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node25>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node26>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node27>(radialGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node28>(sideGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node29>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node30>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node31>(forkGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node32>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node33>(machineGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node34>(laserGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node35>(radialGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node36>(singleShotGun);
         WeaponManager.Instance.AddWeaponEvent <NodeEvents.Node57>(singleShotGun);
     }
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Gun mGun               = new MachineGun();
            Gun sGun               = new ShotGun();
            Gun mGunWithClip       = new GunClip(mGun, 40);
            Gun mGunWithTwoClips   = new GunClip(mGunWithClip, 60);
            Gun mGunWithEverything = new GunSilencer(mGunWithTwoClips, 0.9f);

            Console.Write("MachineGun:\n\t");
            mGun.Fire();
            Console.Write("ShotGun:\n\t");
            sGun.Fire();
            Console.Write("MachineGun with clip:\n\t");
            mGunWithClip.Fire();
            Console.Write("MachineGun with two clips:\n\t");
            mGunWithTwoClips.Fire();
            Console.Write("MachineGun with everything:\n\t");
            mGunWithEverything.Fire();

            try
            {
                new GunSilencer(mGun, 1.2f);
            }
            catch (InvalidOperationException ioe)
            {
                Console.WriteLine(ioe.Message);
            }
            finally
            {
                Console.WriteLine("Thanks for shooting!!");
            }
        }
Exemplo n.º 6
0
    private void Die()
    {
        playerDead = true;

        isSmoking = false;
        Destroy(smoke);

        GameObject explosion = Instantiate(explosionPrefab, gameObject.transform.position, Quaternion.identity);

        //Can't destroy the plane without breaking lots of stuff.
        // move it off screen, and disable all input from the user
        // the explosion prefab takes care of switching the the main menu

        PlayerHealth healthScript = gameObject.GetComponent <PlayerHealth>();

        Destroy(healthScript);

        MachineGun mgScript = gameObject.GetComponent <MachineGun>();

        Destroy(mgScript);

        PlayerMovement pmScript = gameObject.GetComponent <PlayerMovement>();

        Destroy(pmScript);

        gameObject.transform.position = new Vector2(1000, 1000);
    }
Exemplo n.º 7
0
 void Awake()
 {
     machinevars = this.getvars <MachineGun>();
     size        = 0.5f;
     bullets.Add(transform.GetChild(0));
     bullets[0].localPosition = size * Vector3.right;
     OnDisable();
 }
Exemplo n.º 8
0
 private void Awake()
 {
     _machineGun = this.SearchComponent <MachineGun>();
     _skin       = this.SearchComponent <SkinManager>();
     _bullets.Add(transform.GetChild(0));
     _bullets[0].localPosition = Size * Vector3.right;
     OnDisable();
 }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        machineGun = GetComponentInChildren<MachineGun>();
        playerState = GetComponent<PlayerState>();
        baseHealth = 100;

        playerState.CurPlayerState = playerState.playerMoving;
    }
Exemplo n.º 10
0
 // Use this for initialization
 void Start()
 {
     targetImg.SetActive(false);
     pAnimator    = GetComponent <Animator>();
     machineGun   = GetComponentInChildren <MachineGun>();
     health       = 100;
     specialMeter = 10;
     drivingState = true;
 }
Exemplo n.º 11
0
 void Start()
 {
     player = GameObject.Find("Player");
     cargoShip = GameObject.Find("Cargo ship");
     line = gameObject.GetComponent<LineRenderer>();
     flight = gameObject.GetComponent<DroneFlight>();
     gun = gameObject.GetComponent<MachineGun>();
     target = player;
 }
Exemplo n.º 12
0
    //功能:初始化
    //計算血條長度、執行功能"PlayStepSounds"
    void Awake()
    {
        maximumHitPoints = hitPoints;
        machineGun       = GetComponentInChildren <MachineGun>();
        rocketLauncher   = GetComponentInChildren <RocketLauncher>();

        audio = GetComponent <AudioSource> ();

        healthGUIWidth = healthGUI.pixelInset.width;
    }
Exemplo n.º 13
0
    protected override void Awake()
    {
        base.Awake();

        m_rgb2d = GetComponent <Rigidbody2D>();

        MachineGun weapon = new MachineGun(this, "bulletMachineGun", BulletStartPosition);

        SetWeapon(weapon);
    }
Exemplo n.º 14
0
    void Start()
    {
        cargoShip = GameObject.Find("Cargo ship");
        line = gameObject.GetComponent<LineRenderer>();
        flight = gameObject.GetComponent<DroneFlight>();
        gun = gameObject.GetComponent<MachineGun>();

        var c = 2 * Mathf.PI * circleRadius;
        var xySpeed = Mathf.Sqrt(Mathf.Pow(flight.speed, 2) - Mathf.Pow(cargoShip.GetComponent<CargoShipAI>().speed, 2));
        radPerSec = 2 * Mathf.PI * xySpeed / c;
        this.transform.localPosition = NextCircleSpot();
    }
Exemplo n.º 15
0
 void Awake()
 {
     rigi            = GetComponentInParent <Rigidbody>();
     SpeedZ          = 8000f;
     PitchRate       = 70;
     RollRate        = -70;
     YawRate         = 70;
     Physics.gravity = new Vector3(0f, -91.8f, 0f);
     Gun             = GetComponentInChildren <MachineGun>();
     Health          = 200;
     FuelTimer       = 0;
     Fuel            = 100;
 }
Exemplo n.º 16
0
    void Start()
    {
        myIsAlive = true;
        myCanMove = false;

        myAudioSource = GetComponent <AudioSource>();
        myPlayerDeath = Resources.Load <AudioClip>("player-death");

        myPlayer     = GameObject.FindGameObjectWithTag("Player");
        myMachineGun = GetComponent <MachineGun>();
        myShotGun    = GetComponent <ShotGun>();
        myGame       = GameObject.FindGameObjectWithTag("Game").GetComponent <Game>();
    }
Exemplo n.º 17
0
        /// <summary>
        /// Shows interception of an class method.
        /// </summary>
        private static void ClassInvocation()
        {
            Console.WriteLine("ClassInvocation");

            //Wraping the class
            MachineGun machineGun = _engine.WrapClass(typeof(MachineGun)) as MachineGun;

            //Not intercepted. It isn't a virtual method.
            machineGun.Fire(5);

            //Intercepted.
            machineGun.FireTenTimes();
        }
Exemplo n.º 18
0
    IEnumerator doPowerUp(MachineGun machineGun)
    {
        newColor = orange;

        Stats.SetActivePowerUp("pUpRF");
        machineGun.setFireRate(5f);
        goHide();
        yield return(new WaitForSeconds(10));

        machineGun.setFireRate(2f);
        newColor = Color.white;
        Stats.SetActivePowerUp("");
        Destroy(gameObject);
    }
Exemplo n.º 19
0
 private void Awake()
 {
     rigi           = GetComponent <Rigidbody>();
     Speed          = 60000f;
     RotationRate   = 700f;
     AttackDistance = 200f;
     EscapeDistance = 100f;
     Gun            = GetComponentInChildren <MachineGun>();
     Health         = 100;
     if (!Player)
     {
         GameObject go = GameObject.Find("Player");
         Player = go.transform;
     }
 }
Exemplo n.º 20
0
    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        MachineGun mg = hitInfo.gameObject.GetComponent <MachineGun>();

        if (mg != null)
        {
            Stats.SetActivePowerUp("pUpL");
            GameObject sfxPlayer = GameObject.FindGameObjectWithTag("SFX_Player");
            SFX_Player player    = sfxPlayer.GetComponent <SFX_Player>();
            player.Play("powerUp");

            mg.activeWeapon = "laser";
            goHide();
        }
    }
Exemplo n.º 21
0
 public void updateWeaponState(MachineGun weapon)
 {
     if (weapon.getState() == MachineGun.WeaponState.OUT_OF_AMMO)
     {
         GetComponent <TextMesh>().text = "OUT OF AMMO";
     }
     else if (weapon.getState() == MachineGun.WeaponState.REALOAD)
     {
         GetComponent <TextMesh>().text = "RELOAD";
     }
     else
     {
         GetComponent <TextMesh>().text = weapon.getAmmo() + "/" + weapon.getMagazine();
     }
 }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            MachineGun mg = new MachineGun();
            Katana k = new Katana();

            MyWeapon mw = new MyWeapon(mg);

            mw.myWeapon.shoot();
            mw.myWeapon.reload();
            Console.WriteLine();
            mw.myWeapon = k;
            mw.myWeapon.shoot();
            mw.myWeapon.reload();
            Console.Read();
        }
Exemplo n.º 23
0
        private static void Second()
        {
            Blade blade = new Blade(124, 1, "Катана", "Холодное оружие", 3.5);

            Console.WriteLine("Class Balde:");
            Console.WriteLine(blade + "\n");

            Gun gun = new Gun("Автомат", "Огнестрельное оружие", 3.2, 30, 5.45);

            Console.WriteLine("Class Gun:");
            Console.WriteLine(gun + "\n");

            MachineGun machine = new MachineGun("ПКТ", "Огнестрельное оружие", 112.4, 300, 12.7, "БМП", 7.3, 150);

            Console.WriteLine("Class MachineGun:");
            Console.WriteLine(machine + "\n");
        }
Exemplo n.º 24
0
    protected override void _OnGUI()
    {
        base._OnGUI();

        MachineGun g = owner as MachineGun;

        if (g != null)
        {
            if (Fight.f != null && Fight.f.fight_active)
            {
                int tex_id = Mathf.Clamp(Mathf.FloorToInt(g.sec_until_artillery_fire / g.post_mortem_cooldown * atlas_textures), 0, atlas_textures - 1);
                GUI.DrawTextureWithTexCoords(new Rect(Screen.width * 0.5f - texw * 0.5f, texh, texw, texh),
                                             aimer_atlas,
                                             new Rect(atlasw * (tex_id % atlas_width), atlash * (tex_id / atlas_width), atlasw, atlash));
            }
        }
    }
        private Map()
        {
            level       = 0;
            name        = "<insert name here>";
            description = "<insert desc here>";
            flags       = new MapFlags(128);

            InitialScore      = 0;
            InitialLivesCount = 5;
            InitialWeapon     = new MachineGun();

            events = new List <Event>();
            EnemyRessourcesToLoad = new List <BadGuy>();
            MusicRessourcesToLoad = new List <MySong>();

            Ended     = EndMode.None;
            StartTime = 0.0f;
        }
        static void Main(string[] args)
        {
            IWeapon   machineGun   = new MachineGun();
            IBehavior landBehavior = new LandBehavior();
            Unit      ryan         = new Unit("Ryan", machineGun, landBehavior);

            ryan.Move(50, 50);
            ryan.Attack(100, 100);

            Unit ben = new Unit("Ben", machineGun, landBehavior);

            ben.Move(1000, 1000);
            ben.Attack(50, 50);

            ben.Weapon = new Cannon();
            Console.WriteLine("Ben changes weapon.");
            ben.Attack(50, 50);
        }
Exemplo n.º 27
0
    protected override void _Update()
    {
        base._Update();

        MachineGun g = owner as MachineGun;

        if (g != null)
        {
            anim.SetBool("armed", g.artillery_shots_left > 0);
            if (g.artillery_shots_left > 0)
            {
                barrel = artillery;
            }
            else
            {
                barrel = left_barrel ? left : right;
            }
        }
    }
Exemplo n.º 28
0
    private void OnEnable()
    {
        ControllableObject.OnButtonDown += OnButtonDown;
        PlayerHealth.UpdateHealth       += ShowHideIcon;

        _shotgunAmmo    = GameObject.Find("SGAmmoType").GetComponent <Image>();
        _machineGunAmmo = GameObject.Find("MGAmmoType").GetComponent <Image>();

        _shotgun    = GetComponent <Shotgun>();
        _machineGun = GetComponent <MachineGun>();

        if (_shotgun.enabled)
        {
            EnableShotgun();
        }
        else if (_machineGun.enabled)
        {
            EnableMachineGun();
        }
    }
        public Player(TGCGame game, Camera camera, float yPosition = 0, Matrix?scaling = null)
        {
            this.Camera  = camera;
            NewPosition  = Camera.Position + new Vector3(0, yPosition, 0);
            UpVertex     = NewPosition + HitboxSize;
            BottomVertex = NewPosition - HitboxSize;

            // Remover
            Weapons = new List <Weapon>();
            Weapon machineGun = new MachineGun();
            Weapon handgun    = new Handgun();
            Weapon rpg7       = new Rpg7();
            Weapon shotgun    = new Shotgun();

            Weapons.Add(handgun);
            Weapons.Add(machineGun);
            Weapons.Add(shotgun);
            Weapons.Add(rpg7);
            CurrentWeapon = Weapons[0];
        }
Exemplo n.º 30
0
    //get colided objects
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        MachineGun mg = hitInfo.gameObject.GetComponent <MachineGun>();

        if (mg != null)
        {
            Stats.ActivePowerUp = "pUpRF";
            GameObject sfxPlayer = GameObject.FindGameObjectWithTag("SFX_Player");
            SFX_Player player    = sfxPlayer.GetComponent <SFX_Player>();
            player.Play("powerUp");

            planeModel.color = orange;
            planeModel.color = orange;
            planeModel.color = orange;
            planeModel.color = orange;
            planeModel.color = orange;

            StartCoroutine(doPowerUp(mg));
        }
    }
Exemplo n.º 31
0
 private void Start()
 {
     state          = new PlayerState(this);
     rgdb           = GetComponent <Rigidbody2D>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     position       = rgdb.position;
     ChangeStance(PlayerStances.standing);
     rgdb.freezeRotation = true;
     rotation            = rgdb.rotation;
     keyNames[0]         = playerNumber == 0 ? "Horizontal" : "Horizontal" + playerNumber;
     keyNames[1]         = playerNumber == 0 ? "Vertical" : "Vertical" + playerNumber;
     keyNames[2]         = playerNumber == 0 ? "Fire" : "Fire" + playerNumber;
     keyNames[3]         = playerNumber == 0 ? "Switch" : "Switch" + playerNumber;
     machineGun          = new MachineGun(machineGunBullet);
     pistol         = new Pistol(pistolBullet);
     silencedPistol = new SilencedPistol(silencedBullet);
     ammo           = new int[3] {
         0, 0, 0
     };
     healthBar.SetActive(false);
 }
Exemplo n.º 32
0
    // Update is called once per frame
    void Update()
    {
        Transform theSpot = gun.GetComponent <Transform>();

        transform.position = new Vector2(theSpot.position.x, theSpot.position.y);

        pUpTimer -= Time.deltaTime;

        if (pUpTimer <= 0)
        {
            Destroy(gameObject);
            ///MachineGun.cs activeWeapon = "bullet";
            GameObject player = GameObject.FindWithTag("Player");
            if (player != null)
            {
                MachineGun gunScript = player.GetComponent <MachineGun>();
                gunScript.activeWeapon = "bullet";
                Stats.SetActivePowerUp("");
            }
        }
    }
Exemplo n.º 33
0
        private static void MakeRifleShoot(Environment environment, MachineGun machineGun)
        {
            var mousePosition = MouseExtension.Position;
            var rifleBound    = machineGun.Sprite.GetLocalBounds();

            var rifleLength = rifleBound.Width * machineGun.Sprite.Scale.X;

            //В случае, если юзверь тыкнул на позицию игрока с винтовкой, пуля не должна вылетать
            //DIMAN UPDATE: Почему? Лучше пусть стреляет. Только здесь ошибка в коде: если нажать слишком близко,
            //то пуля летит обратно
            //TODO: поправить с.м. выше
            if (rifleLength >= VectorMath.GetLength(machineGun.Sprite.Position, mousePosition))
            {
                return;
            }

            //Левая верхня точка спрайта оружия
            var barrelPosition = VectorMath.GetPointOnVector(rifleLength, machineGun.Sprite.Position, mousePosition);
            //Точка, относительно которой вращалась винтовка
            var barrelOrigin = machineGun.Sprite.Origin.RotateAt(new Vector2f(), machineGun.Sprite.Rotation);

            //угол поворота винтовки
            var rifleAngle = VectorMath.ConvertToRadians(machineGun.Sprite.Rotation);
            //центр винтовки по Y
            var rifleYCenter = rifleBound.Height * machineGun.Sprite.Scale.Y / 2.0f;

            //Смещение дула до центра с поворота на угол rifleAngle
            var barrelOffset = rifleYCenter * new Vector2f(
                -(float)Math.Sin(rifleAngle),
                (float)Math.Cos(rifleAngle)
                );

            var moveUnitVector = barrelPosition.GetUnitVectorTo(mousePosition);

            environment.Bullets.Add(CreateBullet(barrelPosition + barrelOffset - barrelOrigin, moveUnitVector));

            //Звук выстрела из винтовки
            machineGun.Sound.Play();
        }
Exemplo n.º 34
0
Arquivo: Car.cs Projeto: marrony/ncar
    /*
     * motor:wheel
     * 1ª 3,596:1
     * 2ª 2,378:1
     * 3ª 1,531:1
     * 4ª 1,000:1
     * Ré 4,229:1
     * Diferencial 3,92:1
     */
    void Start()
    {
        Transform cg = transform.FindChild("CG");
        rigidbody.centerOfMass = cg.localPosition;

        /*turnLightRL = transform.Find("Model/maverick/RL_Turn_Light").gameObject;
        turnLightRR = transform.Find("Model/maverick/RR_Turn_Light").gameObject;*/
        machineGun = transform.Find("MachineGun").GetComponent<MachineGun>();
        Control = new CarControl();
    }
Exemplo n.º 35
0
 internal void updateWeapon(MachineGun machineGun)
 {
     BroadcastMessage("updateWeaponState", machineGun);
 }
Exemplo n.º 36
0
 void Start()
 {
     playerMG = GameObject.FindGameObjectWithTag("Player").GetComponent <MachineGun>();
 }
Exemplo n.º 37
0
    void Start()
    {
        // Init private variables
        ctrlThrottle = 0.5f;
        ctrlStickPitch = 0.0f;
        ctrlStickYaw = 0.0f;
        ctrlSkating = false;
        normalDrag = rigidbody.drag;

        // add the gun
        if(GunMount != null)
        {
            gun = (MachineGun)Instantiate (Weapon);
            gun.transform.parent = GunMount;
            gun.transform.position = GunMount.position;
            gun.transform.rotation = GunMount.rotation;
        }
    }