Beispiel #1
0
    void OnTriggerEnter(Collider other)
    {
        HHK_Role_Tags role = other.GetComponent <HHK_Role_Tags>();

        if (role)
        {
            if (role.Is_Belong_Teams_Either(allowed))
            {
                // in to this area
                roles.Add(role);
            }
        }

        // leap motion
        RigidFinger finger = other.GetComponentInParent <RigidFinger>();

        if (finger)
        {
            //Debug.Log("finger");
            role = other.GetComponentInParent <HHK_Role_Tags>();

            if (role && !roles.Contains(role))
            {
                // in to this area
                roles.Add(role);
            }
        }
    }
 // 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 #3
0
    void OnTriggerExit(Collider other)
    {
        HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();

        if (rt)
        {
            // leave from this place
            Leave_From_This_Place(rt);
        }
    }
Beispiel #4
0
    void OnTriggerEnter(Collider other)
    {
        HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();

        if (rt)
        {
            // join to this place
            Join_To_This_Place(rt);
        }
    }
Beispiel #5
0
    // get the position of the currently, for the input charactors
    public Vector3 Get_My_Position(HHK_Role_Tags role)
    {
        Vector3 ret = gameObject.transform.position;

        // get the index of the list for the input charactor
        int i = Get_My_Index(role);

        ret += (-gameObject.transform.forward) * interval * i;

        return(ret);
    }
Beispiel #6
0
    void OnTriggerExit(Collider other)
    {
        HHK_Role_Tags role = other.GetComponent <HHK_Role_Tags>();

        if (role)
        {
            if (roles.Contains(role))
            {
                roles.Remove(role);
            }
        }
    }
Beispiel #7
0
    void OnTriggerExit(Collider other)
    {
        HHK_Role_Tags role = other.GetComponent <HHK_Role_Tags>();

        if (role)
        {
            HHK_Role_Tags.TAG[] tags = { HHK_Role_Tags.TAG.Role_Player };
            if (role.Is_Belong_Teams_Either(tags))
            {
                uiPanel.gameObject.SetActive(false);
            }
        }
    }
Beispiel #8
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);
 }
    // get the position of the currently, for the input charactors
    public Vector3 Get_My_Position(HHK_Role_Tags role)
    {
        Vector3 ret = gameObject.transform.position;
        int     i   = charactors.IndexOf(role);

        ret += (-gameObject.transform.forward) * interval * i;

        // randomly x, z
        Vector2 v2 = Random.insideUnitCircle * interval * intervalRandomScale;

        ret.x += v2.x;
        ret.z += v2.y;

        return(ret);
    }
Beispiel #10
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 #11
0
    // Use this for initialization
    void Start()
    {
        // find the player object
        HHK_Role_Tags.TAG[] tags    = { HHK_Role_Tags.TAG.Role_Player };
        HHK_Role_Tags[]     players = HHK_Role_Tags.Find_Objects_Belong_Teams(tags);

        // set the player to the start point;
        players[0].transform.position = entry_points[which_start_point].transform.position;
        // fixed the position.
        players[0].transform.position = new Vector3(players[0].transform.position.x,
                                                    players[0].transform.position.y + offset_y,
                                                    players[0].transform.position.z);
        players[0].transform.rotation = entry_points[which_start_point].transform.rotation;

        ready_to_go = false;         // reset
    }
Beispiel #12
0
    void OnTriggerExit(Collider other)
    {
        // only accept the player get into this trigger
        HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();

        if (rt)
        {
            HHK_Role_Tags.TAG[] tags = { HHK_Role_Tags.TAG.Role_Player };
            if (rt.Is_Belong_Teams(tags))
            {
                // player get into this trigger
                // ready to shift to next level
                HHK_Entry_Points_Manager.ready_to_go = true;
            }
        }
    }
Beispiel #13
0
    void OnTriggerStay(Collider other)
    {
        // just for player
        HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();

        if (rt)
        {
            if (rt.Is_Belong_Teams(new HHK_Role_Tags.TAG[] { HHK_Role_Tags.TAG.Role_Player }))
            {
                // set the time limit;
                force_to_leave_time_limit = maxTime * force_to_leave_time_limit_scale;

                // join to this place
                Join_To_This_Place(rt);
            }
        }
    }
Beispiel #14
0
    void OnTriggerEnter(Collider other)
    {
        // only accept the player get into this trigger
        // and he is ready to go.
        HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();

        if (rt)
        {
            HHK_Role_Tags.TAG[] tags = { HHK_Role_Tags.TAG.Role_Player };
            if (rt.Is_Belong_Teams(tags) &&
                HHK_Entry_Points_Manager.ready_to_go)
            {
                // player get into this trigger
                // shift to the next level and start at the given start point/entry point
                HHK_Entry_Points_Manager.which_start_point = which_start_point;
                Application.LoadLevel(to_next_level);
            }
        }
    }
Beispiel #15
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);
    }
Beispiel #16
0
 void OnTriggerStay(Collider other)
 {
     // when the player click the key, then turn on/off the light
     if (Input.GetKeyDown(actionKey))
     {
         HHK_Role_Tags rt = other.gameObject.GetComponent <HHK_Role_Tags>();
         if (rt)
         {
             // player get stay this trigger
             HHK_Role_Tags.TAG[] tags = { HHK_Role_Tags.TAG.Role_Player };
             if (rt.Is_Belong_Teams(tags))
             {
                 if (target)
                 {
                     target.enabled = !target.enabled;
                 }
             }
         }
     }
 }
Beispiel #17
0
    // Code that runs on entering the state.
    public override void OnEnter()
    {
        HHK_FSM_Walking_NPC_Variables npc = Owner.GetComponent <HHK_FSM_Walking_NPC_Variables> ();

        // play animation via spot
        npc.role_controller.CrossFade(HHK_Role_Controller.AnimName.die);

        HHK_Role_Tags tag = Owner.GetComponent <HHK_Role_Tags>();

        // force to leave the area
        if (npc.waiting_point)
        {
            npc.waiting_point.Leave_From_This_Place(tag);
        }
        if (npc.spot)
        {
            npc.spot.Leave_From_This_Place(tag);
        }

        npc.agent.Stop();

        // send a message
        MessageSystem.Send(MessageSystem.NPC_Die, npc);
    }
Beispiel #18
0
 void Awake()
 {
     agent           = GetComponent <NavMeshAgent>();
     role            = GetComponent <HHK_Role_Tags>();
     role_controller = GetComponent <HHK_Role_Controller>();
 }
Beispiel #19
0
 void Awake()
 {
     agent = GetComponent <NavMeshAgent>();
     role  = GetComponent <HHK_Role_Tags>();
 }
Beispiel #20
0
 // when a charactor leave, it will be removed from the list of Charactors
 void Leave_From_This_Place(HHK_Role_Tags role)
 {
     charactors.Remove(role);
 }
Beispiel #21
0
 // when a charactor have a purpose to go to this place,
 // it will be added to the list of Charactors
 void Join_To_This_Place(HHK_Role_Tags role)
 {
     charactors.Add(role);
 }
Beispiel #22
0
 // check is the charactor in this place
 public bool Is_In_This_Place(HHK_Role_Tags role)
 {
     return(charactors.Contains(role));
 }
    // 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;
            }
        }
    }
Beispiel #24
0
 public bool Join_From_The_Waiting_Line(HHK_Role_Tags role)
 {
     return(Join_To_This_Place(role));
 }
Beispiel #25
0
 // check is the charactor in this place
 public bool Is_In_This_Place(HHK_Role_Tags role)
 {
     return(charactor == role);
 }
Beispiel #26
0
 // get the index of the line
 public int Get_My_Index(HHK_Role_Tags role)
 {
     return(charactors.IndexOf(role));
 }