Esempio n. 1
0
 void DistributeTask(Task task, npc NPC)
 {
     Debug.Log("Giving a task to: " + NPC);
     NPC.GiveTask(task);
     freeNpcs.Remove(NPC);
     tasks.Remove(task);
 }
    public void npcLevel(npc who)
    {
        Debug.Log("Settint Level for scp " + who + " Latest being " + LatestNPC + " current Main " + ZoneMain);
        if (LatestNPC != ZoneMain && who != ZoneMain)
        {
            if (LatestNPC != npc.none)
            {
                mainList[(int)LatestNPC].SetAgroLevel(0);
            }
            mainList[(int)who].SetAgroLevel(1);
            LatestNPC = who;
            NPCTimer  = 75;
        }

        if (LatestNPC != npc.none && who == ZoneMain)
        {
            mainList[(int)LatestNPC].SetAgroLevel(0);
            mainList[(int)who].SetAgroLevel(1);
            LatestNPC = who;
            NPCTimer  = 90;
        }

        if (who == ZoneMain)
        {
            mainList[(int)who].SetAgroLevel(1);
            LatestNPC = who;
            NPCTimer  = 120;
        }
    }
Esempio n. 3
0
    public GameObject SpawnAnNPC(string type, Vector2 pos = default(Vector2))
    {
        GameObject npcinst = Instantiate(NPCPref, pos, Quaternion.identity, transform);

        switch (type)
        {
        case "student":
            student std = npcinst.AddComponent <student> ();
            std.ChangeColour(Color.gray);
            break;

        case "teacher":
            teacher teach = npcinst.AddComponent <teacher> ();
            teach.ChangeColour(Color.green);
            break;

        case "officestaff":
            officestaff of = npcinst.AddComponent <officestaff> ();
            of.ChangeColour(Color.blue);
            break;

        case "cleaner":
            cleaner cln = npcinst.AddComponent <cleaner>();
            cln.ChangeColour(Color.magenta);
            break;

        default:
            npc NPC = npcinst.AddComponent <npc>();
            NPC.ChangeColour(Color.yellow);
            break;
        }
        NPCs.Add(npcinst.GetComponent <npc>());
        return(npcinst);
    }
Esempio n. 4
0
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        foreach (string asset in importedAssets)
        {
            if (!filePath.Equals(asset))
            {
                continue;
            }

            npc data = (npc)AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(npc));
            if (data == null)
            {
                data               = ScriptableObject.CreateInstance <npc> ();
                data.SheetName     = filePath;
                data.WorksheetName = sheetName;
                AssetDatabase.CreateAsset((ScriptableObject)data, assetFilePath);
                //data.hideFlags = HideFlags.NotEditable;
            }

            //data.dataArray = new ExcelQuery(filePath, sheetName).Deserialize<npcData>().ToArray();

            //ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
            //EditorUtility.SetDirty (obj);

            ExcelQuery query = new ExcelQuery(filePath, sheetName);
            if (query != null && query.IsValid())
            {
                data.dataArray = query.Deserialize <npcData>().ToArray();
                ScriptableObject obj = AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
                EditorUtility.SetDirty(obj);
            }
        }
    }
Esempio n. 5
0
        public void InsertNpc(npc toinsert)
        {
            var merchant = new Merchant(toinsert);

            World.Insert(merchant);
            Insert(merchant, merchant.X, merchant.Y);
            merchant.OnSpawn();
        }
Esempio n. 6
0
 public void startConversation(npc _npc)
 {
     //_dialogues = _npc._dialogues; //AsPrus: error here
     isTalking = true;
     dialogueBox.SetActive(true);
     placeInDialogue = 0;
     dialogueState   = State.Writing;
     StartCoroutine(writeText(_dialogues.sentences[placeInDialogue], dialogueTextBox, 0.03f));
 }
 void SetMainNPC(npc New)
 {
     for (int i = 0; i < mainList.Length; i++)
     {
         mainList[i].SetAgroLevel(0);
     }
     mainList[(int)New].SetAgroLevel(1);
     ZoneMain = New;
 }
Esempio n. 8
0
    protected bool getMoveType(Vector2 pos)
    {
        Vector2 now = transform.position;

        now -= new Vector2(0, 0.09f);
        float ep = 0.05f, ep2 = 0.01f;

        bool         xfirst, xC = false, yC = false;
        RaycastHit2D hitx1, hity1, hitx2, hity2, hitx0, hity0;

        hitx0 = Physics2D.Raycast(now, new Vector2((pos - now).x, 0).normalized, 0.05f + ep, rayMask);
        hitx1 = Physics2D.Raycast(now - new Vector2(0, 0.04f + ep2), new Vector2((pos - now).x, 0).normalized, 0.05f + ep, rayMask);
        hitx2 = Physics2D.Raycast(now + new Vector2(0, 0.04f + ep2), new Vector2((pos - now).x, 0).normalized, 0.05f + ep, rayMask);
        hity0 = Physics2D.Raycast(now, new Vector2(0, (pos - now).y - 0.09f).normalized, 0.04f + ep, rayMask);
        hity1 = Physics2D.Raycast(now - new Vector2(0.05f + ep2, 0), new Vector2(0, (pos - now).y - 0.09f).normalized, 0.04f + ep, rayMask);
        hity2 = Physics2D.Raycast(now + new Vector2(0.05f + ep2, 0), new Vector2(0, (pos - now).y - 0.09f).normalized, 0.04f + ep, rayMask);
        if (hitx1 || hitx2 || hitx0)
        {
            xC = true;
        }
        if (hity1 || hity2 || hity0)
        {
            yC = true;
        }

        if (!xC && !yC)
        {
            npc a = gameObject.GetComponent <npc>();
            if (a != null && a.nowState == npcState.follow)
            {
                xfirst = true;
            }
            else if (Mathf.Abs(pos.x - start.x) > Mathf.Abs(pos.y - start.y))
            {
                xfirst = true;
            }
            else
            {
                xfirst = false;
            }
        }
        else if (xC)
        {
            xfirst = false;
        }
        else if (yC)
        {
            xfirst = true;
        }
        else
        {
            //xy都被阻拦,智能寻路之后完善
            xfirst = true;
        }

        return(xfirst);
    }
Esempio n. 9
0
    //  clicked seleccionado
    public void AccionA()
    {
        Boolean ActionDone = false;

        if (currentState == BattleStates.ENEMYC)
        {
            npc Target = null;

            for (int i = 0; i < all.Length; i++)
            {
                if (all[i].clicked)
                {
                    Target = all[i];
                }
            }
            if (Target != null)
            {
                if (tank.getDead())
                {
                    //  aqui va lo que quiera que haga el moco
                    if (player is ReySlime)
                    {
                        ReySlime moco = (ReySlime)player;
                        moco.disparoMoco(Target);
                        ActionDone = true;
                    }

                    //  all[Target].cambiaHp(10000, 'f');
                }
                else
                {
                    if (Target is tankBase)
                    {
                        //  aqui va lo que quiera que haga el moco
                        if (player is ReySlime)
                        {
                            ReySlime moco = (ReySlime)player;
                            moco.disparoMoco(Target);
                            ActionDone = true;
                        }
                    }
                }
                if (ActionDone)
                {
                    BlockButtons(false);
                    //   player.restaCooldowns();
                    StartCoroutine(waiter());
                }
            }

            for (int i = 0; i < all.Length; i++)
            {
                all[i].clicked = false;
            }
        }
    }
Esempio n. 10
0
        void npc_hurt(int index, PointF direction, float force, int takeHealth)
        {
            activeNPCs[index] = new npc(new PointF(activeNPCs[index].position.X, activeNPCs[index].position.Y),
                                        new PointF(activeNPCs[index].moment.X + direction.X * force, activeNPCs[index].moment.Y + direction.Y * force),
                                        activeNPCs[index].health - takeHealth);

            if (activeNPCs[index].health <= 0)
            {
                npc_die(index);
            }
        }
Esempio n. 11
0
 public void SetBattlePositions(battlePositions bpos, player pl, npc np)
 {
     if (bpos == battlePositions.standard)
     {
         //TODO: Support for big parties
         var p1pos = battlemap.GetNode("p1_combat_start") as Node2D;
         var e1pos = battlemap.GetNode("enemy_combat_start") as Node2D;
         pl.SetPosition(p1pos.GetGlobalPosition());
         np.SetPosition(e1pos.GetGlobalPosition());
     }
 }
Esempio n. 12
0
    public void disparoMoco(npc n1)
    {
        int disminuye = (int)(0.03 * mhp);

        cambiaHp(disminuye, 't');
        n1.cambiaHp(ap, 'm');
        n1.recibeEstado("congelado", 1);

        animacionAtaque("disparomoco");
        salpicar(ap - n1.getMr());
        Debug.Log("disparomoco");
    }
Esempio n. 13
0
    public void GenNpc(int x, int z)
    {
        npc player = ((GameObject)Instantiate(inst.npc)).GetComponent <npc>();
        Hex hex    = MapManager.GetInst().GetPlayerHex(x, 0, z);

        player.CurHex          = hex;
        player.CurHex.Passable = false;
        Vector3 v = player.CurHex.transform.position;

        v.y = 1.0f;
        player.transform.position = v;
    }
Esempio n. 14
0
        public LetterMatrix(npc npc)
        {
            this.npc            = npc;
            blocks              = new List <Block>();
            playerTransform     = Player.instance.transform;
            npc.cameraTransform = GameManager.instance.cam.transform;
            npc.spotLight       = npc.lightTransform.gameObject.GetComponent <Light>();
            npc.charactersSize  = npc.letterPrefab.GetComponent <TextMesh>().characterSize *npc.letterPrefab.transform.localScale.x;

            npc.lightTransform.gameObject.SetActive(false);

            center = npc.portraitTransform.position;
            npc.portraitTransform.gameObject.SetActive(false);
        }
Esempio n. 15
0
    public void SetupCombat(npc collidingWith)
    {
        //TODO: make this better
        var tiles = GetNode("../groundlayer") as TileMap;

        GD.Print((int)(((p.Position.x - 16) / 32) + 1) + ", " + (int)(((p.Position.y - 16) / 32) + 1));
        var tilex   = (int)(((p.Position.x - 16) / 32) + 1);
        var tiley   = (int)(((p.Position.y - 16) / 32) + 1);
        int battile = tiles.GetCell(tilex, tiley);

        if (battile == 5181)
        {//dark dirt
            battlemap = GetNode("../battlemap");
            GD.Print("Battle: Dark dirt. tile id " + battile);
        }
        else
        {
            GD.Print("Battle scene: Undefined yet tile id: " + battile);
            battlemap = GetNode("../battlemap");
        }

        g.combatants.Add(collidingWith);
        g.combatants.Add(p);

        foreach (Node n in g.combatants)
        {
            if (n is player)
            {
                //player
                var me = n as player;
                me.actionWeight = 0;
                me.turnTaken    = false;
            }
            else if (n is npc)
            {
                //NPC
                var me = n as npc;
                me.actionWeight = 0;
                me.turnTaken    = false;
            }
        }

        SetBattlePositions(battlePositions.standard, p, collidingWith);
        gui.InitializeCombatUI();

        combatWaitTimer.Connect("timeout", this, "BeginNextTurn");
        combatWaitTimer.SetWaitTime(1.0f);
        combatWaitTimer.OneShot = true;
        combatWaitTimer.Start();
    }
Esempio n. 16
0
 public void StartPostConversation()
 {
     npcObjects[npcCounter].GetChild(0).gameObject.SetActive(true);
     npcParent.SetActive(true);
     if (currentNPC.postTaskDialogue != null)
     {
         CameraZoom.Center(GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(), npcXpos);
         PositionPlayer(GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>());
         GameObject.Find("dialogueManager").GetComponent <Dialogue>().NewText(currentNPC.postTaskDialogue, false, null, null);
         currentNPC       = null;
         currentNPCobject = null;
         currentSceneName = null;
     }
 }
Esempio n. 17
0
 private void CheckWhichNPC(string name)
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         foreach (npc npc in townNPC)
         {
             if (npc.name == name && npc.preTaskDialogue != null && npc.minigameScene != "")
             {
                 currentNPC = npc;
                 StartConversation();
                 npcObjects[npcCounter].GetChild(0).gameObject.SetActive(false);
                 npcCounter++;
             }
         }
     }
 }
Esempio n. 18
0
 public Merchant(npc data)
 {
     Data        = data;
     X           = (byte)data.map_x;
     Y           = (byte)data.map_y;
     Sprite      = (ushort)data.sprite;
     Direction   = (Direction)data.direction;
     Name        = data.name;
     DisplayText = data.display_text;
     Ready       = false;
     Jobs        = (MerchantJob)data.jobs;
     Inventory   = new Dictionary <string, item>();
     //foreach (var item in data.inventory)
     //{
     //   Inventory.Add(item.name, item);
     //}
 }
Esempio n. 19
0
    public void aCenar(npc n1)
    {
        int aumenta = (int)(mhp * 0.2);

        recibeEstado("habcenar", 3);
        if (n1.getHper() <= 30)
        {
            cambiaHp(aumenta, 'c');
            devorar();
            n1.cambiaHp(n1.getHp(), 't');
        }
        else
        {
            disparoMoco(n1);
        }
        Debug.Log("a cenar");
    }
Esempio n. 20
0
    private void CheckCombat(Node col)
    {
        collidingWith = col.GetParent() as npc;

        if (collidingWith == null)
        {
            return;
        }

        ui.collidingWith = collidingWith;

        if (ui.collidingWith.myType == npcType.enemy)
        {
            //TODO: Move elsewhere?
            g.inCombat  = true;
            g.inputMode = inputModes.noInput;
            ui.StartFadeOut();
        }
    }
    public void NPCManager()
    {
        NPCTimer -= Time.deltaTime;

        if (NPCTimer <= 0)
        {
            LatestNPC = npc.none;
        }

        if (GameController.instance.currZone == 2 && ZoneMain != Zone3_Main)
        {
            SetMainNPC(Zone3_Main);
        }
        if (GameController.instance.currZone == 1 && ZoneMain != Zone2_Main)
        {
            SetMainNPC(Zone2_Main);
        }
        if (GameController.instance.currZone == 0 && ZoneMain != Zone1_Main)
        {
            SetMainNPC(Zone1_Main);
        }
    }
Esempio n. 22
0
 public void Check(npc click)
 {
     if (click is arqueroBase)
     {
         tank.clicked       = false;
         healer.clicked     = false;
         espadachin.clicked = false;
         mago.clicked       = false;
     }
     if (click is tankBase)
     {
         dps.clicked        = false;
         healer.clicked     = false;
         espadachin.clicked = false;
         mago.clicked       = false;
     }
     if (click is healerBase)
     {
         dps.clicked        = false;
         tank.clicked       = false;
         espadachin.clicked = false;
         mago.clicked       = false;
     }
     if (click is espadachinBase)
     {
         dps.clicked    = false;
         tank.clicked   = false;
         healer.clicked = false;
         mago.clicked   = false;
     }
     if (click is magoBase)
     {
         dps.clicked        = false;
         tank.clicked       = false;
         healer.clicked     = false;
         espadachin.clicked = false;
     }
 }
Esempio n. 23
0
    public void StartConversation()
    {
        HideMapSelector();
        //GLOBALS KEYWORDS: (firstmeet), (hail), name, job, bye
        //After the line of dialogue has been grabbed,
        //Check the NEXT line
        //and make sure it doesn't contain a **.
        //If it does, perform action.
        g.inputMode    = inputModes.convoListen;
        currentSpeaker = p.targets[mapSelNo] as npc;
        dialogueWin.Show();
        PopKeywords();
        bool npcfound = false;

        for (int c = 0; c < scrip.Length; c++)
        {
            if (scrip[c].Contains("NPC"))
            {
                string npcname = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                if (npcname == currentSpeaker.myName)
                {
                    npcfound = true;
                    GD.Print("speaker dialogue found.");
                }
            }
            if (npcfound)
            {
                if (!g.peopleMet.Contains(currentSpeaker.myName))
                {
                    if (scrip[c].to_lower().Contains("firstmeet"))
                    { //KEYWORD
                        dialogueTxt.Text = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                        for (int j = 1; j < 9; j++)
                        {
                            //Check up to 9 rows ahead for commands.
                            if (scrip[c + j].Contains("**"))
                            {
                                RunConvoAction(scrip[c + j]);
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;
                    }
                }
                else //AREADY MET PERSON CODE:
                {
                    if (scrip[c].to_lower().Contains("hail"))
                    { //KEYWORD
                        dialogueTxt.Text = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                        for (int j = 1; j < 9; j++)
                        {
                            //Check up to 9 rows ahead for commands.
                            if (scrip[c + j].Contains("**"))
                            {
                                RunConvoAction(scrip[c + j]);
                            }
                            else
                            {
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
        oocMenu.Show();
        //TODO: Make another < indicator for dialogue
        var newoocselpos = new Vector2(160, 125);

        oocSel.Position = newoocselpos;
        //TODO:
        //add firstmeet to save
        //if any global keywords or switches are added, add to save
    }
Esempio n. 24
0
    //public bool inarena; besser in map?
    //monster m001;


    // Use this for initialization
    void Start()
    {
        p001 = GameObject.Find("Main Camera").GetComponent <player> ();
        p002 = GameObject.Find("Main Camera").GetComponent <player> ();
        n001 = GameObject.Find("Main Camera").GetComponent <npc> ();
    }
Esempio n. 25
0
 public void AddNPCToQueue(npc newNpc)
 {
     freeNpcs.Add(newNpc);
 }
Esempio n. 26
0
 public void Init(npc NPC)
 {
     this.NPC = NPC;
 }
Esempio n. 27
0
        void npc_move()
        {
            for (int i = 0; i < activeNPCs.Count; i++)
            {
                PointF NPCposition = new PointF(activeNPCs.ElementAt(i).position.X, activeNPCs.ElementAt(i).position.Y);
                PointF moment      = new PointF(activeNPCs.ElementAt(i).moment.X, activeNPCs.ElementAt(i).moment.Y);
                bool   OnGround    = false;

                PointF chasePlayerVector = new PointF(player_position.X - NPCposition.X, player_position.Y - NPCposition.Y);

                if (chasePlayerVector.X != 0)
                {
                    normalize(ref chasePlayerVector);
                }

                //Y
                //Gravity
                moment.Y += 0.5F * timeScale;

                //Add moment to position
                NPCposition.Y += moment.Y * timeScale;
                if (npc_collides_X(NPCposition))
                {
                    if (moment.Y > 0)
                    {
                        OnGround = true;
                    }
                    NPCposition.Y -= moment.Y * timeScale;
                    moment.Y      -= (moment.Y * timeScale) / 2;
                }
                else
                {
                    OnGround = false;
                }

                //X
                if (Math.Abs(moment.X) * ((Math.Sign(moment.X)) * (Math.Sign(chasePlayerVector.X))) < 3)
                {
                    moment.X += (chasePlayerVector.X * timeScale) / 2;
                }
                else
                {
                    moment.X -= moment.X * 0.01f;
                }

                //Add moment to position
                NPCposition.X += moment.X * timeScale;
                if (npc_collides_X(NPCposition))
                {
                    NPCposition.X -= moment.X * timeScale;
                    moment.X      -= (moment.X * timeScale) / 2;

                    //If you collide on X and you're on the ground - jump
                    if (OnGround && Math.Abs(moment.X) * ((Math.Sign(moment.X)) * (Math.Sign(chasePlayerVector.X))) > 0)
                    {
                        moment.Y = -10;
                    }
                }


                //Update values
                activeNPCs[i] = new npc(new PointF(NPCposition.X, NPCposition.Y),
                                        new PointF(moment.X, moment.Y),
                                        activeNPCs[i].health);

                for (int e = 0; e < enemy_eyes.Count; e++)
                {
                    enemy_eyes[e].position.X = activeNPCs[e].position.X;
                    enemy_eyes[e].position.Y = activeNPCs[e].position.Y - 7;
                }
            }
        }
 private void Start()
 {
     count = this;
 }
Esempio n. 29
0
    public void StartConversation()
    {
        HideMapSelector();
        newTopics.Clear();
        //GLOBALS KEYWORDS: (firstmeet), (hail), name, job, bye
        //After the line of dialogue has been grabbed,
        //Check the NEXT line
        //and make sure it doesn't contain a **.
        //If it does, perform action.
        //oocSelNo = 0;
        //oocSel.Position = oocSelBasePos;
        g.inputMode    = inputModes.convoListen;
        currentSpeaker = p.targets[mapSelNo] as npc;
        dialogueWin.Show();
        oocSel.Show();
        InitializeKeywords();
        GD.Print("Keywords initialized OK");
        dialogueReturnTo = "";
        bool npcfound = false;

        for (int c = 0; c < scrip.Length; c++)
        {
            if (scrip[c].Contains("NPC"))
            {
                string npcname = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                if (npcname == currentSpeaker.myName)
                {
                    npcfound = true;
                    dbOffset = c;
                    GD.Print("speaker dialogue found.");
                }
            }
            if (npcfound)
            {
                if (!g.peopleMet.Contains(currentSpeaker.myName))
                {
                    if (scrip[c].to_lower().Contains("'firstmeet'"))
                    { //KEYWORD
                        dialogueTxt.Text = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                        CheckCommands(c);
                        break;
                    }
                }
                else //AREADY MET PERSON CODE:
                {
                    if (scrip[c].to_lower().Contains("'hail'"))
                    { //KEYWORD
                        dialogueTxt.Text = scrip[c].substr(scrip[c].IndexOf(':') + 1, scrip[c].Length - scrip[c].IndexOf(':') - 1);
                        CheckCommands(c);
                        break;
                    }
                }
            }
        }

        //TODO: Make another < indicator for dialogue, make this efficient(static)
        MoveSelectorToDialogueWindow();
        //TODO:
        //add firstmeet to save
        //if any global keywords or switches are added, add to save
    }
Esempio n. 30
0
 public void InsertNpc(npc toinsert)
 {
     var merchant = new Merchant(toinsert);
     World.Insert(merchant);
     Insert(merchant, merchant.X, merchant.Y);
     merchant.OnSpawn();
 }