// TODO: use database ID for edit public EditRegularItemVM(bool _IsIncome, bool _IsAdd, int _RegularItemId) // _RegularItemId could be NEW_REGULAR_ITEM_ID { m_IsIncome = _IsIncome; string action = _IsAdd ? "Add" : "Update"; string direction = _IsIncome ? "Income" : "Expense"; Header = string.Format("{0} {1}", action, direction); HeaderColor = _IsIncome ? "ForestGreen" : "DarkRed"; EditButtonText = string.Format("{0} {1}", action, direction); if (_RegularItemId != RegularItemVM.NEW_REGULAR_ITEM_ID) { RegularItemId = _RegularItemId; RegularStorage db = new RegularStorage(); RegularItem ri = db.GetRegular(_RegularItemId); this.Name = ri.Name; this.Amount = DataConversion.ConvertCentsToCurrency(Math.Abs(ri.Amount)).ToString(); SetPeriod(ri.Period); } else { RegularItemId = RegularItemVM.NEW_REGULAR_ITEM_ID; Name = ""; Amount = ""; SetPeriod(REGULARS_PERIOD.YEARLY); } }
// DB access-constructor public RegularItemVM(int _Id) { RegularStorage db = new RegularStorage(); RegularItem ri = db.GetRegular(_Id); InitializeRegularItem(ri.Id, ri.Name, ri.Amount, ri.Period); }
private void EquipItem() { RegularItem tmpItem = (Instantiate(GameManager.PrefabDictionary["spear"]) as GameObject).GetComponent <RegularItem>(); if (!MountItem(tmpItem, CreatureBodyBones.Right_Arm_Part_2)) { DestroyImmediate(tmpItem.gameObject); } }
// Insert the new contact in the Contacts table. public RegularItem GetRegular(int _RegularItemID) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { RegularItem regularItem = conn.Table <RegularItem>().Where((v) => (v.Id == _RegularItemID)).FirstOrDefault(); return(regularItem); } }
//Update existing conatct public void UpdateRegular(RegularItem _RegularItem) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Update(_RegularItem); }); } }
//Delete specific contact public void DeleteRegular(int _RegularItemID) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { RegularItem ri = new RegularItem(_RegularItemID, "", REGULARS_PERIOD.DAYLY, 0); conn.Delete(ri); }); } }
public override void Enter(Character character, RegularItem regularItem, int bodyPartID) { // set fields this.character = character; this.regularItem = regularItem; this.bodyPartID = bodyPartID; // do animation stuff //Debug.Log("STARTING AT THE IDLE"); character.CharacterAnimator.SetTrigger( regularItem.ItemAnimation[bodyPartID].equipTrigger); character.CharacterAnimator.SetInteger( regularItem.ItemAnimation[bodyPartID].itemState, (int)ItemState.Idle); }
public override void Enter(Character character, RegularItem regularItem, int bodyPartID) { // set fields this.character = character; this.regularItem = regularItem; this.bodyPartID = bodyPartID; // register with animator animationEventHandler.animationCallbacks += AnimationCallback; // do animation stuff character.CharacterAnimator.SetInteger( regularItem.ItemAnimation[bodyPartID].itemState, (int)ItemState.Executing); }
public override void Enter(Character character, RegularItem regularItem, int bodyPartID) { // set fields this.character = character; this.regularItem = regularItem; this.bodyPartID = bodyPartID; //Debug.Log("enter aim"); // register with animator animationEventHandler.animationCallbacks += AnimationCallback; // do animation stuff //checkingForTime = false; character.CharacterAnimator.SetInteger( regularItem.ItemAnimation[bodyPartID].itemState, (int)ItemState.Aim); }
/// <summary> /// Use this when you want to break out of any state. /// </summary> public void BreakState() { // set to idle character.CharacterAnimator.SetInteger( regularItem.ItemAnimation[bodyPartID].itemState, (int)ItemState.Idle); // unequip character.CharacterAnimator.SetTrigger( regularItem.ItemAnimation[bodyPartID].unequipTrigger ); // unregister callback (must be handled by class child) //animationEventHandler.animationCallbacks -= AnimationCallback; Exit(); // set item to null regularItem = null; DestroyImmediate(this); }
/// <summary> /// Mounts an item to the first open mount point. /// </summary> /// <param name="itemToMount">Item to mount to this character.</param> /// <returns>True if the item mounted successfully, otherwise false.</returns> public bool MountItem(RegularItem itemToMount) { // look for empty mount point MountPoint[] mountPoints = GetComponentsInChildren <MountPoint>(); // if slots are full, return false! for (int i = 0; i < mountPoints.Length; ++i) { if (itemToMount.MountTo(mountPoints[i]) != null) { ItemIdle itemStateIdle = ScriptableObject.CreateInstance <ItemIdle>(); itemStateIdle.Enter(this, itemToMount, mountPoints[i].BodyPartType); bodyPartStates[mountPoints[i].BodyPartType] = itemStateIdle; return(true); } } // return true, we did it reddit! return(false); }
/// <summary> /// Mounts a given item to a provided body part type if that joint's mount /// point is empty. /// </summary> /// <param name="itemToMount">Item to mount to this character.</param> /// <param name="bodyPartType">Body part ID to mount this item to.</param> /// <returns>True if the item mounted successfully, otherwise false.</returns> public bool MountItem(RegularItem itemToMount, int bodyPartType) { // ensure joint exists if (!joints.ContainsKey(bodyPartType)) { return(false); } // ensure body part is attached BodyPart attachedBodyPart; if ((attachedBodyPart = joints[bodyPartType].BodyPart) == null) { return(false); } // ensure mount point exists if (attachedBodyPart.MountPoint == null) { return(false); } // mount it if (itemToMount.MountTo(attachedBodyPart.MountPoint) == null) { return(false); } // call animator to equip ItemIdle itemStateIdle = ScriptableObject.CreateInstance <ItemIdle>(); itemStateIdle.Enter(this, itemToMount, bodyPartType); bodyPartStates[bodyPartType] = itemStateIdle; return(true); }
public Map(Player player) { ship = new Ship(3); startInShip = new Location(); Location outsideShip = new Location(); Location cave = new Location(); Location forest = new Location(); Location town = new Location(); Location tavern = new Location(); Location scrapyard = new Location(); Location market = new Location(); locations = new List <Location>(); locations.Add(startInShip); locations.Add(outsideShip); locations.Add(cave); locations.Add(forest); locations.Add(town); locations.Add(tavern); locations.Add(scrapyard); locations.Add(market); //items RegularItem todolist = new RegularItem(1, "todolist", ship.GetStatus()); Debug.Log("ship : " + ship.GetStatus()); RegularItem flower = new RegularItem(2, "flower", "It's a beautiful flower"); ConsumableItem potion = new ConsumableItem(3, "potion", "recover 5 hp", 5, player); items = new List <Item>(); items.Add(todolist); items.Add(potion); //quests Quest bobsFlower = new Quest(player, flower, potion, "Bob wants a flower for his wife."); //npcs NPC bob = new NPC(1, "Bob"); bob.Intro = "Hi foreigner ! I'm Bob."; bob.addDialog("info", "This town is a good place if you want to find some scraps." + "\r\nBe careful, there is an evil citizen !"); bob.addDialog("request", "Today it's my wife birthday. Can you bring me some flower ?", bobsFlower); //Item todoList startInShip.name = "In Ship"; // ship.SetStatus(3); Debug.Log(ship.GetStatus()); startInShip.exitSouth = outsideShip; startInShip.pickupables = new List <Item>(); startInShip.pickupables.Add(todolist); startInShip.descriptions = new string[] { "This is your ship, it looks damaged. Maybe there is something you can do to repair it.\nYou hear a buzz and notice your computer has printed out a piece of paper before shutting off completely.", "If somehow i could find out what's wrong with this ship", "There is no way i am getting off this planet right now." }; startInShip.shortDesc = "This is your ship."; outsideShip.name = "Outside Ship"; outsideShip.exitNorth = startInShip; outsideShip.exitSouth = cave; outsideShip.exitWest = forest; outsideShip.exitEast = town; outsideShip.pickupables = new List <Item>(); outsideShip.descriptions = new string[] { "You are outside your ship." }; outsideShip.shortDesc = "The land around you is barren. Maybe you should explore."; outsideShip.monster = new Monster("Evil Guard", 10, 0, 2); cave.name = "Cave"; cave.exitNorth = outsideShip; cave.pickupables = new List <Item>(); cave.descriptions = new string[] { "You come across a dark cave. You can't see anything without a light." }; cave.shortDesc = ""; cave.monster = new Monster("Cave troll", 13, 1, 3); forest.name = "Forest"; forest.exitEast = outsideShip; forest.pickupables = new List <Item>(); forest.descriptions = new string[] { "You arrive at a seeminly endless forest. It doesnt seem save to traverse unprepared." }; forest.shortDesc = ""; forest.pickupables.Add(flower); forest.monster = new Monster("Enchanted tree", 7, 0, 1); town.name = "Town"; town.exitWest = outsideShip; town.exitNorth = market; town.exitSouth = scrapyard; town.exitEast = tavern; town.pickupables = new List <Item>(); town.descriptions = new string[] { "You reach a small, but busy town." }; town.shortDesc = ""; town.npc = bob; town.shortDesc = ""; town.monster = new Monster("Evil Citizen", 10, 0, 3); //// //// market.name = "Market"; market.exitSouth = town; market.pickupables = new List <Item>(); market.descriptions = new string[] { "You arrive at a small town market. You see 4 market stalls." }; market.shortDesc = ""; market.monster = new Monster("Mad Seller", 15, 0, 1); tavern.name = "Tavern"; tavern.exitWest = town; tavern.pickupables = new List <Item>(); tavern.descriptions = new string[] { "You step inside the taven." }; tavern.shortDesc = ""; tavern.monster = new Monster("Cyclope", 10, 0, 6); scrapyard.name = "Scrapyard"; scrapyard.exitNorth = town; scrapyard.pickupables = new List <Item>(); scrapyard.descriptions = new string[] { "You Walk into the scarpyard." }; scrapyard.shortDesc = ""; scrapyard.monster = new Monster("scrap dealer", 12, 0, 4); }
public abstract void Enter(Character character, RegularItem regularItem, int bodyPartID);
private void RecalculateCollisionBounds(ref Bounds currentBounds, GameObject currentBodyPart) { // make sure not a regular item (i.e. something that wont be ATTACHED like a bodypart) RegularItem regularItem = currentBodyPart.GetComponent <RegularItem>(); if (regularItem != null) { return; } // QUICK FIX TODO DELETE BodyPart currBPart = currentBodyPart.GetComponent <BodyPart>(); if (currBPart != null && (currBPart.BodyPartType == CreatureBodyBones.Left_Arm || currBPart.BodyPartType == CreatureBodyBones.Right_Arm)) { return; } if (currentBodyPart.GetComponent <Cloth>() != null) { return; } //Debug.Log("Added: " + currentBodyPart.name); // keep last local rot Quaternion currLocalRot = currentBodyPart.transform.localRotation; currentBodyPart.transform.localRotation = Quaternion.Euler(0f, 0f, 0f); if (currentBodyPart.transform.childCount != 0) { foreach (Transform child in currentBodyPart.transform) { RecalculateCollisionBounds(ref currentBounds, child.gameObject); } } // attempt to get MeshFilter // TODO OR ASK FOR MESHFILTER IN FUNCTION AS WE CAN DO MESHFILTER.TRANSFORM MeshFilter tmpMeshFilter = currentBodyPart.GetComponent <MeshFilter>(); if (tmpMeshFilter == null) { return; } Bounds newBounds = currentBodyPart.GetComponent <MeshFilter>().mesh.bounds; // GET CENTER OF MESH // DIV BY LOCAL SCALE TO MOVE CENTER TO APPROPRIATE POSITION... // !!!!!! THIS IS WHY EVERYTHING SHOULD IMPORT AT 1 1 1 SCALE !!!!!!! // RENDERER CENTER BOUNDS ARE LOCAL // FIND A WAY TO GET TRUE CENTER ANOTHER WAY (this is because it is in world space and NOT local. //newBounds.center = transform.InverseTransformPoint(currentBodyPart.transform.TransformPoint(newBounds.center)); newBounds.center = transform.InverseTransformPoint(currentBodyPart.transform.TransformPoint(newBounds.center)); currentBounds.Encapsulate(newBounds); // put back rotation after all have been processed? currentBodyPart.transform.localRotation = currLocalRot; }