Esempio n. 1
0
    void Awake()
    {
        // GetComponent<LevelGenerator>().GenerateLevel();
        for (int i = 0; i < zombieStartCount; i++)
        {
            Vector3 position = PositionHelpers.ComputeUnitPositionAroundTarget(new Vector3(0, 0, 0), i);
            Debug.Log(position);
            SpawnZombie(position);
        }

        mainCamera            = Camera.main;
        cameraMovement        = mainCamera.GetComponent <CameraMovement>();
        cameraMovement.Target = zombies[0];
    }
Esempio n. 2
0
 private void SpawnEntities(GameObject prefab, int count)
 {
     for (int i = 0; i < count; i++)
     {
         Vector3 spawnPosition = GetRandomWorldScreenCornerPosition();
         spawnPosition = PositionHelpers.ComputeUnitPositionAroundTarget(spawnPosition, i + 1);
         while (Physics.OverlapSphere(spawnPosition, 1, LayerHelpers.NoGroundMask).Length > 0)
         {
             spawnPosition.x += 1;
             spawnPosition.z += 1;
         }
         Instantiate(prefab, spawnPosition, Quaternion.identity);
     }
 }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(1))
        {
            Ray        ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray.origin, ray.direction, out hit))
            {
                if (hit.collider.tag == "Ground")
                {
                    int i = 0;
                    foreach (GameObject zombie in zombies)
                    {
                        zombiesInfo[zombie].movement.SetNewDestination(PositionHelpers.ComputeUnitPositionAroundTarget(hit.point, i));
                        // zombiesMovements[i].SetNewDestination(ComputePositionAroundCenterZombie(hit.point, i));
                        i += 1;
                    }
                }
            }
        }

        SpawnCivilians();
        SpawnEnemies();
    }