/* Renders the actor's PaperDoll slots. */ void RenderEquipment(int x, int y) { if (manager.actor.doll == null) { return; } int iw = Width() / 4; int ih = Height() / 20; string str; PaperDoll doll = manager.actor.doll; Data eq = doll.Peek(PaperDoll.HEAD); str = "Head : " + (eq != null ? eq.displayName : ""); if (Button(str, x, y, iw, ih, 0, -5)) { doll.Store(PaperDoll.HEAD); } eq = manager.actor.doll.Peek(PaperDoll.TORSO); str = "Torso : " + (eq != null ? eq.displayName : ""); if (Button(str, x, y + ih, iw, ih, 0, -4)) { doll.Store(PaperDoll.TORSO); } eq = manager.actor.doll.Peek(PaperDoll.LEGS); str = "Legs : " + (eq != null ? eq.displayName : ""); if (Button(str, x, y + 2 * ih, iw, ih, 0, -3)) { doll.Store(PaperDoll.LEGS); } }
public Data(Data dat) { if (dat == null) { return; } readyToRead = dat.readyToRead; prefabName = dat.prefabName; displayName = dat.displayName; x = dat.x; y = dat.y; z = dat.z; xr = dat.xr; yr = dat.yr; zr = dat.zr; itemType = dat.itemType; stack = dat.stack; stackSize = dat.stackSize; lastPos = dat.lastPos; baseValue = dat.baseValue; ints = dat.ints; strings = dat.strings; floats = dat.floats; inventoryRecord = dat.inventoryRecord; bools = dat.bools; speechTree = dat.speechTree; equipSlot = dat.equipSlot; doll = dat.doll; }
//This prevents multiple sync requests per frame to 'stack'. only one sync per frame should happen. void SyncPaperDoll(PaperDoll pd) { if (syncing) { return; } StartCoroutine(ReallySync(pd)); }
/* Before Start */ void Awake() { body = gameObject; inventory = new Inventory(); arms = new EquipSlot(offHand, hand, this); doll = new PaperDoll(this); arms.actor = this; stats = new StatHandler(this); }
public void UpdateWindow(UserInterfaceWindow window, PaperDoll paperDoll) { this.window = window; this.paperDoll = paperDoll; if (paperDoll != null) { this.backgroundPanel = (Panel)GetFieldValue("backgroundPanel", paperDoll); } }
public Data() { ints = new List <int>(); strings = new List <string>(); floats = new List <float>(); inventoryRecord = null; bools = new List <bool>(); speechTree = null; equipSlot = null; doll = null; }
/* Deligates to actor */ void Equip(int slot, bool primary) { int status = inv.GetStatus(slot); PaperDoll doll = manager.actor.doll; Data dat = null; if (status == Inventory.EMPTY) { return; } else if (status == Inventory.STORED) { manager.actor.Equip(slot); } else { switch (status) { case Inventory.PRIMARY: arms.Store(EquipSlot.RIGHT); break; case Inventory.SECONDARY: arms.Store(EquipSlot.LEFT); break; case Inventory.HEAD: dat = doll.Peek(PaperDoll.HEAD); if (dat != null) { doll.Store(PaperDoll.HEAD); } break; case Inventory.TORSO: dat = doll.Peek(PaperDoll.HEAD); if (dat != null) { doll.Store(PaperDoll.TORSO); } break; case Inventory.LEGS: dat = doll.Peek(PaperDoll.HEAD); if (dat != null) { doll.Store(PaperDoll.LEGS); } break; } } }
/* Loads data not specified for this prefab for this Actor */ public void LoadData(Data dat) { displayName = dat.displayName; transform.position = new Vector3(dat.x, dat.y, dat.z); transform.rotation = Quaternion.identity; headRotx = dat.xr; headRoty = dat.yr; bodyRoty = dat.yr; int i = 0; arms = dat.equipSlot; doll = dat.doll; arms.Load(offHand, hand, this); inventory.LoadData(dat.inventoryRecord); id = dat.ints[i]; i++; lastPos = dat.lastPos; speechTree = dat.speechTree; }
IEnumerator ReallySync(PaperDoll pd) { yield return(new WaitForEndOfFrame()); foreach (EquipmentAnimatorMapping mapping in animators) { Equipment equipped = null; // Debug.Log ("Syncing " + mapping.type + " animation " + " pd slots size: " + pd.slots.Count); if (pd.slots.TryGetValue(mapping.type, out equipped)) { // if (equipped == null) // Debug.LogError ("equipped is null for " + mapping.type); // else // Debug.Log ("equipped is not null for " + mapping.type + ". YAY!"); if (equipped is GenericWeapon && mapping.type == EquipmentSlotType.OFF_HAND) { GenericWeapon wep = equipped as GenericWeapon; ChangeOutAnimation(mapping.type, wep.OffhandAnimationControllerName); } else { ChangeOutAnimation(mapping.type, equipped.AnimationControllerName); } } else { ClearAnimation(mapping.type); } } if (GetComponent <AT.Battle.Actor> ().CharSheet.race != null) //can be null in some test apps. // Debug.Log("SYCNGIL!: " + GetComponent<AT.Battle.Actor> ().CharSheet.race.BodyAnimationOverride); { ChangeOutAnimation(EquipmentSlotType.BODY_OVERRIDE, GetComponent <AT.Battle.Actor> ().CharSheet.race.BodyAnimationOverride); } else { Debug.LogWarning(GetComponent <AT.Battle.Actor> ().CharSheet.Name + " has no race. Are you just testing something? "); } syncing = false; }
/* Unequips item found at this index. */ void UnequipByIndex(int index) { Inventory inv = manager.actor.inventory; int status = inv.GetStatus(index); PaperDoll doll = manager.actor.doll; switch (status) { case Inventory.PRIMARY: manager.actor.arms.Store(EquipSlot.RIGHT); break; case Inventory.SECONDARY: manager.actor.arms.Store(EquipSlot.LEFT); break; case Inventory.HEAD: doll.Store(PaperDoll.HEAD); break; case Inventory.TORSO: doll.Store(PaperDoll.TORSO); break; case Inventory.LEGS: doll.Store(PaperDoll.LEGS); break; } }
public BackgroundScreen(UserInterfaceWindow window, PaperDoll paperDoll) { UpdateWindow(window, paperDoll); }
void Start() { paperDoll = GetComponent<PaperDoll>(); body = GetComponent<Rigidbody2D>(); }
//Green text. Function here. public Player(ContentManager sCont, gridCoordinate sGridCoord, ref List<string> msgBuffer, Chara_Class myClass, Character myChara, ref PaperDoll pd) { //Constructor stuff cont = sCont; my_grid_coord = new gridCoordinate(sGridCoord); my_Position = new Vector2(sGridCoord.x * 32, sGridCoord.y * 32); rGen = new Random(); message_buffer = msgBuffer; //!Constructor stuff my_gold = 0; base_smell_value = 10; base_sound_value = 10; //Player stuff my_class = myClass; my_character = myChara; base_hp = 3; if (my_character == Character.Belia) base_hp++; //Belia gets +60 HP to all of her body parts. switch (my_character) { case Character.Falsael: my_Texture = cont.Load<Texture2D>("Player/falsael_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/falsael_dead"); break; case Character.Petaer: my_Texture = cont.Load<Texture2D>("Player/petaer_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/petaer_dead"); break; case Character.Ziktofel: my_Texture = cont.Load<Texture2D>("Player/ziktofel_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/ziktofel_dead"); break; case Character.Halephon: my_Texture = cont.Load<Texture2D>("Player/halephon_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/halephon_dead"); break; case Character.Belia: my_Texture = cont.Load<Texture2D>("Player/belia_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/belia_sprite"); break; default: my_Texture = cont.Load<Texture2D>("Player/lmfaoplayer"); my_dead_texture = cont.Load<Texture2D>("Player/playercorpse"); break; } //Health stuff. Head = new Limb(ref rGen, "Head", "Head", base_hp - 2); Torso = new Limb(ref rGen, "Chest", "Chest", base_hp); R_Arm = new Limb(ref rGen, "Right Arm", "RArm", base_hp); L_Arm = new Limb(ref rGen, "Left Arm", "LArm", base_hp); R_Leg = new Limb(ref rGen, "Right Leg", "RLeg", base_hp); L_Leg = new Limb(ref rGen, "Left Leg", "LLeg", base_hp); calculate_dodge_chance(); //Inventory stuff inventory = new List<Item>(); reserved_potion_ids = new List<Tuple<int, int>>(); for(int i = 1; i <= 3; i++) reserved_potion_ids.Add(new Tuple<int,int>(i, new_random_ID_number())); add_starting_gear(); //Character stuff BuffDebuffTracker = new List<StatusEffect>(); pDoll = pd; normal_backing = Color.White; invis_backing = new Color(255, 255, 255, 75); }
public Player(ContentManager sCont, ref List<string> msgBuffer, ref PaperDoll pd, PlayerDC raw_player) { //Constructor stuff cont = sCont; my_grid_coord = new gridCoordinate(raw_player.Player_GC_X, raw_player.Player_GC_Y); my_Position = new Vector2(raw_player.Player_GC_X * 32, raw_player.Player_GC_Y * 32); rGen = new Random(); message_buffer = msgBuffer; //!Constructor stuff my_gold = raw_player.Player_Gold; lifetime_gold = raw_player.Player_Lifetime_Gold; base_smell_value = 10; base_sound_value = 10; //Player stuff my_class = ((Chara_Class)Enum.Parse(typeof(Chara_Class), raw_player.Chara_Class)); my_character = ((Character)Enum.Parse(typeof(Character), raw_player.Character)); switch (my_character) { case Character.Falsael: my_Texture = cont.Load<Texture2D>("Player/falsael_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/falsael_dead"); break; case Character.Petaer: my_Texture = cont.Load<Texture2D>("Player/petaer_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/petaer_dead"); break; case Character.Ziktofel: my_Texture = cont.Load<Texture2D>("Player/ziktofel_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/ziktofel_dead"); break; case Character.Halephon: my_Texture = cont.Load<Texture2D>("Player/halephon_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/halephon_dead"); break; case Character.Belia: my_Texture = cont.Load<Texture2D>("Player/belia_sprite"); my_dead_texture = cont.Load<Texture2D>("Player/belia_sprite"); break; default: my_Texture = cont.Load<Texture2D>("Player/lmfaoplayer"); my_dead_texture = cont.Load<Texture2D>("Player/playercorpse"); break; } //Health stuff. base_hp = raw_player.Base_Health; BuffDebuffTracker = new List<StatusEffect>(); Head = new Limb(raw_player.Limbs[0]); Torso = new Limb(raw_player.Limbs[1]); R_Arm = new Limb(raw_player.Limbs[2]); L_Arm = new Limb(raw_player.Limbs[3]); R_Leg = new Limb(raw_player.Limbs[4]); L_Leg = new Limb(raw_player.Limbs[5]); //Inventory stuff inventory = new List<Item>(); reserved_potion_ids = new List<Tuple<int, int>>(); //WILL NEED TO FIGURE THESE OUT. for (int i = 0; i < raw_player.Reserved_Potion_Code.Count; i++) reserved_potion_ids.Add(new Tuple<int, int>(raw_player.Reserved_Potion_Code[i], raw_player.Reserved_Potion_ID[i])); for (int i = 0; i < raw_player.Armors_In_Inv.Count; i++) inventory.Add(new Armor(raw_player.Armors_In_Inv[i])); for (int i = 0; i < raw_player.Potions_In_Inv.Count; i++) acquire_potion(new Potion(raw_player.Potions_In_Inv[i])); for (int i = 0; i < raw_player.Scrolls_In_Inv.Count; i++) inventory.Add(new Scroll(raw_player.Scrolls_In_Inv[i])); for (int i = 0; i < raw_player.Weapons_In_Inv.Count; i++) inventory.Add(new Weapon(raw_player.Weapons_In_Inv[i])); //Equipped Items Weapon next_mh = null; if (raw_player.Main_Hand != null) { next_mh = new Weapon(raw_player.Main_Hand); equip_main_hand(next_mh); } Weapon next_oh = null; if (raw_player.Off_Hand != null) { next_oh = new Weapon(raw_player.Off_Hand); equip_off_hand(next_oh); } Armor next_helmet = null; if (raw_player.Helmet != null) { next_helmet = new Armor(raw_player.Helmet); equip_armor(next_helmet); } Armor next_OA = null; if (raw_player.Over_Armor != null) { next_OA = new Armor(raw_player.Over_Armor); equip_armor(next_OA); } Armor next_UA = null; if (raw_player.Under_Armor != null) { next_UA = new Armor(raw_player.Under_Armor); equip_armor(next_UA); } //Character stuff base_smell_value = raw_player.Player_Base_Smell; base_sound_value = raw_player.Player_Base_Sound; c_energy = raw_player.Player_Current_Energy; max_energy = raw_player.Player_Max_Energy; calculate_dodge_chance(); pDoll = pd; normal_backing = Color.White; invis_backing = new Color(255, 255, 255, 75); }
public override void Render() { Box("", XOffset(), 0, Width(), Height()); // Background int ah = Height() / 14; // Attribute height int aw = Width() / 6; // Attribute width int aOff = (int)(3.5 * ah); // y Offset for attributes int sh = Height() / 6; // Skill height int sOff = 2 * aw + XOffset(); // x offset for skills string str = ""; // Render navigation buttons. str = "Abilities"; if (Button(str, XOffset(), Height() / 4, aw, Height() / 2, -1)) { manager.Change("ABILITY"); } str = "Quests"; if (Button(str, XOffset() + 5 * aw, Height() / 4, aw, Height() / 2, 1)) { manager.Change("QUEST"); } Actor actor = manager.actor; if (actor == null || actor.stats == null) { return; } StatHandler stats = actor.stats; // Render attribute column PaperDoll doll = manager.actor.doll; str = "Intelligence: " + stats.intelligence; Box(str, XOffset() + aw, aOff + 0, aw, ah); str = "Charisma: " + stats.charisma; Box(str, XOffset() + aw, aOff + ah, aw, ah); str = "Endurance: " + stats.endurance; Box(str, XOffset() + aw, aOff + 2 * ah, aw, ah); str = "Perception: " + stats.perception; Box(str, XOffset() + aw, aOff + 3 * ah, aw, ah); str = "Agility: " + stats.agility; Box(str, XOffset() + aw, aOff + 4 * ah, aw, ah); str = "Willpower: " + stats.willpower; Box(str, XOffset() + aw, aOff + 5 * ah, aw, ah); str = "Strength: " + stats.strength; Box(str, XOffset() + aw, aOff + 6 * ah, aw, ah); str = "Level: " + stats.level; Box(str, XOffset() + aw, 0, aw, ah); str = "XP: " + stats.xp; Box(str, XOffset() + aw, ah, aw, ah); str = "Next level: " + stats.nextLevel; Box(str, XOffset() + aw, 2 * ah, aw, ah); // Render Skills str = "Remaining Skill Points: " + stats.skillPoints; Box(str, sOff, 0, aw, sh); str = "Ranged: " + stats.ranged; if (Button(str, sOff, sh, aw, sh, 0, 0)) { if (stats.skillPoints > 0 && stats.ranged < 100) { stats.skillPoints--; stats.ranged++; Sound(0); } } str = "Melee: " + stats.melee; if (Button(str, sOff, 2 * sh, aw, sh, 0, 1)) { if (stats.skillPoints > 0 && stats.melee < 100) { stats.skillPoints--; stats.melee++; Sound(0); } } str = "Unarmed: " + stats.unarmed; if (Button(str, sOff, 3 * sh, aw, sh, 0, 2)) { if (stats.skillPoints > 0 && stats.unarmed < 100) { stats.skillPoints--; stats.unarmed++; Sound(0); } } str = "Magic: " + stats.magic; if (Button(str, sOff, 4 * sh, aw, sh, 0, 3)) { if (stats.skillPoints > 0 && stats.magic < 100) { stats.skillPoints--; stats.magic++; Sound(0); } } str = "Stealth: " + stats.stealth; if (Button(str, sOff, 5 * sh, aw, sh, 0, 4)) { if (stats.skillPoints > 0 && stats.stealth < 100) { stats.skillPoints--; stats.stealth++; Sound(0); } } }
public TestSerialization() : base() { Test("That can serialize inventory items safely and correctly", () => { Sheet c = new Sheet(); Assert(c.inventory != null); c.inventory.items[0] = new GenericArmour(EquipmentSubtype.ARMOUR_CHAINMAIL); c.inventory.items[1] = new GenericWeapon(EquipmentSubtype.SIMPLE_DAGGER); Manager.Serialize(c, TestPath); Sheet after = Manager.Deserialize <Sheet>(TestPath); Assert(after.inventory != null); Assert(after.inventory.items != null); GenericArmour arm = after.inventory.items[0] as GenericArmour; GenericWeapon wep = after.inventory.items[1] as GenericWeapon; Assert(arm.Subtype == EquipmentSubtype.ARMOUR_CHAINMAIL); Assert(wep.Subtype == EquipmentSubtype.SIMPLE_DAGGER); }); Test("That CanSerializeAFeatureFromAndToSubclass", () => { //create a subclass instance of a feature PerLevelHitPoints flhp = new PerLevelHitPoints(10, ClassType.FIGHTER); string path = Application.persistentDataPath + Path.DirectorySeparatorChar + "test123"; Manager.Serialize(flhp, path); //System.Type t = System.Type.GetType ("AT.Characters.FirstLevelHitPointsWrapper"); GenericFeature f = Manager.Deserialize <GenericFeature> (path); File.Delete(path); Sheet c = new Sheet(); int before = c.HitPoints; f.WhenActivatedOn(c); Assert(c.HitPoints != before); //create a subclass instance of a feature GaugeMod ability = new GaugeMod("dexterity", 10, "bullshit", true); Manager.Serialize(ability, TestPath); //System.Type t = System.Type.GetType ("AT.Characters.FirstLevelHitPointsWrapper"); GenericFeature hamburgerFlip = Manager.Deserialize <GenericFeature> (TestPath); // Debug.Log ("hf: " + hamburgerFlip.GetType()); File.Delete(path); GaugeMod ab = (GaugeMod)hamburgerFlip; Assert(ab.isBase); Sheet cheese = new Sheet(); int before1 = cheese.Dexterity; ab.WhenActivatedOn(cheese); // Debug.Log ("prop aft" + cheese.GaugeByName("dexterity").ModifiedCurrent); Assert(cheese.Dexterity != before1); }); Test("that CanSerializeFeatureBundle", () => { ClassLevel5e fb = new ClassLevel5e(ClassType.CLERIC, 0); fb.features.Add(new PerLevelHitPoints(10, ClassType.FIGHTER)); fb.features.Add(new PerLevelHitPoints(4, ClassType.CLERIC)); fb.features.Add(new PerLevelHitPoints(1, ClassType.ROGUE)); string path = Application.persistentDataPath + Path.DirectorySeparatorChar + "Test"; Manager.Serialize(fb, path); ClassLevel5e unse = Manager.Deserialize <ClassLevel5e> (path); File.Delete(path); Assert(unse.classType == fb.classType); for (int i = 0; i < fb.features.Count; i++) { PerLevelHitPoints before = (PerLevelHitPoints)fb.features [i]; PerLevelHitPoints after = (PerLevelHitPoints)unse.features [i]; Assert(before.amount == after.amount); } }); Test("that CanSerializeWeapon", () => { GenericWeapon sword = new Longsword(); Manager.Serialize(sword, TestPath); GenericWeapon after = Manager.Deserialize <GenericWeapon> (TestPath); File.Delete(TestPath); Assert(after.Dice[0] == sword.Dice[0]); Assert(after.DamageType == sword.DamageType); Assert(after.Subtype == sword.Subtype); Assert(after.Type == sword.Type); //after.WhenEquipped (new Sheet ()); }); Test("that CanSerializeArmour", () => { GenericArmour armour = new PaddedArmour(); Manager.Serialize(armour, TestPath); GenericArmour after = Manager.Deserialize <GenericArmour> (TestPath); File.Delete(TestPath); Assert(armour.BaseAc == after.BaseAc); Assert(armour.Subtype == after.Subtype); Assert(armour.Type == after.Type); }); Test("that CanSerializePaperDoll", () => { PaperDoll pd = new PaperDoll(); pd.slots.Add(EquipmentSlotType.BODY, new PaddedArmour()); pd.slots.Add(EquipmentSlotType.MAIN_HAND, new Longsword()); pd.slots.Add(EquipmentSlotType.OFF_HAND, new Dagger()); Manager.Serialize(pd, TestPath); PaperDoll after = Manager.Deserialize <PaperDoll> (TestPath); File.Delete(TestPath); Assert(after.slots.Count == after.slots.Count); }); Test("that CanSerializeGauge", () => { Gauge g = new Gauge("hello"); Manager.Serialize(g, TestPath); Gauge after = Manager.Deserialize <Gauge> (TestPath); File.Delete(TestPath); Assert(after.ModifiedCurrent == g.ModifiedCurrent); Assert(after.ModifiedMax == g.ModifiedMax); Assert(after.Name == g.Name); }); Test("that CanSerializeRace", () => { Race r = new Race(RaceName.TIEFLING); Manager.Serialize(r, TestPath); Race after = Manager.Deserialize <Race> (TestPath); Assert(after.name == r.name); Assert(after.speed.ModifiedCurrent == r.speed.ModifiedCurrent); int i = 0; foreach (GenericFeature f in after.features) { Assert(f.Name() == r.features [i].Name()); i++; } }); Test("that CanSerializeSheet", () => { Sheet c = new Sheet(); c.race = new Race(RaceName.TIEFLING); ClassLevel5e lvl1 = new ClassLevel5e(ClassType.FIGHTER, 0); lvl1.features.Add(new FighterLevels.ArcheryFightingStyle()); lvl1.features.Add(new FighterLevels.GreatWeaponFightingStyle()); lvl1.features.Add(new FighterLevels.DuelingFightingStyle()); lvl1.features.Add(new FighterLevels.DefenseFightingStyle()); lvl1.features.Add(new FighterLevels.TwoWeaponFightingStyle()); lvl1.InitDefaultFeatures(); c.AddClassLevel(lvl1); c.ActivateFeatures(); Manager.Serialize(c, TestPath); //c.DeactivateFeatures (); Sheet after = Manager.Deserialize <Sheet> (TestPath); after.ActivateFeatures(); Debug.Log("rior " + c.HitPointsGauge.BaseModifierSum + ") " + c.HitPointsGauge.ToString() + " " + c.ToString()); Debug.Log("after " + after.HitPointsGauge.BaseModifierSum + ") " + after.HitPointsGauge.ToString() + " " + after.ToString()); Assert(after.ToString() == c.ToString()); }); }