Exemplo n.º 1
0
        public bool CheckEquipmentAmmunition()
        {
            if (!(m_ActiveableEquipment is IWeapon))
            {
                return(true);
            }

            IWeapon weapon = m_ActiveableEquipment as IWeapon;
            PEGun   gun    = weapon as PEGun;

            if (null != gun)
            {
                if (gun.m_AmmoType == AmmoType.Bullet)
                {
                    return(null != m_Package && m_Package.GetItemCount(gun.curItemID) > 0);
                }

                return(gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon);
            }
            PEBow bow = weapon as PEBow;

            if (null != bow)
            {
                return(null != m_Package && m_Package.GetItemCount(bow.curItemID) > 0);
            }

            return(true);
        }
Exemplo n.º 2
0
 void SetBow(PEEquipment bow)
 {
     m_Bow                 = bow as PEBow;
     m_BowHold.bow         = m_Bow;
     m_BowReload.bow       = m_Bow;
     m_BowShoot.bow        = m_Bow;
     m_ActiveableEquipment = m_Bow;
 }
Exemplo n.º 3
0
        public void CopyTo(PEBow target, CreationData data)
        {
            target.m_AttackMode = m_AttackMode;
            target.m_CostItemID = m_CostItemID;
            target.m_SkillID    = m_SkillID;

            target.m_ReloadAnim    = m_ReloadAnim;
            target.m_ArrowBagTrans = m_ArrowBagTrans;
            target.m_LineBone      = m_LineBone;

            target.m_ArrowModel = m_ArrowModel;

            target.m_RemoveEndAction = m_RemoveEndAction;
            target.m_HandChangeAttr  = m_HandChangeAttr;
            target.m_AimAttr         = m_AimAttr;
            target.showOnVehicle     = showOnVehicle;
        }
Exemplo n.º 4
0
        public bool WeaponCanUse(IWeapon weapon)
        {
            if (!isMainPlayer && null != m_NPC && !m_NPC.HasConsume)
            {
                return(true);
            }
            PeSword sword = weapon as PeSword;

            if (null != sword)
            {
                return(true);
            }
            PEGun gun = weapon as PEGun;

            if (null != gun)
            {
                if (m_GunFire.m_IgnoreItem)
                {
                    return(true);
                }
                if (gun.m_AmmoType == AmmoType.Bullet)
                {
                    return(gun.durability > PETools.PEMath.Epsilon &&
                           (gun.magazineValue > PETools.PEMath.Epsilon || null == m_Package || m_Package.GetItemCount(gun.curItemID) > 0));
                }

                return(gun.durability > PETools.PEMath.Epsilon &&
                       (gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon));
            }
            PEBow bow = weapon as PEBow;

            if (null != bow)
            {
                if (m_BowShoot.m_IgnoreItem)
                {
                    return(true);
                }
                return(bow.durability > PETools.PEMath.Epsilon && null == m_Package || m_Package.GetItemCount(bow.curItemID) > 0);
            }

            return(true);
        }
Exemplo n.º 5
0
    void AddWeaponInfo(ItemProto itemProto, GameObject obj)
    {
        AttackMode attackMode;

        switch (m_Attribute.m_Type)
        {
        case ECreation.Sword:
        case ECreation.SwordLarge:
        case ECreation.SwordDouble:
            PeSword[] swords = obj.GetComponentsInChildren <PeSword>(true);
            if (null != swords && swords.Length > 0)
            {
                PeSword sword = swords[0];
                attackMode                          = new AttackMode();
                itemProto.weaponInfo                = new ItemProto.WeaponInfo();
                itemProto.weaponInfo.attackModes    = new AttackMode[1];
                itemProto.weaponInfo.attackModes[0] = attackMode;
                attackMode.type                     = sword.m_AttackMode[0].type;
                attackMode.minRange                 = sword.m_AttackMode[0].minRange;
                attackMode.maxRange                 = sword.m_AttackMode[0].maxRange;
                attackMode.minSwitchRange           = sword.m_AttackMode[0].minSwitchRange;
                attackMode.maxSwitchRange           = sword.m_AttackMode[0].maxSwitchRange;
                attackMode.minAngle                 = sword.m_AttackMode[0].minAngle;
                attackMode.maxAngle                 = sword.m_AttackMode[0].maxAngle;
                attackMode.frequency                = sword.m_AttackMode[0].frequency;
                attackMode.damage                   = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk);
            }
            break;

        case ECreation.Bow:
            PEBow[] bows = obj.GetComponentsInChildren <PEBow>(true);
            if (null != bows && bows.Length > 0)
            {
                PEBow bow = bows[0];
                attackMode                          = new AttackMode();
                itemProto.weaponInfo                = new ItemProto.WeaponInfo();
                itemProto.weaponInfo.attackModes    = new AttackMode[1];
                itemProto.weaponInfo.attackModes[0] = attackMode;
                attackMode.type                     = bow.m_AttackMode[0].type;
                attackMode.minRange                 = bow.m_AttackMode[0].minRange;
                attackMode.maxRange                 = bow.m_AttackMode[0].maxRange;
                attackMode.minSwitchRange           = bow.m_AttackMode[0].minSwitchRange;
                attackMode.maxSwitchRange           = bow.m_AttackMode[0].maxSwitchRange;
                attackMode.minAngle                 = bow.m_AttackMode[0].minAngle;
                attackMode.maxAngle                 = bow.m_AttackMode[0].maxAngle;
                attackMode.frequency                = bow.m_AttackMode[0].frequency;
                attackMode.damage                   = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk);
                itemProto.weaponInfo.costItem       = bow.m_CostItemID[0];
            }
            break;

        case ECreation.HandGun:
        case ECreation.Rifle:
            PEGun[] guns = obj.GetComponentsInChildren <PEGun>(true);
            if (null != guns && guns.Length > 0)
            {
                PEGun gun = guns[0];
                attackMode                          = new AttackMode();
                itemProto.weaponInfo                = new ItemProto.WeaponInfo();
                itemProto.weaponInfo.attackModes    = new AttackMode[1];
                itemProto.weaponInfo.attackModes[0] = attackMode;
                attackMode.type                     = gun.m_AttackMode[0].type;
                attackMode.minRange                 = gun.m_AttackMode[0].minRange;
                attackMode.maxRange                 = gun.m_AttackMode[0].maxRange;
                attackMode.minSwitchRange           = gun.m_AttackMode[0].minSwitchRange;
                attackMode.maxSwitchRange           = gun.m_AttackMode[0].maxSwitchRange;
                attackMode.minAngle                 = gun.m_AttackMode[0].minAngle;
                attackMode.maxAngle                 = gun.m_AttackMode[0].maxAngle;
                attackMode.frequency                = gun.m_AttackMode[0].frequency;
                attackMode.damage                   = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk);
                itemProto.weaponInfo.costItem       = gun.m_AmmoItemIDList.Length > 0 ? gun.m_AmmoItemIDList[0] : 0;
                itemProto.weaponInfo.useEnergry     = gun.m_AmmoType == AmmoType.Energy;
                itemProto.weaponInfo.costPerShoot   = itemProto.weaponInfo.useEnergry ? (int)gun.m_EnergyPerShoot : 1;
            }
            break;
        }
    }
Exemplo n.º 6
0
    private void BuildCreation()
    {
        #region Root Transform
        // [VCCase] - Set creation root Transform

        if (m_Attribute.m_Type == ECreation.Sword)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpSwordHilt || cdata.m_Type == EVCComponent.cpLgSwordHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.SwordLarge)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpLgSwordHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.SwordDouble)
        {
            Transform pivot = null;
            int       cdcnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand)
                {
                    pivot = cdata.m_Entity.transform;
                    //SingleHandSword
                    Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword");//VCConfig.s_Parts[cdata.m_ComponentId].m_ResObj
                    go.gameObject.name = "SingleHandSwordL";
                    m_RootL.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    m_RootL.transform.Rotate(Vector3.up, -90, Space.World);
                    m_RootL.transform.Rotate(Vector3.right, 90, Space.World);
                    m_RootL.transform.Rotate(Vector3.up, 180, Space.World);
                    m_RootL.transform.Rotate(Vector3.forward, 180, Space.World);
                    m_RootL.transform.localPosition = -pivot.position;
                    cdcnt++;
                }

                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand)
                {
                    pivot = cdata.m_Entity.transform;

                    Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword");
                    go.gameObject.name = "SingleHandSwordR";


                    //m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    //m_Root.transform.Rotate(Vector3.up, -90, Space.World);
                    //m_Root.transform.Rotate(Vector3.right, 90, Space.World);
                    //m_Root.transform.localPosition = pivot.position;
                    m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
                    m_Root.transform.Rotate(Vector3.up, -90, Space.World);
                    m_Root.transform.Rotate(Vector3.right, 90, Space.World);
                    m_Root.transform.Rotate(Vector3.up, 180, Space.World);
                    m_Root.transform.Rotate(Vector3.forward, 180, Space.World);
                    m_Root.transform.localPosition = -pivot.position;
                    cdcnt++;
                }

                if (cdcnt == 2)
                {
                    break;
                }
            }
        }

        else if (m_Attribute.m_Type == ECreation.Bow)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpBowGrip)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            AlignPivotInChild(m_Root.transform, pivot);
        }
        else if (m_Attribute.m_Type == ECreation.Axe)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpAxeHilt)
                {
                    pivot = cdata.m_Entity.transform;
                    break;
                }
            }

            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.Shield)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpShieldHandle)
                {
                    pivot = cdata.m_Entity.GetComponent <VCPShieldHandle>().m_PivotPoint;
                    break;
                }
            }
            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.HandGun || m_Attribute.m_Type == ECreation.Rifle)
        {
            Transform pivot = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpGunHandle)
                {
                    pivot = cdata.m_Entity.GetComponent <VCPGunHandle>().m_FirstHandPoint;
                    break;
                }
            }
            m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation);
            m_Root.transform.Rotate(Vector3.up, -90, Space.World);
            m_Root.transform.Rotate(Vector3.right, 90, Space.World);
            m_Root.transform.localPosition = -pivot.position;
        }
        else if (m_Attribute.m_Type == ECreation.Vehicle)
        {
            Vector3 pivot     = m_Attribute.m_CenterOfMass;
            float   sum_y     = 0;
            int     wheel_cnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpVehicleWheel)
                {
                    sum_y += cdata.m_Entity.GetComponent <VCEComponentTool>().m_DrawPivot.position.y;
                    wheel_cnt++;
                }
            }
            pivot.y = sum_y / (float)wheel_cnt - 0.1f;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Aircraft)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Boat)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.SimpleObject)
        {
            VCComponentData pivotCmpt = null;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpPivot)
                {
                    pivotCmpt = cdata;
                    break;
                }
            }

            Vector3 pivot;
            if (pivotCmpt != null)
            {
                pivot = pivotCmpt.m_Position;
            }
            else
            {
                pivot = m_Attribute.m_CenterOfMass;
            }
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.Robot)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.AITurret)
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }
        else if (m_Attribute.m_Type == ECreation.ArmorHead ||
                 m_Attribute.m_Type == ECreation.ArmorBody ||
                 m_Attribute.m_Type == ECreation.ArmorArmAndLeg ||
                 m_Attribute.m_Type == ECreation.ArmorHandAndFoot ||
                 m_Attribute.m_Type == ECreation.ArmorDecoration
                 )
        {
            Vector3 pivot = m_Attribute.m_CenterOfMass;
            pivot.y = 0;
            m_Root.transform.localRotation = Quaternion.identity;
            m_Root.transform.localPosition = -pivot;
        }

        #endregion

        #region Top Script

        // [VCCase] - Create top scripts
        creationController         = m_Prefab.AddComponent <CreationController>();
        creationController.enabled = false;
        creationController.Init(
            m_PartGroup.transform,
            m_MeshGroup.transform,
            m_DecalGroup.transform,
            m_EffectGroup.transform,
            this);

        switch (m_Attribute.m_Type)
        {
        case ECreation.Sword:
        {
            PeSword      sword      = m_Prefab.AddComponent <PeSword>();
            VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpSwordHilt);
            properties.CopyTo(sword, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            if (properties.Attacktrigger != null)
            {
                for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                {
                    properties.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                    properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                }
            }
        }
        break;

        case ECreation.SwordLarge:
        {
            PeSword      sword      = m_Prefab.AddComponent <PeSword>();
            VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpLgSwordHilt);
            properties.CopyTo(sword, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            if (properties.Attacktrigger != null)
            {
                for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                {
                    properties.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                    properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                }
            }
        }
        break;

        case ECreation.SwordDouble:
        {
            PETwoHandWeapon sword      = m_Prefab.AddComponent <PETwoHandWeapon>();
            VCPSwordHilt    properties = FindComponent <VCPSwordHilt>(EVCComponent.cpDbSwordHilt);
            properties.CopyTo(sword, this);
            sword.m_LHandWeapon = m_RootL;
            float weight = creationController.creationData.m_Attribute.m_Weight;
            sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight);

            //set attacktrigger height
            int cnt = 0;
            foreach (VCComponentData cdata in m_IsoData.m_Components)
            {
                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null)
                {
                    cnt++;
                    VCPSwordHilt hiltL = cdata.m_Entity.GetComponent <VCPSwordHilt>();
                    if (hiltL == null)
                    {
                        continue;
                    }

                    for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                    {
                        hiltL.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.x;
                        hiltL.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z;
                    }
                }

                if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null)
                {
                    cnt++;
                    VCPSwordHilt hiltR = cdata.m_Entity.GetComponent <VCPSwordHilt>();
                    if (hiltR == null)
                    {
                        continue;
                    }

                    for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++)
                    {
                        hiltR.Attacktrigger.attackParts[i].capsule.heigh     = creationController.creationData.m_Attribute.m_AtkHeight.y;
                        hiltR.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.w;
                    }
                }
                if (cnt == 2)
                {
                    break;
                }
            }
        }
        break;


        case ECreation.Bow:
        {
            PEBow      bow           = m_Prefab.AddComponent <PEBow>();
            VCPBowGrip bowProperties = FindComponent <VCPBowGrip>(EVCComponent.cpBowGrip);
            bowProperties.CopyTo(bow, this);
        }
        break;

        case ECreation.Axe:
        {
            PEAxe      axe           = m_Prefab.AddComponent <PEAxe>();
            VCPAxeHilt axeProperties = FindComponent <VCPAxeHilt>(EVCComponent.cpAxeHilt);
            axeProperties.CopyTo(axe, this);
            float weight = creationController.creationData.m_Attribute.m_Weight;
            axe.m_AnimSpeed = VCUtility.GetAxeAnimSpeed(weight);
        }
        break;

        case ECreation.Shield:
        {
            PESheild sheild = m_Prefab.AddComponent <PESheild>();
            sheild.showOnVehicle = false;
        }
        break;

        case ECreation.Rifle:
        case ECreation.HandGun:
        {
            PEGun        gun = m_Prefab.AddComponent <PEGun>();
            VCPGunHandle handleProperties = FindComponent <VCPGunHandle>(EVCComponent.cpGunHandle);
            VCPGunMuzzle muzzleProperties = FindComponent <VCPGunMuzzle>(EVCComponent.cpGunMuzzle);
            handleProperties.CopyTo(gun);
            muzzleProperties.CopyTo(gun);
        }
        break;

        case ECreation.Vehicle:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Aircraft:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Boat:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.Robot:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.AITurret:
        {
            VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>();
            pp.FunctionTag   = VCParticlePlayer.ftExplode;
            pp.LocalPosition = creationController.bounds.center;
            break;
        }

        case ECreation.SimpleObject:
            break;

        case ECreation.ArmorHead:
        case ECreation.ArmorBody:
        case ECreation.ArmorArmAndLeg:
        case ECreation.ArmorHandAndFoot:
        case ECreation.ArmorDecoration:
            break;

        default:
            break;
        }

        #endregion
    }