public override void Initialise(RoomObjectGO roomObject, ObjectInteraction objectInteraction) { Logger.Log("initalise characters options menu"); _objectInteraction = objectInteraction; RoomObject = roomObject; List <Character> possibleInteractionCharacters = CharacterManager.Instance.Characters; AddRoomObjectName(roomObject.RoomObjectBlueprint.Name); for (int i = 0; i < possibleInteractionCharacters.Count; i++) { if (!possibleInteractionCharacters[i].PossibleObjectInteractions.Contains(_objectInteraction.ObjectInteractionType)) { Logger.Log("{0} can not be done by {1}", _objectInteraction.ObjectInteractionType, possibleInteractionCharacters[i].FullName()); continue; } GameObject InteractionOptionGO = Instantiate(ObjectInteractionOptionsContainerGO.InteractionOptionPrefab, InteractionOptionsContainer.transform); InteractionOptionGO.name = CharacterNameGenerator.GetName(possibleInteractionCharacters[i].CharacterName); ObjectInteractionOptionButton objectInteractionOptionButton = CreateInteractionOptionButton(InteractionOptionGO, i, possibleInteractionCharacters.Count); objectInteractionOptionButton.SetInteractingCharacter(possibleInteractionCharacters[i]); objectInteractionOptionButton.SetInteractionOptionText(possibleInteractionCharacters[i].FullName()); } }
private void CreateRuneStone(int ItemID) { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(ItemID, 0, 0, 1, 256); GameObject myObj = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, new Vector3(64.5f, 4.0f, 24.5f)).gameObject; UnFreezeMovement(myObj); }
private void LeftOvers() { int LeftOverToCreate = -1; switch (item_id) { case 176: case 177: //meat LeftOverToCreate = 197; break; case 186: //honeycomb LeftOverToCreate = 210; break; case 187: case 188: case 189: //bottles. LeftOverToCreate = 317; break; } if (LeftOverToCreate != -1) { ObjectLoaderInfo newobjt = ObjectLoader.newObject(LeftOverToCreate, 40, 0, 0, 256); newobjt.InUseFlag = 1; ObjectInteraction created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position); GameWorldController.MoveToWorld(created.gameObject); CurrentObjectInHand = created; //UWHUD.instance.CursorIcon = created.GetInventoryDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; } }
public override bool LookAt() { //public void LookAt() //Generally gives the object description but depending on the trigger target type it may activate (lookat trigger) //GameObject triggerObj= ObjectLoader.getObjectIntAt(link).gameObject; GameObject triggerObj = ObjectLoader.getGameObjectAt(link); if (triggerObj != null) { ObjectInteraction TargetObjInt = triggerObj.GetComponent <ObjectInteraction>(); UWHUD.instance.MessageScroll.Add(StringController.instance.GetFormattedObjectNameUW(objInt())); if (TargetObjInt.GetItemType() == ObjectInteraction.A_LOOK_TRIGGER)//A look trigger. { base.LookAt(); this.Activate(this.gameObject); } else { base.LookAt(); } } else { base.LookAt(); } return(true); }
protected override void Start() { base.Start(); if (_RES == GAME_UW2) { if (SpellObjectOwnerToCreate == -1) { //This is wand with infinite charges. Does not use a spell object for it's enchantment. //Debug.Log("linking wand " + this.name + " to an existing spell"); //SpellObjectLink = ObjectLoader.getObjectIntAt(objInt().link).link; } else { if (objInt().PickedUp) { //A wand and spell in the inventory loaded from a playerdat file. Need to create it's spell object now ObjectLoaderInfo newobjt = ObjectLoader.newObject(288, SpellObjectQualityToCreate, SpellObjectOwnerToCreate, SpellObjectLink, 256); ObjectInteraction spell = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, GameWorldController.instance.LevelMarker().position); objInt().link = newobjt.index; } } } //UW2 stores enchantments on the player.dat. This is not properly implemented yet if (ObjectLoader.getObjectIntAt(objInt().link) != null) { SpellObjectLink = ObjectLoader.getObjectIntAt(objInt().link).link; } }
public string GetFormattedObjectNameUW(ObjectInteraction objInt, int Quantity) { //Eventually this will return things like proper quants etc. string output = GetString(4, objInt.item_id); if ((objInt.isQuant == true) && (objInt.isEnchanted == false)) { if (output.Contains("&")) { //string is split into a singular and plural if ((objInt.Link > 1) && (Quantity > 1)) { //Plural description output = objInt.Link + " " + output.Split('&')[1]; } else { output = output.Split('&')[0]; } } else { output = output.Replace("a_", Quantity + "_"); output = output.Replace("an_", Quantity + "_"); } } else { if (output.Contains("&")) { output = output.Split('&')[0]; } } output = output.Replace("_", " "); return(GetString(1, 260) + output); }
private void Start() { _objectInteraction = GetComponent <ObjectInteraction>(); _playerAudioSource = Camera.main.GetComponent <AudioSource>(); StartCoroutine(ActiveCheck()); }
short getDefenceAtSlot(int slot) { ObjectInteraction obj = GetObjectIntAtSlot(slot); if (obj != null) { switch (slot) { case 0: //Helm case 1: //Chest case 2: //Leggings case 3: //Boots case 4: //Gloves if (obj.GetComponent <Armour>() != null) { return(obj.GetComponent <Armour>().Protection()); } break; case 5: //rings { if (obj.GetComponent <Ring>() != null) { return(obj.GetComponent <Ring>().Protection()); } break; } case 7: //HandRight if (UWCharacter.Instance.isLefty) { return(0); } else { if (obj.GetComponent <Shield>() != null) { return(obj.GetComponent <Shield>().Protection()); } } break; case 8: //HandLeft if (!UWCharacter.Instance.isLefty) { return(0); } else { if (obj.GetComponent <Shield>() != null) { return(obj.GetComponent <Shield>().Protection()); } } break; } } return(0); }
//public int xpos; /* * Per uw-formats.txt * 018e a_check variable trap * the "value" from the set variable trap (018d) is also used here. * the trap checks a range of variables, starting from "zpos" and of * length "heading". if "xpos" is not 0, the variable values in range * are added; if it is 0, the lower 3 bits of every variable value are * shifted into the resulting value. here's some meta-C code to show * how the check works: * * bool check_variable_trap(zpos,heading,value) * { * Int16 cmp = 0; * for(Int16 i=zpos; i<zpos+heading; i++) * { * if (xpos != 0) * cmp += game_vars[i]; * else * { * cmp <<= 3; * cmp |= game_vars[i] & 7; * } * } * * return di != value * } * * The trigger associated with the trap is set off when the resulting * value is not equal the "value". * * Examples of usage * the left, right, center button combination on Level3. * */ public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { //Debug.Log (this.name); if (check_variable_trap()) { TriggerNext(triggerX, triggerY, State); PostActivate(src); } else { if (_RES == GAME_UW2) { //If linked to a null trap in UW2 the next of the null trap will act as a "false" action. ObjectInteraction nullObj = ObjectLoader.getObjectIntAt(objInt().link); //if (triggerObj.tileX==TileMap.ObjectStorageTile) if (nullObj.GetItemType() == ObjectInteraction.A_NULL_TRAP) { ObjectInteraction triggerObj = ObjectLoader.getObjectIntAt(nullObj.next); if (triggerObj != null) { if (triggerObj.GetComponent <trap_base>() != null) { triggerObj.GetComponent <trap_base>().Activate(this, triggerX, triggerY, State); PostActivate(src); } } } } } }
public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame) { try { ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(Item_ID, 40, StartFrame, 1, 256); if (newobjt != null) { ObjectInteraction objInt = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition); //objInt.GetComponent<AnimationOverlay>().Looping = false; objInt.GetComponent <AnimationOverlay>().StartFrame = StartFrame; objInt.GetComponent <AnimationOverlay>().NoOfFrames = EndFrame - StartFrame; objInt.GetComponent <AnimationOverlay>().StartingDuration = objInt.GetComponent <AnimationOverlay>().NoOfFrames; objInt.gameObject.layer = LayerMask.NameToLayer("Animation"); return(objInt.gameObject); } else { return(null); } } catch { return(null); } }
// Update is called once per frame private void Update() { if (canInteract) { SetCursor(cursorInteract); if (Input.GetButtonUp("Fire1")) { if (EventSystem.current.IsPointerOverGameObject()) // Make click not work on world objects if mouse over GUI { return; } interactableObject.InteractWithObject(); } else if (Input.GetButtonDown("Fire2")) { if (EventSystem.current.IsPointerOverGameObject()) { return; } tempInteractObjectReference = interactableObject; ShowContextMenu(); } } else { //SetCursor(cursorDefault); } }
/// <summary> /// Populates the container based on what is linked to the objInt /// </summary> /// <param name="cn">Cn.</param> /// <param name="objInt">Object int.</param> public static void PopulateContainer(Container cn, ObjectInteraction objInt, ObjectLoader objList) { //cn.ObjectsAccepted=-1;//For now default to accept all cn.Capacity = 40; for (int i = 0; i <= cn.MaxCapacity(); i++) { //init the variables. if (cn.items[i] == null) { cn.items[i] = ""; } } if (objInt.link != 0) //Container has objects { ObjectLoaderInfo tmpobj = ObjectLoader.getObjectInfoAt(objInt.link, objList); //int count = 0; if (ObjectLoader.GetItemTypeAt(objInt.link, objList) != ObjectInteraction.LOCK) { cn.AddItemToContainer(ObjectLoader.UniqueObjectName(tmpobj)); } while (tmpobj.next != 0) { tmpobj = ObjectLoader.getObjectInfoAt((int)tmpobj.next, objList); //objList[tmpobj.next]; cn.AddItemToContainer(ObjectLoader.UniqueObjectName(tmpobj)); } } }
public void GiveKeyOfTruth() { if (HasGivenKey == false) { //Code to spawn key of truth in player hand //Debug.Log ("You get the key of truth"); UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_none_of_your_skills_improved_)); //No skills appear //inputctrl.text=UWHUD.instance.MessageScroll.text; Shrine.HasGivenKey = true; //create the key of truth. ObjectLoaderInfo newobjt = ObjectLoader.newObject(225, 0, 0, 0, 256); GameObject key = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject; GameWorldController.MoveToInventory(key); ObjectInteraction myObjInt = key.GetComponent <ObjectInteraction>(); /*ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(225); * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform; * GameWorldController.MoveToInventory(myObjInt.gameObject);*/ UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name; UWHUD.instance.CursorIcon = myObjInt.GetInventoryDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; InteractionModeControl.UpdateNow = true; } }
/// <summary> /// The projectile will only damage anything for a short period after it hits something /// To support bouncing around /// </summary> public IEnumerator EndProjectile() { yield return(new WaitForSeconds(1.0f)); ObjectInteraction.DestroyObjectFromUW(this.GetComponent <ObjectInteraction>()); //Destroy(this.gameObject); }
public override bool ActivateByObject(GameObject ObjectUsed) { ObjectInteraction objI = ObjectUsed.GetComponent <ObjectInteraction>(); if (objI != null) { if (objI.GetItemType() == ObjectInteraction.A_BLACKROCK_GEM) { if (objI.owner == 1) { int thisGemIndex = objI.item_id - 280; int bitField = (1 << thisGemIndex); Quest.instance.x_clocks[2]++; Quest.instance.QuestVariables[130] |= bitField; UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338)); UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338 + Quest.instance.x_clocks[2])); objI.consumeObject(); } else { UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 347)); } UWCharacter.Instance.playerInventory.ObjectInHand = ""; return(true); } } return(false); }
/*static public bool xAddObjectToContainer(GameObject objInHand, GameObject objUseOn) * { * Container subContainer = objUseOn.GetComponent<Container>(); * if (subContainer.AddItemToContainer(objInHand.name)) * { * Container ObjInHandContainer=objInHand.GetComponent<Container>(); * if (ObjInHandContainer!=null) * { * subContainer=objInHand.GetComponent<Container>(); * subContainer.ContainerParent=objUseOn.name; * } * return true; * } * else * { * return false; * } * }*/ public void OpenContainer() { playerUW.playerInventory.ContainerOffset = 0; ScrollButtonStatsDisplay.ScrollValue = 0; ObjectInteraction currObjInt = this.gameObject.GetComponent <ObjectInteraction>(); if (currObjInt.PickedUp == false) { //The requested container is open in the game world. This can cause problems! //Debug.Log ("Opening a container in the real world"); SpillContents(); return; } //Sort the container Container.SortContainer(this); GameObject.Find("ContainerOpened").GetComponent <UITexture>().mainTexture = currObjInt.GetEquipDisplay().texture; if (this.isOpenOnPanel == false) { this.isOpenOnPanel = true; ContainerParent = playerUW.playerInventory.currentContainer; } playerUW.playerInventory.currentContainer = this.name; if (playerUW.playerInventory.currentContainer == "") { playerUW.playerInventory.currentContainer = playerUW.name; this.ContainerParent = playerUW.name; } for (int i = 0; i < 8; i++) { string sItem = this.GetItemAt(i); playerUW.playerInventory.SetObjectAtSlot(i + 11, sItem); } }
//To support potions that are linked to spells/damage traps public override void MoveToWorldEvent() { if ((isquant == 0) && (link < 256) && (link > 0)) {//Object links to a spell. if (linked != null) { bool match = false; //Try and find a spell already in the level that matches the characteristics of this spell ObjectLoaderInfo[] objList = CurrentObjectList().objInfo; for (int i = 0; i <= objList.GetUpperBound(0); i++) { if (objList[i].GetItemType() == linked.GetItemType())//Find a matching item type { if (objList[i].instance != null) { if ((objList[i].link == linked.link) && (objList[i].owner == linked.owner) && (objList[i].quality == linked.quality)) {//Point to that instance if found instead. Destroy(linked.gameObject); linked = objList[i].instance; link = i; match = true; break; } } } } if (!match) { //linkedspell.gameObject.transform.parent=GameWorldController.instance.DynamicObjectMarker(); GameWorldController.MoveToWorld(linked.gameObject); } } } }
public override bool ActivateByObject(GameObject ObjectUsed) { ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>(); if (objIntUsed != null) { switch (objIntUsed.ItemType) { case ObjectInteraction.POLE: playerUW.playerInventory.ObjectInHand = ""; playerUW.CursorIcon = playerUW.CursorIconDefault; ml.Set(playerUW.StringControl.GetString(1, 157)); return(Activate()); break; default: playerUW.playerInventory.ObjectInHand = ""; playerUW.CursorIcon = playerUW.CursorIconDefault; objIntUsed.FailMessage(); return(false); break; } } return(false); }
public override bool ActivateByObject(GameObject ObjectUsed) { if ((UWEBase._RES == UWEBase.GAME_UW1) && (TextureIndex == 47)) //The door to the base of the abyss. { if (ObjectUsed.GetComponent <ObjectInteraction>().item_id == 231) //The key of infinity. { if (objInt().link != 0) { GameObject triggerObj = ObjectLoader.getGameObjectAt(objInt().link); if (triggerObj != null) { ObjectInteraction objIntTrigger = triggerObj.GetComponent <ObjectInteraction>(); if ( (objIntTrigger.GetItemType() == ObjectInteraction.AN_OPEN_TRIGGER) ) { objIntTrigger.GetComponent <trigger_base> ().Activate(this.gameObject); UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; UWCharacter.Instance.playerInventory.ObjectInHand = ""; return(true); } } } } } return(base.ActivateByObject(ObjectUsed)); }
/// <summary> /// Begins the combat state of the player. Sets AttackCharging. /// Animates the weapon becoming ready. /// For ranged weaponry it checks for the weapon ammo. /// </summary> public override void CombatBegin() { if(IsMelee()) {///If melee sets the proper weapon drawn back animation. CurrentStrike=GetStrikeType(); UWHUD.instance.wpa.SetAnimation= GetWeapon () +"_" + CurrentStrike + "_" + GetRace () + "_" + GetHand() + "_Charge"; } else { ///If ranged check for ammo as defined by the Weapon /// If ammo if found give the player a targeting crosshair currentAmmo=GameWorldController.instance.playerUW.playerInventory.findObjInteractionByID(currWeaponRanged.AmmoType); if ((currentAmmo == null) && (ObjectInteraction.Alias(currWeaponRanged.AmmoType)!=currWeaponRanged.AmmoType)) {//Ammo type has an alias. try and find that instead. currentAmmo=GameWorldController.instance.playerUW.playerInventory.findObjInteractionByID(ObjectInteraction.Alias(currWeaponRanged.AmmoType)); } if (currentAmmo==null) {//No ammo. UWHUD.instance.MessageScroll.Add ("Sorry, you have no " + StringController.instance.GetObjectNounUW(currWeaponRanged.AmmoType)); return; } else { //Change the crosshair UWHUD.instance.CursorIcon=UWHUD.instance.CursorIconTarget; } } ///Starts the counter AttackCharging=true; Charge=0; }
/// <summary> /// Finds the trap of the specified type in chain of execution of linked items /// </summary> /// <returns><c>true</c>, if trap in chain was found, <c>false</c> otherwise.</returns> /// <param name="link">Link.</param> /// <param name="TrapType">Trap type.</param> public virtual ObjectInteraction FindObjectInChain(int link, int ItemType) { if (link != 0) { ObjectInteraction objLink = CurrentObjectList().objInfo[link].instance; if (objLink != null) { if (objLink.GetItemType() == ObjectInteraction.A_DELETE_OBJECT_TRAP) {//Stop infinite loops if (ItemType == ObjectInteraction.A_DELETE_OBJECT_TRAP) { return(objLink); } else { return(null); } } if (objLink.GetItemType() == ItemType) { return(objLink); } else { return(FindObjectInChain(objLink.link, ItemType)); } } } return(null); }
public override bool ActivateByObject(GameObject ObjectUsed) { ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>(); if (objIntUsed != null) { switch (objIntUsed.GetItemType()) { case ObjectInteraction.AN_ORB_ROCK: { if ((_RES == GAME_UW1) && (GameWorldController.instance.LevelNo == 6)) { UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault; UWCharacter.Instance.playerInventory.ObjectInHand = ""; OrbRock.DestroyOrb(objInt()); return(true); } else { return(base.ActivateByObject(ObjectUsed)); } } } } return(base.ActivateByObject(ObjectUsed)); }
public override bool ActivateByObject(ObjectInteraction ObjectUsed) { //ObjectInteraction objI=ObjectUsed.GetComponent<ObjectInteraction>(); if (ObjectUsed != null) { if (ObjectUsed.GetItemType() == ObjectInteraction.A_BLACKROCK_GEM) { if (ObjectUsed.owner == 1) { int thisGemIndex = ObjectUsed.item_id - 280; int bitField = (1 << thisGemIndex); Quest.instance.x_clocks[2]++; Quest.instance.QuestVariables[130] |= bitField; UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338)); UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338 + Quest.instance.x_clocks[2])); CameraShake.instance.ShakeEarthQuake(Quest.instance.x_clocks[2] * 0.2f); ObjectUsed.consumeObject(); } else { UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 347)); } CurrentObjectInHand = null; return(true); } } return(false); }
private bool PickUpSeed() { ObjectLoaderInfo newseed = ObjectLoader.newObject(290, 40, 16, 1, 256); newseed.is_quant = 1; ObjectInteraction newseedobj = ObjectInteraction.CreateNewObject ( CurrentTileMap(), newseed, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, CurrentTileMap().getTileVector(TileMap.ObjectStorageTile, TileMap.ObjectStorageTile) ); GameWorldController.MoveToInventory(newseedobj.gameObject); UWCharacter.Instance.ResurrectPosition = Vector3.zero; UWCharacter.Instance.ResurrectLevel = 0; UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 9)); CurrentObjectInHand = newseedobj; //newseedobj.UpdateAnimation(); //UWHUD.instance.CursorIcon = newseedobj.GetWorldDisplay().texture; UWCharacter.InteractionMode = UWCharacter.InteractionModePickup; InteractionModeControl.UpdateNow = true; objInt().consumeObject(); return(true); }
public override float GetUseRange() { if (isTelekinetic == true) { return(useRange * 8.0f); } else { if (playerInventory.GetObjectInHand() == "") { return(useRange); } else { //Test if this is a pole. If so extend the use range by a small amount. ObjectInteraction objIntInHand = playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>(); if (objIntInHand != null) { switch (objIntInHand.ItemType) { case ObjectInteraction.POLE: return(useRange * 2); break; } } return(useRange); } } }
public float getInventoryWeight() { float answer = 0.0f; //Get the weight of all the equipment slots for (int i = 0; i <= 10; i++) { ObjectInteraction objItem = GetObjectIntAtSlot(i); if (objItem != null) { answer += objItem.GetWeight(); } } //Get the weight of the gronk container as that is alway the top level of the inventory for (short i = 0; i <= playerContainer.MaxCapacity(); i++) { ObjectInteraction objItem = playerContainer.GetItemAt(i); //GameObject.Find (playerContainer.GetItemAt(i)); if (objItem != null) { answer += objItem.GetWeight(); } else { answer += 0; } } return(answer); }
/// <summary> /// Activation of this object by another. EG key on door /// </summary> /// <returns>true</returns> /// <c>false</c> /// <param name="ObjectUsed">Object used.</param> /// Handles anvil usage public override bool ActivateByObject(GameObject ObjectUsed) { ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>(); if (objIntUsed != null) { switch (objIntUsed.GetItemType()) { case ObjectInteraction.ANVIL: //ANVIL { //Do a difficulty check and prompt for approval. UWHUD.instance.MessageScroll.Set("[placeholder]You think it will be hard/easy to repair this item. Press Y or N followed by enter to proceed"); InputField inputctrl = UWHUD.instance.InputControl; inputctrl.gameObject.SetActive(true); inputctrl.gameObject.GetComponent <InputHandler>().target = this.gameObject; inputctrl.gameObject.GetComponent <InputHandler>().currentInputMode = InputHandler.InputAnvil; inputctrl.contentType = InputField.ContentType.Alphanumeric; inputctrl.Select(); WindowDetect.WaitingForInput = true; Time.timeScale = 0.0f; return(true); } } } return(false); }
public override void Patch() { base.Patch(); ObjectInteraction allAccess = RogueLibsInteractions.CreateOriginalInteraction("AllAccessAlarmButton", InteractionType.Button, (agent, obj) => obj is AlarmButton a && agent.interactionHelper.interactingFar && !a.hacked); allAccess.Action = (_, obj) => { AlarmButton alarmButton = (AlarmButton)obj; alarmButton.hacked = true; if (!alarmButton.gc.serverPlayer) { alarmButton.gc.playerAgent.objectMult.ObjectAction(alarmButton.objectNetID, "AllAccess"); } alarmButton.StopInteraction(); return(true); }; ObjectInteraction pressAlarmButton = RogueLibsInteractions.CreateOriginalInteraction("PressAlarmButton", InteractionType.InteractOrButton, new CustomNameInfo("Call a Supercop", null, null, null, null, "Вызвать Суперкопа", null, null), (agent, obj) => obj is AlarmButton a && !a.isBroken() && (agent.upperCrusty || a.hacked)); pressAlarmButton.Action = (agent, obj) => { ((AlarmButton)obj).ToggleSwitch(agent, null); return(true); }; }
private void UpdateObjectInteraction() { if (targetInteractionObject == null) { return; } if (!targetInteractionObject.TryGetAction( out var distance, out var action, out var interactionRange)) { return; } if (distance <= interactionRange) { try { // ignore examinations if (action.Id == 0) { uiManager.ChatPanel.OnExamine(targetInteractionObject.ObjectData.Description); return; } networkClient.SendObjectAction(targetInteractionObject.ServerId, action.Id, 0); } finally { targetInteractionObject = null; } } }
/// <summary> /// Creates bridges in a line /// </summary> /// <param name="triggerX"></param> /// <param name="triggerY"></param> void CreateBridges(int triggerX, int triggerY) { int dirX = 0; int dirY = 0; GetDirectionsForBridgeTrap(ref dirX, ref dirY); for (int i = 0; i < quality; i++) { int tileX = triggerX + dirX * i; int tileY = triggerY + dirY * i; if (TileMap.ValidTile(tileX, tileY)) { //Create a bridge at this tile. Only if no bridge is already there. if (ObjectLoader.findObjectByTypeInTile(CurrentObjectList().objInfo, (short)tileX, (short)tileY, ObjectInteraction.BRIDGE) == -1) { ObjectLoaderInfo newObj = ObjectLoader.newObject(356, 40, 0, 0, 256); newObj.xpos = 4; newObj.ypos = 4; newObj.zpos = zpos; // bridge texture will be set by (bridge.enchantment << 3) | bridge.flags & 0x3F; newObj.flags = (short)(owner & 0x7); newObj.enchantment = (short)((owner >> 3) & 0x1); newObj.heading = heading; newObj.ObjectTileX = (short)tileX; newObj.ObjectTileY = (short)tileY; Vector3 pos = ObjectLoader.CalcObjectXYZ(newObj.index, 0); ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.LevelModel, pos); } } } }
public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State) { string created = ""; //if (objInt().quality <= Random.Range(1,41)) //100% chance when quality is zero. //{ ObjectInteraction objToClone = ObjectLoader.getObjectIntAt(objInt().link); if (objToClone != null) { GameObject NewObject = CloneObject(objToClone, triggerX, triggerY, true); LastObjectCreated = NewObject.name; created = NewObject.name; if (objToClone.GetComponent <Container>() != null) { //Clone the items on this object for (short i = 0; i <= objToClone.GetComponent <Container>().MaxCapacity(); i++) { if (objToClone.GetComponent <Container>().GetItemAt(i) != "") { GameObject obj = objToClone.GetComponent <Container>().GetGameObjectAt(i); GameObject CloneContainerItem = CloneObject(obj.GetComponent <ObjectInteraction>(), triggerX, triggerY, false); NewObject.GetComponent <Container>().items[i] = CloneContainerItem.name; } } } } //} Debug.Log(this.name + " " + created); }
/* IEnumerator FindActors(){ // deprecated? yield return new WaitForSeconds(3); // would be better if this were somehow event based... List<BaseObject> list = ObjectManager.GetInstance().GetObjectList(); foreach (BaseObject obj in list){ if ((obj as ObjectInteraction) != null && !actors.Contains(obj as ObjectInteraction)) actors.Add (obj as ObjectInteraction); } initialized = true; // assign any queued script xml now that the actors are all registered foreach (string xmlPath in scriptsToAssign) AssignScripts (xmlPath); scriptsToAssign.Clear(); } */ public void RegisterObject(BaseObject obj){ // add this to our actor list, and assign any scripts we already know about ObjectInteraction actor = obj as ObjectInteraction; if (actor != null && !actors.Contains(actor)){ actors.Add (actor); if (actor.name == "ScribeNurse") scribeNurse = actor; AssignScripts (actor); } }
public override void Initialize(ScreenInfo parent) { patient = Patient.FindObjectOfType(typeof(Patient)) as Patient; Object[] temp = ObjectInteraction.FindObjectsOfType(typeof(ObjectInteraction)); foreach (Object obj in temp) { if (obj == patient) continue; roomObjects.Add(obj as ObjectInteraction); } base.Initialize(parent); }
static int RollForAHitMelee(NPC Origin, ObjectInteraction Target) { return 1;//Temp NPC will always hit. }
public static void Split(ObjectInteraction splitFrom) { splitFrom.GetComponent<object_base>().Split (); }
public void Execute(ScriptedObject thisCaller,string argString="", GameObject obj=null){ caller = thisCaller; foreach (ObjectInteraction actor in actorObjects){ actor.reservedForScript = null; // incase anyone got reserved who doesn't get picked by the dispatcher } // here, we must find a character for each role, assign and reserve them Dispatcher.GetInstance().FillRoles(this); // bail if fail if (obj == null) myObject = caller.gameObject; // the scripted object by default else myObject = obj; args.Clear(); // clear the dictionary to start SetArgs (startingArgs); SetArgs(argString); currentLine = 0; nextLineLabel = ""; isRunning = true; readyState = readiness.executing; myOI = caller.GetComponent<ObjectInteraction>(); //Debug.LogWarning(name+" reserving "+myOI.name); foreach (ObjectInteraction actor in actorObjects){ actor.actingInScript = this; actor.reservedForScript = null; } foreach (ScriptedAction sa in scriptLines) sa.hasExecuted = false; // really just for debug use, would break 'executeOnlyOnce' // if there's an interaction set specified, send it to the interaction manager. if (interactionSet != null && interactionSet.Name != null && interactionSet.Name != "") InteractionMgr.GetInstance().CurrentSet = interactionSet; if (debug) Debug.Log ("Script "+name+" execution started"); // we're going to have to handle multiple current lines for roles if (scriptLines[currentLine] != null) scriptLines[currentLine].Execute(this); else OnScriptComplete(""); }
static int RollForAHitMelee(UWCharacter Origin, ObjectInteraction Target, WeaponMelee weap) { //0 =Miss //1 = hit //2 = Crit eventually. int HitScore; int DefenseScore; int WeaponSkill; if (weap!=null) { WeaponSkill= Origin.PlayerSkills.GetSkill(weap.GetSkill()); } else { WeaponSkill= Origin.PlayerSkills.GetSkill(Skills.SkillUnarmed); } HitScore=Origin.PlayerSkills.Attack/2+WeaponSkill+ Random.Range(1,5); if (Target.GetComponent<NPC>()!=null) {//Target is an NPC //Need to calculate this based on npc level DefenseScore=-1; //Until I figure out what values drive this, always hit. } else { DefenseScore=-1;//Will always hit an non-npc; } if (DefenseScore<=HitScore) { return 1; } else { return 0;//A Miss } }
override public void PutMessage(GameMsg msg) { Debug.Log("ObjectInteraction:PutMessage() : " + msg.ToString()); if (IsActive() == false) return; InteractMsg imsg = msg as InteractMsg; if (imsg != null) { // default msg, create an interaction InteractionMgr.GetInstance().SendInteractionMap("", imsg.map); } InteractDialogMsg dialogmsg = msg as InteractDialogMsg; if (dialogmsg != null) { if (dialogmsg.command == DialogMsg.Cmd.open && dialogmsg.items != null) { // close info dialog InfoDialogMsg dmsg = new InfoDialogMsg(); dmsg.command = DialogMsg.Cmd.close; InfoDialog.GetInstance().PutMessage(dmsg); //print(dialogmsg.items[0].response); // copy new items items = dialogmsg.items; // set game object interactObject = dialogmsg.baseobj; #if BRAIN_DEBUG if (interactObject != null) Debug.Log("InteractDialog : interactObject = " + interactObject.name); else Debug.Log("InteractDialog : no object"); #endif //menuLocation = interactObject.Name; baseXML = dialogmsg.baseXML; // set position x = dialogmsg.x; y = dialogmsg.y; // set visible SetVisible(true); } } base.PutMessage(msg); }
// build a list of interactions an entity could do right now. // this would be to build a menu or as a starting place for planning. public List<InteractionMap> GetValidInteractionsFor(ObjectInteraction obj){ // go thru all the known interactions, checking each one with obj List<InteractionMap> validList = new List<InteractionMap>(); foreach (InteractionMap map in Interactions){ if (obj.IsValidInteraction(map.item)) // this is just a placeholder test for now { validList.Add (map); } } return validList; }
// Use this for initialization void Start() { objInt = GameObject.Find("Player").GetComponent<ObjectInteraction>(); invMng = objInt.gameObject.GetComponent<InventoryManagement>(); }
// Add a new instance of a script to an actor if the primary role is supported. public bool AssignScript(InteractionScript script, ObjectInteraction oi){ bool assigned = false; if (oi.Roles.Contains(script.roles[0])){ //assigned by primary role // be sure we have a scriptedObject ScriptedObject so = oi.GetComponent<ScriptedObject>(); if (so == null){ so = oi.gameObject.AddComponent<ScriptedObject>(); so.scripts = new InteractionScript[0]; // prettyname! } // perform replacement if a script with the same name already exists. // this supports overriding base scripts with later loads foreach (InteractionScript scr in so.scripts){ if (scr.name == script.name){ so.RemoveScript(scr); DestroyImmediate (scr.gameObject); break; } } so.InsertScriptSorted(script); // this sets the parent, we need to duplicate the script at this point. assigned = true; } return assigned; }
void Start () { FirstPersonCamera = transform.Find("FirstPersonCamera"); LocalObjectInteraction = transform.GetComponent<ObjectInteraction>(); }
/// <summary> /// Gets the object interaction that this object base works with /// </summary> /// <returns>The object interaction.</returns> public ObjectInteraction objInt() { //CheckReferences(); if (_objInt==null) { _objInt=this.GetComponent<ObjectInteraction>(); } return _objInt; //this.gameObject.GetComponent<ObjectInteraction>(); }
/// <summary> /// Gets the object noun for a passed object /// </summary> /// <returns>The object noun U.</returns> /// <param name="objInt">Object int.</param> public string GetObjectNounUW(ObjectInteraction objInt) { //The single noun return GetObjectNounUW(objInt.item_id); }
/// <summary> /// Gets the simple object name for the pass object. /// </summary> /// <returns>The simple object name U.</returns> /// <param name="objInt">Object int.</param> public string GetSimpleObjectNameUW(ObjectInteraction objInt) { //Without quants. return GetSimpleObjectNameUW(objInt.item_id); }
public void SetTarget(ObjectInteraction obj) { target = obj; }
public static void Merge(ObjectInteraction mergingInto, ObjectInteraction mergingFrom) { //ObjectUsedOn.GetComponent<ObjectInteraction>().Link=ObjectUsedOn.GetComponent<ObjectInteraction>().Link+objInt().Link; mergingInto.Link += mergingFrom.Link; mergingInto.GetComponent<object_base>().MergeEvent(); Destroy(mergingFrom.gameObject); }
/// <summary> /// Gets the formatted object name with a description of its qualty. (EG smell fish.) /// </summary> /// <returns>The formatted object name U.</returns> /// <param name="objInt">Object int.</param> /// <param name="QualityString">Quality string.</param> public string GetFormattedObjectNameUW(ObjectInteraction objInt, string QualityString) { //Eventually this will return things like proper quants etc. string output = GetString (4,objInt.item_id); if (output==null) { output=""; } if ((objInt.isQuant ==true) && (output.Contains("&")) && (objInt.isEnchanted==false) ) { if (objInt.Link>1) {//Plural description output= objInt.Link + " " + output.Split ('&')[1]; } else { output= output.Split ('&')[0]; } } else { if (output.Contains("&")) { output= output.Split ('&')[0]; } } string isThisAVowel=QualityString.Substring(0,1).ToUpper(); if ( (isThisAVowel == "A") || (isThisAVowel == "E") || (isThisAVowel == "I") || (isThisAVowel == "O") || (isThisAVowel == "U") ) { if (output.Contains("a_")) { output = output.Replace("a_","an " + QualityString + " "); } else { if (output.Contains("_")) { output =output.Replace("_", " " + QualityString + " "); } else { output = QualityString + " " + output + " "; } } } else { if (output.Contains("an_")) { output = output.Replace("an_","a " +QualityString + " "); } else { if (output.Contains("_")) { output =output.Replace("_", " " + QualityString + " "); } else { output = QualityString + " " + output + " "; } } } //output =output.Replace("_", " " + QualityString + " "); return GetString(1,260) + output; }
public static bool CanMerge(ObjectInteraction mergingInto, ObjectInteraction mergingFrom) { //if ((objInt().item_id==ObjectUsedOn.GetComponent<ObjectInteraction>().item_id) && (objInt().Quality==ObjectUsedOn.GetComponent<ObjectInteraction>().Quality)) return ( ( (mergingInto.item_id == mergingFrom.item_id) || (mergingInto.AliasItemId() == mergingFrom.item_id) || (mergingInto.item_id == mergingFrom.AliasItemId()) ) && (mergingInto.Quality==mergingFrom.Quality) ); }
/// <summary> /// Gets the formatted object name for the passed object and a specified quantity. /// </summary> /// <returns>The formatted object name U.</returns> /// <param name="objInt">Object int.</param> /// <param name="Quantity">Quantity that I want to display</param> public string GetFormattedObjectNameUW(ObjectInteraction objInt,int Quantity) { //Eventually this will return things like proper quants etc. string output = GetString (4,objInt.item_id); if ((objInt.isQuant ==true) && (objInt.isEnchanted==false)) { if (output.Contains("&")) {//string is split into a singular and plural if ((objInt.Link>1) && (Quantity>1)) {//Plural description output= objInt.Link + " " + output.Split ('&')[1]; } else { output= output.Split ('&')[0]; } } else { output = output.Replace("a_",Quantity + "_"); output = output.Replace("an_",Quantity + "_"); output = output.Replace("some_",Quantity + "_"); } } else { if (output.Contains("&")) { output= output.Split ('&')[0]; } } output =output.Replace("_"," "); return GetString(1,260) + output; }
// assign any supported, registered scripts to a new actor void AssignScripts(ObjectInteraction actor){ foreach (ScriptedObject.ScriptedObjectInfo info in scriptedObjectInfos){ // handle multiple drop targets foreach (InteractionScript.InteractionScriptInfo scriptInfo in info.scripts){ string targetString = info.dropTargetName; if (scriptInfo.owningRole != null && scriptInfo.owningRole != "") targetString = scriptInfo.owningRole; // handle multiple drop targets string[] targets = targetString.Split (','); foreach (string target in targets){ if (actor.Roles.Contains(target)){ GameObject go = new GameObject(scriptInfo.unityObjectName); InteractionScript newScript = go.AddComponent("InteractionScript") as InteractionScript; //link script to drop target NOW so roles[0] can be resolved go.transform.parent = actor.transform; newScript.InitFrom(scriptInfo); newScript.Start (); // if (newScript.roles == null || newScript.roles.Length==0){ // newScript.roles = new string[1]; // newScript.roles[0] = info.dropTargetName; // temporary hack until roles are properly edited // } // if (newScript.menuOrder == 0) // newScript.menuOrder = 99999; // add at end, hack until menu orders are set... AssignScript (newScript, actor); } } } } }
/// <summary> /// Actions to take when the projectile hits a specific object. /// </summary> /// <param name="objInt">Object Interaction of what it hits,</param> public virtual void onHit(ObjectInteraction objInt) { }
public InteractDialogMsg() : base() { items = new List<InteractionMap>(); baseobj = null; }
public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv) { //completes the pickup. objPicked.PickedUp=true; if (objPicked.GetComponent<Container>()!=null) { Container.SetPickedUpFlag(objPicked.GetComponent<Container>(),true); Container.SetItemsParent(objPicked.GetComponent<Container>(),InvMarker.transform); Container.SetItemsPosition (objPicked.GetComponent<Container>(),InvMarker.transform.position); } UWHUD.instance.CursorIcon=objPicked.GetInventoryDisplay().texture; pInv.ObjectInHand=objPicked.transform.name; //////pInv.JustPickedup=true;//To stop me throwing it away immediately. if (objPicked.GetComponent<Rigidbody>() !=null) { GameWorldController.FreezeMovement(objPicked.gameObject); } //Clone the object into the inventory if (WindowDetectUW.UsingRoomManager==true) { GameObject objClone = Instantiate(objPicked.gameObject); objClone.name=objPicked.name; objPicked.name=objPicked.name+ "_destroyed"; //objPicked.transform.DestroyChildren(); DestroyImmediate(objPicked.gameObject); objClone.transform.position = InvMarker.transform.position; objClone.transform.parent=InvMarker.transform; objClone.GetComponent<ObjectInteraction>().Pickup(); /* UniqueIdentifier uid=objClone.GetComponent<UniqueIdentifier>(); if (uid!=null) { //uid.Id=uid.GetInstanceID().ToString(); } */ objClone.GetComponent<ObjectInteraction>().Pickup(); return objClone.GetComponent<ObjectInteraction>(); } else { objPicked.transform.position=InvMarker.transform.position; objPicked.transform.parent=InvMarker.transform; objPicked.Pickup(); return objPicked; } //objPicked.transform.position = InvMarker.transform.position; //objPicked.transform.parent=InvMarker.transform; //objPicked.Pickup();//Call pickup event for this object. }
void Reset () { m_interactions = m_target.GetComponent<ObjectInteraction>(); // m_delay = 0.0f; }
public void ExecuteEvent(ScriptedObject thisCaller,string eventName){ // intended to be called from animation Events, start execution at the named line, and // run until an action flagged sequenceEnd=true; // Look for the line. fail if not found int startingIndex=-1; for (int i=0;i<scriptLines.Length;i++){ if (scriptLines[i].name == eventName){ startingIndex=i; break; } } if (startingIndex <0){ Debug.LogError("AnimationEvent using "+name+" could not find line "+eventName); return; } // caller is only used by ExecuteScript and onScriptComplete, so we might go without it... caller = thisCaller; myObject = caller.gameObject; args.Clear(); // do we need any args for events ? SetArgs (startingArgs); currentLine = startingIndex; nextLineLabel = ""; isRunning = true; readyState = readiness.executing; myOI = caller.GetComponent<ObjectInteraction>(); if (debug) Debug.Log ("Script "+name+" execution started"); if (scriptLines[currentLine] != null) scriptLines[currentLine].ForceExecute(this); else OnScriptComplete(""); }
public override void Initialize(ScreenInfo parent) { // Create the space to make the left and right side menus // and add the generated GUIMenu objects into it. List<GUIObject> find = FindObjectsOfType(typeof(GUIMenu)); if (find.Count > 0) lmenu = find[0] as GUIMenu; find = FindObjectsOfType(typeof(GUIScrollMenu)); if (find.Count > 0) rmenu = find[0] as GUIScrollMenu; find = FindObjectsOfType(typeof(GUILabel)); if (find.Count > 0) { title = find[0] as GUILabel; if (interactObject != null) title.text = interactObject.prettyname; } find.Clear(); Elements.Clear(); GUIVerticalCommand vert = new GUIVerticalCommand(); vert.Elements = new List<GUIObject>(); Elements.Add(vert); if (title != null ) vert.Elements.Add(title); GUISpace space = new GUISpace(); space.pixels = 5; vert.Elements.Add(space); if (lmenu != null && rmenu != null) { GUIHorizontalCommand hc = new GUIHorizontalCommand(); hc.Elements = new List<GUIObject>(); hc.Elements.Add(lmenu); hc.Elements.Add(rmenu); vert.Elements.Add(hc); } base.Initialize(parent); patient = Patient.FindObjectOfType(typeof(Patient)) as Patient; Object[] temp = ObjectInteraction.FindObjectsOfType(typeof(ObjectInteraction)); foreach (Object obj in temp) { if (obj == patient) continue; roomObjects.Add(obj as ObjectInteraction); } listings = new Listings(); listings.category = "root"; current = listings; }
public override void Execute() { if (!Visible) return; base.Execute(); int i; List<GUIMenu.MenuButton> buttons = lmenu.GetButtons(); GUIMenu.MenuButton mbutton = lmenu.GetOnButton(); if ( mbutton != null ) { // Check Target button, if active if ( mbutton.button.text == sHome ) // Patient button { interactObject = target; // change title if ( title != null ) title.text = interactObject.prettyname; InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; //idmsg.LoadXML(xmlData); idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; Setup(idmsg); pastXMLs.Clear(); rooming = false; } if ( mbutton.button.text == sPatient ) // Patient button { interactObject = patient; // change title if ( title != null ) title.text = interactObject.prettyname; InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; //idmsg.LoadXML(xmlData); idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; Setup(idmsg); pastXMLs.Clear(); rooming = false; } else if ( mbutton.button.text == sTeam ) // Team button { // change button[0] name to this object // Setup buttons List<string> entries = new List<string>(); foreach (ObjectInteraction obj in roomObjects) { if (obj.onTeamMenu) entries.Add(obj.prettyname); } rmenu.Setup(entries); rooming = true; } else if ( mbutton.button.text == sBack ) // GoBack button { if (current != listings) { //InteractDialogMsg idmsg = new InteractDialogMsg(); //xmlData = pastXMLs[pastXMLs.Count - 1]; //idmsg.LoadXML(xmlData); //idmsg.baseXML = xmlData; //idmsg.baseobj = interactObject; //Setup(idmsg); //pastXMLs.RemoveAt(pastXMLs.Count - 1); //rooming = false; current = current.parent; rooming = false; SetupRight(current); } else { Visible = false; } } // clear buttons for (i = 0; i < buttons.Count; i++) { buttons[i].on = false; } } buttons = rmenu.GetButtons(); for (i = 0; i < buttons.Count; i++) { if (rooming) { if (buttons[i].on) { interactObject = null; // Find matching Object by name (allows for onTeamMenu to work during runtime) foreach (ObjectInteraction oi in roomObjects) { if (buttons[i].button.text == oi.prettyname) { interactObject = oi; break; } } if (interactObject == null) break; // Safety measure InteractDialogMsg idmsg = new InteractDialogMsg(); xmlData = interactObject.originXML; ScriptedObject so = interactObject.GetComponent<ScriptedObject>(); if (so != null) idmsg.items = so.QualifiedInteractions(); else idmsg.items = interactObject.ItemResponse; idmsg.baseXML = xmlData; idmsg.baseobj = interactObject; // change the title bar (or first element of left column for now) to be // this button name title.text = buttons[i].button.text; Setup(idmsg); pastXMLs.Clear(); rooming = false; break; } } else { if (buttons[i].on) { if (i < current.subCategories.Count) { current = current.subCategories[i]; SetupRight(current); break; } else { InteractionMap im = current.items[i - current.subCategories.Count]; // Activate interaction! interactObject.PutMessage(new InteractMsg(interactObject.gameObject, im, im.log)); current=listings; // reset the menu for next time PAA Visible = false; break; } } } buttons[i].on = false; } }
public void Start() { // base.Start(); // base.LoadXML(XMLName); myOI = GetComponent<ObjectInteraction>(); if (myOI == null){ myOI = gameObject.AddComponent<ObjectInteraction>(); if (prettyname == null || prettyname == "") prettyname = name; myOI.prettyname = prettyname; myOI.ActivateDistance = 10; } // register this object if (register) ObjectManager.GetInstance().RegisterObject(myOI); // this might result in the duplicate messages ? StartCoroutine(AddItems()); // see if delaying this has any effect }
public float GetCost(ObjectInteraction obj){ // lets try something based on: skill fit, number of lines, distance to the character? Vector3 skillLocation = new Vector3(0,0,0); if (skillVector != null && skillVector.Length>0) skillLocation = skillVector[0]; float cost = extraCost; float skillFactor = 1; if (obj != null) skillFactor = (1.0f+obj.SkillMetric(skillLocation)); cost+= scriptLines.Length*skillFactor; // we could add in a factor for distance to travel to perform this task if (obj != null) cost += MoveDistance(obj.gameObject); // add a penalty if the script isn't ready if (!isReadyFor(obj)) cost+= 10; if (!isReadyToRun(obj,false)) cost+= 10; return cost; }