private void OnPlayerTakesDamage(PlayerDamageEvent args) { try { SkillPlayer player = PlayerManager.GetPlayer(args.HurtPlayerIndex); SkillInformation info = player.GetSkillInformation(Name); if (info == null) { info = new SkillInformation() { Name = this.Name, Value = 0 }; player.SetSkillInformation(info); return; } if (info.Value > 0 && !args.PVP) { FireRocket(player, args.Damage, 1); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private void AddSkillPoint(CommandArgs args) { try { SkillPlayer ply = PlayerManager.GetPlayer(args.Player.Index); SkillInformation info = ply.GetSkillInformation(Name); SkillInformation newInfo; if (info == null) { newInfo = new SkillInformation() { Name = this.Name, Value = 0 } } ; else { newInfo = new SkillInformation() { Name = this.Name, Value = info.Value + 1 } }; ply.SetSkillInformation(newInfo); } catch (Exception e) { //player is not logged in Console.WriteLine(e.Message); } }
private void OnPlayerDamagesNPC(NpcDamageEvent args) { try { SkillPlayer player = PlayerManager.GetPlayer(args.PlayerIndex); SkillInformation info = player.GetSkillInformation(Name); if (info == null) { info = new SkillInformation() { Name = this.Name, Value = 0 }; player.SetSkillInformation(info); return; } if (info.Value > 0) { double ratio = Math.Min(info.Value / 20.0, 1.0); int health = (int)Math.Ceiling(ratio * args.Damage); player.Player.Heal(health); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private void FireRocket(SkillPlayer origin, int damage, int strikes) { for (int i = 0; i < strikes; i++) { int xOffset = rand.Next(-10 * strikes, 10 * strikes); int projectileIndex = Projectile.NewProjectile(origin.Player.TPlayer.position.X + xOffset, origin.Player.TPlayer.position.Y - 300, 0, 3, 207, damage, 50, origin.Player.Index, 0, 0); NetMessage.SendData(27, -1, -1, "", projectileIndex); } }
public void toggleUI(SkillPlayer player) { if (gui.isVisible()) { gui.hideSkillTreeUI(); } else { gui.showSkillTreeUI(player); } }
public void showSkillTreeUI(SkillPlayer player) { this.player = player; currentUI.hide(); if (player.hasPickedWay()) { currentUI = skillTreeUI; skillTreeInterface.SetState(skillTreeUI); } else { currentUI = choiceUI; skillTreeInterface.SetState(choiceUI); } currentUI.show(); }
// Use this for initialization void Start() { TestTimePlayer player1 = new TestTimePlayer("A"); player1.Init(new TimePlayerData(0.5f, 0, 1)); TestTimePlayer player2 = new TestTimePlayer("B"); player2.Init(new TimePlayerData(1, 0, 5)); SkillPlayer skillPlayer = new SkillPlayer(); skillPlayer.Init(new BasePlayerData(1, 0), new BasePlayer[] { player1, player2 }); skillPlayer.Start(); //Debug.Log(ReXmlSerializer.WriteToXmlDocument("SkillPlayer", skillPlayer).InnerXml); }