示例#1
0
    public void Shoot(GameObject projectilePrefab, Vector3 firePoint, Quaternion direction, bool isChild = false, bool cameraShouldFollow = true, Transform target = null, int numItemsToDrop = -1, int dropArea = -1)
    {
        if (projectilePrefab != null)
        {
            go = Instantiate(projectilePrefab, firePoint, direction);

            if (isChild)
            {
                go.transform.parent = weapon.transform;
            }
            if (cameraShouldFollow)                         //Don't follow the sniper or shotgun or melee weapons
            {
                playerSettings.gameManager.projectile = go; //Tell GM what projectile is  in the game, to tell the camera to follow it
            }

            //Specific targeting info for some prefabs like plane and homing bazooka
            if (target != null)
            {
                PlaneManager pm = go.GetComponent <PlaneManager>();
                if (pm != null)
                {
                    pm.GM = playerSettings.gameManager;
                    pm.SetTarget(target.position, numItemsToDrop, dropArea);
                    return;
                }
                HomingBomb hb = go.GetComponent <HomingBomb>();
                if (hb != null)
                {
                    hb.target = target.position;
                    return;
                }
            }
        }
    }
示例#2
0
    void DeployPlane(GameObject prefab)
    {
        GLOBALS.GM.turnClock += (int)(GLOBALS.mapXMax / 100) + 5f;
        planeSpawnPoint       = new Vector3(GLOBALS.mapXMax + 30f, GLOBALS.mapYMax + 20f, 0);
        this.go                = Instantiate(prefab, planeSpawnPoint, Quaternion.identity);
        cam.soldier            = this.go;
        cam.shouldFollowTarget = true;
        cam.SetZoom(100f);
        PlaneManager pm = this.go.transform.GetComponent <PlaneManager>();

        pm.SetTarget(new Vector2((GLOBALS.mapXMax / 2) + Random.Range(-20f, 20f), Random.Range(15f, 40f)), (int)Random.Range(3, 6), (GLOBALS.mapXMax / 2) - (int)Random.Range(0f, 30f));
    }