Esempio n. 1
0
        bool CheckEquipConditions(int side, vMeleeWeapon weapon)
        {
            if (side == 1)
            {
                if ((weapon.meleeType == vMeleeWeapon.MeleeType.All && (weapon.handEquip == vMeleeWeapon.HandEquip.BothHand || weapon.handEquip == vMeleeWeapon.HandEquip.RightHand)))
                {
                    return(true);
                }
                if (weapon.meleeType == vMeleeWeapon.MeleeType.Attack)
                {
                    return(true);
                }
            }
            else if (side == -1)
            {
                if (weapon.useTwoHand)
                {
                    return(false);
                }
                if ((weapon.meleeType == vMeleeWeapon.MeleeType.All && (weapon.handEquip == vMeleeWeapon.HandEquip.BothHand || weapon.handEquip == vMeleeWeapon.HandEquip.RightHand)))
                {
                    return(true);
                }
                if (weapon.meleeType == vMeleeWeapon.MeleeType.Defense)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
    /// <summary>
    /// Init properties
    /// </summary>
    protected virtual void Init()
    {
        fighter = gameObject.GetMeleeFighter();
        ///Initialize all bodyMembers and weapons
        foreach (vBodyMember member in Members)
        {
            ///damage of member will be always the defaultDamage
            //member.attackObject.damage = defaultDamage;
            member.attackObject.damage.damageValue = defaultDamage.damageValue;
            if (member.bodyPart == HumanBodyBones.LeftLowerArm.ToString())
            {
                var weapon = member.attackObject.GetComponentInChildren <vMeleeWeapon>();
                leftWeapon = weapon;
            }
            if (member.bodyPart == HumanBodyBones.RightLowerArm.ToString())
            {
                var weapon = member.attackObject.GetComponentInChildren <vMeleeWeapon>();
                rightWeapon = weapon;
            }
            member.attackObject.meleeManager = this;
            member.SetActiveDamage(false);
        }

        if (leftWeapon != null)
        {
            leftWeapon.SetActiveDamage(false);
            leftWeapon.meleeManager = this;
        }
        if (rightWeapon != null)
        {
            rightWeapon.meleeManager = this;
            rightWeapon.SetActiveDamage(false);
        }
    }
    void CreateDefaultHitbox(ref vMeleeWeapon meleeWeapon, Transform hand, Transform arm, float height, bool invertRotation)
    {
        if (Selection.activeGameObject != null && PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab || !Selection.activeGameObject.activeSelf)
        {
            return;
        }
        GameObject defaultHitbox = Resources.Load("defaultHitBox") as GameObject;

        if (defaultHitbox == null)
        {
            return;
        }

        GameObject def = Instantiate(defaultHitbox);

        meleeWeapon            = def.GetComponent <vMeleeWeapon>();
        def.transform.position = hand.position;

        var scale = Vector3.Distance(hand.position, arm.position) * 0.5f;

        def.transform.localScale = new Vector3(scale, scale, scale);

        SetupTransform(def.transform, hand, arm, height, invertRotation);
        def.transform.parent = hand;
        def.tag   = "Weapon";
        def.layer = LayerMask.NameToLayer("Ignore Raycast");
    }
Esempio n. 4
0
 void Start()
 {
     usingPhysics = true;
     if (_meleeWeapon == null)
     {
         _meleeWeapon = GetComponentInChildren <vMeleeWeapon>();
     }
 }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="weaponObject"></param>
 public void SetRightWeapon(vMeleeWeapon weapon)
 {
     if (weapon)
     {
         rightWeapon = weapon;
         rightWeapon.meleeManager = this;
         rightWeapon.SetActiveDamage(false);
     }
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="weaponObject"></param>
 public void SetLeftWeapon(vMeleeWeapon weapon)
 {
     if (weapon)
     {
         leftWeapon = weapon;
         leftWeapon.SetActiveDamage(false);
         leftWeapon.meleeManager = this;
     }
 }
Esempio n. 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="weaponObject"></param>
 public void SetLeftWeapon(GameObject weaponObject)
 {
     if (weaponObject)
     {
         leftWeapon = weaponObject.GetComponent <vMeleeWeapon>();
         if (leftWeapon)
         {
             leftWeapon.SetActiveDamage(false);
             leftWeapon.meleeManager = this;
         }
     }
 }
Esempio n. 8
0
 public override void SetRightWeapon(vMeleeWeapon weapon)
 {
     base.SetRightWeapon(weapon);
     if (GetComponent <PhotonView>().IsMine == true)
     {
         GetComponent <PhotonView>().RPC(
             "MeleeManager_ReceiveSetLeftWeapon",
             RpcTarget.Others,
             (weapon) ? StaticMethods.BuildChildTree(transform, weapon.transform, false) : new int[] { }
             );
     }
 }
 public void DropLeftWeapon()
 {
     if (currentMeleeWeaponLA != null)
     {
         var collectable = currentMeleeWeaponLA.GetComponentInParent <vCollectableMelee>();
         if (collectable != null)
         {
             collectable.transform.parent = null;
             collectable.DisableMeleeItem();
             if (collectable.destroyOnDrop)
             {
                 Destroy(collectable.gameObject);
             }
             currentMeleeWeaponLA = null;
             SendMessage("SetCombatID", GetCombatID(), SendMessageOptions.DontRequireReceiver);
         }
     }
 }
    public void SetLeftMeleeWeapon(Transform handler)
    {
        if (handler)
        {
            var meleeWeapon = handler.GetComponentInChildren <vMeleeWeapon>();

            if (meleeWeapon)
            {
                if (currentMeleeWeaponRA != null && currentMeleeWeaponRA.useTwoHand)
                {
                    DropRightWeapon();
                }
                currentMeleeWeaponLA = meleeWeapon;
                currentMeleeWeaponLA.Init();
                currentMeleeWeaponLA.hitProperties = this.hitProperties;
                SendMessage("SetCombatID", GetCombatID(), SendMessageOptions.DontRequireReceiver);
            }
            changeWeapon = false;
        }
    }
Esempio n. 11
0
 private void ActiveSecundaryWeapon()
 {
     if (secundaryWeapon)
     {
         secundaryWeapon.gameObject.SetActive(true);
     }
     else
     {
         secundaryWeapon = Instantiate(secundaryWeaponPrefab);
         secundaryWeapon.transform.parent           = otherSideTransform;
         secundaryWeapon.transform.localPosition    = Vector3.zero;
         secundaryWeapon.transform.localEulerAngles = Vector3.zero;
     }
     if (!manager)
     {
         manager = GetComponentInParent <vMeleeManager>();
     }
     if (manager)
     {
         manager.SetLeftWeapon(secundaryWeapon);
     }
 }
    void DrawShieldHandle(vMeleeWeapon weapon)
    {
        var meleeManager = weapon.gameObject.GetComponentInParent <vMeleeManager>();

        if (weapon.top != null)
        {
            if (weapon.top.gameObject.activeSelf && weapon.meleeType == vMeleeWeapon.MeleeType.Defense)
            {
                weapon.top.gameObject.SetActive(false);
            }
        }
        if (weapon.center != null)
        {
            if (weapon.center.gameObject.activeSelf && weapon.meleeType == vMeleeWeapon.MeleeType.Defense)
            {
                weapon.center.gameObject.SetActive(false);
            }
        }
        if (weapon.bottom != null)
        {
            if (weapon.bottom.gameObject.activeSelf && weapon.meleeType == vMeleeWeapon.MeleeType.Defense)
            {
                weapon.bottom.gameObject.SetActive(false);
            }
        }
        if (weapon != null && meleeManager != null && (weapon.meleeType == vMeleeWeapon.MeleeType.Defense || weapon.meleeType == vMeleeWeapon.MeleeType.All))
        {
            var coll = meleeManager.gameObject.GetComponent <Collider>();
            if (coll)
            {
                Handles.DrawWireDisc(coll.bounds.center, Vector3.up, .5f);
                Handles.color = new Color(1, 0, 0, 0.2f);
                Handles.DrawSolidArc((Vector3)coll.bounds.center, Vector3.up, (Vector3)meleeManager.transform.forward, (float)weapon.defenseRange, .5f);
                Handles.DrawSolidArc((Vector3)coll.bounds.center, Vector3.up, (Vector3)meleeManager.transform.forward, (float)-weapon.defenseRange, .5f);
                Handles.color = new Color(1, 1, 1, 0.5f);
                Handles.DrawSolidDisc(coll.bounds.center, Vector3.up, .3f);
            }
        }
    }
 public override void SetLeftWeapon(vMeleeWeapon weapon)
 {
     if (weapon)
     {
         base.SetLeftWeapon(weapon);
         if (GetComponent <PhotonView>().IsMine == true)
         {
             send = true;
             foreach (Component comp in weapon.GetComponents <Component>())
             {
                 if (comp.ToString().Contains("vShooterEquipment"))
                 {
                     send = false;
                 }
             }
             if (send == true)
             {
                 gameObject.GetComponent <PhotonView>().RPC("SetLeftWeapon", RpcTarget.OthersBuffered, weapon.gameObject.name);
             }
         }
     }
 }
 bool checkWeaponType(vMeleeWeapon m_weapon, vMeleeWeapon.MeleeType type)
 {
     return(m_weapon.meleeType == vMeleeWeapon.MeleeType.All || m_weapon.meleeType == type);
 }
    static void DrawWeaponHandler(vMeleeWeapon weapon)
    {
        try
        {
            var parent = weapon.transform.parent;
            if (parent != null)
            {
                if (weapon.top != null)
                {
                    if (!weapon.top.gameObject.activeSelf)
                    {
                        weapon.top.gameObject.SetActive(true);
                    }
                    weapon.top.gameObject.tag = weapon.tag;
                }

                if (weapon.center != null)
                {
                    if (!weapon.center.gameObject.activeSelf)
                    {
                        weapon.center.gameObject.SetActive(true);
                    }
                    weapon.center.gameObject.tag = weapon.tag;
                }

                if (weapon.bottom != null)
                {
                    if (!weapon.bottom.gameObject.activeSelf)
                    {
                        weapon.bottom.gameObject.SetActive(true);
                    }
                    weapon.bottom.gameObject.tag = weapon.tag;
                }
            }

            var curCenterSize = 0f;
            if ((Mathf.Abs(weapon.centerPos) + weapon.centerSize) > 2.9f)
            {
                curCenterSize = weapon.centerSize - (Mathf.Abs(weapon.centerPos * 2f));
            }
            else
            {
                curCenterSize = weapon.centerSize;
            }

            var boxSize = weapon.top.BoxSize();
            Gizmos.color = new Color(0, 1, 0, .5f);
            var resultSize     = new Vector3(boxSize.x, boxSize.y, boxSize.z);
            var resultPosition = weapon.top.GetBoxPoint().center;
            var matrix         = Matrix4x4.TRS(resultPosition, weapon.top.transform.rotation, resultSize);
            Gizmos.matrix = matrix;
            Gizmos.DrawCube(Vector3.zero, new Vector3(1, 1, 1));

            boxSize        = weapon.center.BoxSize();
            Gizmos.color   = new Color(1, 1, 0, 0.5f);
            resultSize     = new Vector3(boxSize.x, boxSize.y, boxSize.z);
            resultPosition = weapon.center.GetBoxPoint().center;
            matrix         = Matrix4x4.TRS(resultPosition, weapon.center.transform.rotation, resultSize);
            Gizmos.matrix  = matrix;
            Gizmos.DrawCube(Vector3.zero, new Vector3(1, 1, 1));

            boxSize        = weapon.bottom.BoxSize();
            Gizmos.color   = new Color(1, 0, 0, 0.5f);
            resultSize     = new Vector3(boxSize.x, boxSize.y, boxSize.z);
            resultPosition = weapon.bottom.GetBoxPoint().center;
            matrix         = Matrix4x4.TRS(resultPosition, weapon.bottom.transform.rotation, resultSize);
            Gizmos.matrix  = matrix;
            Gizmos.DrawCube(Vector3.zero, new Vector3(1, 1, 1));

            weapon.top.gameObject.hideFlags    = weapon.showHitboxes ? HideFlags.None : HideFlags.HideInHierarchy;
            weapon.center.gameObject.hideFlags = weapon.showHitboxes ? HideFlags.None : HideFlags.HideInHierarchy;
            weapon.bottom.gameObject.hideFlags = weapon.showHitboxes ? HideFlags.None : HideFlags.HideInHierarchy;

            if (weapon.lockHitBox)
            {
                weapon.top.transform.localPosition = new Vector3(0, 1.5f, 0);
                weapon.top.transform.localRotation = Quaternion.Euler(Vector3.zero);
                weapon.top.transform.localScale    = new Vector3(1, ((3f * 0.5f) - (curCenterSize * 0.5f)) - weapon.centerPos, 1);
                weapon.top.size   = Vector3.one;
                weapon.top.center = new Vector3(0, -0.5f, 0);

                weapon.center.transform.localPosition = new Vector3(0, weapon.centerPos, 0);
                weapon.center.transform.localRotation = Quaternion.Euler(Vector3.zero);

                weapon.center.transform.localScale = new Vector3(1, curCenterSize, 1);
                weapon.center.size   = Vector3.one;
                weapon.center.center = Vector3.zero;

                weapon.bottom.transform.localPosition = new Vector3(0, -1.5f, 0);
                weapon.bottom.transform.localRotation = Quaternion.Euler(Vector3.zero);
                weapon.bottom.transform.localScale    = new Vector3(1, ((3f * 0.5f) - (curCenterSize * 0.5f)) + weapon.centerPos, 1);
                weapon.bottom.size   = Vector3.one;
                weapon.bottom.center = new Vector3(0, 0.5f, 0);
            }

            if (weapon.transform.childCount > 3)
            {
                for (int i = 0; i < weapon.transform.childCount; i++)
                {
                    if ((!weapon.transform.GetChild(i).Equals(weapon.top.transform)) &&
                        (!weapon.transform.GetChild(i).Equals(weapon.bottom.transform)) &&
                        (!weapon.transform.GetChild(i).Equals(weapon.center.transform)))
                    {
                        DestroyImmediate(weapon.transform.GetChild(i).gameObject);
                    }
                }
            }
        }
        catch
        {
            if (weapon.top == null || weapon.hitTop == null)
            {
                var _top = weapon.transform.FindChild("hitBox_Top");
                if (_top == null)
                {
                    _top        = new GameObject("hitBox_Top").transform;
                    _top.parent = weapon.transform;
                }
                weapon.hitTop = _top.GetComponent <vHitBox>() == null?_top.gameObject.AddComponent <vHitBox>() : _top.GetComponent <vHitBox>();

                weapon.top = _top.GetComponent <BoxCollider>();
            }
            if (weapon.center == null || weapon.hitCenter == null)
            {
                var _center = weapon.transform.FindChild("hitBox_Center");
                if (_center == null)
                {
                    _center        = new GameObject("hitBox_Center").transform;
                    _center.parent = weapon.transform;
                }
                weapon.hitCenter = _center.GetComponent <vHitBox>() == null?_center.gameObject.AddComponent <vHitBox>() : _center.GetComponent <vHitBox>();

                weapon.center = _center.GetComponent <BoxCollider>();
            }
            if (weapon.bottom == null || weapon.hitBottom == null)
            {
                var _botton = weapon.transform.FindChild("hitBox_Botton");
                if (_botton == null)
                {
                    _botton        = new GameObject("hitBox_Botton").transform;
                    _botton.parent = weapon.transform;
                }
                weapon.hitBottom = _botton.GetComponent <vHitBox>() == null?_botton.gameObject.AddComponent <vHitBox>() : _botton.GetComponent <vHitBox>();

                weapon.bottom = _botton.GetComponent <BoxCollider>();
            }
        }
    }
    void OnSceneGUI()
    {
        vMeleeWeapon weapon = (vMeleeWeapon)target;

        DrawShieldHandle(weapon);
    }