Exemple #1
0
        public float GetDamage(HealthType healthType)
        {
            HealthModifier healthModifier = GetComponentInChildren <HealthModifier>();

            if (healthModifier == null)
            {
                ProjectileLauncher projectileLauncher = GetComponentInChildren <ProjectileLauncher>();
                if (projectileLauncher != null)
                {
                    healthModifier = projectileLauncher.ProjectilePrefab.GetComponent <HealthModifier>();
                }
            }

            if (healthModifier != null)
            {
                float damageValue = healthModifier.DefaultDamageValue;
                for (int i = 0; i < healthModifier.DamageOverrideValues.Count; ++i)
                {
                    if (healthModifier.DamageOverrideValues[i].HealthType == healthType)
                    {
                        damageValue = healthModifier.DamageOverrideValues[i].Value;
                    }
                }
                return(damageValue);
            }
            else
            {
                return(0);
            }
        }
    public Enemy CreateEnemy(
        GameObject prefab,
        HealthType healthType,
        AttackerType attackerType,
        MoverType moverType,
        PerceptionType perceptionType,
        ICharacter target)
    {
        var newGameObject = UnityEngine.Object.Instantiate(prefab);

        newGameObject.name  = "Enemy";
        newGameObject.layer = LayerMask.NameToLayer("Enemy");

        var enemy = newGameObject.AddComponent <Enemy>();

        enemy.InitializeBrain();
        enemy.InitializePathfindingAgent();
        enemy.InitializeHealth(GetHealthData(healthType));
        enemy.InitializeAttacker(GetAttackerData(attackerType));
        enemy.InitializeMover(GetMoverData(moverType));
        enemy.InitializeLoot();
        enemy.InitializePerception(GetPerceptionData(perceptionType));
        enemy.InitializeTarget(target);

        return(enemy);
    }
        public void SaveHospital(Rootobject hospital)
        {
            var cat = new Category
            {
                Name  = "Sağlık",
                Color = "#aa76f7"
            };

            UnitOfWork.CurrentSession.Categories.Add(cat);

            var type = new HealthType
            {
                Name       = "Devlet Hastahane",
                CategoryId = cat.Id,
            };

            UnitOfWork.CurrentSession.HealthTypes.Add(type);

            foreach (var item in hospital.response.venues)
            {
                var health = new Health
                {
                    Name         = item.name,
                    HealthTypeId = type.Id,
                    Lat          = item.location != null ? item.location.lat : "",
                    Long         = item.location != null ? item.location.lng : "",
                    Phone        = item.contact != null ? item.contact.phone : "",
                    Url          = item.url ?? "",
                    IconId       = 24
                };
                UnitOfWork.CurrentSession.Healths.Add(health);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #4
0
        public float GetDamage(HealthType healthType)
        {
            DamageEmitter damageEmitter = GetComponentInChildren <DamageEmitter>();

            if (damageEmitter == null)
            {
                ProjectileLauncher projectileLauncher = GetComponentInChildren <ProjectileLauncher>();
                if (projectileLauncher != null)
                {
                    damageEmitter = projectileLauncher.ProjectilePrefab.GetComponent <DamageEmitter>();
                }
            }

            if (damageEmitter != null)
            {
                for (int i = 0; i < damageEmitter.HealthTypeDamageValues.Count; ++i)
                {
                    if (damageEmitter.HealthTypeDamageValues[i].HealthType == healthType)
                    {
                        return(damageEmitter.HealthTypeDamageValues[i].DamageValue);
                    }
                }
                return(0);
            }
            else
            {
                return(0);
            }
        }
        public void SaveClinic(Rootobject clinic)
        {
            var type = new HealthType
            {
                Name       = "Sağlık Ocağı",
                CategoryId = 30
            };

            UnitOfWork.CurrentSession.HealthTypes.Add(type);


            foreach (var item in clinic.response.venues)
            {
                var data = new Health
                {
                    Name         = item.name,
                    HealthTypeId = type.Id,
                    Lat          = item.location != null ? item.location.lat : "",
                    Long         = item.location != null ? item.location.lng : "",
                    Phone        = item.contact != null ? item.contact.phone : "",
                    Url          = item.url ?? "",
                    IconId       = 24
                };
                UnitOfWork.CurrentSession.Healths.Add(data);
            }
            UnitOfWork.CurrentSession.SaveChanges();
        }
Exemple #6
0
 public HealthPoints(string name, float maxvalue, HealthType isCritical)
 {
     _name         = name;
     _maxValue     = maxvalue;
     _currentValue = maxvalue;
     _healthType   = isCritical;
 }
    public bool HitBlock()
    {
        if (curHealth == -1)
        {
            return(false);
        }

        health = (HealthType)Mathf.Abs(Utils.Map(0.0f, 10.0f, 0.0f, maxHealth, --curHealth) - 10);

        if (curHealth == (maxHealth - 1))
        {
            World.Queue.Run(owner.mb.HealBlock(pos));
        }

        if (curHealth <= 0)
        {
            if (bType == BlockType.SAND && pos.y == World.chunkSize - 1)
            {
                GetBlock((int)pos.x, (int)pos.y + 1, (int)pos.z).owner.UpdateChunk();
            }
            SetType(BlockType.AIR, false);
            owner.Redraw();
            owner.UpdateChunk();
            return(true);
        }
        owner.Redraw();
        return(false);
    }
Exemple #8
0
        private HealthResponse GetHealthByType(HealthType type)
        {
            try
            {
                // get results
                var results = _healthCheckRegistry.GetResults(type);

                // prepare response
                HealthResponse healthResponse = new HealthResponse();
                healthResponse.Checks = results;
                healthResponse.Status = State.UP;

                // check if any check is down
                if (results.Where(e => State.DOWN.Equals(e.Status)).Any())
                {
                    healthResponse.Status = State.DOWN;
                }

                return(healthResponse);
            }
            catch
            {
                return(null);
            }
        }
Exemple #9
0
        public void Instantiate(Func <string, string, string, string, Action, Action, Action, Task> setButtonsBehaviour, EnemiesController ec, SoldiersController sc)
        {
            _recruitNewUnitButton.onClick.AddListener(async() =>
            {
                if (!_ecoController.TryBuy(UnitPrice))
                {
                    Debug.Log("Too little quants! Try earning more.");
                    return;
                }
                GameController.Mode = GameMode.Building;

                await setButtonsBehaviour("Choose a weapon type for this soldier.", "Laser Weapon", "Plasma Weapon", "Ballistic Weapon",
                                          () => { SelectedDamageType = DamageType.Laser; },
                                          () => { SelectedDamageType = DamageType.Plasma; },
                                          () => { SelectedDamageType = DamageType.Ballistic; }
                                          );

                await setButtonsBehaviour("Choose a type of protection for this soldier.", "EMF Defense", "Armor", "Energy Shields",
                                          () => { SelectedHealthType = HealthType.EMF; },
                                          () => { SelectedHealthType = HealthType.Armor; },
                                          () => { SelectedHealthType = HealthType.EnergyShields; }
                                          );
            });

            _sellUnitButton.onClick.AddListener(() =>
            {
                if (_upgradeManager.CurrentUnit == null)
                {
                    return;
                }
                _upgradeManager.CurrentUnit.RemoveUnit();
                _upgradeManager.CurrentUnit = null;
            });
        }
Exemple #10
0
 public HealthMonitorResult(string name, HealthType healthType, ResultStatus status, string message = "") : this(name, healthType)
 {
     Status = status;
     if (!string.IsNullOrEmpty(message))
     {
         MessageBuilder.Append(message);
     }
 }
 public void SetType(BlockType b, bool isConstructor)
 {
     bType = b;
     SetTypeData(b, isConstructor);
     isSolid   = (bType == BlockType.AIR || bType == BlockType.WATER) ? false : true;
     parent    = (bType == BlockType.WATER) ? owner.fluid.gameObject : owner.chunk.gameObject;
     health    = HealthType.NOCRACK;
     curHealth = maxHealth;
 }
        public HealthBar(vec3 pos, float max_health, HealthType type)
        {
            maxHealth = max_health;
            position  = pos;
            myType    = type;
            string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;

            healthtTex = new Texture(projectPath + "\\Textures\\Green.png", 22, true);
        }
Exemple #13
0
    private float CalculateHealthTypeLost(HealthType healthType, float value)
    {
        PartHub hub = Hubs.First(h => h.HealthType == healthType);

        if (!hub.Item)
        {
            return((-.25f - .025f * value) * Time.deltaTime);
        }
        return((.25f + .025f * (10 - value)) * hub.Item.RepairItem.HealthValue * Time.deltaTime);
    }
 // Use this for initialization
 void Start()
 {
     healthType = ht;
     if (ht == 0)
     {
         Healthcount = 1;
     }
     else
     {
         Healthcount = hp;
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     CurrentHealth = MaxHealth;
     if (GetComponent <YeetedAI>())
     {
         ai = GetComponent <YeetedAI>();
         if (ai.GetComponent <AI>().r.type == RoleType.Yeeter || ai.GetComponent <AI>().r.type == RoleType.Hunter)
         {
             type = HealthType.Yeeter;
         }
     }
 }
Exemple #16
0
        /// <summary>
        /// Get the current health for a specified health type.
        /// </summary>
        /// <param name="healthType">The health type being queried.</param>
        /// <returns>The current health.</returns>
        public virtual float GetCurrentHealthByType(HealthType healthType)
        {
            float currentHealth = 0;

            for (int i = 0; i < damageables.Count; ++i)
            {
                if (damageables[i].HealthType == healthType)
                {
                    currentHealth += damageables[i].CurrentHealth;
                }
            }

            return(currentHealth);
        }
Exemple #17
0
        /// <summary>
        /// Get the maximum health for a specified health type.
        /// </summary>
        /// <param name="healthType">The health type being queried.</param>
        /// <returns>The maximum health.</returns>
        public virtual float GetMaxHealthByType(HealthType healthType)
        {
            float maxHealth = 0;

            for (int i = 0; i < damageables.Count; ++i)
            {
                if (damageables[i].HealthType == healthType)
                {
                    maxHealth += damageables[i].HealthCapacity;
                }
            }

            return(maxHealth);
        }
        public HealthFragment(SmartEntity source, HealthType type, int quantity)
        {
            this.Type = type;
            int splashQuantity = quantity;

            if (type != HealthType.Healing && source != null)
            {
                int modifyValueMax = quantity;
                Service.Get <BuffController>().ApplyActiveBuffs(source, BuffModify.Damage, ref quantity, modifyValueMax);
                splashQuantity = quantity;
                Service.Get <BuffController>().ApplyActiveBuffs(source, BuffModify.SplashDamage, ref splashQuantity, modifyValueMax);
            }
            this.Quantity       = quantity;
            this.SplashQuantity = splashQuantity;
        }
Exemple #19
0
        /// <summary>
        /// Get the fraction of health remaining of a specified type.
        /// </summary>
        /// <param name="healthType">The health type.</param>
        /// <returns>The health fraction remaining</returns>
        public virtual float GetCurrentHealthFractionByType(HealthType healthType)
        {
            float currentHealth = 0;
            float maxHealth     = 0.00001f;

            for (int i = 0; i < damageables.Count; ++i)
            {
                if (damageables[i].HealthType == healthType)
                {
                    currentHealth += damageables[i].CurrentHealth;
                    maxHealth     += damageables[i].HealthCapacity;
                }
            }

            return(currentHealth / maxHealth);
        }
    private HealthData GetHealthData(HealthType healthType)
    {
        switch (healthType)
        {
        case HealthType.Low:
            return(new HealthData(Constants.LOW_HEALTH));

        case HealthType.Medium:
            return(new HealthData(Constants.MEDIUM_HEALTH));

        case HealthType.High:
            return(new HealthData(Constants.HIGH_HEALTH));

        default:
            throw new NotImplementedException("HealthType not implemented: " + healthType);
        }
    }
Exemple #21
0
    /// <summary>
    /// 加血
    /// </summary>
    /// <param name="health"></param>
    /// <param name="type"></param>
    /// <param name="maxHealth"></param>
    public void AddHealth(int health, HealthType type, int maxHealth = 0)
    {
        this.MaxHealth += maxHealth;
        switch (type)
        {
        case HealthType.Normal:
            Health += health;
            break;

        case HealthType.Soul:
            SoulHealth += health;
            break;

        default:
            break;
        }

        UI.hp.UpdateHP();
    }
        private bool IsValidType(HealthCheck check, HealthType type)
        {
            Type attributeType = null;

            if (type == HealthType.Liveness)
            {
                attributeType = typeof(LivenessAttribute);
            }
            else if (type == HealthType.Readiness)
            {
                attributeType = typeof(ReadinessAttribute);
            }

            if (attributeType == null)
            {
                return(true);
            }

            return(check.GetType().GetCustomAttributes(attributeType, true).Any());
        }
Exemple #23
0
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            StateComponent stateComp = troopEntity.StateComp;

            if (stateComp == null)
            {
                logger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                logger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            if (troopComp.TroopType == null)
            {
                logger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                logger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            TroopRole troopRole = shooterComp.ShooterVO.TroopRole;

            if (troopRole == TroopRole.None)
            {
                troopRole = shooterComp.OriginalShooterVO.TroopRole;
            }
            HealthType healthType = (troopRole != TroopRole.Healer) ? HealthType.Damaging : HealthType.Healing;

            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.BattleController, troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }
        public IEnumerable <HealthCheckResponse> GetResults(HealthType type)
        {
            _logger.LogInformation("Getting health check results");

            foreach (var pair in _healthChecks)
            {
                if (!IsValidType(pair.Value, type))
                {
                    continue;
                }

                var response = pair.Value?.CheckResponse();
                if (response == null)
                {
                    continue;
                }

                response.Name = pair.Key;
                yield return(response);
            }
        }
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTSLogger   staRTSLogger = Service.Get <StaRTSLogger>();
            StateComponent stateComp    = troopEntity.StateComp;

            if (stateComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            ITroopDeployableVO troopType = troopComp.TroopType;

            if (troopType == null)
            {
                staRTSLogger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            HealthType       healthType  = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging;
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                staRTSLogger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }
Exemple #26
0
        protected Enemy(MapField[] path, SoldiersController sc, EnemiesController ec, PlayerBase targetBase, DamageType dt, HealthType ht, UnitParameters up, int defaultDamage) : base(sc, ec, up)
        {
            PathToTraverse = path;
            _targetBase    = targetBase;
            _up            = up;

            switch (ht)
            {
            case HealthType.Armor:
                _up.Armor = up.Health;
                break;

            case HealthType.EnergyShields:
                _up.EnergyShields = up.Health;
                break;

            case HealthType.EMF:
                _up.EMF = up.Health;
                break;
            }

            switch (dt)
            {
            case DamageType.Plasma:
                _up.PlasmaDamage = defaultDamage * 2;
                break;

            case DamageType.Ballistic:
                _up.BallisticDamage = Mathf.CeilToInt(defaultDamage / 2);
                break;

            case DamageType.Laser:
                _up.LaserDamage = defaultDamage;
                break;
            }

            CurrentMovementTarget = PathToTraverse[0].Position;
        }
Exemple #27
0
 public HealthMonitorResult(string name, HealthType healthType) : this()
 {
     Name       = name;
     HealthType = healthType;
 }
Exemple #28
0
 public HealthModifierValue(HealthType healthType, float value)
 {
     this.healthType = healthType;
     this.value      = value;
 }
Exemple #29
0
 public DummyEnemy(MapField[] path, SoldiersController sc, EnemiesController ec, PlayerBase pb, DamageType dt,
                   HealthType ht, UnitParameters up, int defaultDamage) : base(path, sc, ec, pb, dt, ht, up, defaultDamage)
 {
     Position = Vector2.down * 1000;
 }
 public HealthTypeDamageValue(HealthType healthType, float damageValue)
 {
     this.healthType  = healthType;
     this.damageValue = damageValue;
 }