/// <summary> /// Maps the entity part from package part. /// </summary> /// <param name="entityPartPackagePart">The entity part package part.</param> /// <param name="includeData">if set to <c>true</c> include data with the entity part.</param> /// <returns>EntityPart.</returns> public EntityPart MapEntityPartFromPackagePart(PackagePart entityPartPackagePart, bool includeData) { //Get the entity part metadata and deserialize. EntityPartMetadata metadata = GetEntityPartMetadata(entityPartPackagePart); var result = new EntityPart { Category = metadata.Category, Created = metadata.Created, CreatedBy = User.GetUser(metadata.CreatedBy), EntityId = new Guid(entityPartPackagePart.Package.PackageProperties.Identifier), ETag = metadata.Etag, Modified = metadata.Modified, ModifiedBy = User.GetUser(metadata.ModifiedBy), Name = metadata.Name, }; if (includeData) { using (var fs = entityPartPackagePart.GetStream()) { var bytes = fs.ReadToEnd(); result.Data = Encoding.UTF8.GetString(bytes); } } return(result); }
public Entity(SerializationInfo info, StreamingContext cntxt) : base(info, cntxt) { Name = (string)info.GetValue("Entity_Name", typeof(string)); Equipment = (Equipment)info.GetValue("Entity_Equipment", typeof(Equipment)); Stats = (EntityStats)info.GetValue("Entity_Stats", typeof(EntityStats)); XPValue = (int)info.GetValue("Entity_XPValue", typeof(int)); facing = (Direction)info.GetValue("Entity_Facing", typeof(Direction)); MAX_SPEED = (float)info.GetValue("Entity_MaxSpeed", typeof(float)); msVel = (Vector2)info.GetValue("Entity_MsVel", typeof(Vector2)); bounds = (EntityBounds)info.GetValue("Entity_EBounds", typeof(EntityBounds)); State = (EntityState)info.GetValue("Entity_State", typeof(EntityState)); // Init entity in loaded classes Stats.setEntity(this); EBounds.setEntity(this); Equipment.setEntity(this); // Un-saved values GScreen = (GameScreen)ScreenManager.getScreen(ScreenId.Game); lastHitPart = EntityPart.Body; jumpDelay = attackDelay = showHpTicks = 0; speedMultiplier = MAX_SPEED; pDrops = new PossibleDrop[0]; sprite.setFrame(250, 3); }
//------------------------------------------------------------------------------------------------------- // 获取组件 public IEntityPart GetPart(EntityPart entityPart) { int key = (int)entityPart; if (!m_Parts.ContainsKey(key)) { return(null); } return(m_Parts[key]); }
public void doAttack(TileMap map, EntityPart part) { if (Alive) { Attack attack = base.attack(part, HotBar.getSelected()); if (attack != null) { aliveSpells.Add(attack); } } }
public Attack attack(TileMap map, EntityPart part, Func <Entity, EntityPart, TileMap, Attack> factoryFunc) { if (canAttack()) { Attack a = factoryFunc(this, part, map); map.addAttack(a); attackDelay = ATTACK_DELAY_MS; return(a); } return(null); }
public void doAttack(TileMap map, EntityPart part) { if (Alive) { Attack attack = base.attack(map, part, AttackFactory.FireBall); if (attack != null) { myAttacks.Add(attack); } } }
public DecomposeCreaturePart(EntityCreature creature, EntityPart part) : base(0.5f) { _entityParts.Add(new EntityPart(this, part.element)); _entityParts[0].sortZOffset = 1f; _viewAngle = part.viewAngle; _decayTime = Random.Range(5f, 10f); AttachPhysics(0.25f, 0.5f); velocity = CustomMath.HorizontalRotate(creature.velocity, Random.Range(-30f, 30f)); }
public AnimationRigBipedal(EntityPart body, EntityPart head, EntityPart rArm, EntityPart lArm, EntityPart rLeg, EntityPart lLeg, EntityPart rFoot, EntityPart lFoot) : base() { _body = body; _head = head; _rArm = rArm; _lArm = lArm; _rLeg = rLeg; _lLeg = lLeg; _rFoot = rFoot; _lFoot = lFoot; ChangeState(new StateIdle()); }
public EntityPartInstance(ScriptEngine engine, EntityPart entityPart) : base(engine) { if (entityPart == null) { throw new ArgumentNullException("entityPart"); } m_entityPart = entityPart; this.PopulateFields(); this.PopulateFunctions(); }
public Attack attack(EntityPart part, Func <Entity, EntityPart, TileMap, Attack> factoryFunc) { if (canAttack() && factoryFunc != null) { Attack a = factoryFunc(this, part, Map); if (a != null) { Map.addAttack(a); attackDelay = ATTACK_DELAY_MS; return(a); } } return(null); }
public AnimationRigHandle(EntityPart rArm, EntityPart lArm, EntityPart item) : base() { _rArm = rArm; _lArm = lArm; _item = item; _states = new AnimationState <AnimationRigHandle>[] { null, new StateHold1Hand(), new StateHold2Hands(), new StateHoldBlock() }; }
public Granade(Entity owner, Damage damage, Vector3 velocity) : base(0f) { _owner = owner; _damage = damage; AttachPhysics(0.2f, 0.2f); this.velocity = velocity; _part = new EntityPart(this, Futile.atlasManager.GetElementWithName("entities/bullet12")); _entityParts.Add(_part); _hitAudio = Resources.Load <AudioClip>("SoundEffects/BulletHit"); }
public override void run() { EntityPart part = (target.Entity.Location.Y > Entity.Location.Y) ? EntityPart.Head : EntityPart.Body; Entity.attack(part); if (target.Entity.Location.X < Entity.Location.X) { Entity.setXSpeedPerMs(-0.05f); } else { Entity.setXSpeedPerMs(0.05f); } }
public int getFireFrom(EntityPart part) { if (part == EntityPart.Legs) { return(legs.Top + 1); } else if (part == EntityPart.Head) { return(head.Center.Y); } else { return(body.Center.Y); } }
public int getFireFrom(EntityPart part) { int variation = GameScreen.RANDOM.Next(2) - 1; if (part == EntityPart.Legs) { return(legs.Top + 1 + variation); } else if (part == EntityPart.Head) { return(head.Center.Y + variation); } else { return(body.Center.Y + variation); } }
public Rectangle getRectFromPart(EntityPart part) { if (part == EntityPart.Body) { return(body); } else if (part == EntityPart.Head) { return(head); } else if (part == EntityPart.Legs) { return(legs); } return(ZERO_RECT); }
public static Attack Raise_Death(Entity e, EntityPart part, TileMap map) { // Static int width = AttackFactory.RAISE_DEATH_WIDTH, height = 8; // Changes based on entity state int x; int y = e.EBounds.Top - (height * 2); float speed = 0.175f; if (e.isFacingForward()) { x = e.EBounds.Right + (AttackFactory.RAISE_DEATH_WIDTH * 5); } else { x = e.EBounds.Left - (AttackFactory.RAISE_DEATH_WIDTH * 5); } return new Attack(map, e, map.GScreen.SprAttack[AttackSpriteId.Raise_Death], new Rectangle(x, y - (height / 2), width, height), (int) (8 * e.Stats.AttackPower), speed, TileMap.SPRITE_SIZE, false); }
public static Attack Scurge_Shot(Entity e, EntityPart part, TileMap map) { // Static int width = 20, height = 8; // Changes based on entity state int x; int y = e.EBounds.getFireFrom(part); float speed = 0.15f; if (e.isFacingForward()) { x = e.EBounds.Right + 1; } else { speed *= -1; x = e.EBounds.Left - width - 1; } return new Attack(map, e, map.GScreen.SprAttack[AttackSpriteId.Scurge_Shot], new Rectangle(x, y - (height / 2), width, height), (int) (8 * e.Stats.AttackPower), speed, 200); }
private void InitializeRigging() { Vector3 CamPoleLocation = new Vector3(1, 0, 0); Vector3 CamPoleScaleCorrection = new Vector3(.75f, .5f, .75f); Vector3 CamArmAPointOfRotationFromPole = new Vector3(0, 1, 0); Vector3 CamArmAOriginCorrection = new Vector3(0, 0, -.1f); Vector3 CamArmBPointOfRotationFromArmA = new Vector3(.07f, .07f, -.19f); Vector3 CamArmBOriginCorrection = new Vector3(0, 0, -.1f); Vector3 CamArmBOrientCorrection = new Vector3(0, 0, -(float)Math.PI / 2.0f); Vector3 CamBoxPointOfRotationFromArmB = new Vector3(0, 0, 0); Matrix CamBoxRotation = Matrix.CreateFromQuaternion(Quaternion.CreateFromYawPitchRoll(0, 0, 0)); //Matrix CamBoxOrientCorrection = Matrix.CreateFromQuaternion(Quaternion.CreateFromYawPitchRoll(0, (float)Math.PI, -(float)Math.PI / 2.0f)); Vector3 CamBoxOrientCorrection = new Vector3(0, (float)Math.PI, 0); Vector3 CamBoxOriginCorrection = new Vector3(0, 0, .13f); //Vector3 LaserBoxRelativeToCam = new Vector3(-.47f, -.1f, .06f); Vector3 LaserBoxRelativeToCam = new Vector3(-.35f, .1f, -.26f); //X:-0.35 Y:0.1 Z:-0.26 Vector3 LaserScaleCorrection = new Vector3(.05f, .05f, .1f); EntityPart CameraPole = EntityPart.GetPart((int)RigParts.CameraPole, Pole, CamPoleScaleCorrection, Vector3.Zero, CamPoleLocation, Vector3.Zero, Vector3.Zero); EntityPart CameraArmA = EntityPart.GetPart((int)RigParts.CameraArmA, Arm, 1.4f, Vector3.Zero, CamArmAPointOfRotationFromPole, Vector3.Zero, CamArmAOriginCorrection); CameraArmA.AdjustYawPitchRoll(rotCamYaw, 0, 0); EntityPart CameraArmB = EntityPart.GetPart((int)RigParts.CameraArmB, Arm, 1.4f, Vector3.Zero, CamArmBPointOfRotationFromArmA, CamArmBOrientCorrection, CamArmBOriginCorrection); CameraArmB.AdjustYawPitchRoll(0, rotCamPitch, 0); EntityPart CameraBox = EntityPart.GetPart((int)RigParts.CameraBox, Cam, Vector3.Zero, CamBoxPointOfRotationFromArmB, CamBoxOrientCorrection, CamBoxOriginCorrection); EntityPart LaserBox = EntityPart.GetPart((int)RigParts.LaserBox, Laser, LaserScaleCorrection, Vector3.Zero, LaserBoxRelativeToCam, Vector3.Zero, Vector3.Zero); rig.AddPart(-1, CameraPole); rig.AddPart((int)RigParts.CameraPole, CameraArmA); rig.AddPart((int)RigParts.CameraArmA, CameraArmB); rig.AddPart((int)RigParts.CameraArmB, CameraBox); rig.AddPart((int)RigParts.CameraBox, LaserBox); }
public void Update(float deltaTime) { Vector3 playerPosition = _player.worldPosition; _bodyRig.worldPosition = playerPosition; _bodyRig.viewAngle = _player.viewAngle; _bodyRig.moveSpeed = new Vector2(_player.velocity.x, _player.velocity.z).magnitude *deltaTime * 1.45f; _bodyRig.landed = _player._physics.landed; _handleRig.worldPosition = playerPosition; _handleRig.viewAngle = _player.viewAngle; _handleRig.cameraViewAngle = _player.worldCamera.viewAngle; GetEntityPart(PartType.Scarf).worldPosition = Vector3.Lerp(GetEntityPart(PartType.Body).worldPosition, GetEntityPart(PartType.Head).worldPosition, 0.3f); GetEntityPart(PartType.Tail).worldPosition = playerPosition + CustomMath.HorizontalRotate(new Vector3(-0.3f, 0.75f + Mathf.Sin(_runfactor * 2f) * -0.05f, Mathf.Sin(_runfactor * 2f) * 0.05f), _player.viewAngle); for (int index = 0; index < entityParts.Count; index++) { _player._entityParts[index].viewAngle = _player.viewAngle; } HoldType holdType = HoldType.None; EntityPart item = GetEntityPart(PartType.Item); item.element = null; if (!_player._pickedItemContainer.blank) { Item pickingItem = _player.pickItemStack.item; item.element = pickingItem.element; holdType = pickingItem.holdType; } _handleRig.ChangeHoldState(holdType); _bodyRig.Update(deltaTime); _handleRig.Update(deltaTime); }
public PlayerGraphics(Player player) { this._player = player; _runfactor = 0f; EntityPart body = new EntityPart(player, "entityplayerbody"); EntityPart head = new ZFlipEntityPart(player, "entityplayerhead", "entityplayerheadback"); EntityPart rArm = new EntityPart(player, "entityplayerarm"); EntityPart lArm = new EntityPart(player, "entityplayerarm"); EntityPart rLeg = new EntityPart(player, "entityplayerleg1"); EntityPart lLeg = new EntityPart(player, "entityplayerleg1"); EntityPart rFoot = new EntityPart(player, "entityplayerleg2"); EntityPart lFoot = new EntityPart(player, "entityplayerleg2"); EntityPart item = new EntityPart(player, null as FAtlasElement); _bodyRig = new AnimationRigBipedal(body, head, rArm, lArm, rLeg, lLeg, rFoot, lFoot); _handleRig = new AnimationRigHandle(rArm, lArm, item); entityParts.Add(body); entityParts.Add(head); entityParts.Add(new EntityPart(player, "entityplayerscarf")); entityParts.Add(rLeg); entityParts.Add(lLeg); entityParts.Add(rFoot); entityParts.Add(lFoot); entityParts.Add(rArm); entityParts.Add(lArm); entityParts.Add(new EntityPart(player, "entityplayertail")); entityParts.Add(item); GetEntityPart(PartType.Scarf).sortZOffset = 0.6f; GetEntityPart(PartType.Body).sortZOffset = -0.5f; GetEntityPart(PartType.RLeg).sortZOffset = 0.1f; GetEntityPart(PartType.LLeg).sortZOffset = 0.1f; GetEntityPart(PartType.RFoot).sortZOffset = 0.5f; GetEntityPart(PartType.LFoot).sortZOffset = 0.5f; GetEntityPart(PartType.Item).scale = new Vector2(-1f, 1f); }
public static Attack Raise_Death(Entity e, EntityPart part, TileMap map) { // Static int width = AttackFactory.RAISE_DEATH_WIDTH, height = 8; // Changes based on entity state int x; int y = e.EBounds.Top - (height * 2); float speed = 0.175f; if (e.isFacingForward()) { x = e.EBounds.Right + (AttackFactory.RAISE_DEATH_WIDTH * 5); } else { x = e.EBounds.Left - (AttackFactory.RAISE_DEATH_WIDTH * 5); } return(new Attack(map, e, map.gameScreen.SprAttack[AttackSpriteId.Raise_Death], new Rectangle(x, y - (height / 2), width, height), (int)(80 * e.Stats.AttackPower), speed, TileMap.SPRITE_SIZE, false)); }
public static Attack Scurge_Shot(Entity e, EntityPart part, TileMap map) { // Static int width = 20, height = 8; // Changes based on entity state int x; int y = e.EBounds.getFireFrom(part); float speed = 0.15f; if (e.isFacingForward()) { x = e.EBounds.Right + 1; } else { speed *= -1; x = e.EBounds.Left - width - 1; } return(new Attack(map, e, map.gameScreen.SprAttack[AttackSpriteId.Scurge_Shot], new Rectangle(x, y - (height / 2), width, height), (int)(80 * e.Stats.AttackPower), speed, 200)); }
public int hitInThe(EntityPart part, int dmg, float reducer) { showHpTicks = HP_BAR_SHOW_MS; lastHitPart = part; int realDmg = 0; if (part == EntityPart.Legs) { realDmg = (int)(dmg * Stats.TLegsMultiplier); } else if (part == EntityPart.Head) { realDmg = (int)(dmg * Stats.THeadMultiplier); } else if (part == EntityPart.Body) { realDmg = (int)(dmg * Stats.TBodyMultiplier); } realDmg = (int)(realDmg * reducer); Stats.addHp(-realDmg); return(realDmg); }
public Rectangle getRectFromPart(EntityPart part) { if (part == EntityPart.Body) return body; else if (part == EntityPart.Head) return head; else if (part == EntityPart.Legs) return legs; return ZERO_RECT; }
public int getFireFrom(EntityPart part) { if (part == EntityPart.Legs) return legs.Top + 1; else if (part == EntityPart.Head) return head.Center.Y; else return body.Center.Y; }
public Entity(SerializationInfo info, StreamingContext cntxt) : base(info, cntxt) { Name = (string) info.GetValue("Entity_Name", typeof(string)); Equipment = (Equipment) info.GetValue("Entity_Equipment", typeof(Equipment)); Stats = (EntityStats) info.GetValue("Entity_Stats", typeof(EntityStats)); XPValue = (int) info.GetValue("Entity_XPValue", typeof(int)); facing = (Direction) info.GetValue("Entity_Facing", typeof(Direction)); MAX_SPEED = (float) info.GetValue("Entity_MaxSpeed", typeof(float)); msVel = (Vector2) info.GetValue("Entity_MsVel", typeof(Vector2)); bounds = (EntityBounds) info.GetValue("Entity_EBounds", typeof(EntityBounds)); State = (EntityState) info.GetValue("Entity_State", typeof(EntityState)); // Init entity in loaded classes Stats.setEntity(this); EBounds.setEntity(this); Equipment.setEntity(this); // Un-saved values GScreen = (GameScreen) ScreenManager.getScreen(ScreenId.Game); lastHitPart = EntityPart.Body; jumpDelay = attackDelay = showHpTicks = 0; speedMultiplier = MAX_SPEED; pDrops = new PossibleDrop[0]; sprite.setFrame(250, 3); }
public Attack attack(EntityPart part) { return(this.attack(part, AttackFactory.Scurge_Shot)); }
public AnimationRigQuadrupedal(EntityPart body, EntityPart head) : base() { _body = body; _head = head; }
public EntityHit(EntityPart part, float percFromCenter) { Part = part; PercFromCenter = percFromCenter; }
public int hitInThe(EntityPart part, int dmg, float reducer) { showHpTicks = HP_BAR_SHOW_MS; lastHitPart = part; int realDmg = 0; if (part == EntityPart.Legs) realDmg = (int)(dmg * Stats.TLegsMultiplier); else if (part == EntityPart.Head) realDmg = (int)(dmg * Stats.THeadMultiplier); else if (part == EntityPart.Body) realDmg = (int) (dmg * Stats.TBodyMultiplier); realDmg = (int) (realDmg * reducer); Stats.addHp(-realDmg); return realDmg; }
//------------------------------------------------------------------------------------------------------- public void AddPart(EntityPart enPart) { int entityPart = (int)enPart; if (m_Parts.ContainsKey(entityPart)) { return; } switch (enPart) { case EntityPart.Skill: // 技能 { ISkillSystem skillSys = EntitySystem.m_ClientGlobal.GetSkillSystem(); if (skillSys == null) { //编辑器模式不需要 break; } ISkillPart skillPart = skillSys.CreateSkillPart(); if (skillPart == null) { return; } if (!skillPart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); skillPart = null; return; } m_Parts[entityPart] = skillPart; break; } case EntityPart.Buff: // Buff { ISkillSystem skillSys = EntitySystem.m_ClientGlobal.GetSkillSystem(); if (skillSys == null) { //编辑器模式不需要 break; } IBuffPart buffpart = skillSys.CreateBuffPart(); if (buffpart == null) { return; } if (!buffpart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); buffpart = null; return; } m_Parts[entityPart] = buffpart; break; } case EntityPart.Equip: // Equip 装备 { IEquipPart equipPart = new EquipPart(); if (equipPart == null) { return; } if (!equipPart.Create(this)) { Engine.Utility.Log.Error("AddPart failed!"); equipPart = null; return; } m_Parts[entityPart] = equipPart; break; } } }
/// <summary> /// When overridden in a subclass, allows custom processing to occur on the SPFile/EntityPart that is retrieved from SharePoint. /// </summary> /// <param name="containerTitle"></param> /// <param name="entityId"></param> /// <param name="entityPartFile"></param> /// <param name="entity"></param> /// <param name="partName"></param> protected virtual void ProcessEntityPartFile(string containerTitle, Guid entityId, string partName, SPFile entityPartFile, EntityPart entity) { //Does nothing in the base implementation. }
public EntityHit(EntityPart part, float percFromCenter, Direction knockBack) { Part = part; PercFromCenter = percFromCenter; KnockBack = knockBack; }
public Attack attack(EntityPart part) { return(this.attack(part, AttackFactory.Raise_Death)); }
public Attack attack(EntityPart part) { return(this.attack(part, AttackFactory.Fireball)); }
public Attack attack(TileMap map, EntityPart part, Func<Entity, EntityPart, TileMap, Attack> factoryFunc) { if (canAttack()) { Attack a = factoryFunc(this, part, map); map.addAttack(a); attackDelay = ATTACK_DELAY_MS; return a; } return null; }