예제 #1
0
    public override void Update()
    {
        objName = "Object";
        if (obj.GetType() == typeof(Creature))
        {
            string firstName = AuroraEngine.Resources.GetString(((AuroraUTC)obj.template).FirstName);
            string lastName  = AuroraEngine.Resources.GetString(((AuroraUTC)obj.template).LastName);
            objName = firstName + (lastName != "" ? (" " + lastName) : "");
        }
        else if (obj.GetType() == typeof(Door))
        {
            objName = AuroraEngine.Resources.GetString(((AuroraUTD)obj.template).LocName);
        }
        else if (obj.GetType() == typeof(Placeable))
        {
            objName = AuroraEngine.Resources.GetString(((AuroraUTP)obj.template).LocName);

            // Check if the placeable is empty; if so, append " (Empty)" to the name
            if (((AuroraUTP)obj.template).ItemList.Count == 0)
            {
                objName += " (Empty)";
            }
        }

        left   = new SelectorList(this.width / 3, this.height * 2 / 3, options1);
        middle = new SelectorList(this.width / 3, this.height * 2 / 3, options2);
        right  = new SelectorList(this.width / 3, this.height * 2 / 3, options3);
    }
예제 #2
0
    public void EndDialog()
    {
        if (curMode == DialogMode.FINISHED)
        {
            return;
        }

        curMode = DialogMode.FINISHED;

        // Call any scripts that should run when the dialog finishes
        Debug.Log(stateManager);
        Debug.Log(dialogue.EndConversation);
        stateManager.RunScript(dialogue.EndConversation, owner);
        if (owner.GetType() == typeof(Creature))
        {
            ((Creature)owner).OnEndDialogue();
        }
    }
예제 #3
0
    void StartDialog(AuroraDLG dlg, AuroraObject owner)
    {
        // TODO: Find the appropriate starting point by running
        // the relevant NCS scripts
        dialogue = dlg;

        if (owner.GetType() == typeof(Creature))
        {
            ((Creature)owner).OnDialogue();
        }

        AuroraDLG.AStarting starter = null;
        foreach (AuroraDLG.AStarting option in dlg.StartingList)
        {
            string scriptName = option.Active;
            if (scriptName == "")
            {
                starter = option;
                break;
            }
            if (stateManager.RunConditionalScript(scriptName, owner) > 0)
            {
                starter = option;
                break;
            }
        }

        if (starter == null)
        {
            // Could not find a starter
            throw new System.Exception("Failed to find a successful starting option for dialog");
        }

        AuroraDLG.AEntry startEntry = dlg.EntryList[(int)starter.Index];

        Debug.Log("Start entry: " + startEntry);

        curEntry = startEntry;

        if (curEntry.Script != "")
        {
            stateManager.RunScript(curEntry.Script, owner);
        }

        curMode = DialogMode.NPC;

        this.owner = owner;
    }
예제 #4
0
    void DrawHooks()
    {
        selectedHook = null;

        GUIStyle style = new GUIStyle();

        style.fontSize         = 16;
        style.normal.textColor = Color.red;
        style.alignment        = TextAnchor.MiddleCenter;

        List <GameObject> allHooks = new List <GameObject>();

        foreach (GameObject obj in GameObject.FindGameObjectsWithTag("LookAtHook"))
        {
            //Debug.Log("Considering object " + obj.name);
            AuroraObject auroraObject = obj.GetComponent <LookAtHook>().obj;

            if (auroraObject == null)
            {
                continue;
            }

            if (auroraObject.GetType() == typeof(Door))
            {
                Door      door = (Door)auroraObject;
                AuroraUTD utd  = (AuroraUTD)door.template;
                // TODO: Support closing doors? Don't think this is a thing in KotOR/TSL
                if (door.open)
                {
                    //Debug.Log("Door is open, so not drawing hook");
                    continue;
                }
                //Debug.Log("Drawing hook for door");
                allHooks.Add(obj);
            }
            else if (auroraObject.GetType() == typeof(Creature))
            {
                // Check if the creature has a default conversation
                Creature  creature = (Creature)auroraObject;
                AuroraUTC utc      = (AuroraUTC)creature.template;

                bool selectable = false;

                if (utc.Conversation == null || utc.Conversation == "")
                {
                    //Debug.Log("Creature has no conversation, so not drawing hook");
                    selectable = true;
                }
                else if (NWScript.GetIsEnemy(creature, stateSystem.PC) > 0)
                {
                    selectable = true;
                }

                if (selectable)
                {
                    allHooks.Add(obj);
                }
            }
            else if (auroraObject.GetType() == typeof(Placeable))
            {
                // Check if the placeable can be interacted with
                Placeable placeable = (Placeable)auroraObject;
                AuroraUTP utp       = (AuroraUTP)placeable.template;

                if (utp.Useable == 0)
                {
                    //Debug.Log("Placeable is not useable, so not drawing hook");
                    continue;
                }
                //Debug.Log("Drawing hook for placeable");
                allHooks.Add(obj);
            }
        }

        //Debug.Log("Considering " + allHooks.Count + " hooks");

        List <GameObject> hooks = new List <GameObject>();

        foreach (GameObject g in allHooks)
        {
            //Debug.Log("Checking if hook " + g.name + " is visible");
            // Determine whether the object is blocked by another collider
            Vector2    point = Camera.main.WorldToScreenPoint(g.transform.position);
            Ray        r     = Camera.main.ScreenPointToRay(point);
            RaycastHit hit;

            if (Physics.Raycast(r, out hit, float.MaxValue, hookMask))
            {
                // We might hit the boundary of the object represented by the hook?
                if (hit.transform.gameObject == g || Vector3.Distance(hit.point, g.transform.position) < 1f)
                {
                    hooks.Add(g);
                }
            }
        }

        //Debug.Log("Showing " + hooks.Count + " hooks");

        float dist = float.PositiveInfinity;

        selectedHook = null;
        foreach (GameObject h in hooks)
        {
            Vector2 hPos = Camera.main.WorldToScreenPoint(h.transform.position);
            float   d    = Vector2.Distance(
                new Vector2(hPos.x, Screen.height - hPos.y),
                new Vector2(
                    Screen.width / 2,
                    Screen.height / 2
                    )
                );

            if (d < dist)
            {
                dist         = d;
                selectedHook = h;
            }
        }

        foreach (GameObject g in hooks)
        {
            Vector2 point = Camera.main.WorldToScreenPoint(g.transform.position);
            if (g == selectedHook)
            {
                if (Vector3.Distance(pc.transform.position, selectedHook.transform.position) < interactionRange)
                {
                    style.normal.textColor = Color.green;
                    style.fontSize         = 28;
                }
                else
                {
                    style.normal.textColor = Color.blue;
                    style.fontSize         = 28;
                }
            }
            else
            {
                style.normal.textColor = Color.red;
                style.fontSize         = 16;
            }

            Rect labelRect = new Rect(point.x - 90, Screen.height - point.y - 240, 180, 240);

            AuroraObject obj = g.GetComponent <LookAtHook>().obj;
            if (obj.GetType() == typeof(Door))
            {
                TooltipWindow doorTooltip = ((Door)obj).GetTooltip();
                using (new GUILayout.AreaScope(labelRect))
                {
                    doorTooltip.Draw();
                }
            }
            GUI.Label(
                new Rect(point.x - 25, Screen.height - point.y - 25, 50, 50),
                "O",
                style
                );;
        }
    }