Example #1
0
        public static void AddNewSkladStorage(string NameFaction)
        {
            const int Pistols  = 1000;
            const int Rifle    = 1000;
            const int SMG      = 1500;
            const int Shotgun  = 2500;
            const int Melee    = 2500;
            const int Armor    = 2500;
            const int Medicals = 2500;

            switch (NameFaction)
            {
            case "Start":

                Dictionary <string, string> parametersStatr = new Dictionary <string, string>
                {
                    { "@NameFaction", NameFaction },
                    { "@Pistols", Pistols.ToString() },
                    { "@Rifle", Rifle.ToString() },
                    { "@SMG", SMG.ToString() },
                    { "@Shotgun", Shotgun.ToString() },
                    { "@Melee", Melee.ToString() },
                    { "@Armor", Armor.ToString() },
                    { "@Medicals", Medicals.ToString() }
                };

                DataTable resultStatr = Database.ExecutePreparedStatement("INSERT INTO sklad_faction_storages (NameFaction, Pistols, Rifle, SMG, Shotgun, Melee, Armor, Medicals) " +
                                                                          DatabaseValues, parametersStatr);

                break;
            }
        }
Example #2
0
        static void Main(string[] argv)
        {
            Weapon AK47   = new Rife("AK 47", 200, 100);
            Weapon SawOff = new Shotgun("SawOff", 500, 150);
            Weapon Mp5    = new SMG("Mp5", 150, 200);

            AK47.fire();
        }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        GameObject Pistol = GameObject.Find("SMGOff");

        if (Pistol != null)
        {
            SMG Shoot = GameObject.Find("SShooT").GetComponent <SMG>();
            Shoot.Holders = globalAmmo;
        }
    }
Example #4
0
 private void OnCollisionEnter(Collision collision)
 {
     Debug.Log(collision.gameObject.name);
     if (collision.gameObject.tag == "Player")
     {
         Debug.Log("clided");
         SMG gun = this;
         collision.gameObject.GetComponent <PC>().SetWeapon(gun);
         // PhotonNetwork.Destroy(this.gameObject);
         //  collision.transform.GetComponent<PhotonView>().RPC("SetWeapon", Photon, gun);
     }
 }
Example #5
0
    public static void SaveSMG(SMG smg)
    {
        BinaryFormatter formatter = new BinaryFormatter();                        // allows conversion to a binary format
        string          sFilePath = Application.persistentDataPath + "/SMG.sdat"; // creates a persistant path to the save file meaning it doesn't get moved around the system

        FileStream stream = new FileStream(sFilePath, FileMode.Create);           // create the save file on the system

        SMGData smgData = new SMGData(smg);                                       // get the player information defined in the PlayerData.cs script

        formatter.Serialize(stream, smgData);                                     // serialize our data into a binary format
        stream.Close();                                                           // close our stream to stop leaks
    }
Example #6
0
 void Start()
 {
     smg = GameObject.Find("MP5").GetComponent <SMG>();
     go_PlayerController = GameObject.FindGameObjectWithTag("Player");
     playerController    = go_PlayerController.GetComponent <PlayerController>();
     if (playerController.bFacingRight == true)
     {
         bulletRigidBody2D.velocity = Vector2.right * fBulletSpeed;
     }
     else
     {
         bulletRigidBody2D.velocity = Vector2.right * -fBulletSpeed;
     }
 }
Example #7
0
    public override void Spawn()
    {
        int index = Random.Range(0, smgPrefabs.Length);

        if (count < maxCount && timer >= spawnCooltme)
        {
            timer = 0;
            Vector3 position = GetSpawonPosition(0, 0);
            position.y = smgPrefabs[index].transform.position.y;
            SMG smg = Instantiate(smgPrefabs[index], position, smgPrefabs[index].transform.rotation);
            smg.SetSpawnerDelegate(new OnChildDestroyCallback(OnChildDestroy));
            count++;
        }
    }
Example #8
0
    // Start is called before the first frame update
    void Start()
    {
        animr = GetComponent <Animator>();
        smg   = FindObjectOfType <SMG>();

        smg.cam = GetComponentInChildren <Camera>();

        controllerMode = true;

        shieldMat = shield.GetComponent <MeshRenderer>().material;

        shieldMat.SetFloat("_Alpha", 0);
        shield.SetActive(false);


        powerBar = FindObjectOfType <PowerBar>();
    }
    // Use this for initialization
    private void Start()
    {
        if (isLocalPlayer)
        {
            m_CharacterController = GetComponent <CharacterController>();
            m_Camera = Camera.main;
            m_OriginalCameraPosition = m_Camera.transform.localPosition;
            m_FovKick.Setup(m_Camera);
            m_HeadBob.Setup(m_Camera, m_StepInterval);
            m_StepCycle = 0f;
            m_NextStep  = m_StepCycle / 2f;
            m_Jumping   = false;
            m_MouseLook.Init(transform, m_Camera.transform);

            currentPower = PowerUp.NONE;
            health       = gameObject.GetComponent <Health>();
            inventory    = gameObject.GetComponent <Inventory>();
            powerActive  = false; doubleDamageVar = false;
            pistol.SetActive(true); SMG.SetActive(false);
            chatUp = false;

            //Attaches the gun to the camera
            foreach (Transform child in transform)
            {
                if (child.CompareTag("Rifle"))
                {
                    child.SetParent(Camera.main.transform, false);
                    Vector3 newPos = child.position;
                    newPos.y      -= 0.5f;
                    newPos.z      -= 0.05f;
                    child.position = newPos;
                    break;
                }
            }

            powerUpTimerText      = GameObject.FindGameObjectWithTag("Timer").GetComponent <Text>();
            powerUpTimerText.text = "";

            powerEffect.Add(PowerUp.DOUBLE_DAMAGE, doubleDamage);
            powerEffect.Add(PowerUp.FAST_FIRE, fastFire);
            powerEffect.Add(PowerUp.FAST_MOVE, fastWalk);
            powerEffect.Add(PowerUp.JUMP_HIGH, jumpHigh);
            powerEffect.Add(PowerUp.INVINCIBLE, invincible);
        }
    }
Example #10
0
    public void WeaponSelect()
    {
        switch (Weapon)
        {
        case ("Sniper"):

            Sniper newSniper = new Sniper(Name, FireRate, Range, GunEnd);
            break;

        case ("Rifle"):
            Rifle newRifle = new Rifle(Name, FireRate, Range, GunEnd);
            break;

        case ("SMG"):
            SMG newSMG = new SMG(Name, FireRate, Range, GunEnd);
            break;

        case ("Shotgun"):
            Shotgun newGun = new Shotgun(Name, FireRate, Range, GunEnd);
            break;
        }
    }
Example #11
0
    private void SetCommand()
    {
        _weapons = new Weapon[6];

        _weapons[0]        = new Pistol();
        pistol.coolTime    = FileManager.weaponInfo["pistol_respawn"];
        pistol.divCooltime = 1 / pistol.coolTime;
        Copy_Paste(_weapons[0], pistol);

        _weapons[1]     = new SMG();
        smg.coolTime    = FileManager.weaponInfo["smg_respawn"];
        smg.divCooltime = 1 / smg.coolTime;
        Copy_Paste(_weapons[1], smg);

        _weapons[2]        = new Sniper();
        sniper.coolTime    = FileManager.weaponInfo["sniper_respawn"];
        sniper.divCooltime = 1 / sniper.coolTime;
        Copy_Paste(_weapons[2], sniper);

        _weapons[3]    = new AR();
        ar.coolTime    = FileManager.weaponInfo["ar_respawn"];
        ar.divCooltime = 1 / ar.coolTime;
        Copy_Paste(_weapons[3], ar);

        _weapons[4]    = new SG();
        sg.coolTime    = FileManager.weaponInfo["sg_respawn"];
        sg.divCooltime = 1 / sg.coolTime;
        Copy_Paste(_weapons[4], sg);

        _weapons[5]         = new Grenade();
        grenade.coolTime    = FileManager.weaponInfo["grenade_respawn"];
        grenade.divCooltime = 1 / grenade.coolTime;
        Copy_Paste(_weapons[5], grenade);

        for (i = 0; i < _weapons.Length; i++)
        {
            _weapons[i].Init();
        }
    }
Example #12
0
 void Start()
 {
     smg = GameObject.Find("MP5").GetComponent <SMG>();
 }
    // Use this for initialization
    void Start()
    {
        healthBar       = GameObject.Find("HealthBar").GetComponent <RectTransform>();
        gmanager        = GameObject.Find("GameManager").GetComponent <GameManager>();
        maxHealth       = health;
        playerAnimsCont = GetComponent <Animation>();
        playerCol       = GetComponent <CapsuleCollider>();
        PlayerAnimator  = GetComponent <Animator>();
        weppos          = GameObject.FindGameObjectWithTag("WepActiveLoc");
        wepPanel        = GameObject.FindGameObjectWithTag("WeaponsPanel");
        ArmMover        = GameObject.FindGameObjectWithTag("ArmMover");
        PHand           = ArmMover.GetComponent <ArmMover>().playerHand;
        playerarm       = GetComponent <AimIK>();

        GameObject[] arr = GameObject.FindGameObjectsWithTag("PlayerWeapon");
        if (arr.Length < maxWeapons)
        {
            weapons = new GameObject[arr.Length];
        }
        else
        {
            weapons = new GameObject[maxWeapons];
        }

        wepbuts = new Button[wepPanel.GetComponentsInChildren <Button>(true).Length];
        wepbuts = wepPanel.GetComponentsInChildren <Button>(true);

        int count = 0;

        foreach (GameObject arrItem in arr)
        {
            if (arrItem.name == "SMG")
            {
                SMG script = arrItem.GetComponent <SMG>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }

            if (arrItem.name == "Sword")
            {
                Sword script = arrItem.GetComponent <Sword>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }

            if (arrItem.name == "Pistol")
            {
                Pistol script = arrItem.GetComponent <Pistol>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }


            arrItem.SetActive(false);
            count++;
        }

        if (weapons[currentWeaponIndex] != null)
        {
            weapon = weapons[currentWeaponIndex];
        }
        else
        {
            weapon = weapons[0];
        }
    }
Example #14
0
 public SMGData(SMG smg)
 {
     fSMGDamage   = smg.fDamage;
     fSMGOverheat = smg.fOverHeatRate;
 }
Example #15
0
 // Use this for initialization
 void Awake()
 {
     Instance = GetComponent <SMG>();
 }
    // Update is called once per frame
    private void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        Cursor.lockState = CursorLockMode.None;
        Cursor.lockState = CursorLockMode.Confined;
        Cursor.visible   = true;
        Camera.main.transform.position = transform.position + transform.up * 0.5f;
        Camera.main.transform.parent   = transform;

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            chatUp = !chatUp;
        }

        if (!chatUp)
        {
            //equip smg
            if (Input.GetKeyDown(KeyCode.O))
            {
                Debug.Log("SMG equipped");
                smgE = true; pistolE = false;
                pistol.SetActive(false); SMG.SetActive(true);
                //equip pistol
            }
            else if (Input.GetKeyDown(KeyCode.P))
            {
                Debug.Log("Pistol equipped");
                smgE = false; pistolE = true;
                pistol.SetActive(true); SMG.SetActive(false);
            }

            //for activating power ups
            //testing purposes ONLY

            /*if (Input.GetKeyDown(KeyCode.I)) {
             *  inventory.AddPowerUp(PowerUp.FAST_MOVE);
             * }
             * else if (Input.GetKeyDown(KeyCode.G)) {
             *  inventory.AddPowerUp(PowerUp.DOUBLE_DAMAGE);
             * }
             * else if (Input.GetKeyDown(KeyCode.F)) {
             *  inventory.AddPowerUp(PowerUp.FAST_FIRE);
             * }
             * else if (Input.GetKeyDown(KeyCode.B)) {
             *  inventory.AddPowerUp(PowerUp.INVINCIBLE);
             * }
             * else if (Input.GetKeyDown(KeyCode.J)) {
             *  inventory.AddPowerUp(PowerUp.JUMP_HIGH);
             * }*/

            //Check if the player wishes to use a power up
            if (!powerActive)
            {
                if (Input.GetButtonDown("Inventory1"))
                {
                    currentPower = inventory.getPowerUp(1);
                    if (currentPower != PowerUp.NONE)
                    {
                        inventory.RemovePowerUp(1);
                        powerEffect[currentPower]();
                        powerActive = true;
                    }
                }
                else if (Input.GetButtonDown("Inventory2"))
                {
                    currentPower = inventory.getPowerUp(2);
                    if (currentPower != PowerUp.NONE)
                    {
                        inventory.RemovePowerUp(2);
                        powerEffect[currentPower]();
                        powerActive = true;
                    }
                }
                else if (Input.GetButtonDown("Inventory3"))
                {
                    currentPower = inventory.getPowerUp(3);
                    if (currentPower != PowerUp.NONE)
                    {
                        inventory.RemovePowerUp(3);
                        powerEffect[currentPower]();
                        powerActive = true;
                    }
                }
                else if (Input.GetButtonDown("Inventory4"))
                {
                    currentPower = inventory.getPowerUp(4);
                    if (currentPower != PowerUp.NONE)
                    {
                        inventory.RemovePowerUp(4);
                        powerEffect[currentPower]();
                        powerActive = true;
                    }
                }
                else if (Input.GetButtonDown("Inventory5"))
                {
                    currentPower = inventory.getPowerUp(5);
                    if (currentPower != PowerUp.NONE)
                    {
                        inventory.RemovePowerUp(5);
                        powerEffect[currentPower]();
                        powerActive = true;
                    }
                }
            }
            else
            {
                powerUpTimer -= Time.deltaTime;
                int g = (int)powerUpTimer;
                powerUpTimerText.text = g.ToString();
            }

            if (powerUpTimer <= 0.0f)
            {
                Debug.Log("Power up over");
                if (currentPower == PowerUp.INVINCIBLE)
                {
                    health.SwitchInvincibility();
                }

                powerUpTimerText.text = "";
                m_WalkSpeed           = 8; m_JumpSpeed = 6;
                nextFireP             = 0.7f; nextFireS = 0.1f;
                powerUpTimer          = 10.0f;
                currentPower          = PowerUp.NONE;
                doubleDamageVar       = false; powerActive = false;
            }

            //countdown timer to allow the player to shoot again its just always subtracting and resets when the player shoots
            nextFireP -= Time.deltaTime;
            nextFireS -= Time.deltaTime;

            //used to fire the guns
            if (Input.GetButton("Fire1"))
            {
                if (smgE && nextFireS <= 0.0f)
                {
                    CmdfireBullet();
                    //timer until can shoot again
                    if (currentPower == PowerUp.FAST_FIRE)
                    {
                        nextFireS = 0.05f;
                    }
                    else
                    {
                        nextFireS = 0.1f;
                    }
                }
                else if (pistolE && nextFireP <= 0.0f)
                {
                    CmdfireBullet();
                    //timer until can shoot again
                    if (currentPower == PowerUp.FAST_FIRE)
                    {
                        nextFireP = 0.35f;
                    }
                    else
                    {
                        nextFireP = 0.7f;
                    }
                }
            }

            RotateView();

            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                m_MoveDir.y = 0f;
                m_Jumping   = false;
            }

            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
    }