Пример #1
0
    public void PoliceStartLeave()
    {
        myAction = Action.Leave;

        int spawnIndex = Random.Range(0, IAM.SpawnPoints.Count);

        if (actualRoom != null)
        {
            actualRoom.Population.Remove(this);
            actualRoom = null;
        }

        myNavMesh.enabled = true;
        myNavMesh.SetDestination(IAM.SpawnPoints[spawnIndex].position);

        myAnimator.SetTrigger("Walk");
        myNavMesh.speed = 1.5f;
    }
Пример #2
0
    void RandomChangeRoom(bool isFuite = false)
    {
        aRoom theRoom = null;

        if (actualRoom != null && (Random.Range(0, 4) > 0) && isFuite == false)
        {
            theRoom = actualRoom;
        }
        else
        {
            aRoom theNewRoom = RM.Rooms[Random.Range(0, RM.Rooms.Count)];

            if (Random.Range(0, 2) <= (int)theNewRoom.Densité && theNewRoom != actualRoom)
            {
                theRoom = theNewRoom;
            }
        }

        if (theRoom == null || (theRoom == actualRoom && myType == Type.Policeman))
        {
            RandomChangeRoom(isFuite);
        }
        else
        {
            if (!isFuite && myType == Type.Civilian && actualRoom == theRoom && theRoom.Pieges.Count > 0 && Random.Range(0, 101) < 50)
            {
                for (int i = 0; i < theRoom.Pieges.Count; i++)
                {
                    if (theRoom.Pieges[i].theUser == null)
                    {
                        PiegeReservé         = theRoom.Pieges[i];
                        PiegeReservé.theUser = this;
                        //Utilisation du piège
                    }
                }
            }
            else if (isFuite && PiegeReservé != null)
            {
                PiegeReservé.theUser = null;
                PiegeReservé         = null;
            }

            if (PiegeReservé != null)
            {
                myNavMesh.SetDestination(new Vector3(PiegeReservé.transform.GetChild(0).transform.position.x, 0, PiegeReservé.transform.GetChild(0).transform.position.z));
            }

            else
            {
                myNavMesh.SetDestination(new Vector3(Random.Range(theRoom.downLeft.x, theRoom.downRight.x), 0, Random.Range(theRoom.downLeft.z, theRoom.upLeft.z)));
            }

            if (actualRoom != theRoom)
            {
                if (actualRoom != null)
                {
                    actualRoom.Population.Remove(this);
                }

                actualRoom = theRoom;

                if (!theRoom.Population.ContainsKey(this))
                {
                    theRoom.Population.Add(this, gameObject.name);
                }
            }

            if (isFuite == false)
            {
                myAction = Action.Move;
                myAnimator.SetTrigger("Walk");
                myNavMesh.speed = 1.5f;
            }
            else
            {
                myNavMesh.speed = 5f;
                myAnimator.SetTrigger("Run");
                myAction = Action.Flee;
            }
            if (BasePerso)
            {
                BasePerso = false;
            }
        }
    }