Beispiel #1
0
    void Start()
    {
        player = GameObject.Find("Player");
        walls  = GameObject.FindGameObjectWithTag("Walls").GetComponent <WallColliderPosition>();

        weaponsActiveCount = 0;
    }
    void Start()
    {
        walls          = GameObject.FindGameObjectWithTag("Walls").GetComponent <WallColliderPosition>();
        gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
        Camera cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();

        transform.position = new Vector3(cam.ScreenToWorldPoint(new Vector3(Screen.width / 2f, 0f, 0f)).x,
                                         0f, cam.ScreenToWorldPoint(new Vector3(0f, Screen.height / 2f, 0f)).z);
    }
Beispiel #3
0
    // this function will return a vector that is not too close to the player and not outside the wall
    public static Vector3 GetRandomLocation(WallColliderPosition walls, GameObject player)
    {
        Vector3 pos = RandomVector(walls);

        while (VectorTooClose(pos, player))
        {
            pos = RandomVector(walls);
        }
        return(pos);
    }
Beispiel #4
0
    public static bool InsideTheWall(Vector3 pos, WallColliderPosition walls)
    {
        bool inside = true;

        if (pos.x > walls.right.position.x - 1f || pos.x < walls.left.position.x + 1f)
        {
            inside = false;
        }
        if (pos.z > walls.top.position.z - 1f || pos.z < walls.bottom.position.z + 1f)
        {
            inside = false;
        }
        return(inside);
    }
Beispiel #5
0
    void Start()
    {
        walls = GameObject.FindGameObjectWithTag("Walls").GetComponent <WallColliderPosition>();
        GetComponent <NavMeshAgent>().enabled = false;
        GetComponent <EnemyAttack>().activateColliders();

        // we dont want the static enemy to collide with walls
        Collider[] colliders = GetComponents <SphereCollider>();
        foreach (Collider col in colliders)
        {
            if (!col.isTrigger)
            {
                col.enabled = false;
            }
        }
    }
Beispiel #6
0
 public static Vector3 RandomVector(WallColliderPosition walls)
 {
     return(new Vector3(Random.Range(walls.left.position.x + 2f, walls.right.position.x - 2f),
                        0f, Random.Range(walls.top.position.z - 2f, walls.bottom.position.z + 2f)));
 }