Esempio n. 1
0
    public override void SetEntities(List <s_map.s_chara> characters)
    {
        foreach (s_map.s_chara c in characters)
        {
            if (InEditor)
            {
                if (c.charType == "guard")
                {
                    npc_guard guar = Instantiate <npc_guard>(FindOBJ <npc_guard>("guard"), new Vector3(c.pos_x, c.pos_y), Quaternion.identity);
                    guar.name = c.charname;
                    guar.marchDirection.Clear();
                    List <s_map.s_customType> custom   = c.CustomTypes.FindAll(x => x.name == "node");
                    s_map.s_customType        location = c.CustomTypes.Find(x => x.name == "location");
                    guar.teleportLoc = location.type3;

                    foreach (s_map.s_customType cu in custom)
                    {
                        guar.marchDirection.Add(cu.type);
                    }
                    guar.transform.SetParent(entitiesObj.transform);
                }
            }
            else
            {
                if (c.charType == "guard")
                {
                    npc_guard guar = SpawnObject <npc_guard>("guard", new Vector3(c.pos_x, c.pos_y), Quaternion.identity);
                    guar.name = c.charname;
                    guar.marchDirection.Clear();
                    if (guar.path != null)
                    {
                        guar.path.Clear();
                    }
                    guar.marchPoint = 0;
                    guar.state      = npc_guard.AI_STATE.IDLE;
                    List <s_map.s_customType> custom   = c.CustomTypes.FindAll(x => x.name == "node");
                    s_map.s_customType        location = c.CustomTypes.Find(x => x.name == "location");
                    guar.teleportLoc    = location.type3;
                    guar.marchDirection = new List <int>();
                    foreach (s_map.s_customType cu in custom)
                    {
                        guar.marchDirection.Add(cu.type);
                    }
                    guar.transform.SetParent(entitiesObj.transform);
                    allcharacters.Add(guar);
                }
            }
        }
    }
Esempio n. 2
0
    public override List <s_map.s_chara> GetEntities(o_character[] characters)
    {
        List <s_map.s_chara> t = new List <s_map.s_chara>();

        foreach (o_character c in characters)
        {
            s_map.s_chara ch = new s_map.s_chara(c.transform.position, "", c.name, c.ID, true, true, true, "fjks");
            npc_guard     g  = c.GetComponent <npc_guard>();
            for (int i = 0; i < g.marchDirection.Count; i++)
            {
                ch.AddCustomTag("node", g.marchDirection[i]);
                ch.AddCustomTag("location", g.teleportLoc);
            }
            t.Add(ch);
        }
        return(t);
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GameObject obj = Selection.activeGameObject;

        if (obj != null)
        {
            npc_guard anim = obj.GetComponent <npc_guard>();
            if (anim != null)
            {
                anim.ID      = EditorGUILayout.TextField(anim.ID);
                anim.faction = EditorGUILayout.TextField(anim.faction);
                EditorGUILayout.LabelField("Teleport location");
                anim.teleportLoc = EditorGUILayout.TextField(anim.teleportLoc);
                anim.marchPoint  = EditorGUILayout.IntField(anim.marchPoint);

                EditorGUILayout.LabelField("Pathfinding");
                if (anim.path != null)
                {
                    for (int i = 0; i < anim.path.Count; i++)
                    {
                        EditorGUILayout.LabelField(anim.path[i].id + "");
                    }
                }
                EditorGUILayout.LabelField("Path to follow");
                for (int i = 0; i < anim.marchDirection.Count; i++)
                {
                    int nod = anim.marchDirection[i];
                    if (GUILayout.Button("ID: " + nod))
                    {
                        anim.marchDirection.Remove(nod);
                    }
                }
                EditorGUILayout.LabelField("Nodes in map");
                if (nodes == null)
                {
                    s_ninjaloader nin = GameObject.Find("General").GetComponent <s_ninjaloader>();
                    s_ninjaloader.nl = nin;
                    nodes            = nin.GetNodes();
                }
                else
                {
                    for (int i = 0; i < nodes.Count; i++)
                    {
                        s_map.s_tileobj nod = nodes[i];
                        if (nod.TYPENAME != "Node")
                        {
                            continue;
                        }

                        if (GUILayout.Button(i + ""))
                        {
                            anim.marchDirection.Add(i);
                        }
                    }
                }
                EditorGUILayout.LabelField("Targets");
                if (anim.targets != null)
                {
                    for (int i = 0; i < anim.targets.Count; i++)
                    {
                        EditorGUILayout.LabelField(anim.targets[i].name + "");
                    }
                }
            }
        }
        Repaint();
    }