void SetupStartingArea()
    {
        cameraHolderPrefab = CameraReferenceSingleton.Instance.gameplayCamHolderPrefab_01;
        GroundTileScript centreBaseTile     = baseTilesList[4];
        Vector3          positionOfBase     = centreBaseTile.nodeReference.worldPosition;
        Vector3          centreCameraToBase = positionOfBase + cameraOffset;

        GameObject baseBuilding = GameObject.Instantiate(mainBaseBuildingPrefab, positionOfBase, Quaternion.identity);

        baseBuilding.name = "MainBase";

        baseBuilding.GetComponent <UI_ActionsButtons>().UIButtonPack = ui_ButtonPackAssociatorLocal.UIButtonPack[0];   // Make sure the first element in the list is the base button pack !!!!

        // Instantiates camera holder prefab in the world and centres it on the base building.

        GameObject mainCameraHolder = GameObject.Instantiate(cameraHolderPrefab, centreCameraToBase, Quaternion.identity);

        mainCameraHolder.name = "Main Camera Holder";

        CameraControl cameraController = cameraControl.GetComponent <CameraControl>();

        cameraController.FetchCameraprefab(mainCameraHolder);
        UnitComponent.FetchCameraprefab(mainCameraHolder);  // if "FetchCameraprefab()" is not static, this line needs to be placed in BaseSpawner script instead, and the reference set upon unit instantiation.
        UnitSelectionManager uSM = gameObject.GetComponent <UnitSelectionManager>();

        uSM.FetchCameraPrefab(mainCameraHolder);
        BaseSpawner_a01.FetchCameraPrefab(mainCameraHolder);
        MinimapClickToGoThere.FetchCameraprefabs(minimapCam, mainCameraHolder, cameraOffset, mapSize);


        gameObject.GetComponent <UI_SetCamsOrder>().SetCams(mainCameraHolder);
    }
Exemplo n.º 2
0
    private void Awake()
    {
        // Create Init if it doesn't exist --> singleton
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance == this)
        {
            Destroy(gameObject);
        }
        // Don't delete when switching scenes
        DontDestroyOnLoad(gameObject);

        // initialize the game strings instances
        SceneNames = new SceneNames();
        Tags       = new Tags();

        // initialize the unit selection manager instance and add it to the Init game object
        _unitSelectionManager = gameObject.AddComponent <UnitSelectionManager>();

        // initialize the player instance
        // PlayerData = gameObject.AddComponent<PlayerData>();

        // initialize camera controller
        _cameraController = gameObject.AddComponent <CameraController>();

        // finally, set up the game with the player progress
        SetUpGame();
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Awake()
 {
     usmInstance = this;
     // Old stuff
     //levelScript = gameObject.GetComponent<TerrainBuilder_02>();
     //playerCam = levelScript.cameraHolderPrefab.GetComponentInChildren<Camera>();
 }
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
     {
         UnitSelectionManager.DeselectAll(new BaseEventData(EventSystem.current));
     }
     selectionBoxImage.gameObject.SetActive(true);
     startPos      = eventData.position;
     selectionRect = new Rect();
 }
Exemplo n.º 5
0
    void Start()
    {
        selectionMgr = GetComponent <UnitSelectionManager>();
        var laserPointers = steamVRCameraRig.GetComponentsInChildren <SteamVR_LaserPointer>();

        if (laserPointers != null)
        {
            foreach (var laserPointer in laserPointers)
            {
                laserPointer.PointerIn    += OnHighlightObject;
                laserPointer.PointerOut   += OnUnhighlightObject;
                laserPointer.PointerClick += OnSelectObject;
            }
        }
    }
Exemplo n.º 6
0
    private void LeftMouseClick()
    {
        if (hud.CursorInBounds())
        {
            GameObject hitObject = FindHitObject();
            Vector3    hitPoint  = FindHitPoint();
            if (hitObject && hitPoint != ResourceManager.InvalidPosition)
            {
                if (!WorkManager.ObjectIsGround(hitObject))
                {
                    if (!hitObject.transform.parent)
                    {
                        return;
                    }

                    Unit unitToSelect = hitObject.transform.parent.GetComponent <Unit>();
                    if (unitToSelect)
                    {
                        if (player.selectedAllyTargettingAbility != null)
                        {
                            AbilityUtils.ApplyAllyAbilityToTarget(unitToSelect, player);
                        }
                        else if (Input.GetButton(InputNames.SELECTION_MODIFIER) || Gamepad.GetButton(InputNames.SELECTION_MODIFIER))
                        {
                            UnitSelectionManager.HandleUnitSelectionWithModifierPress(unitToSelect, player, hud);
                        }
                        else
                        {
                            UnitSelectionManager.HandleUnitSelection(unitToSelect, player, mainCamera, hud);
                        }
                    }
                }
                else if (player.SelectedObject)
                {
                    player.SelectedObject.SetSelection(false, hud.GetPlayingArea());
                    player.SelectedObject = null;
                    player.selectedObjects
                    .Where(p => p != null)
                    .ToList()
                    .ForEach(p => p.SetSelection(false, hud.GetPlayingArea()));
                    player.selectedObjects = new List <WorldObject>();
                }
            }
        }
    }
Exemplo n.º 7
0
 public void SpawnUnitYellow()
 {
     Client.LocalClient.SpawnUnitClient(TeamType.Yellow);
     UnitSelectionManager.TurnOnUnitSelection(TeamType.Yellow);
 }
Exemplo n.º 8
0
 public void SpawnUnitGreen()
 {
     Client.LocalClient.SpawnUnitClient(TeamType.Green);
     UnitSelectionManager.TurnOnUnitSelection(TeamType.Green);
 }
Exemplo n.º 9
0
 public void SpawnUnitBlue()
 {
     Client.LocalClient.SpawnUnitClient(TeamType.Blue);
     UnitSelectionManager.TurnOnUnitSelection(TeamType.Blue);
 }
Exemplo n.º 10
0
 public void SpawnUnitRed()
 {
     Client.LocalClient.SpawnUnitClient(TeamType.Red);
     UnitSelectionManager.TurnOnUnitSelection(TeamType.Red);
 }
 protected override void OnTrackingLost()
 {
     base.OnTrackingLost();
     Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
     UnitSelectionManager.TurnLaserOff(mTrackableBehaviour.gameObject);
 }
 protected override void OnTrackingFound()
 {
     base.OnTrackingFound();
     Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
     UnitSelectionManager.TurnLaserOn(mTrackableBehaviour.gameObject);
 }