コード例 #1
0
    // Use this for initialization
    void Start()
    {
        currentResetIntervalCount = 0;
        maxGunChangeCount         = gunsStatus.getChangeWeaponTime;
        currentGunChangeCount     = maxGunChangeCount;
        audioSource = gameObject.GetComponent <AudioSource>();
        bulletDangerText.SetActive(false);

        guns = new BaseGun[NUM_GUN_TYPE];

        guns[0] = new HandGun();
        guns[1] = new SubmachineGun();
        guns[2] = new ShotGun();

        for (int i = 0; i < NUM_GUN_TYPE; i++)
        {
            guns[i].setGunStatus(gunsStatus.getGunsStatus[i]);
            guns[i].baseInit(i, gunImages[i], bullet, gunSound[i]);
            guns[i].init();
        }

        //ハンドガンに持ちかえる
        currentGunIndex = 0;
        chaneGunType(0);
        //audioSource.clip = gunSE;
    }
コード例 #2
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!!");
            }
        }
コード例 #3
0
 public void SpawnWeapon()
 {
     //if our parameters exist spawn a weapon on our socket depending on the type of the weapon
     if (m_AssaultGunTemplate && m_ShotGunTemplate && m_SubMachineGunTemplate && m_PrimarySocket)
     {
         if (m_WhichWeapon == Weapon.Shotgun)
         {
             var gunObject = Instantiate(m_ShotGunTemplate, m_PrimarySocket.transform, true);
             gunObject.transform.localPosition = Vector3.zero;
             gunObject.transform.localRotation = Quaternion.identity;
             m_ShotGun = gunObject.GetComponent <ShotGun>();
         }
         if (m_WhichWeapon == Weapon.assaultGun)
         {
             var gunObject = Instantiate(m_AssaultGunTemplate, m_PrimarySocket.transform, true);
             gunObject.transform.localPosition = Vector3.zero;
             gunObject.transform.localRotation = Quaternion.identity;
             m_AssaultGun   = gunObject.GetComponent <AssaultGun>();
             m_IsAssaultGun = true;
         }
         if (m_WhichWeapon == Weapon.SMG)
         {
             var gunObject = Instantiate(m_SubMachineGunTemplate, m_PrimarySocket.transform, true);
             gunObject.transform.localPosition = Vector3.zero;
             gunObject.transform.localRotation = Quaternion.identity;
             m_SubmachineGun = gunObject.GetComponent <SubmachineGun>();
         }
     }
 }
コード例 #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         ShotGun _shotGun = other.GetComponent <ShotGun>();
         _shotGun.canShoot_shotGun = true;
         Destroy(gameObject);
     }
 }
コード例 #5
0
ファイル: Crasher.cs プロジェクト: worthrd/PongCrasher
        public Crasher()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);

            gameState = new GameState();

            settings = GameSettings.GetInstance();

            Brick.Height = settings.BrickHeight;
            Brick.Width  = settings.BrickWidth;

            Wall.Width  = settings.WallWidth;
            Wall.Height = settings.WallHeight;

            Ball.Radius       = settings.BallRadius;
            Ball.InitialSpeed = settings.BallInitialSpeed;

            settings.BallMaxX = (float)ClientSize.Width;

            settings.BallMaxY = (float)ClientSize.Height;

            //Create the bat Sprites - they need the keyboard controls and the gameplay area limits
            _player1 = new Wall(settings.PlayerDefaultX, Keys.Up, Keys.Down, settings.MinPosition, (float)ClientSize.Height, Wall.Width, Wall.Height);

            //use this line for a second human player
            //_player2 = new Bat(player2Bat, ClientSize.Width - 30 - Bat.Width, Keys.P, Keys.L, 0, ClientSize.Height);

            //use this line for a computer player
            _player2 = new Wall((float)ClientSize.Width - settings.PlayerDefaultX - Wall.Width, settings.MinPosition, (float)ClientSize.Height, Wall.Width, Wall.Height);


            _ball_1 = new Ball(settings.BallMinX, (float)ClientSize.Width, settings.BallMinY, (float)ClientSize.Height, gameState, ref _player1, ref _player2);

            _player1.Ball = _ball_1;

            //Connect the AI player with the ball
            _player2.Ball = _ball_1;

            //Initialise and start the timer
            _lastTime = 0.0;
            _timer.Start();


            Sprite shotGun  = new ShotGun(_player1, _player2, _ball_1);
            Sprite shotGun2 = new ShotGun(_player1, _player2, _ball_1);

            _player1.Weapons.Add(shotGun);
            _player1.Weapons.Add(shotGun2);

            /*
             * ((Weapon)shotGun).Use();
             */
        }
コード例 #6
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>();
    }
コード例 #7
0
 void Awake()
 {
     _movement                = GetComponent <Movement>();
     _shoot                   = GetComponent <ShootRifle>();
     _shotGun                 = GetComponent <ShotGun>();
     _health                  = GetComponent <CharacterHealth>();
     _shield                  = GetComponent <Shield>();
     _health.OnUnitDied      += OnPlayerDied;
     _health.OnHealthChanged += OnHealthChanged;
     GameController.GameControllerInstance.playerTransform  = transform;
     GameController.GameControllerInstance.playerGameobject = gameObject;
     _shoot.hitLayerShoot   = enemyLayer;
     _shotGun.hitLayerShoot = enemyLayer;
 }
コード例 #8
0
ファイル: Player.cs プロジェクト: BerendWeij/PRO_3
    void Start()
    {
        // we halen even de andere components op
        handGun = GetComponent <HandGun>();
        shotGun = GetComponent <ShotGun>();
        nuclearMissileLauncher = GetComponent <NuclearMissileLauncher>();

        // we laten currentWeapon verwijzen naar de shotGun
        currentWeapon = shotGun;

        // waarom gebruiken we een interface?
        // omdat Classes alleen maar van elkaar mogen weten wat je bij elkaar mag doen. Niet 'hoe' het gebeurd.
        // Standaard regel: Program to an interface, not an implementation
        // met 'implementation' bedoeld men dat je hard tegen een bepaalde Class Type (bijvoorbeeld HandGun) aanscript
        // met interfaces wordt het heel duidelijk wat je mag verwachten van een Class. In de grote mensenwereld wordt
        // veel gewerkt met interfaces. .Net heeft hele conventies over welke interfaces je zou moeten hanteren
    }
コード例 #9
0
 public void AddGun(GunType type)
 {
     if (!_guns.ContainsKey(type))
     {
         if (type == GunType.BasicGun)
         {
             _guns[type] = new BasicGun();
         }
         else if (type == GunType.ShotGun)
         {
             _guns[type] = new ShotGun();
         }
         else
         {
             _guns[type] = new Rifle();
         }
     }
     _guns[type].IncreaseBullets();
     _guns[type].PlayerGun = this;
 }
コード例 #10
0
    void Start()
    {
        // Make the rigid body not change rotation
        if (GetComponent <Rigidbody>())
        {
            GetComponent <Rigidbody>().freezeRotation = true;
        }

        nextFire = 0;

        CalibrateAccelerometer();


        shotGun        = GetComponent <ShotGun> ();
        fireRate       = shotGun.fireRate;
        Time.timeScale = 1f;
        Debug.Log("Time.Scale" + Time.timeScale);

        //Time.timeScale = .2f;
    }
コード例 #11
0
    private void Awake()
    {
        if (instance)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }
        Physics2D.gravity = Vector2.zero;
        init = GetComponent <InitGameManager>();

        pistol             = new Pistol();
        rifts              = new Rifts();
        shotGun            = new ShotGun();
        sniper             = new Sniper();
        aug                = new AUG();
        dualBerretas       = new DualBerretas();
        knife              = new Knife();
        allWeaponsPossible = new List <Gun> {
            pistol,
            shotGun,
            rifts,
            sniper,
            aug,
            dualBerretas,
            knife
        };
        Quaternion quaternion = new Quaternion {
            eulerAngles = new Vector3(0, 0, 90)
        };

        playerTransform = Instantiate(playerPrefab, playerOriginPosition, quaternion);
        hc = playerTransform.GetComponent <HeroController>();
    }
コード例 #12
0
    public void shoot()  //射击
    {
        //用什么枪 => 枪类(射击频率,装弹CD,动画等)近距离用刀

        //根据枪种类产生子弹(碰撞,位置,动画,轨迹,子弹伤害)

        switch (Gun.holdGun)
        {
        case Gun.gunKind.handGun:
        {
            //Debug.Log("handGun");
            break;
        }

        case Gun.gunKind.shotGun:
        {
            //Debug.Log("shotGun");
            GameObject.Find("SoundControler").GetComponent <AudioSource>().
            PlayOneShot(GameData.getInstance().Effect_shotGun);
            ShotGun.getInstance().fixBulletDirecAndPos();
            break;
        }
        }
    }
コード例 #13
0
        public void Add(Item item)
        {
            item.SetActive(false);
            item.DisableRigidBody();
            item.transform.parent        = Main.Instance.Hand;
            item.transform.localPosition = Vector3.zero;
            item.transform.localRotation = Quaternion.Euler(Vector3.zero);

            if (item is AutoGunClip)
            {
                AutoGun a = Find <AutoGun>();
                a?.AddClip(item as AutoGunClip);
                return;
            }

            if (item is ShotGunClip)
            {
                ShotGun a = Find <ShotGun>();
                a?.AddClip(item as ShotGunClip);
                return;
            }

            _items.Add(item);
        }
コード例 #14
0
ファイル: Test2.cs プロジェクト: dargonesti/AsteroidsGame
        protected override List <MovingObject> GetIAs(Ship playerShip)
        {
            EnnemyShip          enemyShip;
            ActionFollowPlayer  mouvement;
            List <MovingObject> retour = new List <MovingObject>();
            Weapon wep;

            for (int i = 10; i < 100; i++)
            {
                enemyShip          = new EnnemyShip(false);
                enemyShip.Position = new Vector2(10 + i * 30, 100);
                enemyShip.Speed    = new Vector2(3, 0);
                if (i % 5 != 0)
                {//nous visent au 5 sec, tirent aux 2 sec
                    mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120, 5000);
                }
                else
                {//suivent toujours
                    mouvement = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
                }
                mouvement.Recursive = true;
                wep = new Weapon(enemyShip, 500);

                enemyShip.AddAction(mouvement);
                enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip, 2000), 2000, (int)(2000)));

                retour.Add(enemyShip);
            }
            //Enemis tourrelles*
            enemyShip           = new EnnemyShip(false);
            enemyShip.Position  = new Vector2(100, GetHeight() - 100);
            enemyShip.Speed     = new Vector2(0, 0);
            mouvement           = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);
            //tourelle 2
            enemyShip           = new EnnemyShip(false);
            enemyShip.Position  = new Vector2(100, 100);
            enemyShip.Speed     = new Vector2(0, 0);
            mouvement           = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);
            //tourelle 3

            enemyShip           = new EnnemyShip(false);
            enemyShip.Position  = new Vector2(GetWidth() - 100, 100);
            enemyShip.Speed     = new Vector2(0, 0);
            mouvement           = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            retour.Add(enemyShip);
            //tourelle 4
            enemyShip           = new EnnemyShip(false);
            enemyShip.Position  = new Vector2(GetWidth() - 100, GetHeight() - 100);
            enemyShip.Speed     = new Vector2(0, 0);
            mouvement           = new ActionFollowPlayer(enemyShip, playerShip, Laser.LASER_SPEED, 120);
            mouvement.Recursive = true;
            wep = new ShotGun(enemyShip, 1500);
            enemyShip.AddAction(new ActionShoot(enemyShip, new Weapon(enemyShip), 1000));
            enemyShip.AddAction(mouvement);
            enemyShip.AddAction(new ActionShoot(enemyShip, wep, 5000));
            retour.Add(enemyShip);


            return(retour);
        }
コード例 #15
0
        static async Task CollectPdfs(String seleniumHost, String fileName, String exportDirectory)
        {
            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            var service = new ServiceCollection().AddHttpClient().BuildServiceProvider();
            var gun     = new ShotGun(service.GetService <IHttpClientFactory>(),
                                      new PdfCreator(),
                                      new GunOptions($"{seleniumHost}/wd/hub"));


            var completeFileName = $"{DefaultFileCompletePrefix}-{fileName}";

            var completeLinks = new String[0];

            if (File.Exists(completeFileName))
            {
                completeLinks = await File.ReadAllLinesAsync(completeFileName);
            }
            else
            {
                File.Create(completeFileName);
            }

            var links = await File.ReadAllLinesAsync(fileName);

            links = links.Distinct()
                    .Except(completeLinks)
                    .ToArray();

            var options = new ShotOptions
            {
                Width       = 1024,
                StepHeight  = 754,
                ImageFormat = "png",
                IsGrayscale = true,
                OverlaySize = 23,
                TryMobile   = true,
                HideOverlayElementsImmediate = true
            };

            var index = 1;

            foreach (var link in links)
            {
                try
                {
                    options.Uri = new Uri(link);

                    var shot = await gun.ShotPdfAsync(options);

                    if (File.Exists($"{exportDirectory}/{shot.FileName}"))
                    {
                        Console.WriteLine($"Skip exist file : {shot.FileName}");
                        await File.AppendAllLinesAsync(completeFileName, new List <String> {
                            link
                        });

                        continue;
                    }

                    await File.WriteAllBytesAsync($"{exportDirectory}/{shot.FileName}", shot.Bytes);

                    await File.AppendAllLinesAsync(completeFileName, new List <String> {
                        link
                    });

                    Console.WriteLine($"{shot.FileName} is exported. {index++.ToString()}/{links.Length.ToString()}");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }
コード例 #16
0
 private void Start()
 {
     player   = GameController.GameControllerInstance.playerGameobject;
     _shotGun = player.GetComponent <ShotGun>();
     SpawnWave();
 }
コード例 #17
0
 public ShotGunDrawer(Sprite s) : base(s)
 {
     g = s as ShotGun;
 }
コード例 #18
0
ファイル: Attack.cs プロジェクト: vszed/MetalSlug
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            switch (Character.getInstance().CharacStatus)
            {
            case Character.Status.idle:
            {
                switch (Gun.holdGun)
                {
                case Gun.gunKind.handGun:
                {
                    break;
                }

                case Gun.gunKind.shotGun:
                {
                    if (ShotGun.getInstance().admitShoot == true)                 //冷却时间定时器
                    {
                        Character.getInstance().shoot();
                        ShotGun.getInstance().admitShoot = false;

                        Character.getInstance().CharacAttackMode = Character.AttackMode.shoot;
                        Character.getInstance().CharacStatus     = Character.Status.idleAttack;
                    }

                    break;
                }
                }

                break;
            }

            case Character.Status.move:
            {
                switch (Gun.holdGun)
                {
                case Gun.gunKind.handGun:
                {
                    break;
                }

                case Gun.gunKind.shotGun:
                {
                    if (ShotGun.getInstance().admitShoot == true)                 //冷却时间定时器
                    {
                        Character.getInstance().shoot();
                        ShotGun.getInstance().admitShoot = false;

                        Character.getInstance().CharacAttackMode = Character.AttackMode.shoot;
                        Character.getInstance().CharacStatus     = Character.Status.moveAttack;
                    }

                    break;
                }
                }

                break;
            }

            case Character.Status.jump:
            {
                switch (Gun.holdGun)
                {
                case Gun.gunKind.handGun:
                {
                    break;
                }

                case Gun.gunKind.shotGun:
                {
                    if (ShotGun.getInstance().admitShoot == true)                 //冷却时间定时器
                    {
                        Character.getInstance().shoot();
                        ShotGun.getInstance().admitShoot = false;

                        Character.getInstance().CharacAttackMode = Character.AttackMode.shoot;
                        Character.getInstance().CharacStatus     = Character.Status.jumpAttack;
                    }

                    break;
                }
                }

                break;
            }
            }
        }

        //状态切换
        if ((!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D)) || (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D)))
        {
            if (Character.getInstance().CharacAttackMode != Character.AttackMode.disAttack)
            {
                Character.getInstance().CharacStatus = Character.Status.idleAttack;
            }
            return;
        }

        if (Input.GetKey(KeyCode.A))
        {
            if (Character.getInstance().CharacAttackMode != Character.AttackMode.disAttack)
            {
                Character.getInstance().CharacStatus = Character.Status.moveAttack;
            }
        }
        else if (Input.GetKey(KeyCode.D))
        {
            if (Character.getInstance().CharacAttackMode != Character.AttackMode.disAttack)
            {
                Character.getInstance().CharacStatus = Character.Status.moveAttack;
            }
        }
    }
コード例 #19
0
 public ScreenshotController(ShotGun shooterManager,
                             ILogger <ScreenshotController> logger)
 {
     _shooterManager = shooterManager;
     _logger         = logger;
 }
コード例 #20
0
ファイル: ShotGun.cs プロジェクト: vszed/MetalSlug
 void Awake()
 {
     instance = this;
 }
コード例 #21
0
ファイル: Shotgun.cs プロジェクト: Rakiah/Aeternam
 public ShotGun(ShotGun copy)
 {
 }