예제 #1
0
    void OnTriggerEnter(Collider c)
    {
        EAActor pAttackedActor = c.gameObject.GetComponent <EAActor>();

        EAActor pActor = GetOwnerActor();

        if (pAttackedActor != null)
        {
            //  [4/11/2018 puos] attacker is not dead
            if (pActor != null)
            {
                if (pActor.GetCharBase().GetObjID() != pAttackedActor.GetCharBase().GetObjID())
                {
                    EA_GameEvents.onAttackMsg(pActor.GetCharBase(), pAttackedActor.GetCharBase(), WeaponInfo, GetItemBase().GetObjID());
                }
                else
                {
                    //  [12/2/2019 puos] If attacker and attacked are the same, passing
                    return;
                }
            }
            else
            {
                EA_GameEvents.onAttackMsg(null, pAttackedActor.GetCharBase(), WeaponInfo, GetItemBase().GetObjID());
            }
        }

        if (WeaponInfo.onExplosionEvent != null)
        {
            WeaponInfo.onExplosionEvent(GetItemBase().GetObjID());
        }
    }
예제 #2
0
    /// <summary>
    /// Id of the weapon owner
    /// </summary>
    /// <returns></returns>
    public EAObjID GetOwnerActorId()
    {
        EAObjID OwnActorId = CObjGlobal.InvalidObjID;

        EAActor pActor = GetOwnerActor();

        if (pActor != null && pActor.GetCharBase() != null)
        {
            OwnActorId = pActor.GetCharBase().GetObjID();
        }

        return(OwnActorId);
    }
예제 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pAttackedActor"></param>
    protected void Slice(EAActor pAttackedActor)
    {
        EAActor pActor = GetOwnerActor();

        //  [4/11/2018 puos] bug fixed attacker dies
        if (pAttackedActor != null)
        {
            if (pActor != null)
            {
                //  [4/18/2018 puos] Collided object must not be self
                if (pActor.GetCharBase().GetObjID() != pAttackedActor.GetCharBase().GetObjID())
                {
                    EA_GameEvents.onAttackMsg(pActor.GetCharBase(), pAttackedActor.GetCharBase(), GetAttackWeaponInfo(), CObjGlobal.InvalidObjID);
                }
            }
            else
            {
                EA_GameEvents.onAttackMsg(null, pAttackedActor.GetCharBase(), GetAttackWeaponInfo(), CObjGlobal.InvalidObjID);
            }
        }
    }
예제 #4
0
    public void FireShoot()
    {
        EAActor pActor = GetOwnerActor();

        Debug.Assert(pActor != null, "FireShoot Actor is null");

        if (fireDummyObject != null && pActor != null)
        {
            ObjectInfo ObjInfo = new ObjectInfo();

            ObjInfo.spawnPos[0] = fireDummyObject.transform.position.x;
            ObjInfo.spawnPos[1] = fireDummyObject.transform.position.y;
            ObjInfo.spawnPos[2] = fireDummyObject.transform.position.z;

            ObjInfo.spawnAngle[0] = fireDummyObject.transform.rotation.eulerAngles.x;
            ObjInfo.spawnAngle[1] = fireDummyObject.transform.rotation.eulerAngles.y;
            ObjInfo.spawnAngle[2] = fireDummyObject.transform.rotation.eulerAngles.z;

            ObjInfo.m_ModelTypeIndex = WeaponInfo.uProjectileModelType;
            ObjInfo.m_objClassType   = WeaponInfo.m_objProjectileClassType;
            ObjInfo.SetObjName("projectile");

            ItemObjInfo itemInfo = new ItemObjInfo();

            EA_CCharBPlayer pCharBase = pActor.GetCharBase();

            if (pCharBase != null)
            {
                itemInfo.m_HavenUser = pCharBase.GetObjID();
            }

            if (ObjInfo.m_objClassType == default(Type))
            {
                ObjInfo.m_objClassType = typeof(EAProjectile);
            }

            itemInfo.m_eItemType = eItemObjType.IK_Projectile;
            EA_CItem pItem = EACObjManager.instance.CreateItem(ObjInfo, itemInfo);

            // Create if no bullet. Do not use pool
            if (pItem.GetLinkEntity() == null)
            {
                GameObject pGameObject = new GameObject("projectile", ObjInfo.m_objClassType);

                pGameObject.transform.position    = new Vector3(ObjInfo.spawnPos[0], ObjInfo.spawnPos[1], ObjInfo.spawnPos[2]);
                pGameObject.transform.eulerAngles = new Vector3(ObjInfo.spawnAngle[0], ObjInfo.spawnAngle[1], ObjInfo.spawnAngle[2]);

                pItem.SetLinkEntity(pGameObject);
                pItem.SetLinkItem(pGameObject.GetComponent <EAProjectile>());
            }

            GameObject   item        = pItem.GetLinkEntity();
            EAProjectile pProjectile = null;

            if (item != null)
            {
                pProjectile = item.GetComponent <EAProjectile>();
            }

            if (pProjectile != null)
            {
                if (ProjectileTransform.instance != null)
                {
                    pProjectile.transform.SetParent(ProjectileTransform.instance.transform);
                }

                // use sphereCollider
                Collider c = pProjectile.GetComponent <Collider>();

                if (c == null)
                {
                    SphereCollider sc = pProjectile.gameObject.AddComponent <SphereCollider>();
                    sc.radius = WeaponInfo.projectileRadius;
                }

                pProjectile.SetProjectileDir(fireDummyObject.transform.forward);

                pProjectile.SetOwnActor(itemInfo.m_HavenUser);

                pProjectile.SetWeapon(GetItemBase().GetObjID());

                pProjectile.SetWeaponInfo(WeaponInfo);

                Debug.Log("fire shoot - weapon user id :" + itemInfo.m_HavenUser + " projectile type : " + WeaponInfo.projectileType);
            }

            pItem.Use();
        }
    }
예제 #5
0
    /// <summary>
    ///
    /// </summary>
    private void RayProjectileType()
    {
        Ray ray = new Ray(transform.position, m_vDir);

        List <RaycastHit> hits = new List <RaycastHit>();

        EACObjManager.instance.For(x =>
        {
            GameObject obj = x.GetLinkEntity();

            if (obj != null)
            {
                float distance = (obj.transform.position - transform.position).magnitude;

                if (distance <= WeaponInfo.fKillDistance)
                {
                    Collider c = x.collider;

                    if (c != null)
                    {
                        RaycastHit hitInfo;

                        if (c.Raycast(ray, out hitInfo, WeaponInfo.fKillDistance))
                        {
                            hits.Add(hitInfo);
                        }
                    }
                }
            }

            return(false);
        });

        if (hits != null && 0 < hits.Count)
        {
            hits.Sort(delegate(RaycastHit a, RaycastHit b)
            {
                // 3 decimal places
                return((int)((a.distance - b.distance) * 1000));
            });

            EAActor pActor = GetOwnerActor();

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider != null)
                {
                    Collider c = hit.collider;

                    EAActor pAttackedActor = c.gameObject.GetComponent <EAActor>();

                    if ((pActor && pAttackedActor) &&
                        (pActor.GetCharBase().GetObjID() != pAttackedActor.GetCharBase().GetObjID()))
                    {
                        OnTriggerEnter(c);
                        break;
                    }
                }
            }
        }

        ExPlosion();
    }