public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;

            GameObject prefab = prefabStorage.GetPrefab(viewType);
            GameObject go     = physicsSpawner.SpawnProjectile(prefab, spawnPosition, spawnRotation);

            go.layer = projectileLayerNumber;
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            go.Link(entity);
            entity.AddView(go);

            if (entity.hasParentWarship)
            {
                var        projectileCollider = go.GetComponent <Collider>();
                Collider[] warshipColliders   = entity.parentWarship.entity.warshipColliders.colliders;


                Vector3 parentVelocity = entity.parentWarship.entity.rigidbody.value.velocity;
                rigidbody.velocity = parentVelocity;
                physicsSpawner.Ignore(new[] { projectileCollider }, warshipColliders);
            }
        }
예제 #2
0
        public void Execute()
        {
            var entities = needHealthBar.GetEntities();

            for (var index = 0; index < entities.Length; index++)
            {
                var entity = entities[index];
                if (!entity.hasView)
                {
                    log.Error("Если есть NeedHealthBar, то обязательно должен быть view");
                    continue;
                }

                //Создать полоску
                ServerGameEntity healthBarEntity = gameContext.CreateEntity();
                GameObject       prefab          = healthBarStorage.GetPrefab();
                GameObject       go = Object.Instantiate(prefab);
                go.Link(entity);
                go.transform.position = new Vector3(0, healthBarHeightStorage.GetHeight(entity.viewType.value));
                Slider slider = go.transform.Find("Slider").GetComponent <Slider>();
                if (slider == null)
                {
                    log.Error("Не найден слайдер на полоске хп");
                    continue;
                }

                TextMeshProUGUI username = go.transform.Find("Text_Username").GetComponent <TextMeshProUGUI>();
                if (username == null)
                {
                    log.Error("Не найден text username на полоске хп");
                    continue;
                }

                TextMeshProUGUI healthPoints = go.transform.Find("Slider/Text_HealthPoints")
                                               .GetComponent <TextMeshProUGUI>();
                if (healthPoints == null)
                {
                    log.Error("Не найден text healthPoints на полоске хп");
                    continue;
                }


                healthBarEntity.AddView(go);
                healthBarEntity.AddTransform(go.transform);
                healthBarEntity.AddHealthBar(slider, username, healthPoints, entity);

                if (entity.hasHealthBarParent)
                {
                    log.Error("У этой сущности не должно быть этого компонета.");
                    continue;
                }
                entity.AddHealthBarParent(healthBarEntity);
            }
        }
예제 #3
0
        public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;
            GameObject   prefab        = prefabStorage.GetPrefab(viewType);
            GameObject   go            = physicsSpawner.Spawn(prefab, spawnPosition, spawnRotation);

            go.Link(entity);
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            entity.AddView(go);

            //todo не забыть убрать компонент
            // entity.RemoveSpawnTransform();
        }
예제 #4
0
        public void Spawn(ServerGameEntity entity)
        {
            ViewTypeEnum viewType      = entity.viewType.value;
            Vector3      spawnPosition = entity.spawnTransform.position;
            Quaternion   spawnRotation = entity.spawnTransform.rotation;
            GameObject   prefab        = prefabStorage.GetPrefab(viewType);
            GameObject   go            = physicsSpawner.Spawn(prefab, spawnPosition, spawnRotation);

            go.layer = playersLayerNumber;
            go.Link(entity);
            entity.AddView(go);
            entity.AddTransform(go.transform);
            Rigidbody rigidbody = go.GetComponent <Rigidbody>();

            entity.AddRigidbody(rigidbody);
            shootingPointsHelper.AddShootingPoints(go, entity);
            Collider[] colliders = go.GetComponents <Collider>();
            entity.AddWarshipColliders(colliders);
        }