// when a charactor leave, it will be removed from the list of Charactors
 public void Leave_From_This_Place(HHK_Role_Tags role)
 {
     charactors.Remove(role);
     // change color for test
     if (change_color_for_test)
     {
         role.GetComponent <Renderer>().material.color = Color.blue;
     }
 }
Beispiel #2
0
 // when a charactor have a purpose to go to this place,
 // it will be added to the list of Charactors
 public bool Join_To_This_Place(HHK_Role_Tags role)
 {
     if (charactors.Count < max_len_of_line)
     {
         charactors.Add(role);
         // change color for test
         if (change_color_for_test)
         {
             role.GetComponent <Renderer>().material.color = Color.red;
         }
         return(true);
     }
     return(false);
 }
Beispiel #3
0
    // when a charactor leave, it will be removed from the list of Charactors
    bool Leave_From_This_Place(HHK_Role_Tags role)
    {
        if (charactor == role)
        {
            // change color for test
            if (change_color_for_test)
            {
                role.GetComponent <Renderer>().material.color = Color.blue;
            }

            charactor = null;
            return(true);
        }
        return(false);
    }
Beispiel #4
0
    // when a charactor have a purpose to go to this place,
    // it will be added to the list of Charactors
    bool Join_To_This_Place(HHK_Role_Tags role)
    {
        if (charactor)
        {
            return(false);
        }

        // change color for test
        if (change_color_for_test)
        {
            role.GetComponent <Renderer>().material.color = Color.yellow;
        }

        // set the time limit;
        force_to_leave_time_limit = maxTime * force_to_leave_time_limit_scale;

        charactor = role;
        return(true);
    }
    // Code that runs every frame.
    public override void OnUpdate()
    {
        timeout -= Time.deltaTime;
        if (timeout >= 0.0f)
        {
            return;
        }

        HHK_FSM_Walking_NPC_Variables npc = Owner.GetComponent <HHK_FSM_Walking_NPC_Variables> ();

        // rotataion
        //npc.transform.forward = Vector3.Lerp(npc.transform.forward, newDir,
        //                                     npc.agent.angularSpeed * Time.deltaTime);
        // npc.transform.rotation = Quaternion.Lerp (npc.transform.rotation, npc.waiting_point.transform.rotation,
        //                                     npc.agent.angularSpeed * Time.deltaTime);

        waitingTime -= Time.deltaTime;
        if (waitingTime <= 0.0f)
        {
            Fsm.Event(boring);
        }

        // keep checking any availabe spot
        if (npc.index_of_waiting_line == 0)
        {
            npc.spot = npc.place.Any_Available_Spot();
            if (npc.spot)
            {
                // leave this please
                npc.waiting_point.Leave_From_This_Place(Owner.GetComponent <HHK_Role_Tags> ());
                // join the spot first
                npc.spot.Join_From_The_Waiting_Line(Owner.GetComponent <HHK_Role_Tags> ());
                // to spot
                Fsm.Event(walkingToSpot);
                return;
            }
        }

        // keep checking the new waiting index of the line, move to the new position
        if (npc.index_of_waiting_line != npc.waiting_point.Get_My_Index(Owner.GetComponent <HHK_Role_Tags> ()))
        {
            // waiting ,until the prev moved
            HHK_Role_Tags prevTag
                = npc.waiting_point.At_Index(npc.waiting_point.Get_My_Index(Owner.GetComponent <HHK_Role_Tags> ()) - 1);

            // I am the first one
            if (prevTag == null)
            {
                // go to the waitting line
                Fsm.Event(walkingToWaitingPoint);
                return;
            }

            HHK_FSM_Walking_NPC_Variables prev = prevTag.GetComponent <HHK_FSM_Walking_NPC_Variables> ();
            // prev moved
            if (prev.index_of_waiting_line == prev.waiting_point.Get_My_Index(prev.GetComponent <HHK_Role_Tags> ()))
            {
                // go to the waitting line
                Fsm.Event(walkingToWaitingPoint);
                return;
            }
        }
    }