示例#1
0
    public static HidingPoint GetRandomPoint()
    {
        HidingPoint point = HidingPoints[Random.Range(0, HidingPoints.Length)];

        while (point.name == "Final")
        {
            point = HidingPoints[Random.Range(0, HidingPoints.Length)];
        }
        Debug.Log(point.transform.position);
        return(point);
    }
示例#2
0
 void IMonsterState.Start()
 {
     if (willMoveForward)
     {
         monsterEyes.ChangeEyeColor(MonsterEyes.EyeColors.green);
         currentDestination = MonsterHidingPointStorage.GetNextPointTowardsCenter(monsterController.transform.position);
         monsterController.monsterNavAgent.destination = currentDestination.transform.position;
     }
     else
     {
         monsterEyes.ChangeEyeColor(MonsterEyes.EyeColors.red);
         currentDestination = MonsterHidingPointStorage.GetNextPointTowardsCenter(monsterController.transform.position);
         monsterController.monsterNavAgent.destination = currentDestination.transform.position;
     }
     monsterController.monsterNavAgent.isStopped = false;
 }
示例#3
0
    public static HidingPoint GetNextPointAwayFromCenter(Vector3 monsterPos)
    {
        HidingPoint neareastPoint = GetNearestPoint(monsterPos);

        if (neareastPoint.backwardsPoints.Length > 0)
        {
            return(neareastPoint.backwardsPoints[Random.Range(0, neareastPoint.backwardsPoints.Length)]);
        }
        else if (neareastPoint.radiusPoints.Length > 0)
        {
            return(neareastPoint.radiusPoints[Random.Range(0, neareastPoint.radiusPoints.Length)]); // make random
        }
        else if (neareastPoint.forwardPoints.Length > 0)
        {
            return(neareastPoint.forwardPoints[Random.Range(0, neareastPoint.forwardPoints.Length)]);  // make random
        }

        // if for some reason your point has no registered connected points. just return a random point so game doesn't break
        print(neareastPoint.name + " has no connected nodes, make sure to hook them up in the scene, Monster went to a random point");
        return(HidingPoints[Random.Range(0, HidingPoints.Length)]);
    }
示例#4
0
    void IMonsterState.Start()
    {
        ace        = monsterController.GetComponent <AudioSource>();
        ace.volume = 8;
        ace.clip   = monsterController.parrotAudio[UnityEngine.Random.Range(0, monsterController.currentIndex)];
        ace.Play();

        if (willMoveForward)
        {
            monsterEyes.ChangeEyeColor(MonsterEyes.EyeColors.green);
            currentDestination = MonsterHidingPointStorage.GetNextPointTowardsCenter(monsterController.transform.position);
            monsterController.monsterNavAgent.destination = currentDestination.transform.position;
        }
        else
        {
            monsterEyes.ChangeEyeColor(MonsterEyes.EyeColors.red);
            currentDestination = MonsterHidingPointStorage.GetNextPointTowardsCenter(monsterController.transform.position);
            monsterController.monsterNavAgent.destination = currentDestination.transform.position;
        }
        monsterController.monsterNavAgent.isStopped = false;
    }