public void TestTemplateInitializer() { Template templHuman = holder.templates.GetTemplate(GameConsts.TEMPL_HUMANOID); Assert.IsNotNull(templHuman); Assert.IsTrue(templHuman.name == GameConsts.TEMPL_HUMANOID); Template templHumanWithTag = holder.templates.GetTemplateWithTag(GameConsts.TAG_HUMANOID + " " + GameConsts.TAG_ORGANIC); Assert.IsNotNull(templHumanWithTag); Assert.IsTrue(templHumanWithTag == templHuman); Template templNullTag = holder.templates.GetTemplateWithTag(GameConsts.TAG_HUMANOID + " lixo " + GameConsts.TAG_ORGANIC); Assert.IsNull(templNullTag); HumanoidEntity human = templHuman.Spawn(world, new Position(10, 10, 0)) as HumanoidEntity; Assert.IsNotNull(human); TraitManagerComponent traits = human.GetComponent(GameConsts.COMPONENT_TYPE.TRAIT_MANAGER) as TraitManagerComponent; Assert.IsNotNull(traits); Assert.IsTrue(traits.owner == human); Assert.IsTrue(traits.traits.Count == GameConsts.allTraits.Count); int count = 0; foreach (Trait trait in traits.traits) { Assert.IsTrue(trait.value >= 0 && trait.value <= GameConsts.MAX_TRAIT_VALUE); count += trait.value; } Assert.IsTrue(count > 0); }
public EquiptmentManager(HumanoidEntity entity) { Entity = entity; EquiptItems = new Dictionary <LoadedEquiptmentPlacement, EquiptableItem>(); EquiptArmor = new Armor[5]; DefaultItems = new Dictionary <LoadedEquiptmentPlacement, EquiptableItem>(); }
public override void Tick(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: non-humanoid support return; } HumanoidEntity character = (HumanoidEntity)entity; if (character.Flags.HasFlag(YourStatusFlags.RELOADING) && (character.TheRegion.GlobalTickTime - character.LastGunShot >= FireRate)) { character.Flags &= ~YourStatusFlags.RELOADING; UpdatePlayer(character); } else if (!character.Flags.HasFlag(YourStatusFlags.RELOADING) && (character.TheRegion.GlobalTickTime - character.LastGunShot < FireRate)) { character.Flags |= YourStatusFlags.RELOADING; UpdatePlayer(character); } if (!character.Flags.HasFlag(YourStatusFlags.NEEDS_RELOAD) && item.Datum == 0) { character.Flags |= YourStatusFlags.NEEDS_RELOAD; UpdatePlayer(character); } else if (character.Flags.HasFlag(YourStatusFlags.NEEDS_RELOAD) && item.Datum != 0) { character.Flags &= ~YourStatusFlags.NEEDS_RELOAD; UpdatePlayer(character); } }
private void Awake() { characterEntity = transform.root.GetComponent <HumanoidEntity>(); characterEquipment = characterEntity.equipment; animator = GetComponent <Animator>(); controller = GetComponent <CharacterController>(); }
public void TestSpawnPawn() { HumanoidEntity pawn = factory.SpawnPawn(20); Assert.IsNotNull(pawn); Assert.IsTrue(world.ContainsEntity(pawn)); //Assert.IsTrue(pawn.name != null); /* GameComponent brain = pawn.GetComponent(GameConsts.COMPONENT_TYPE.BRAIN); * Assert.IsNotNull(brain); * Assert.IsTrue(brain.type == GameConsts.COMPONENT_TYPE.BRAIN); * Assert.IsTrue(brain.owner == pawn);*/ Assert.IsNotNull(pawn.position); Assert.IsNotNull(pawn.dimension); /* TraitManagerComponent traits = pawn.GetComponent(GameConsts.COMPONENT_TYPE.TRAIT_MANAGER) as TraitManagerComponent; * Assert.IsNotNull(traits); * Assert.IsTrue(traits.traits.Count == GameConsts.allTraits.Count); * int count = 0; * foreach (Trait trait in traits.traits) * { * Assert.IsTrue(trait.value >= 0 && trait.value <= GameConsts.MAX_TRAIT_VALUE); * count += trait.value; * } * Assert.IsTrue(count == GameConsts.HUMAN_TRAITS_POINTS);*/ }
public void UpdatePlayer(HumanoidEntity character) { // TODO: Should this be a method on PlayerEntity? if (character is PlayerEntity) { ((PlayerEntity)character).Network.SendPacket(new YourStatusPacketOut(character.GetHealth(), character.GetMaxHealth(), character.Flags)); } }
public override void ReleaseClick(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: non-humanoid support return; } HumanoidEntity character = (HumanoidEntity)entity; character.WaitingForClickRelease = false; }
public override void SwitchFrom(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: Non-human support? return; } HumanoidEntity human = (HumanoidEntity)entity; human.JPBoost = false; human.JPHover = false; }
public override void SwitchTo(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: Non-human support? return; } HumanoidEntity human = (HumanoidEntity)entity; bool has_fuel = human.ConsumeFuel(0); human.TheRegion.SendToVisible(human.GetPosition(), new FlagEntityPacketOut(human, EntityFlag.HAS_FUEL, has_fuel ? 1f : 0f)); }
public override void Tick(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: Non-human support? return; } HumanoidEntity human = (HumanoidEntity)entity; human.JPBoost = human.ItemLeft; human.JPHover = human.ItemRight; }
/// <summary> /// Calculates the final damage dealt to entity after taking into account /// defencive score from armour, as well as active effects and spells (TODO) /// </summary> /// <param name="baseDamage"></param> /// <param name="damageType"></param> /// <returns></returns> public float CalculateDamageValue(float baseDamage, DamageType damageType) { if (Entity is HumanoidEntity) { HumanoidEntity hum = Entity as HumanoidEntity; float armourVal = hum.EquiptmentManager.GetArmourValue(); if (armourVal <= 1) { return(baseDamage); } return(baseDamage / Mathf.Sqrt(armourVal)); } return(baseDamage); }
public bool Reload(HumanoidEntity character, ItemStack item) { if (character.Flags.HasFlag(YourStatusFlags.RELOADING)) { return(false); } int clipSize = (int)((double)ClipSize * item.GetAttributeF("clipsize_mod", 1f)); if (item.Datum < clipSize) { for (int i = 0; i < character.Items.Items.Count; i++) { ItemStack itemStack = character.Items.Items[i]; if (itemStack.Info is BulletItem && itemStack.SecondaryName == AmmoType) { if (itemStack.Count > 0) { int reloading = clipSize - item.Datum; if (reloading > itemStack.Count) { reloading = itemStack.Count; } item.Datum += reloading; if (character is PlayerEntity) { ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(character.Items.Items.IndexOf(item), item)); } itemStack.Count -= reloading; if (itemStack.Count <= 0) { character.Items.RemoveItem(i + 1); } else { if (character is PlayerEntity) { ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(i, itemStack)); } } } character.Flags |= YourStatusFlags.RELOADING; character.WaitingForClickRelease = true; character.LastGunShot = character.TheRegion.GlobalTickTime + ReloadDelay; UpdatePlayer(character); return(true); } } } return(false); }
public override void Click(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: non-humanoid support return; } HumanoidEntity character = (HumanoidEntity)entity; double fireRate = FireRate * item.GetAttributeF("firerate_mod", 1f); if (item.Datum != 0 && !character.WaitingForClickRelease && (character.TheRegion.GlobalTickTime - character.LastGunShot >= fireRate)) { double spread = Spread * item.GetAttributeF("spread_mod", 1f); double speed = Speed * item.GetAttributeF("speed_mod", 1f); int shots = (int)((double)Shots * item.GetAttributeF("shots_mod", 1f)); for (int i = 0; i < shots; i++) { BulletEntity be = new BulletEntity(character.TheRegion); be.SetPosition(character.GetEyePosition()); // TODO: ItemPosition? be.NoCollide.Add(character.EID); Location ang = character.Direction; ang.Yaw += Utilities.UtilRandom.NextDouble() * spread * 2 - spread; ang.Pitch += Utilities.UtilRandom.NextDouble() * spread * 2 - spread; be.SetVelocity(Utilities.ForwardVector_Deg(ang.Yaw, ang.Pitch) * speed); be.Size = RoundSize; be.Damage = ImpactDamage; be.SplashSize = SplashSize; be.SplashDamage = SplashMaxDamage; character.TheRegion.SpawnEntity(be); } if (ShotPerClick) { character.WaitingForClickRelease = true; } character.LastGunShot = character.TheRegion.GlobalTickTime; item.Datum -= 1; if (character is PlayerEntity) { ((PlayerEntity)character).Network.SendPacket(new SetItemPacketOut(character.Items.Items.IndexOf(item), item)); } } else if (item.Datum == 0 && !character.WaitingForClickRelease) { Reload(character, item); } }
private void Awake() { currentEntity = transform.root.GetComponent <HumanoidEntity>(); rings = new List <Inventory>(10); rings.Add(lRing0Equipment); rings.Add(lRing1Equipment); rings.Add(lRing2Equipment); rings.Add(lRing3Equipment); rings.Add(lRing4Equipment); rings.Add(rRing0Equipment); rings.Add(rRing1Equipment); rings.Add(rRing2Equipment); rings.Add(rRing3Equipment); rings.Add(rRing4Equipment); armorSlots = new List <Inventory>(17); armorSlots.Add(headEquipment); armorSlots.Add(chestEquipment); armorSlots.Add(beltEquipment); armorSlots.Add(lBracletEquipment); armorSlots.Add(rBracletEquipment); armorSlots.Add(legsEquipment); armorSlots.Add(feetEquipment); armorSlots.AddRange(rings); weaponSlots = new List <Inventory>(2); weaponSlots.Add(lHandEquipment); weaponSlots.Add(rHandEquipment); allSlots = new List <Inventory>(19); allSlots.AddRange(weaponSlots); allSlots.AddRange(armorSlots); for (int i = 0; i < allSlots.Count; i++) { allSlots[i].onItemAdded = ItemAdded; allSlots[i].onItemRemoved = ItemRemoved; allSlots[i].onItemBeginDrag = ItemBeginDrag; allSlots[i].onItemDrop = ItemDrop; } }
public override void SwitchFrom(Entity entity, ItemStack item) { if (!(entity is HumanoidEntity)) { // TODO: non-humanoid support return; } HumanoidEntity character = (HumanoidEntity)entity; character.WaitingForClickRelease = false; character.LastGunShot = 0; if (!(entity is PlayerEntity)) { return; } PlayerEntity player = (PlayerEntity)entity; player.Flags &= ~YourStatusFlags.RELOADING; player.Flags &= ~YourStatusFlags.NEEDS_RELOAD; UpdatePlayer(player); }
public override void DebugDraw() { base.DebugDraw(); if (HumanoidEntity == null) { return; } HumanoidActions.AiTarget.DebugDraw(); var headMatrix = HumanoidEntity.GetHeadMatrix(true, true, false, true); // VRageRender.MyRenderProxy.DebugDrawAxis(headMatrix, 1.0f, false); VRageRender.MyRenderProxy.DebugDrawLine3D(headMatrix.Translation, headMatrix.Translation + headMatrix.Forward * 30, Color.HotPink, Color.HotPink, false); VRageRender.MyRenderProxy.DebugDrawAxis(HumanoidEntity.PositionComp.WorldMatrix, 1.0f, false); var invHeadMatrix = headMatrix; invHeadMatrix.Translation = Vector3.Zero; invHeadMatrix = Matrix.Transpose(invHeadMatrix); invHeadMatrix.Translation = headMatrix.Translation; }
public override void DebugDraw() { base.DebugDraw(); if (HumanoidEntity == null) { return; } HumanoidActions.AiTargetBase.DebugDraw(); var headMatrix = HumanoidEntity.GetHeadMatrix(true, true, false, true); // VRageRender.MyRenderProxy.DebugDrawAxis(headMatrix, 1.0f, false); //VRageRender.MyRenderProxy.DebugDrawLine3D(headMatrix.Translation, headMatrix.Translation + headMatrix.Forward * 30, Color.HotPink, Color.HotPink, false); if (HumanoidActions.AiTargetBase.HasTarget()) { HumanoidActions.AiTargetBase.DrawLineToTarget(headMatrix.Translation); Vector3D targetPos; float radius; HumanoidActions.AiTargetBase.GetTargetPosition(headMatrix.Translation, out targetPos, out radius); if (targetPos != Vector3D.Zero) { MyRenderProxy.DebugDrawSphere(targetPos, 0.3f, Color.Red, 0.4f, false); VRageRender.MyRenderProxy.DebugDrawText3D(targetPos, "GetTargetPosition", Color.Red, 1, false); } } VRageRender.MyRenderProxy.DebugDrawAxis(HumanoidEntity.PositionComp.WorldMatrix, 1.0f, false); var invHeadMatrix = headMatrix; invHeadMatrix.Translation = Vector3.Zero; invHeadMatrix = Matrix.Transpose(invHeadMatrix); invHeadMatrix.Translation = headMatrix.Translation; }
public void Init(HumanoidEntity currentEntity) { Stats stats = currentEntity.stats; textsStats = new List <TextStat>(); //track textStatLevel?.SetTrack(stats.Level); textStatLevelExperience?.SetTrack(stats.LevelExperience); textStatSkillPoints?.SetTrack(stats.SkillPoints); textStatHealthPoints?.SetTrack(stats.HealthPoints); textStatManaPoints?.SetTrack(stats.ManaPoints); textStatResistFire?.SetTrack(stats.ResistFire); textStatResistIce?.SetTrack(stats.ResistIce); textStatResistPoison?.SetTrack(stats.ResistPoison); textStatStrength?.SetTrack(stats.Strength, currentEntity.IncreaseStrength, currentEntity.DecreaseStrength); textStatAgility?.SetTrack(stats.Agility, currentEntity.IncreaseAgility, currentEntity.DecreaseAgility); textStatIntelligence?.SetTrack(stats.Intelligence, currentEntity.IncreaseIntelligence, currentEntity.DecreaseIntelligence); textStatLuck?.SetTrack(stats.Luck, currentEntity.IncreaseLuck, currentEntity.DecreaseLuck); textStatPhysicalArmor?.SetTrack(stats.PhysicalArmor); textStatArmorHead?.SetTrack(currentEntity.equipment.armorHead); textStatArmorTorso?.SetTrack(currentEntity.equipment.armorTorso); textStatArmorBelt?.SetTrack(currentEntity.equipment.armorBelt); textStatArmorLegs?.SetTrack(currentEntity.equipment.armorLegs); textStatArmorFeet?.SetTrack(currentEntity.equipment.armorFeet); textStatMagicArmor?.SetTrack(stats.MagicArmor); textPrimaryHand?.SetTrack(currentEntity.equipment.lHandDamage); textSecondaryHand?.SetTrack(currentEntity.equipment.rHandDamage); textStatMeleeDamage?.SetTrack(stats.MeleeDamage); textStatShotDamage?.SetTrack(stats.ShotDamage); textStatMagicDamage?.SetTrack(stats.MagicDamage); textStatСhanceCriticalStrike?.SetTrack(stats.СhanceCriticalStrike); textStatСhanceCriticalShot?.SetTrack(stats.СhanceCriticalShot); textStatСhanceAvoid?.SetTrack(stats.ChanceAvoid); //to list textsStats.Add(textStatLevel); textsStats.Add(textStatLevelExperience); textsStats.Add(textStatSkillPoints); textsStats.Add(textStatHealthPoints); textsStats.Add(textStatManaPoints); textsStats.Add(textStatResistFire); textsStats.Add(textStatResistIce); textsStats.Add(textStatResistPoison); textsStats.Add(textStatStrength); textsStats.Add(textStatAgility); textsStats.Add(textStatIntelligence); textsStats.Add(textStatLuck); textsStats.Add(textStatPhysicalArmor); textsStats.Add(textStatArmorHead); textsStats.Add(textStatArmorTorso); textsStats.Add(textStatArmorBelt); textsStats.Add(textStatArmorLegs); textsStats.Add(textStatArmorFeet); textsStats.Add(textStatMagicArmor); textsStats.Add(textPrimaryHand); textsStats.Add(textSecondaryHand); textsStats.Add(textStatMeleeDamage); textsStats.Add(textStatShotDamage); textsStats.Add(textStatMagicDamage); textsStats.Add(textStatСhanceCriticalStrike); textsStats.Add(textStatСhanceCriticalShot); textsStats.Add(textStatСhanceAvoid); }