Example #1
0
 private bool IsByActivity()
 {
     if (npcObject.getX() == targetObject.getX())
     {
         if (npcObject.getY() + 1 == targetObject.getY())
         {
             return(true);
         }
         else if (npcObject.getY() - 1 == targetObject.getY())
         {
             return(true);
         }
     }
     else if (npcObject.getY() == targetObject.getY())
     {
         if (npcObject.getX() + 1 == targetObject.getX())
         {
             return(true);
         }
         else if (npcObject.getX() - 1 == targetObject.getX())
         {
             return(true);
         }
     }
     return(false);
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time - durration_stemp > dur_delta)
        {
            StateCalculator();
            if (doing is idle.searching)
            {
                buildSelfState();
                // printToDebug("running", 56);
                if (path.Count == 0)
                {
                    // printToDebug("case 1 ", 59);

                    // printToDebug("Before Astar", 61);
                    path = algo.runASTARonState(currentState, StateMap);
                    if (path == null)
                    {
                        printToDebug("error case , path not found ", 65);
                    }
                    else
                    {
                        //printToDebug("path count" + path.Count, 67);
                        // printToDebug("After Astar", 68);
                    }
                }
                else
                {
                    //printToDebug("case 2 ", 68);
                    Node next = path[path.Count - 1];
                    path.RemoveAt(path.Count - 1);
                    if (next != null)
                    {
                        // printToDebug("IN change", 68);
                        // currentState.getStart().printNode("current start at NPC");
                        int oldx = npcObject.getX();
                        int oldy = npcObject.getY();
                        setAvatarDirection(oldx, oldy, next.getX(), next.getY());
                        // next.printNode("next tile in NPC");
                        npcObject.setMapLocation(next.getX(), next.getY(), manager.size);
                        manager.UpdateNPCPlaces(oldx, oldy,
                                                npcObject.getX(), npcObject.getY());
                    }
                }
            }
            else if (doing is idle.using_activity)
            {
                //printToDebug("using activity", 102);
                //printToDebug("activity counter: " + activity_counter,103);
                activity_counter--;
            }
            decreaseNeeds();
            npcPrintStatus();
            manager.RealeaseLockWorldUpdate();
            durration_stemp = Time.time;
        }

        playAnimation();
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Debug.Log("exit");
            Application.Quit();
        }
        if (unlockUpdate)
        {
            foreach (GameObject go in activ_list)
            {
                ActivityObject ao = go.GetComponent <ActivityObject>();

                if (ao.getNeed() == activities.social)
                {
                    go.gameObject.transform.position = ao.getLocation();
                    //go.gameObject.transform.Translate( ao.getLocation(),Space.World);

                    NPCObject npc_temp = go.GetComponent <NPCObject>();

                    dict[go].material.SetColor("_Color", npc_temp.getStatusColor());
                    if (npc_temp.getCurrentIdleStats() == idle.searching)
                    {
                        ao.invokeStatusMassage("(" + ao.getX() + "," + ao.getY() + ")");
                    }
                    else
                    {
                        ao.invokeStatusMassage(npc_temp.getOccupiedActivity() + "");
                    }
                }
                else
                {
                    if (ao.getStatus())
                    {
                        ao.invokeStatusMassage("Occupied");
                        dict[go].material.SetColor("_Color", Color.red);
                    }
                    else
                    {
                        ao.invokeStatusMassage("avilable");
                        dict[go].material.SetColor("_Color", Color.green);
                    }
                }
            }
            unlockUpdate = false;
        }
    }