internal override void OnCreate()
        {
            CreationTime = entity.entityManager.matchManager.CurrentTick;

            StartPoint = Vector2.Zero;

            EndPoint = Vector2.Zero;

            root = EntityPointer.Null;
        }
Пример #2
0
        internal void Create(Entity entity)
        {
            if (Entity != null)
            {
                throw new InvalidOperationException("UnityEntity already created!");
            }

            Entity        = entity ?? throw new ArgumentNullException(nameof(entity));
            EntityPointer = entity.Pointer;

            gameObject.SetActive(true);

            foreach (var unityComponent in unityComponents)
            {
                unityComponent.OnCreate();
            }
        }
Пример #3
0
        internal void Destroy()
        {
            if (Entity == null)
            {
                throw new InvalidOperationException("UnityEntity already destroyed!");
            }

            for (var i = unityComponents.Length - 1; i >= 0; i--)
            {
                unityComponents[i].OnDestroy();
            }

            gameObject.SetActive(false);

            Entity = null;

            EntityPointer = EntityPointer.Null;
        }
        internal void Init(EntityPointer rootEntityPointer, Vector2 dir)
        {
            root = rootEntityPointer;

            var entityManager = entity.entityManager;

            var rootEntity = entityManager.TryGetEntity(root);

            StartPoint = rootEntity == null ? Vector2.Zero : rootEntity.GetComponent <Transform>().Position;

            EndPoint = StartPoint + dir * LaserLength;

            var physicsManager = entityManager.matchManager.physicsManager;

            var intersectionsCount = physicsManager.FindLineSegmentIntersections(StartPoint, EndPoint, CollisionLayersConfig.WeaponLayer);

            if (intersectionsCount == 0)
            {
                return;
            }

            var player = entityManager.matchManager.playerManager.GetPlayerById(entity.Owner);


            for (var i = 0; i < intersectionsCount; i++)
            {
                var e = entityManager.TryGetEntity(physicsManager.GetLastLineSegmentIntersectionEntityPointer(i));
                if (e == null)
                {
                    continue;
                }

                if (player != null)
                {
                    player.Score += 200;
                }

                e.Destroy();
            }
        }