public bool Use(int index, GameObject user) { //Checks we have an item in this slot if (_dockedItems.ContainsKey(index)) { //If the item is an action item ActionItem action = _dockedItems[index].item as ActionItem; if (action) { action.Use(user, index); if (action.IsConsumable) { RemoveItems(index, 1); } return(true); } //if the item is an armor item ArmorConfig armor = _dockedItems[index].item as ArmorConfig; if (armor) { armor.Use(gameObject, index); RemoveItems(index, 1); } //if the item is a weapon WeaponConfig weapon = _dockedItems[index].item as WeaponConfig; if (weapon) { weapon.Use(gameObject, index); } } return(false); }
protected Character(CharacterSO other) { // name displayName = other.displayName; // stats attributes = other.attributes; elementAttack = other.elementAttack; elementDefense = other.elementDefense; combatStats = other.combatStats; // level and class level = other.level; charClass = other.charClass; // create armor and weapon configs from class rules mWeaponConfig = charClass.CreateWeaponConfig(); mArmorConfig = charClass.CreateArmorConfig(); for (int i=0; i < other.weapons.Length; i++) { mWeaponConfig.EquipWeapon(other.weapons[i], i); } // TODO, this should be tightly coupled with SO implementation // for (int i=0; i < other.weapons.Length; i++) { // mArmorConfig.EquipArmor(other.armors[i], i); // } curHP = maxHP; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); UnitMeshAttachment_Test m_test = target as UnitMeshAttachment_Test; TargetUnitMesh = m_test.gameObject; armor_test_config = EditorGUILayout.ObjectField("Test Armor", armor_test_config, typeof(ArmorConfig), false) as ArmorConfig; weapon_test = EditorGUILayout.ObjectField("Test Armor", weapon_test, typeof(Weapon), false) as Weapon; }
public static DataComponent CreateDataComponent( GameObject parent, UnitConfig config, MobilityData mobilityData) { MobilityConfig mobilityConfig = config.Mobility; ArmorConfig armorConfig = config.Armor; parent.AddComponent <DataComponent>(); DataComponent c = parent.GetComponent <DataComponent>(); c.MovementSpeed = config.MovementSpeed.Value * Constants.MAP_SCALE; c.ReverseSpeed = config.ReverseSpeed.Value * Constants.MAP_SCALE; c.AccelRate = config.AccelRate.Value * Constants.MAP_SCALE; c.MaxRotationSpeed = config.MaxRotationSpeed.Value; c.MinTurnRadius = config.MinTurnRadius.Value * Constants.MAP_SCALE; c.MaxLateralAccel = config.MaxLateralAccel.Value * Constants.MAP_SCALE; c.Suspension = config.Suspension.Value / Constants.MAP_SCALE; c.MaxHealth = config.MaxHealth.Value; c.Length = config.Length.Value * Constants.MAP_SCALE; c.Width = config.Width.Value * Constants.MAP_SCALE; c.MobilityData = mobilityData; c.Radius = Mathf.Sqrt(c.Length * c.Width) / 2; c.OptimumTurnSpeed = Mathf.Sqrt(c.MaxLateralAccel * c.MinTurnRadius); c.SuspensionForward = c.Suspension * c.Radius / c.Length; c.SuspensionSide = c.Suspension * c.Radius / c.Width; c.AccelDampTime = 0.15f * c.MovementSpeed / c.AccelRate; c.ApImmunity = armorConfig.ApImmunity; c.FrontArmor = armorConfig.FrontArmor; c.SideArmor = armorConfig.SideArmor; c.RearArmor = armorConfig.RearArmor; c.TopArmor = armorConfig.TopArmor; ReconConfig reconConfig = config.Recon; c.MaxSpottingRange = reconConfig.MaxSpottingRange; c.Stealth = reconConfig.Stealth; c.StealthPenetration = reconConfig.StealthPenetration; c.CanCaptureZones = config.CanCaptureZones.Value; c.ModelCount = config.ModelCount.Value; c.TransportableSize = config.TransportableSize.Value; c.TransporterCapacity = config.TransporterCapacity.Value; return(c); }
public static DataComponent CreateDataComponent( GameObject parent, UnitConfig config, MobilityData mobilityData) { UnitDataConfig unitConfig = config.Data; MobilityConfig mobilityConfig = config.Mobility; ArmorConfig armorConfig = config.Armor; parent.AddComponent <DataComponent>(); DataComponent c = parent.GetComponent <DataComponent>(); c.MovementSpeed = unitConfig.MovementSpeed * Constants.MAP_SCALE; c.ReverseSpeed = unitConfig.ReverseSpeed * Constants.MAP_SCALE; c.AccelRate = unitConfig.AccelRate * Constants.MAP_SCALE; c.MaxRotationSpeed = unitConfig.MaxRotationSpeed; c.MinTurnRadius = unitConfig.MinTurnRadius * Constants.MAP_SCALE; c.MaxLateralAccel = unitConfig.MaxLateralAccel * Constants.MAP_SCALE; c.Suspension = unitConfig.Suspension / Constants.MAP_SCALE; c.MaxHealth = unitConfig.MaxHealth; c.Length = unitConfig.Length * Constants.MAP_SCALE; c.Width = unitConfig.Width * Constants.MAP_SCALE; c.MobilityData = mobilityData; c.Radius = Mathf.Sqrt(c.Length * c.Width) / 2; c.OptimumTurnSpeed = Mathf.Sqrt(c.MaxLateralAccel * c.MinTurnRadius); c.SuspensionForward = c.Suspension * c.Radius / c.Length; c.SuspensionSide = c.Suspension * c.Radius / c.Width; c.AccelDampTime = 0.15f * c.MovementSpeed / c.AccelRate; c.ApImmunity = armorConfig.ApImmunity; c.FrontArmor = armorConfig.FrontArmor; c.SideArmor = armorConfig.SideArmor; c.RearArmor = armorConfig.RearArmor; c.TopArmor = armorConfig.TopArmor; ReconConfig reconConfig = config.Recon; c.MaxSpottingRange = reconConfig.MaxSpottingRange; c.Stealth = reconConfig.Stealth; c.StealthPenetration = reconConfig.StealthPenetration; return(c); }
private void UpdateArmor() { //TODO: Better way of doing this as this couples the player to the equipment PlayerController player = GetComponent <PlayerController>(); //Reset the stats of the player player.ResetStats(); foreach (EquipLocation location in GetAllPopulatedSlots()) { ArmorConfig armor = GetItemInSlot(location) as ArmorConfig; if (armor != null) { foreach (StatValues stat in armor.GetStatValues()) { player.EquipStat(stat); } } } }