Пример #1
0
 public void WeaponSwitched(WeaponProp wep)
 {
     wepInHand    = wep;
     emptyMag     = wepInHand.emptyMag;
     audShoot     = wepInHand.audShoot;
     audReloading = wepInHand.audReloading;
     magText.text = wepInHand.TotalPlusMag();
 }
Пример #2
0
    public void PlayerHit(RaycastHit rayHits, WeaponProp wepon)
    {
        foreach (EnemyMove enTemp in FindObjectsOfType <EnemyMove>())
        {
            if (Vector3.Distance(rayHits.point, enTemp.transform.position) <= 10f)
            {
                enTemp.SetAgro(playerModel);
            }
        }

        if (rayHits.collider.material.name.Equals("Meat (Instance)"))
        {
            EnemyHealth temp = rayHits.transform.GetComponent <EnemyHealth>();
            if (temp.ReturnHealth() > 0f)
            {
                GameObject part = Instantiate(hitBlood, rayHits.point, Quaternion.LookRotation(rayHits.normal));
                Destroy(part, 1.5f);
            }
            temp.TakeDamage(wepon.GetWeaponDMG(), playerModel);
        }
        else if (rayHits.collider.material.name.Equals("Stone (Instance)"))
        {
            GameObject part = Instantiate(hitStone, rayHits.point, Quaternion.LookRotation(rayHits.normal));
            Destroy(part, 3f);
        }
        else if (rayHits.transform.tag.Equals("Terra"))
        {
            Vector3 tempShoot = rayHits.point;
            terTest    = rayHits.collider.GetComponent <Terrain>();
            tempShoot -= terTest.GetPosition();
            float pointHeight = terTest.terrainData.GetHeight(System.Convert.ToInt32(tempShoot.x), System.Convert.ToInt32(tempShoot.z));
            if (pointHeight + 0.5f < tempShoot.y)
            {
                GameObject tempPart = Instantiate(hitWood, rayHits.point, Quaternion.LookRotation(rayHits.normal));
                Destroy(tempPart, 3f);
                return;
            }
            GameObject part = Instantiate(hitTerra, rayHits.point, Quaternion.LookRotation(rayHits.normal));
            Destroy(part, 1.5f);
        }
        else
        {
            HitEnemy(rayHits, wepon);
        }
    }
Пример #3
0
        private void getAllWeapons(Weapon[] weapons, WeaponProp[] props)
        {
            foreach (Weapon wep in weapons)
            {
                wep.setOwnerFaction(m_ownersFaction);
                wep.setAimed(false);
                wep.setGunTarget(m_target);
                wep.gameObject.SetActive(false);
                wep.addOnWeaponFireEvent(onWeaponFire);

                Weapon.WEAPONTYPE type = wep.getWeaponType();

                switch (type)
                {
                case Weapon.WEAPONTYPE.primary:
                    m_rifle = wep;
                    break;

                case Weapon.WEAPONTYPE.secondary:
                    m_pistol = wep;
                    break;
                }
            }

            foreach (WeaponProp prop in props)
            {
                Weapon.WEAPONTYPE type = prop.getPropType();

                switch (type)
                {
                case Weapon.WEAPONTYPE.primary:
                    m_rifleProp = prop;
                    break;

                case Weapon.WEAPONTYPE.secondary:
                    m_pistolProp = prop;
                    break;
                }
            }
        }
Пример #4
0
    public void HitEnemy(RaycastHit rayHits, WeaponProp wepon)
    {
        if (rayHits.collider.tag.Equals("Enemy"))
        {
            EnemyHitted tempHit = rayHits.collider.GetComponent <EnemyHitted>();
            if (tempHit.partType == EnemyHitted.PartOfEnemy.Chest)
            {
                EnemyHealth temp = rayHits.transform.GetComponentInParent <EnemyHealth>();
                if (temp.ReturnHealth() > 0f)
                {
                    GameObject part = Instantiate(hitTerra, rayHits.point, Quaternion.LookRotation(rayHits.normal));
                    Destroy(part, 1.5f);
                }
                temp.TakeDamage(wepon.GetWeaponDMG() * GetComponentInParent <PlayerInventory>().GetDMGRatio(), playerModel);
            }

            else if (tempHit.partType == EnemyHitted.PartOfEnemy.Head)
            {
                EnemyHealth temp = rayHits.transform.GetComponentInParent <EnemyHealth>();
                if (temp.ReturnHealth() > 0f)
                {
                    GameObject part = Instantiate(hitTerra, rayHits.point, Quaternion.LookRotation(rayHits.normal));
                    Destroy(part, 1.5f);
                }
                temp.TakeDamage((wepon.GetWeaponDMG() * GetComponentInParent <PlayerInventory>().GetDMGRatio()) * 1.5f, playerModel);
            }

            else if (tempHit.partType == EnemyHitted.PartOfEnemy.Limb)
            {
                EnemyHealth temp = rayHits.transform.GetComponentInParent <EnemyHealth>();
                if (temp.ReturnHealth() > 0f)
                {
                    GameObject part = Instantiate(hitTerra, rayHits.point, Quaternion.LookRotation(rayHits.normal));
                    Destroy(part, 1.5f);
                }
                temp.TakeDamage((wepon.GetWeaponDMG() * GetComponentInParent <PlayerInventory>().GetDMGRatio()) * .5f, playerModel);
            }
        }
    }
Пример #5
0
 public void setCurretnWeaponProp(WeaponProp weaponProp)
 {
     this.m_pistolProp = weaponProp;
 }
Пример #6
0
    public void SetWeaponInSlot(bool first, GameObject weap, GameObject charSlot)
    {
        GameObject wepSlot;
        WeaponItem tWeapon = new WeaponItem();

        int count = 0;

        foreach (Text temp in weap.GetComponentsInChildren <Text>())
        {
            if (temp.name.Equals("WeaponType"))
            {
                if (temp.text == "Ak47")
                {
                    tWeapon.weaponType = WeaponItem.Type.Ak47;
                }
                else
                {
                    tWeapon.weaponType = WeaponItem.Type.M4A1;
                }
                count++;
            }
            else if (temp.name.Equals("DMG"))
            {
                string tDmg = "";
                foreach (char c in temp.text)
                {
                    if (char.IsDigit(c) || c == '.')
                    {
                        tDmg += c;
                    }
                }
                tWeapon.weaponDMG = System.Convert.ToSingle(tDmg);
                count++;
            }
            else if (temp.name.Equals("LVL"))
            {
                string tLVL = "";
                foreach (char c in temp.text)
                {
                    if (char.IsDigit(c))
                    {
                        tLVL += c;
                    }
                }
                tWeapon.weaponLvl = System.Convert.ToInt32(tLVL);
                count++;
            }

            if (count == 3)
            {
                break;
            }
        }

        int counter = 0;

        foreach (WeaponItem wepTe in weapons)
        {
            if (wepTe.weaponType == tWeapon.weaponType)
            {
                if (wepTe.weaponLvl == tWeapon.weaponLvl)
                {
                    weapons.RemoveAt(counter);
                    break;
                }
            }
            counter++;
        }

        if (first)
        {
            wepSlot = GetComponentInChildren <WeaponChage>().firstSlot;
            if (firstSlot != null)
            {
                FromCharToBag(charSlot);
                Destroy(wepSlot.GetComponentInChildren <WeaponProp>().gameObject);
            }
        }
        else
        {
            wepSlot = GetComponentInChildren <WeaponChage>().secondSlot;
            if (secondSlot != null)
            {
                FromCharToBag(charSlot);
                Destroy(wepSlot.GetComponentInChildren <WeaponProp>().gameObject);
            }
        }

        GameObject weaponinpos;

        if (tWeapon.weaponType == WeaponItem.Type.Ak47)
        {
            weaponinpos = Instantiate(CreateAK, wepSlot.transform);
        }
        else
        {
            weaponinpos = Instantiate(CreateM4, wepSlot.transform);
        }

        weaponinpos.GetComponent <WeaponMove>().playerAnim = GetComponent <Animator>();
        weaponinpos.GetComponent <WeaponMove>().mainCam    = GetComponentInChildren <Camera>();

        WeaponProp tProp = weaponinpos.GetComponent <WeaponProp>();

        tProp.SetDamage(tWeapon.weaponDMG);
        tProp.weaponLvL = tWeapon.weaponLvl;

        if (first)
        {
            firstSlot = tProp;
        }
        else
        {
            secondSlot = tProp;
        }

        ShowInSlot(tWeapon, charSlot);
        GetComponent <UIControlling>().ResetInventory();
    }