Beispiel #1
0
    public void OnGUI()
    {
        List <string> options = new List <string>();

        if (GUILayout.Button("Reset"))
        {
            NCSTrace.traces.Clear();
        }

        if (NCSTrace.traces.Count == 0)
        {
            return;
        }

        int i = 0;

        foreach (NCSTrace t in NCSTrace.traces)
        {
            AuroraObject obj = t.contexts[0].objectSelf;

            string tag;
            if (obj == null)
            {
                tag = "NULL";
            }
            else
            {
                dynamic template = obj.template;
                tag = template.Tag;
            }
            options.Add(i + ": " + tag);
            i++;
        }

        selectedTrace = EditorGUILayout.Popup(selectedTrace, options.ToArray());

        NCSTrace trace = NCSTrace.traces[selectedTrace];

        DrawTrace(trace);
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        AuroraObject container = (AuroraObject)target;

        //foreach (Component component in container.GetComponents<Component>())
        //{
        //    if (component.GetType() != typeof(AuroraObject) && component.GetType() != typeof(Transform))
        //    {
        //        component.hideFlags = HideFlags.HideInInspector;
        //    }
        //}
        base.OnInspectorGUI();

        if (container.template == null)
        {
            return;
        }

        EditorGUILayout.LabelField("Editing type " + container.template.GetType().Name);

        CreateInspector(container, container.template, "");
    }
Beispiel #3
0
    AuroraObject CreatePC()
    {
        // Create the PC
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        AuroraObject pcObj = player.AddComponent <Creature>();

        stateManager.PC = pcObj;

        // Set the PC as the leader of the party
        stateManager.party[0] = pcObj;

        AuroraUTC template = new AuroraUTC();

        // Initialize the lists
        template.ClassList       = new List <AuroraUTC.AClass>();
        template.Equip_ItemList  = new List <AuroraUTC.AEquip_Item>();
        template.FeatList        = new List <AuroraUTC.AFeat>();
        template.ItemList        = new List <AuroraUTC.AItem>();
        template.SkillList       = new List <AuroraUTC.ASkill>();
        template.SpecAbilityList = new List <AuroraUTC.ASpecAbility>();

        // TODO: Temporary stuff; this should be set by character creation later
        // Set some default scripts
        template.ScriptUserDefine = "k_def_userdef01";

        // Set some default variable values
        template.Gender = 0;
        template.ClassList.Add(new AuroraUTC.AClass()
        {
            structid   = 0,
            Class      = 0,
            ClassLevel = 1
        });

        pcObj.template = template;

        return(pcObj);
    }
    public AuroraObject GetClosestObjectByTag(string tag, AuroraObject target, int nNth)
    {
        // nNth is 1-based for some reason...
        nNth -= 1;

        if (!auroraObjects.ContainsKey(tag))
        {
            return(AuroraObject.OBJECT_INVALID);
        }

        List <AuroraObject> objs = new List <AuroraObject>(auroraObjects[tag]);

        if (nNth >= objs.Count)
        {
            return(null);
        }

        objs.Sort(
            (x, y) => Vector3.Distance(target.transform.position, x.transform.position).CompareTo(Vector3.Distance(target.transform.position, y.transform.position))
            );

        return(objs[nNth]);
    }
Beispiel #5
0
 public MovementAction(AuroraObject obj) : base(obj)
 {
     agent = obj.GetComponent <NavMeshAgent>();
 }
Beispiel #6
0
 public ActionBarkString(AuroraObject obj, int strRef) : base(obj)
 {
 }
Beispiel #7
0
 public ActionLockObject(AuroraObject obj, AuroraObject oTarget) : base(obj)
 {
 }
Beispiel #8
0
 public ActionTaunt(AuroraObject obj) : base(obj)
 {
 }
Beispiel #9
0
 public ActionCastSpellAtObject(AuroraObject obj, int nSpell, AuroraObject oTarget, int nMetaMagic, bool bCheat, int nDomainLevel, int nProjectilePathType, bool bInstantSpell) : base(obj)
 {
 }
Beispiel #10
0
 public ActionStopConversation(AuroraObject obj) : base(obj)
 {
 }
Beispiel #11
0
 public ActionMoveToObject(AuroraObject obj, AuroraObject other, bool bRun, float fRange) : base(obj)
 {
     target = other;
     run    = bRun;
     range  = 2 * fRange;
 }
Beispiel #12
0
 public ActionHeal(AuroraObject obj) : base(obj)
 {
 }
Beispiel #13
0
 public ActionCastFakeSpellAtLocation(AuroraObject obj, int nSpell, AuroraLocation lTarget, int nProjectilePathType) : base(obj)
 {
 }
Beispiel #14
0
 public ActionCounterSpell(AuroraObject obj) : base(obj)
 {
 }
Beispiel #15
0
 public ActionCastSpellAtLocation(AuroraObject obj, int nSpell, AuroraLocation lTargetLocation,
                                  int nMetaMagic, bool bCheat, int nProjectilePathType, bool bInstantSpell) : base(obj)
 {
 }
Beispiel #16
0
 public ActionCastSpell(AuroraObject obj) : base(obj)
 {
 }
Beispiel #17
0
 public ActionRandomWalk(AuroraObject obj) : base(obj)
 {
     basePos   = obj.transform.position;
     curTarget = obj.transform.position;
     time      = 6f;
 }
Beispiel #18
0
 public ActionResumeConversation(AuroraObject obj) : base(obj)
 {
 }
Beispiel #19
0
 public ActionFollowLeader(AuroraObject obj) : base(obj)
 {
     stateSystem = GameObject.Find("State System").GetComponent <StateSystem>();
 }
Beispiel #20
0
 public AuroraTalent(AuroraObject owner, int id, TalentType talentType)
 {
     this.owner      = owner;
     this.id         = id;
     this.talentType = talentType;
 }
Beispiel #21
0
 public ActionForceFollowObject(AuroraObject obj, AuroraObject oFollow, float fFollowDistance) : base(obj)
 {
     target = oFollow;
     range  = fFollowDistance;
 }
    void PointCamera()
    {
        if (curMode == DialogMode.PC)
        {
            // Make the camera point at the PC
            // Focus on the speaker
            GameObject pc = stateManager.PC.gameObject;

            // Calculate a camera position in front of the speaker, facing them
            Camera.main.transform.position = pc.transform.position + pc.transform.forward * 0.5f + pc.transform.up * 1.6f;
            Camera.main.transform.rotation = Quaternion.LookRotation(
                pc.transform.forward * -0.5f,
                pc.transform.up
                );
        }
        else if (curMode == DialogMode.NPC)
        {
            // Play the current camera animation, if there is one
            // Use the default camera pointing via camera angle
            GameObject speaker, listener;
            Vector3    cameraPosition = Camera.main.transform.position;
            Quaternion cameraRotation = Camera.main.transform.rotation;

            if (curEntry.Speaker == "")
            {
                // Speaker is the current owner
                speaker = owner.gameObject;
            }
            else
            {
                speaker = stateManager.GetObjectByTag(curEntry.Speaker).gameObject;
            }

            // TODO: Support other listeners, will be important in K2?
            listener = stateManager.PC.gameObject;


            switch (curEntry.CameraAngle)
            {
            case 0:
            case 1:
                // Focus on the speaker
                // Calculate a camera position in front of the speaker, facing them
                cameraPosition = speaker.transform.position +
                                 speaker.transform.forward * 0.5f +
                                 speaker.transform.up * 1.5f;
                cameraRotation = Quaternion.LookRotation(speaker.transform.forward * -0.5f, speaker.transform.up);
                break;

            case 2:
                Vector3 delta = listener.transform.position - speaker.transform.position;
                // Behind the listener, facing the speaker
                cameraPosition = listener.transform.position +
                                 listener.transform.forward * -1f +
                                 speaker.transform.up * 1.5f;
                cameraRotation = Quaternion.LookRotation(delta, speaker.transform.up);
                break;

            case 3:
            case 5:
            case 6:
                cameraPosition = speaker.transform.position +
                                 speaker.transform.forward * 2.5f +
                                 speaker.transform.up * 1.5f;
                cameraRotation = Quaternion.LookRotation(speaker.transform.forward * -2.5f, speaker.transform.up);
                break;

            case 4:
                // Animated camera
                AnimationState selectedClip = GetAnimationState();

                Animation animator = cameraModel.GetComponent <Animation>();
                if (selectedClip != null)
                {
                    // Play the selected clip
                    animator.Play(selectedClip.name);
                }

                // Bind the camera transform to the camera model transform
                Transform cameraPos = null;
                foreach (Transform t in cameraModel.transform)
                {
                    if (t.name == "camerahook")
                    {
                        cameraPos = t;
                        break;
                    }
                }

                Camera.main.transform.localPosition = priorCamPos;
                Camera.main.transform.localRotation = priorCamRot;

                if (cameraPos != null)
                {
                    cameraPosition = cameraPos.transform.position;
                    cameraRotation = Quaternion.Euler(
                        cameraPos.transform.rotation.eulerAngles +
                        new Vector3(90, 0, 0)
                        );
                }
                break;

            //case 5:
            //    // Focus on listener (is broken in original game)
            //    break;
            //case 6:
            //    // Module-specific static camera
            //    break;
            default:
                // In this case, "break" is used literally
                break;
            }


            Camera.main.transform.position = cameraPosition;
            Camera.main.transform.rotation = cameraRotation;

            // Play animations for the current entry
            foreach (AuroraDLG.AEntry.AAnim anim in curEntry.AnimList)
            {
                string participant = anim.Participant;

                Debug.Log("Triggering dialog animation for " + participant);

                int animID = (int)anim.Animation;

                AuroraObject target = null;
                if (participant == "PLAYER")
                {
                    target = stateManager.PC;
                }
                else if (participant == null)
                {
                    // Not sure what to do here?
                }
                else
                {
                    target = stateManager.GetObjectByTag(participant);
                }

                if (target != null)
                {
                    target.PlayAnimation(animID);
                }
                else
                {
                    Debug.Log("Could not find target " + participant);
                }
            }
        }
    }
Beispiel #23
0
 public ActionPauseConversation(AuroraObject obj) : base(obj)
 {
 }
Beispiel #24
0
 public ActionSit(AuroraObject obj) : base(obj)
 {
 }
Beispiel #25
0
 public ActionDialogObject(AuroraObject obj) : base(obj)
 {
 }
Beispiel #26
0
 public ActionSpeakString(AuroraObject obj, string sStringToSpeak, int nTalkVolume) : base(obj)
 {
 }
Beispiel #27
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
                );;
        }
    }
Beispiel #28
0
 public ActionSpeakStringByStrRef(AuroraObject obj, int nStrRef, int nTalkVolume) : base(obj)
 {
 }
Beispiel #29
0
 public AuroraEffect GetFirstEffect(AuroraObject target)
 {
     iterEffects = new List <AuroraEffect>(target.effects);
     return(GetNextEffect());
 }
Beispiel #30
0
 public ActionUseObject(AuroraObject obj) : base(obj)
 {
 }