Esempio n. 1
0
    // TODO: Add cold/hot animation, Add feedback: Cold breath, sweat.
    private void ApplyTemperatureEffect()
    {
        float adjustedTemperature = (Temperature > 0) ? Temperature - _actor.Statistics.CurrentStatistics[StatisticType.HEAT_RESISTANCE] : Temperature - _actor.Statistics.CurrentStatistics[StatisticType.COLD_RESISTANCE];

        Debug.Log("Adjusted Temperature: " + adjustedTemperature);

        // TODO replace this by CONSTANT
        if (adjustedTemperature > 25)
        {
            StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 0.5f, StatusEffectManager.GetStatusEffectData("Hot")));
        }
        else
        {
            // TODO check if there is a hot status effect, if so remove it.
        }


        if (adjustedTemperature < 0)
        {
            StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 0.5f, StatusEffectManager.GetStatusEffectData("Cold")));
        }
        else
        {
            // TODO check if there is a cold status effect, if so add it.
        }
    }
Esempio n. 2
0
    public void Initialize(ActorDto actorDto)
    {
        Guid            = Guid.Parse(actorDto.Guid);
        gameObject.name = Guid.ToString();
        gameObject.tag  = FactionType.ToString();

        FactionType = actorDto.FactionType;
        Playable    = actorDto.Playable;

        TaskScheduler.Initialize(Guid);
        StatusEffectScheduler.Initialize(Guid);
        Attributes.Initialize(this, actorDto.AttributesDto);
        Status.Initialize(actorDto.StatusDto);

        Inventory.Initialize(actorDto.InventoryDto);
        Armory.Initialize(this, actorDto.ArmoryDto);
        Skills.Initialize(actorDto.SkillsDto);

        SkinnedMeshRenderer skinnedMeshRenderer = GetComponentInChildren <SkinnedMeshRenderer>();

        Face.Initialize(skinnedMeshRenderer, actorDto.FeaturesDto);
        Body.Initialize(skinnedMeshRenderer, actorDto.FeaturesDto);

        if (Playable)
        {
            Squad.AddToSquad(this);
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Suffer X amount of damage. If health is empty, call the virtual OnDeath event.
    /// </summary>
    /// <param name="damage">Amount of damage to suffer.</param>
    public void SufferDamage(float damage)
    {
        Health -= damage;

        OnUpdateHealthEvent?.Invoke(Health / MaxHealth);

        if (Health <= 0)
        {
            StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 1f, StatusEffectManager.GetStatusEffectData(Constant.DEATH)));
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Reduce the food by X. Apply a Hungry status effect if the food equals to 0.
    /// </summary>
    /// <param name="value">Amount of food to deduct.</param>
    public void ReduceFood(float value)
    {
        Food -= value;

        if (Food <= 0)
        {
            Food = 0;
            StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 0.5f, StatusEffectManager.GetStatusEffectData(Constant.STARVING)));
        }

        OnUpdateFoodEvent?.Invoke(Food);
    }
Esempio n. 5
0
    /// <summary>
    /// Increase the food bar by X. Remove any Hungry status effects.
    /// </summary>
    /// <param name="value">Amount of food to restore.</param>
    public void IncreaseFood(float value)
    {
        Food += value;

        StatusEffectScheduler.Instance(_actor.Guid).RemoveStatusEffect(Constant.STARVING);

        if (Food > Constant.ACTOR_BASE_FOOD)
        {
            Food = Constant.ACTOR_BASE_FOOD;
        }

        OnUpdateFoodEvent?.Invoke(Food);
    }
Esempio n. 6
0
    public void Initialize(Actor actor, AttributesDto attributesDto)
    {
        MaxHealth          = attributesDto.MaxHealth;
        Health             = attributesDto.Health;
        HealthRegeneration = attributesDto.HealthRegeneration;
        Speed       = attributesDto.Speed;
        Damage      = attributesDto.Damage;
        HungerRate  = attributesDto.HungerRate;
        Food        = attributesDto.Food;
        Temperature = attributesDto.Temperature;

        _actor = actor;
        StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 1f, StatusEffectManager.GetStatusEffectData(Constant.HUNGRY)));
    }
Esempio n. 7
0
 public void Initialize(Guid guid)
 {
     Debug.Log("Initialized status handler !");
     if (_initialized == false)
     {
         _initialized = true;
         StatusEffectScheduler.Instance(guid).OnAddStatusEffectEvent     += OnAdd;
         StatusEffectScheduler.Instance(guid).OnRemoveStatusEffectEvent  += OnRemove;
         StatusEffectScheduler.Instance(guid).OnUpdateStatusEffectsEvent += OnBulkUpdate;
         StatusEffectScheduler.Instance(guid).OnUpdateStatusEffectEvent  += OnUpdate;
     }
     else
     {
         Debug.LogError("This component has already been initialized with: " + guid.ToString());
     }
 }