Мне нужна помощь в следующем.
Вычислить только с помощью переменной суммы и перечисления, чтобы указать тип расчета, чтобы я мог установить правильное значение статистики для статистики. p>
Убедитесь, что правильная статистика изменена.
Другими словами, убедитесь, что правильная статистика изменена на правильную величину.
Вот код, который у меня есть на данный момент (единственный скрипт, который, по моему мнению, необходимо изменить, это скрипт PlayerStatCalculator)
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using UnityEngine;
public class PlayerStatCalculator : MonoBehaviour
{
public CardSO collectedCard;
public PlayerStats playerStatToChange;
public void OnCardCollected()
{
//piece of code to activate abilities
foreach (var statChanges in collectedCard.StatChanges)
{
SetStats(statChanges.statChangeAmount, statChanges.changeType);
//statChanges.statName
}
}
void SetStats(float amount, EStatChangeType type)
{
float statToChange = 0;// this needs to become the stat that needs to be changed in playerStatToChange
switch (type)
{
case EStatChangeType.Fixed:
statToChange += amount;
break;
case EStatChangeType.Persentage:
break;
case EStatChangeType.Set:
statToChange = amount;
break;
case EStatChangeType.Second:
break;
case EStatChangeType.SecondPersentage:
break;
}
}
}
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
[CreateAssetMenu]
public class CardSO : ScriptableObject
{
public string CardName;
public bool CanGet = true;
public bool CanSpawn = true;
public Image CardBG;
public ECardRarity rarity;
public EAbilityType abilityType;
//need to make it so i can only set this if i give the abilityType the correct value
public EBlockAbility blockAbility;
public EBulletAbility bulletAbility;
public EPlayerAbility playerAbility;
public CardStat[] StatChanges;
}
public enum EAbilityType
{
None,
Block,
Bullet,
Player
}
public enum EPlayerAbility
{
None
}
public enum EBlockAbility //things like implosion are going in here
{
None,
Bombs_Away
}
public enum EBulletAbility //things like poison cloud are going in here
{
None,
Poison,
Parasite
}
public enum ECardRarity
{
None,
common,
uncommon,
rare,
epic,
legendairy,
mythic
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class PlayerStats : ScriptableObject
{
public int Hp = 100;
public int Damage = 55;
public float ReloadTime = 1;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class CardStat
{
public EStatToChange statName;
public EStatChangeType changeType;
public float statChangeAmount;
}
public enum EStatChangeType
{
none,
Fixed,
Persentage,
Set,
Second,
SecondPersentage
}
public enum EStatToChange
{
none,
Hp,
Damage,
ReloadTime
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... -persentag
Рассчитайте сумму со значением и типом расчета (установленный, фиксированный, секунды, проценты, секунды процента) и изм ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение