コード例 #1
0
ファイル: RegroupPeople.cs プロジェクト: Scover-w/Among_Them
        private void OnCollisionEnter(Collision other)
        {
            if (other.gameObject.tag.Equals("Player"))
            {
                List <NavMeshAgent> agentsAffected = new List <NavMeshAgent>();

                foreach (var ca in crowdAgentsList)
                {
                    float distanceSqr = (objectTransform.position - ca.gameObject.transform.position).sqrMagnitude;
                    if (distanceSqr < radius)
                    {
                        agentsAffected.Add(ca);
                        NavMeshHit hit = new NavMeshHit();

                        NavMesh.SamplePosition(objectTransform.position, out hit, 16f, NavMesh.AllAreas);
                        ca.SetDestination(hit.position);
                    }
                }

                StartCoroutine(NavMeshAgentManager.Instance().ChangeDestinationAfterEvents(agentsAffected, waitingTime));
            }

            if (other.gameObject.tag.Equals("CrowdAgent"))
            {
                other.gameObject.GetComponent <NavMeshAgent>()
                .SetDestination(NavMeshAgentManager.Instance().GetRandomPositionOnNavMesh());
            }
        }
コード例 #2
0
 // Start is called before the first frame update
 void Start()
 {
     _singleton     = this;
     Time.timeScale = 1f;
     agentList      = new List <NavMeshAgent>();
     animators      = new List <Animator>();
     copsList       = new List <NavMeshAgent>();
 }
コード例 #3
0
ファイル: AgentMovement.cs プロジェクト: Scover-w/Among_Them
    IEnumerator GetANewDestination(float waitingTime)
    {
        yield return(new WaitForSeconds(waitingTime));

        destination    = NavMeshAgentManager.Instance().GetRandomPositionOnNavMesh();
        hasDestination = true;
        agentNavMesh.SetDestination(destination);
        agentNavMesh.GetComponent <Animator>().SetBool("isWalking", true);
    }
コード例 #4
0
ファイル: OrbBehaviour.cs プロジェクト: Scover-w/Among_Them
    IEnumerator TicTac(bool isRed)
    {
        yield return(new WaitForSeconds((isRed)? 1f : 5f));

        // TO DO : Explode
        SoundManager.Instance.Play("Poi");
        NavMeshAgentManager.Instance().RegroupAround(transform.position);
        Destroy(gameObject);
    }
コード例 #5
0
ファイル: GameManager.cs プロジェクト: Scover-w/Among_Them
    IEnumerator InstantiateCrowd()
    {
        yield return(null);

        yield return(null);

        NavMeshAgentManager.Instance().InstantiateCrowd();
        target = NavMeshAgentManager.Instance().GetTargetAgent();

        StartCoroutine(nameof(BeginLevelCinematic));
    }
コード例 #6
0
ファイル: GameManager.cs プロジェクト: Scover-w/Among_Them
 public void TeleportPlayerToGoal()
 {
     if (targetIsAlive) // Tp to target
     {
         Vector3 tpPosition = NavMeshAgentManager.Instance().GetPositionOnNavMesh(target.transform.position);
         player.transform.position = new Vector3(tpPosition.x, tpPosition.y + 3f, tpPosition.z);
     }
     else // Tp to door
     {
         Vector3 tpPosition = NavMeshAgentManager.Instance().GetPositionOnNavMesh(appartmentTargetDoor.transform.position);
         player.transform.position = new Vector3(tpPosition.x + (tpPosition.x > 0? -1f : 1f), tpPosition.y + 1f, tpPosition.z + (tpPosition.z > 0? -1f : 1f));
     }
 }
コード例 #7
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
コード例 #8
0
    private void Start()
    {
        instance            = this;
        gameManager         = GameManager.Instance();
        navMeshAgentManager = NavMeshAgentManager.Instance();
        if (PlayerPrefs.HasKey("lookSensity"))
        {
            lookSensitivity = PlayerPrefs.GetFloat("lookSensity");
        }

#if !UNITY_STANDALONE
        middleScreen = new Vector2(Screen.width / 2f, Screen.height / 2f);
#endif

        yRotation = 0f;
        xRotation = 0f;
    }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: Scover-w/Among_Them
 public void StartTutorial()
 {
     isTutorial = true;
     NavMeshAgentManager.Instance().InstantiateCrowd();
 }
コード例 #10
0
    public void RaycastInteractiveElement()
    {
        int layerMask = 1 << 8;


        layerMask = ~layerMask;

        if (!canClick)
        {
            return;
        }

        Ray ray;

#if UNITY_STANDALONE
        ray = cam.ScreenPointToRay(Input.mousePosition);
#else
        ray = cam.ScreenPointToRay(middleScreen);
#endif
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 200f, layerMask))
        {
            switch (hit.transform.gameObject.tag)
            {
            case "ToKillAgent":
                if (hit.transform.gameObject.tag.Contains("ToKillAgent"))
                {
                    if (hit.distance < 2.0f)
                    {
                        if (IsSomeoneWatching())
                        {
                            if (gameManager.IsTutorial())
                            {
                                gameManager.ReplacePlayerOnStartPosition();
                            }
                            else
                            {
                                gameManager.CinematicPlayerDie();
                            }
                        }
                        else
                        {
                            if (ProgressionManager.GetWealthValue() > 0.99f)
                            {
                                gameManager.CinematicWinGame();
                            }
                            else
                            {
                                NavMeshAgentManager.Instance().CopsGoOnCrimeScene();
                                gameManager.KillTarget();
                                if (gameManager.IsTutorial())
                                {
                                    TutorialManager.Instance().NextStep();
                                }
                            }
                        }
                    }
                }
                break;

            case "Orb":
                if (hit.transform.parent.CompareTag("Orb"))
                {
                    Destroy(hit.transform.parent.gameObject);
                }
                else
                {
                    Destroy(hit.transform.gameObject);
                }

                OrbManager.IncrementOrb(UnityEngine.Random.Range(0f, 1f) < .5f);
                break;

            case "InteractiveElement":
                Vector3 origin = hit.transform.position;
                Destroy(hit.transform.gameObject);
                break;

            case "TargetRoomDoor":
                if (!gameManager.IsTargetAlive())
                {
                    CodeMission.Instance().OpenMissionPanel();
                }
                break;

            case "LaptopInfo":
                PCMission.Instance().OpenMissionPanel();

                break;

            case "ElevatorDoor":
                if (!gameManager.IsDataRetrieve())
                {
                    return;
                }
                if (gameManager.IsTutorial())
                {
                    if (TutorialManager.Instance().GetStep() == 6)
                    {
                        gameManager.EndTutorial();
                        return;
                    }
                }
                gameManager.GoToNextFloor(hit.transform.parent.gameObject);
                break;
            }
        }
    }
コード例 #11
0
ファイル: RegroupPeople.cs プロジェクト: Scover-w/Among_Them
 // Start is called before the first frame update
 void Start()
 {
     objectTransform = this.gameObject.transform;
     crowdAgentsList = NavMeshAgentManager.Instance().GetCrowdAgent();
 }