Beispiel #1
0
        public Npc(Diet diet, BodyMass bodyMass)
        {
            DietHabits = diet;
            MassSize   = bodyMass;

            SetNpcBaseSettings();
        }
Beispiel #2
0
        public void UpdateUserProfile(UpdateProfileInputModel model)
        {
            var userProfile = _subscriberRepository.GetById(model.Id);

            userProfile.EmailAddress = model.EmailAddress;
            userProfile.ModifiedBy   = Environment.UserName;
            userProfile.ModifiedDate = DateTime.Now;

            var userBodyMass = new BodyMass
            {
                Profile_Fk     = userProfile.Profile_Pk,
                HeightInInches = model.Height,
                WeightInPounds = model.Weight,
                CreateDate     = DateTime.Now,
                CreatedBy      = Environment.UserName,
                StartDate      = DateTime.Now
            };

            var bmis = _subscriberBodyMassRepository.GetAll().Any(x => x.WeightInPounds == model.Weight &&
                                                                  x.HeightInInches == model.Height &&
                                                                  x.CreateDate.Date == DateTime.Today);

            if (userProfile.EmailAddress == model.EmailAddress && bmis)
            {
                return;
            }

            _subscriberRepository.Update(userProfile);
            _subscriberBodyMassRepository.Insert(userBodyMass);
        }
Beispiel #3
0
        /// <summary>
        /// Constructeur
        /// </summary>
        public BodyCalculator(Guid nbticket, Body body)
        {
            ticket     = nbticket;
            bodyInput  = body;
            bodyOutput = new BodyMass();

            // Autres traitements particuliers pour le moteur de calcul
        }
        public void UpdateUserProfile(UpdateProfileInputModel model)
        {
            var userProfile = _subscriberRepository.GetById(model.Id);

            userProfile.EmailAddress = model.EmailAddress;
            userProfile.ModifiedBy   = Environment.UserName;
            userProfile.ModifiedDate = DateTime.Now;
            userProfile.DateOfBirth  = model.DateOfBirth;

            var userBodyMass = new BodyMass
            {
                Profile_Fk     = userProfile.Profile_Pk,
                HeightInInches = model.Height,
                WeightInPounds = model.Weight,
                CreateDate     = DateTime.Now,
                CreatedBy      = Environment.UserName,
                StartDate      = DateTime.Now
            };

            _subscriberRepository.Update(userProfile);
            _subscriberBodyMassRepository.Insert(userBodyMass);
        }
    private Entity CreatePlanetEntity(Entity prefabEntity, List <int> usedIndexes)
    {
        Entity spawnedEntity = EntityManager.Instantiate(prefabEntity);

        RenderMesh renderMesh = EntityManager.GetSharedComponentData <RenderMesh>(spawnedEntity);

        UnityEngine.Material mat = new UnityEngine.Material(renderMesh.material);
        mat.SetVector("_RedMinMax", new UnityEngine.Vector4(_random.NextFloat(0f, 1f), _random.NextFloat(0f, 1f)));
        mat.SetVector("_GreenMinMax", new UnityEngine.Vector4(_random.NextFloat(0f, 1f), _random.NextFloat(0f, 1f)));
        mat.SetVector("_BlueMinMax", new UnityEngine.Vector4(_random.NextFloat(0f, 1f), _random.NextFloat(0f, 1f)));
        mat.SetFloat("_NoiseScale", _random.NextFloat(10f, 80f));
        renderMesh.material = mat;
        EntityManager.SetSharedComponentData(spawnedEntity, renderMesh);

        float rndSize           = _random.NextFloat(1f, 2.5f);
        int   rndOrbitRadiusIdx = _random.NextInt(0, SpawnRadiuses.Length);

        while (usedIndexes.Contains(rndOrbitRadiusIdx))
        {
            rndOrbitRadiusIdx = _random.NextInt(0, SpawnRadiuses.Length);
        }

        float rndOrbitRadius = SpawnRadiuses[rndOrbitRadiusIdx];
        int   rndDir         = _random.NextInt(-5, 6);

        rndDir = rndDir * 2 + 1;
        float movementSpeed = math.sign(rndDir) * 1f * rndSize / rndOrbitRadius;
        float rndPosRadians = _random.NextFloat(0f, math.PI);

        EntityManager.AddComponentData(spawnedEntity, new OrbitRadius {
            Value = rndOrbitRadius
        });
        EntityManager.AddComponentData(spawnedEntity, new MovementSpeed {
            Value = movementSpeed
        });
        EntityManager.AddComponentData(spawnedEntity, new OrbitAngle {
            Value = rndPosRadians
        });
        EntityManager.AddComponentData(spawnedEntity, new Scale {
            Value = rndSize
        });
        EntityManager.AddComponentData(spawnedEntity, new ShootCooldown {
            Value = 0.5f
        });
        EntityManager.AddComponentData(spawnedEntity, new ShootTime {
            Value = 0f
        });
        EntityManager.AddComponentData(spawnedEntity, new AddPlanetHUD());
        EntityManager.AddComponentData(spawnedEntity, new ChangeSphereColliderRadius {
            Value = rndSize * 0.5f
        });
        EntityManager.AddComponentData(spawnedEntity, new NextRocketType {
            Value = 0
        });
        BodyMass planetMass = EntityManager.GetComponentData <BodyMass>(spawnedEntity);

        planetMass.Value *= rndSize;
        EntityManager.SetComponentData(spawnedEntity, planetMass);
        SimpleSphereCollider collider = EntityManager.GetComponentData <SimpleSphereCollider>(spawnedEntity);

        collider.Radius = rndSize * 0.5f;
        EntityManager.SetComponentData(spawnedEntity, collider);
        EntityManager.SetComponentData(spawnedEntity,
                                       new Translation {
            Value = new float3(math.cos(_random.NextFloat(0f, 1f) * math.PI), 0f, math.sin(_random.NextFloat(0f, 1f) * math.PI)) * rndOrbitRadius
        });

        usedIndexes.Add(rndOrbitRadiusIdx);

        return(spawnedEntity);
    }