Beispiel #1
0
    public override void Initialise()
    {
        myType       = behaviourType.searchRooms;
        myController = this.gameObject.GetComponent <NPCController> ();

        //int r = Random.Range(0,100);
        //if (r < 25) {
        if (roomToGoTo == null)
        {
            roomToGoTo = LevelController.me.roomsInLevel [Random.Range(0, LevelController.me.roomsInLevel.Length)];
        }
        point         = roomToGoTo.getRandomPoint();
        searchingRoom = true;
        //} else {
        //searchingRoom = false;
        //	point = LevelController.me.actionsInWorld [Random.Range (0, LevelController.me.actionsInWorld.Count)].positionForAction.gameObject;
        //}
        //midPoint = roomToGoTo.bottomLeft.position + (( roomToGoTo.topRight.position - roomToGoTo.bottomLeft.position )/2);

        myController.pf.getPath(this.gameObject, point);
        radioMessageOnStart();
        isInitialised = true;
    }
    public override void OnUpdate()
    {
        if (isInitialised == false)
        {
            Initialise();
        }

        if (pointToInvestigate == null)
        {
            myController.npcB.suspisious           = false;
            myController.memory.noiseToInvestigate = Vector3.zero;
            myController.npcB.doing = whatAiIsDoing.starting;
            Destroy(this);
        }

        if (isNearLoc() == false && gotToLocation == false)
        {
            moveToCurrentPoint();
            myController.pwc.aimDownSight = false;
        }
        else
        {
            if (investigated == false)
            {
                if (gotRoom == false)
                {
                    room    = LevelController.me.getRoomObjectIsIn(this.gameObject);
                    gotRoom = true;
                }

                if (room == null)
                {
                    myController.npcB.suspisious           = false;
                    myController.memory.noiseToInvestigate = Vector3.zero;
                    Destroy(this);
                }
                else
                {
                    if (room.pointsInRoom.Count == 0)
                    {
                        myController.npcB.suspisious           = false;
                        myController.memory.noiseToInvestigate = Vector3.zero;
                        Destroy(this);
                    }
                    else
                    {
                        if (pointsGoneTo < 4)
                        {
                            if (pointToInvestigate == null || myController.pf.target != pointToInvestigate)
                            {
                                pointToInvestigate = room.getRandomPoint();
                                myController.pf.getPath(this.gameObject, pointToInvestigate);
                            }

                            if (Vector2.Distance(this.transform.position, pointToInvestigate.transform.position) > 1.5f)
                            {
                                moveToCurrentPoint();
                            }
                            else
                            {
                                pointToInvestigate = room.getRandomPoint();
                                myController.pf.getPath(this.gameObject, pointToInvestigate);

                                pointsGoneTo++;
                            }
                        }
                        else
                        {
                            myController.npcB.suspisious           = false;
                            myController.memory.noiseToInvestigate = Vector3.zero;
                            myController.npcB.doing = whatAiIsDoing.starting;
                            Destroy(this);
                        }
                    }
                }
            }

            /*	if (waitTimer <= 0) {
             *              myController.npcB.suspisious = false;
             *              myController.memory.noiseToInvestigate = Vector3.zero;
             *              Destroy (this);
             *      } else {
             *              waitTimer -= Time.deltaTime;
             *              myController.pmc.rotateToFacePosition (location);
             *
             *      }*/
        }
    }