예제 #1
0
        public void Initialize(Vector2 startLocation)
        {
            IsDisposed = false;
            Location   = startLocation;

            if (Maths.Chance(50))
            {
                Direction = 1;
            }
            else
            {
                Direction = -1;
            }

            if (Maths.Chance(50) || Level.Instance.MGCnt == Level.MAX_MG_CNT)
            {
                Boom1 bm = Level.Instance.BoomPool.New();
                bm.Initialize(new Vector2(Animation.Width / 2 - 9, Animation.Height / 2), null);
                Guns.Add(bm);
            }
            else
            {
                MG1 mg = Level.Instance.MGPool.New();
                mg.Initialize(new Vector2(Animation.Width / 2 - 4 - 10, Animation.Height), new Vector2(Animation.Width / 2 - 4 + 10, Animation.Height), null);
                Guns.Add(mg);
                Level.Instance.MGCnt++;
            }
        }
예제 #2
0
 public Gun(Guns type, int ammo, float shot_time, float reload_time)
 {
     this.type        = type;
     this.ammo        = ammo;
     this.shot_time   = shot_time;
     this.reload_time = reload_time;
 }
예제 #3
0
    /// <summary>
    /// Bu method xml dosyasından silah verilerini çeker.
    /// </summary>
    Guns GunDataHook()
    {
        Debug.Log("Silah bilgileri çekiliyor");

        try
        {
            //xml file path to string
            string path = "Assets/Scripts/gunList.xml";

            //Guns serialization
            XmlSerializer serializer = new XmlSerializer(typeof(Guns));

            //xml data.
            StreamReader reader = new StreamReader(path);
            //Deserialize.
            Guns gunDeserialize = ((Guns)serializer.Deserialize(reader));
            //xml reader closed.
            reader.Close();

            return(gunDeserialize);
        }
        catch
        {
            Debug.Log("Silah verileri çekilirken hata oluştur. Oyun kapanıyor");
            Application.Quit();
            return(null);
        }
    }
예제 #4
0
    private void SwitchWeapons()
    {
        int weaponIndex = 0;

        foreach (Transform weapon in transform)
        {
            if (weaponIndex == _currentGun)
            {
                Debug.Log("Weapon Index: " + weaponIndex.ToString());
                switch (weaponIndex)
                {
                case (0):
                    _playerGun = Guns.Rifle;
                    Debug.Log("Rifle now selected!");
                    break;

                case (1):
                    _playerGun = Guns.Smg;
                    Debug.Log("Smg now selected!");
                    break;
                }
                weapon.gameObject.SetActive(true);
            }
            else
            {
                weapon.gameObject.SetActive(false);
            }
            weaponIndex++;
        }
    }
예제 #5
0
    void Start()
    {
        bed          = GameObject.Find("bed");
        player       = GameObject.Find("Player");
        wave         = GameObject.Find("Enemies").GetComponent <Wave>();
        playerScript = player.GetComponent <PlayerCore>();
        gun          = playerScript.guns.GetComponent <Guns>();

        multiplier           = Random.Range(1, 4);
        transform.localScale = new Vector3(0.5f, 0.5f, 0.5f) + new Vector3(0.05f * multiplier, 0.05f * multiplier, 0.05f * multiplier);
        hp         *= multiplier;
        speed      /= multiplier;
        scoreWorth *= multiplier;
        moneyWorth *= multiplier;
        damage     *= multiplier;

        agent              = GetComponent <NavMeshAgent>();
        anim               = GetComponent <Animator>();
        lastTarget         = bed;
        agent.speed        = speed;
        agent.angularSpeed = 1200 * multiplier;
        agent.Warp(transform.position);

        MoveToTarget(bed);
    }
예제 #6
0
 IEnumerator Ammo_Check()
 {
     while (true)
     {
         if (is_Reloading)
         {
             GetComponent <Slider>().value        = Guns.GetInstance().Get_Waited_Reload_Time() / Guns.GetInstance().Get_Gun_Reload_Time();
             GetComponentInChildren <Text>().text = "Reloading!";
             if (Guns.GetInstance().Get_Gun_Left_Rounds_In_Magazine() >= Guns.GetInstance().Get_Gun_Fire_Per_Reload())
             {
                 is_Reloading = false;
             }
         }
         else
         {
             GetComponent <Slider>().value        = Guns.GetInstance().Get_Gun_Left_Rounds_In_Magazine() / Guns.GetInstance().Get_Gun_Fire_Per_Reload();
             GetComponentInChildren <Text>().text = "AMMO : " + Guns.GetInstance().Get_Gun_Left_Rounds_In_Magazine().ToString() + " / " + Guns.GetInstance().Get_Gun_Fire_Per_Reload().ToString();
             if (Guns.GetInstance().Get_Gun_Left_Rounds_In_Magazine() <= 0)
             {
                 is_Reloading = true;
             }
         }
         yield return(null);
     }
 }
예제 #7
0
    IEnumerator Show(Guns gun)
    {
        float alpha = 1f;

        if (gun == Guns.pistol)
        {
            GetComponent <Image>().sprite = weaponBar[0];
        }
        else if (gun == Guns.shotgun)
        {
            GetComponent <Image>().sprite = weaponBar[1];
        }
        else if (gun == Guns.jumpgun)
        {
            GetComponent <Image>().sprite = weaponBar[2];
        }
        Color oldColor = GetComponent <Image>().color;

        GetComponent <Image>().color = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
        yield return(new WaitForSeconds(1f));

        while (alpha >= 0f)
        {
            GetComponent <Image>().color = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
            yield return(new WaitForSeconds(0.1f));

            alpha -= 0.1f;
        }
    }
예제 #8
0
    public void MyGun(int gunNumber)
    {
        switch (gunNumber)
        {
        case (0):
            curruntGun = Guns.Pistol;
            Debug.Log("Pistol");
            break;

        case (1):
            curruntGun = Guns.MachineGun;
            Debug.Log("Machine");
            break;

        case (2):
            curruntGun = Guns.ShotGun;
            Debug.Log("ShotGun");
            break;

        case (3):
            curruntGun = Guns.Rocket;
            Debug.Log("Rocket");
            break;
        }
    }
예제 #9
0
    public void SetGun(string name)
    {
        Dictionary <Enum, Vector3[]> transforms = new Dictionary <Enum, Vector3[]>()
        {
            { Guns.PISTOL, new Vector3[] { new Vector3(3.5f, -.5f, 0), new Vector3(0, 0, -20f), new Vector3(1f, 1f, 1f) } },
            { Guns.RIFLE, new Vector3[] { new Vector3(3.5f, 0, 0), new Vector3(0, 0, -45f), new Vector3(1.6f, 1.6f, 1.6f) } },
            { Guns.SHOTGUN, new Vector3[] { new Vector3(3.5f, 0, 0), new Vector3(0, 0, -45f), new Vector3(1.6f, 1.6f, 1.6f) } },
        };

        Guns gun = (Guns)System.Enum.Parse(typeof(Guns), name.ToUpper());

        GunController.self.SetGun(gun);

        Sprite sprite = Resources.Load <Sprite>("textures/Guns/" + gun.ToString().ToLower());

        gun_image.sprite = sprite;
        PlayerMovement.self.transform.Find("GunAnimator").GetChild(0).GetComponent <SpriteRenderer>().sprite = sprite;

        SetGunText(GunController.self.guns[gun].ammo, GunController.self.guns[gun].ammo);

        Transform gun_transform = PlayerMovement.self.transform.Find("GunAnimator").GetChild(0).transform;

        gun_transform.localPosition    = transforms[gun][0];
        gun_transform.localEulerAngles = transforms[gun][1];
        gun_transform.localScale       = transforms[gun][2];
    }
예제 #10
0
 private void Start()
 {
     database     = GameObject.Find("Game").GetComponent <database>();
     InputManager = GetComponent <InputManager>();
     Guns         = GetComponent <Guns>();
     guntxt.text  = bullets.ToString();
 }
예제 #11
0
    public void Set_Status(int gun_type) // 총의 종류에 맞게 총알의 스탯 설정.
    {
        m_Damage              = Guns.GetInstance().Get_Gun_Damage();
        m_Move_Speed          = Guns.GetInstance().Get_Gun_Bullet_Speed();
        m_Knock_Back_Distance = Guns.GetInstance().Get_Gun_Knock_Back_Distance();

        Vector3 size = GetComponent <BoxCollider>().size;

        transform.localPosition = Vector3.zero;
        switch (gun_type)
        {
        case GUN_TYPE.SHOTGUN:
            size.x = BULLET_SIZE.SHOTGUN_X;
            size.y = BULLET_SIZE.SHOTGUN_Y;
            break;

        case GUN_TYPE.DSMG:
            size.x = BULLET_SIZE.DSMG_X;
            size.y = BULLET_SIZE.DSMG_Y;
            break;

        case GUN_TYPE.AR:
            size.x = BULLET_SIZE.AR_X;
            size.y = BULLET_SIZE.AR_Y;
            break;
        }
        GetComponent <BoxCollider>().size = size;

        Set_Random_Direction(gun_type);
    }
예제 #12
0
파일: Weapon.cs 프로젝트: fsmilu/seventwo
 public void PickGun(Guns gun)
 {
     gunNow    = gun;
     loadCount = gunInfo[gun][2];
     GetComponent <Animator>().SetInteger("stat", (int)gunNow);
     FindObjectOfType <WeaponBar>().PickGun(this);
 }
예제 #13
0
        public void InitializeGun(Guns gun)
        {
            name = gun.ToString();
            switch (gun)
            {
            case Guns.assaultRifle:
                rateOfFire = 2;
                range      = 2;
                shortRange = true;
                bulky      = false;
                break;

            case Guns.sniperRifle:
                rateOfFire = 1;
                range      = 4;
                shortRange = false;
                bulky      = true;
                break;

            case Guns.machineGun:
                rateOfFire = 4;
                range      = 2;
                shortRange = true;
                bulky      = true;
                break;
            }
        }
예제 #14
0
    void Awake()
    {
        //pulling data from xml's
        gunList   = GunDataHook();
        enemyList = EnemyDataHook();

        isReady = true;
    }
 bool CheckForGun(Guns gunToSearchFor)
 {
     if (iPlayerCurrentGuns[(int)gunToSearchFor] == gunToSearchFor)
     {
         return(true);
     }
     return(false);
 }
예제 #16
0
    public PlayerData(string name, int lookID)
    {
        Name   = name;
        LookID = lookID;

        Guns           = GunsManager.Instance.GetGuns();
        SpecialGuns    = GunsManager.Instance.GetSpecialGuns();
        CurrentGunName = Guns.Find(x => x.IsBought).Name;
    }
예제 #17
0
 public void EquipGun(Guns gunToEquip)
 {
     if (equippedGun != null)
     {
         Destroy(equippedGun.gameObject);
     }
     equippedGun = Instantiate(gunToEquip, weaponHold.position, weaponHold.rotation) as Guns;
     equippedGun.transform.parent = weaponHold;
 }
예제 #18
0
        public ActionResult Guns(string first, string last)
        {
            List <gun> _list = TableUtils.queryToTable <gun>("SELECT * FROM shooters.Gun");
            Guns       model = new Guns();

            model._guns = _list;
            return(View(model));
            // return View();
        }
예제 #19
0
 // Use this for initialization
 void Start()
 {
     turretAI   = AI.Searching;
     target     = GameObject.FindGameObjectWithTag("Player");
     upperScan  = new Vector2(0, 16);
     upperAngle = Vector3.Angle(Vector2.up, upperScan);
     lowerScan  = new Vector2(16, -2);
     lowerAngle = Vector2.Angle(Vector2.up, lowerScan);
     gun        = GetComponent <Guns>();
 }
        public void Initialize(Vector2 startLoc)
        {
            IsDisposed = false;
            Location   = startLoc;

            DualMissile45 d45 = Level.Instance.DualMissile45Pool.New();

            d45.Initialize(new Vector2(10, 31), null);
            Guns.Add(d45);
        }
예제 #21
0
    void Awake()
    {
        m_Instance = this;

        m_Gun_Animations = GetComponent <Animation>();

        Gun_Change(GUN_TYPE.SHOTGUN);

        m_Waited_Reload_Time = 0.0f;
    }
예제 #22
0
        private static IGun CreateGun(string name, int bulletsCount, Guns gun)
        {
            IGun gunToAdd = gun switch
            {
                Guns.Pistol => new Pistol(name, bulletsCount),
                Guns.Rifle => new Rifle(name, bulletsCount)
            };

            return(gunToAdd);
        }
        public void Initialize(Vector2 startLocation)
        {
            IsDisposed = false;
            Location   = startLocation;

            Velocity = Maths.RandomNr(7, 9);
            AutoAim aa = Level.Instance.AutoAimPool.New();

            aa.Initialize(new Vector2(Animation.Width / 2 - 8, Animation.Height / 2 - 8), null);
            Guns.Add(aa);
        }
예제 #24
0
 IEnumerator Attack()
 {
     while (true)
     {
         if (!StageManager.GetInstance().Get_isPause() && m_is_Alive)
         {
             Guns.GetInstance().GunFire();
         }
         yield return(null);
     }
 }
예제 #25
0
    public void SetRandomGun()
    {
        while (RandomGun == Gun)
        {
            RandomGun = (Guns)Random.Range(0, Enum.GetNames(typeof(Guns)).Length);
        }

        SetGun(RandomGun);

        Gun = RandomGun;
    }
예제 #26
0
    // Use this for initialization
    void Start()
    {
        // refer to the camera parent of the weapons object
        _camera     = GetComponentInParent <Camera>();
        _gunFire    = GetComponent <AudioSource>();
        _playerGun  = Guns.Rifle;
        _currentGun = 0;

        /*Cursor.lockState = CursorLockMode.Locked;
         * Cursor.visible = false;*/
    }
예제 #27
0
    private void Start()
    {
        Guns guns = GetComponent <Guns>();

        Shoot         = guns.GetShootEvent();
        maxShootSpeed = guns.GetGunsMaxShootSpeed();

        GetComponent <Health>().OnHealthChange += OnHealthChange;

        flightModeSwitcher = GetComponent <StarshipFlightModeSwitcher>();
    }
예제 #28
0
        public PlayGameForm(Guns gun, Birds bird)
        {
            InitializeComponent();

            this.GameStatus   = GameStatus.Continue;
            this.SelectedGun  = gun;
            this.SelectedBird = bird;

            SetupCrossHair();

            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }
예제 #29
0
    // Update is called once per frame
    void Update()
    {
        // Check for wheel
        float wheelInput = Input.GetAxis("Mouse ScrollWheel");

        if (wheelInput < 0)
        {
            //currentGun = (Guns)(((int)(currentGun + 1)) % System.Enum.GetValues(typeof(Guns)).Length);
            int nextGun = GetNextGun();
            if (nextGun >= 0)
            {
                ChangeGun((Guns)nextGun);
            }
        }
        else if (wheelInput > 0)
        {
            //currentGun = (Guns)(((int)(currentGun - 1)) % System.Enum.GetValues(typeof(Guns)).Length);
            int nextGun = GetPrevGun();
            if (nextGun >= 0)
            {
                ChangeGun((Guns)nextGun);
            }
        }
        // Check for Numpad inputs
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            if (guns[Guns.PISTOL].GetComponent <Pistol>().active)
            {
                currentGun = Guns.PISTOL; ChangeGun(Guns.PISTOL);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            if (guns[Guns.SHOTGUN].GetComponent <Pistol>().active)
            {
                currentGun = Guns.SHOTGUN; ChangeGun(Guns.SHOTGUN);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            if (guns[Guns.MACHINEGUN].GetComponent <Pistol>().active)
            {
                currentGun = Guns.MACHINEGUN; ChangeGun(Guns.MACHINEGUN);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            if (guns[Guns.SNIPER].GetComponent <Pistol>().active)
            {
                currentGun = Guns.SNIPER; ChangeGun(Guns.SNIPER);
            }
        }
    }
예제 #30
0
    private void EquipGun(Guns _gun)
    {
        currentGun = _gun;

        GameObject _gunIns = (GameObject)Instantiate(_gun.model, gunHolder.position, gunHolder.rotation);

        _gunIns.transform.SetParent(gunHolder);
        if (isLocalPlayer)
        {
            _gunIns.layer = LayerMask.NameToLayer(gunLayerName);
        }
    }