Ejemplo n.º 1
0
    public void interact()
    {
        Grab      grabber   = myPlayer.grabber;
        Inventory inventory = myPlayer.inventory;

        if (grabber.hasObject())
        {
            grabber.dropObject();
        }
        else
        {
            Vector3    point;
            GameObject nearest = getTarget(out point);
            if (nearest != null && !inventory.take(nearest))
            {
                Label trgt;
                bool  canInteract = hasInteractable(nearest, out trgt);
                if (canInteract)
                {
                    InteractTrigger trig = new InteractTrigger();
                    trig.setPoint(point);
                    trgt.sendTrigger(nearest, trig);
                }
                else
                {
                    grabber.grabObject(nearest, point);
                }
            }
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider collision)
    {
        if (collision == null)
        {
            return;
        }

        InteractTrigger nextTarget = collision.transform.GetComponent <InteractTrigger>();

        if (nextTarget == null)
        {
            return;
        }

        if (nextTarget != currentTarget)
        {
            if (currentTarget != null)
            {
                currentTarget.SetIsTargeted(false);
            }

            previousTarget = currentTarget;
            currentTarget  = nextTarget;

            if (nextTarget != null)
            {
                nextTarget.SetIsTargeted(true);
            }
        }
    }
Ejemplo n.º 3
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_EXAMPLES)
                return;

            #region defineNPCs

            GameNPC[] npcs = WorldMgr.GetNPCsByName("Sir Quait", eRealm.Albion);
            npcs = WorldMgr.GetNPCsByName("Sir Quait", (eRealm)1);
            GameNPC SirQuait = null;
            if (npcs.Length == 0)
            {
                SirQuait = new DOL.GS.GameNPC();
                SirQuait.Model = 40;
                SirQuait.Name = "Sir Quait";
                if (log.IsWarnEnabled)
                    log.Warn("Could not find " + SirQuait.Name + ", creating ...");
                SirQuait.Realm = eRealm.Albion;
                SirQuait.CurrentRegionID = 1;
                SirQuait.Size = 50;
                SirQuait.Level = 10;
                SirQuait.MaxSpeedBase = 100;
                SirQuait.Faction = FactionMgr.GetFactionByID(0);
                SirQuait.X = 531971;
                SirQuait.Y = 478955;
                SirQuait.Z = 0;
                SirQuait.Heading = 3570;
                SirQuait.RespawnInterval = 0;
                SirQuait.BodyType = 0;

                StandardMobBrain brain = new StandardMobBrain();
                brain.AggroLevel = 0;
                brain.AggroRange = 0;
                SirQuait.SetOwnBrain(brain);

                SirQuait.AddToWorld();
            }
            else
            {
                SirQuait = npcs[0];
            }

            #endregion defineNPCs

            #region defineBehaviours

            BaseBehaviour b = new BaseBehaviour(SirQuait);
            MessageAction a = new MessageAction(SirQuait, "This is just a simple test bahaviour.", eTextType.Emote);
            b.AddAction(a);
            InteractTrigger t = new InteractTrigger(SirQuait, b.NotifyHandler, SirQuait);
            b.AddTrigger(t);

            // store the behaviour in a list so it won't be garbage collected
            behaviours.Add(b);

            #endregion defineBehaviours

            log.Info("Simple Test Behaviour added");
        }
Ejemplo n.º 4
0
        public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
        {
            if (!ServerProperties.Properties.LOAD_EXAMPLES)
            {
                return;
            }

            GameNPC[] npcs = WorldMgr.GetObjectsByName <GameNPC>("Sir Quait", eRealm.Albion);
            npcs = WorldMgr.GetObjectsByName <GameNPC>("Sir Quait", (eRealm)1);
            GameNPC SirQuait = null;

            if (npcs.Length == 0)
            {
                SirQuait       = new DOL.GS.GameNPC();
                SirQuait.Model = 40;
                SirQuait.Name  = "Sir Quait";
                if (log.IsWarnEnabled)
                {
                    log.Warn("Could not find " + SirQuait.Name + ", creating ...");
                }

                SirQuait.Realm           = eRealm.Albion;
                SirQuait.CurrentRegionID = 1;
                SirQuait.Size            = 50;
                SirQuait.Level           = 10;
                SirQuait.MaxSpeedBase    = 100;
                SirQuait.Faction         = FactionMgr.GetFactionByID(0);
                SirQuait.X               = 531971;
                SirQuait.Y               = 478955;
                SirQuait.Z               = 0;
                SirQuait.Heading         = 3570;
                SirQuait.RespawnInterval = 0;
                SirQuait.BodyType        = 0;

                StandardMobBrain brain = new StandardMobBrain();
                brain.AggroLevel = 0;
                brain.AggroRange = 0;
                SirQuait.SetOwnBrain(brain);

                SirQuait.AddToWorld();
            }
            else
            {
                SirQuait = npcs[0];
            }

            BaseBehaviour b = new BaseBehaviour(SirQuait);
            MessageAction a = new MessageAction(SirQuait, "This is just a simple test bahaviour.", eTextType.Emote);

            b.AddAction(a);
            InteractTrigger t = new InteractTrigger(SirQuait, b.NotifyHandler, SirQuait);

            b.AddTrigger(t);

            // store the behaviour in a list so it won't be garbage collected
            behaviours.Add(b);

            log.Info("Simple Test Behaviour added");
        }
Ejemplo n.º 5
0
 void OnTriggerExit(Collider other)
 {
     //  Destroy interactable reference when too far
     if (other.CompareTag("Interactable"))
     {
         interactionTrigger.isPlayerNear = false;
         isNearInteractable = false;
         interactionTrigger = null;
     }
 }
Ejemplo n.º 6
0
 void OnTriggerEnter(Collider other)
 {
     // Set interactable reference when near
     if (other.CompareTag("Interactable"))
     {
         isNearInteractable = true;
         interactionTrigger = other.gameObject.GetComponent <InteractTrigger>();
         interactionTrigger.isPlayerNear = true;
     }
 }
Ejemplo n.º 7
0
    void OnTriggerExit(Collider collision)
    {
        InteractTrigger pastTarget = collision.transform.GetComponent <InteractTrigger>();

        if (currentTarget == pastTarget && currentTarget != null)
        {
            currentTarget.SetIsTargeted(false);
            previousTarget = currentTarget;
            currentTarget  = null;
        }
    }
Ejemplo n.º 8
0
    void EndDialogue()
    {
        if (theOption == 0)
        {
            IT.doneConversation = true;
        }

        IT = null;
        Debug.Log("End of all things interact");
        intCanvas.enabled = false;
        Time.timeScale    = 1;
    }
    private void Update()
    {
        // Interact button
        if (Input.GetMouseButtonDown(1))
        {
            // Get the mouse position in world coordinates
            Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            // Check if the mouse is within the player's reach
            if (Vector2.Distance(transform.position, mousePosition) < interactRange)
            {
                // Check if an interactible was clicked
                InteractTrigger trigger = Physics2D.OverlapPoint(mousePosition)?.GetComponent <InteractTrigger>();
                if (trigger)
                {
                    trigger.Trigger();                              // Run the trigger
                }
            }
        }
    }
Ejemplo n.º 10
0
	public void interact() {
		Grab grabber = myPlayer.grabber;
		Inventory inventory = myPlayer.inventory;
		if (grabber.hasObject ()) {
			grabber.dropObject ();
		} else {
			Vector3 point;
			GameObject nearest = getTarget(out point);
			if (nearest != null && !inventory.take(nearest)) {
				Label trgt;
				bool canInteract = hasInteractable(nearest, out trgt);
				if(canInteract) {
					InteractTrigger trig = new InteractTrigger();
					trig.setPoint(point);
					trgt.sendTrigger(myPlayer.gameObject, trig);
				} else {
					grabber.grabObject(nearest, point);
				}
            }
		}
	}