Beispiel #1
0
    private void OnCreateHandler()
    {
        SelectorKeeper selectorKeeper = this.Container.AddComponent <SelectorKeeper>();

        selectorKeeper.OwnerID = this.ID;
        Tag = GameObjectTags.Entity;
    }
Beispiel #2
0
    private void OnCollider(GameObject colliderTarget)
    {
        if (colliderTarget.tag == GameObjectTags.Terrain || colliderTarget.tag == GameObjectTags.Bullet)
        {
            return;
        }
        else
        {
            Transform tempTransform = colliderTarget.transform;
            while (tempTransform.parent)
            {
                tempTransform = tempTransform.parent;
            }
            SelectorKeeper selectorKeeper = tempTransform.gameObject.GetComponent <SelectorKeeper>();
            if (selectorKeeper == null)
            {
                //说明不是攻击目标 直接结束
                if (tween != null)
                {
                    tween.Kill();
                }
                if (bullet != null)
                {
                    bullet.Stop();
                }
            }
            else
            {
                if (ownerId == selectorKeeper.OwnerID)
                {
                    return;
                }
                if (tween != null)
                {
                    tween.Kill();
                }
                if (bullet != null)
                {
                    bullet.Stop();
                }

                Creature owner  = EntityManager.GetEntityByID(ownerId) as Creature;
                Vector3  pos    = owner.GetPosition();
                Creature target = EntityManager.GetEntityByID(TargetId) as Creature;
                if (target != null)
                {
                    //target
                    if (hitMove)
                    {
                        target.DoHitFly(pos, hitMoveDistance, hitMoveTime);
                    }
                    else if (hitFly)
                    {
                        target.DoHitFly(pos, hitFlyDistance, hitFlyTime);
                    }
                    else
                    {
                        target.DoHit();
                    }
                }
            }
        }
    }