Пример #1
0
    /*Returns the points that is going to patroll in a RandomZone*/
    public void GetPointsToPatroll()
    {
        pointsToPatroll = new List <Vector2>();

        //int randomZone = Random.Range(0, ObjectRefs.Instance.GetPatrollZoneList().Count);
        switch (behaviourType)
        {
        case ia_BehaviourType.Stationary:
            pointsToPatroll.Add(iniPos);
            break;

        case ia_BehaviourType.RandomZone:
            int randomZone  = Random.Range(0, patrollZones_List.Count);
            int nulOfPoints = Random.Range(minPositionsPatrolling, maxPositionsPatrolling);
            for (int x = 0; x < nulOfPoints; x++)
            {
                Vector2 newPoint = Outils.RandomPointInBounds(patrollZones_List[randomZone].GetComponent <BoxCollider2D>().bounds);
                pointsToPatroll.Add(newPoint);
            }
            break;

        case ia_BehaviourType.SuccessivePoints:
            for (int x = 0; x < patrollPoints_List.Count; x++)
            {
                Vector2 newPoint = patrollPoints_List[x].transform.position;
                pointsToPatroll.Add(newPoint);
            }
            break;
        }


        playerMakerSFM.SendEvent("PatrollZoneSetUp");
    }
Пример #2
0
    public void CheckingZoneIni()
    {
        checkingtheZone = true;
        chasingPlayer   = false;

        playerSpottedSprite.enabled = false;
        checkingZoneSprite.enabled  = true;

        GetComponent <FOV_vBT>().viewAngle = alertviewAngle;
        //Points the Check INI
        for (int x = 0; x < checkZone_NumPoints; ++x)
        {
            Bounds  bounds_tmp = new Bounds(pointToGo[0], checkZoneSize);
            Vector3 pointTmp   = new Vector3(0, 0, 0);
            bool    check      = false;
            int     checkNum   = 0;
            while (!check && checkNum < 10)
            {
                pointTmp = Outils.RandomPointInBounds(bounds_tmp);
                check    = Outils.IsPointRecheable(pointTmp, pointToGo[0], this.gameObject, collidersCheckZone);
                ++checkNum;
            }
            if (checkNum < 10)
            {
                pointToGo.Add(pointTmp);
            }
        }
    }
Пример #3
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Get_CharacterController(animator);

        navMeshPath = new NavMeshPath();
        // Where to Dance
        int index = Random.Range(0, characterController.dancePositions.Length);

        wheretoDance   = Outils.RandomPointInBounds(characterController.dancePositions[index].GetComponent <BoxCollider>().bounds);
        wheretoDance.y = 2;
        Get_NavMeshAgent(animator).SetDestination(wheretoDance);
    }
Пример #4
0
    /*Returns the points that is going to patroll in a RandomZone*/
    public void GetPointsToPatroll()
    {
        pointsToPatroll = new List <Vector2>();
        int randomZone  = Random.Range(0, ObjectRefs.Instance.GetPatrollZoneList().Count);
        int nulOfPoints = Random.Range(minPositionsPatrolling, maxPositionsPatrolling);

        for (int x = 0; x < nulOfPoints; x++)
        {
            Vector2 newPoint = Outils.RandomPointInBounds(ObjectRefs.Instance.GetPatrollZoneList()[randomZone].GetComponent <BoxCollider2D>().bounds);
            pointsToPatroll.Add(newPoint);
        }
        playerMakerSFM.SendEvent("PatrollZoneSetUp");
    }
Пример #5
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (Vector3.Distance(Get_CharacterPosition(), wheretoDance) < distanceToStartDancing)
     {
         animator.SetBool("isDancing", true);
         animator.SetBool("GoingToDance", false);
     }
     else
     {
         Get_NavMeshAgent(animator).CalculatePath(wheretoDance, navMeshPath);
         if (navMeshPath.status != NavMeshPathStatus.PathComplete)
         {
             int index = Random.Range(0, characterController.dancePositions.Length);
             wheretoDance   = Outils.RandomPointInBounds(characterController.dancePositions[index].GetComponent <BoxCollider>().bounds);
             wheretoDance.y = 2;
             Get_NavMeshAgent(animator).SetDestination(wheretoDance);
         }
     }
 }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Get_CharacterController(animator);

        navMeshPath = new NavMeshPath();

        //Setting up the random points where the killer will go (inside a BoxCollider)
        positionsToPatroll = new List <Vector3>();
        int index       = Random.Range(0, killerController.patrollingAreas.Length);
        int nulOfPoints = Random.Range(minPositionsPatrolling, maxPositionsPatrolling);

        for (int x = 0; x < nulOfPoints; x++)
        {
            Vector3 newPoint = Outils.RandomPointInBounds(killerController.patrollingAreas[index].GetComponent <BoxCollider>().bounds);
            newPoint.y = killerController.transform.position.y;
            positionsToPatroll.Add(newPoint);
        }
        killerController.GetAgent().SetDestination(positionsToPatroll[0]);
        killerController.GetAgent().speed = patrollingSpeed;
    }
Пример #7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (((1 << collision.gameObject.layer) & playerMask) != 0)
        {
            //ObjectRefs.Instance.menuCanvas.GetComponent<LevelMenu_Manager>().Active_LosePanel();
            if (IASpawn != null && delaySpawn_tmp <= 0)
            {
                for (int x = 0; x < IASpawnNum; ++x)
                {
                    Vector3    whereToSpawn = Outils.RandomPointInBounds(IASpawn.gameObject.GetComponent <BoxCollider2D>().bounds);
                    GameObject IA_tmp       = Instantiate(IAPrefab, whereToSpawn, Quaternion.identity);
                    IA_tmp.GetComponent <GuardIAController_v2>().spawnedIA = true;
                    //IA_tmp.GetComponent<GuardIAController_v2>().checkingtheZone = true;
                    IA_tmp.GetComponent <GuardIAController_v2>().IASpawned(ObjectRefs.Instance.player.transform.position);
                    //IA_tmp.GetComponent<NavMeshAgent>().SetDestination(ObjectRefs.Instance.player.transform.position);

                    delaySpawn_tmp = delaySpawn;
                }
            }
        }
    }
Пример #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerControl voleur = collision.gameObject.GetComponent <PlayerControl>();

        if (voleur != null)
        {
            if ((voleur.stat.power == Power.Cheater && !voleur.isPowerActive()) || (voleur.stat.power != Power.Cheater))
            {
                bool metal = false;
                foreach (Tresor tre in voleur.Get_inventory())
                {
                    if (tre.materialObj == MaterialObj.Metal)
                    {
                        metal = true;
                    }
                }
                if (metal)
                {
                    //GAME OVER
                    //GameManager.Instance.DetectorMetal();
                    if (IASpawn != null && delaySpawn_tmp <= 0)
                    {
                        for (int x = 0; x < IASpawnNum; ++x)
                        {
                            Vector3    whereToSpawn = Outils.RandomPointInBounds(IASpawn.gameObject.GetComponent <BoxCollider2D>().bounds);
                            GameObject IA_tmp       = Instantiate(IAPrefab, whereToSpawn, Quaternion.identity);
                            IA_tmp.GetComponent <GuardIAController>().behaviourType = ia_BehaviourType.SpawnedIA;
                            IA_tmp.GetComponent <GuardIAController>().StartChasingPlayerVarInis();
                            IA_tmp.GetComponent <NavMeshAgent>().SetDestination(ObjectRefs.Instance.player.transform.position);

                            delaySpawn_tmp = delaySpawn;
                        }
                    }
                }
            }
        }
    }