Пример #1
0
    void FixedUpdate()
    {
        // playerStats.playerData._position = prefabLocation.position;
        // playerStats.playerData._rotation = prefabLocation.rotation;
        // playerStats.playerData._spacePrefabName = spacePrefab.name;
        // playerStats.playerData._groundPrefabName = groundPrefab.name;
        // playerStats.playerData._tag = prefabLocation.gameObject.tag;
        // playerStats.playerData._location = playerLocation;
        // playerStats.playerData.sceneName = SceneManager.GetActiveScene().name;

        // if (!updateTargets.Equals(false)){
        //     //if (selectionUI != null)
        //GameObject.Find("UIManager").GetComponentInChildren<SelectionUI>().enabled = true;
        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        //Debug.Log(selectionUI);
        selectionUI.FindSelectionObjects();
        //this.currentPrefab = locatePlayerPrefab();
        //Debug.Log(locatePlayerPrefab());
        //playerStatsJSON.name = "currentPlayer.name";
        //playerStatsJSON.score = "100";
        //playerStats.playerData.
        //playerStatsJSON = JsonUtility.ToJson(playerStats);
        //Debug.Log(playerStatsJSON);
        //Debug.Log(currentPlayer);
        // updateTargets = false;
        // }
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        prefabManager    = GameObject.Find("PrefabManager").GetComponent <PrefabManager> ();
        spawnManager     = GameObject.Find("SpawnManager").GetComponent <SpawnManager> ();
        inventoryManager = GameObject.Find("InventoryManager").GetComponent <InventoryManager> ();

        follow    = GameObject.Find("MainCamera").GetComponent <CamFollow> ();
        mapFollow = GameObject.Find("MapCamera").GetComponent <CamFollow> ();
        //playerStats = GameObject.Find("GameManager").GetComponent<PlayerStats>();

        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        if (!selectionUI.Equals(null))
        {
            selectionUI.FindSelectionObjects();
        }
    }
Пример #3
0
    void Awake()
    {
        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        //Variables.App.Set("name", "David Crispin");
        spawnManager     = GameObject.Find("SpawnManager").GetComponent <SpawnManager>();
        prefabManager    = GameObject.Find("PrefabManager").GetComponent <PrefabManager>();
        characterManager = GameObject.Find("CharacterManager").GetComponent <CharacterManager>();
        selectionUI.FindSelectionObjects();
        //GameObject.Find("UIManager").GetComponent<SelectionUI>().FindSelectionObjects();
        //Debug.Log("Awake");
        //if (spawnManager.findPlayer() == null)  _SpawnPlayer();
        // spawnName = "none";
        follow    = GameObject.Find("MainCamera").GetComponent <CamFollow> ();
        mapFollow = GameObject.Find("MapCamera").GetComponent <CamFollow> ();

        follow.target    = prefabManager.currentPrefab.transform;
        mapFollow.target = prefabManager.currentPrefab.transform;
        //DontDestroyOnLoad(this.gameObject);
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (!gameStarted)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.Z))    // load
        //playerData.LoadData ();
        {
            characterManager.ReadFile("");
        }

        if (Input.GetKeyDown(KeyCode.C))    // save
        //playerData.SaveData ();
        {
            characterManager.WriteFile("");
        }

        //Debug.Log(findPlayer());
        if (isLanding)
        {
            //landPlayerShip();
            if (playerLocation == locationType.Ground)
            {
                prefabManager.currentPrefab.GetComponent <SimpleTankController> ().playerControl = false;
                isLanding = false;
            }
        }
        else
        {
            prefabManager.currentPrefab.GetComponent <SimpleTankController> ().playerControl = true;
            count = 0;
        }

        if (locatePlayerPrefab() == null)
        {
            _SpawnPlayer();
            prefabManager.currentPrefab = findPlayer();
        }
        if (GameObject.FindWithTag("Player") != null)
        {
            prefabLocation = prefabManager.currentPrefab.transform;

            //GameObject.FindWithTag("Player").transform;
        }
        //if (prefabLocation == null) spawnName = "none";

        if (Input.GetMouseButton(1) || Input.GetKeyDown(KeyCode.Escape))
        {
            //movable = false;
            //destinationPosition = new Vector3(this.myTransform.position.x, this.myTransform.position.y, this.myTransform.position.z);
            GameObject.Find("UIManager").GetComponentInChildren <SelectionUI> ().enabled = true;
            if (GameObject.Find("UIManager").GetComponent <SelectionUI> ().target != null)
            {
                selectionUI.FindSelectionObjects();
                if (GameObject.Find("UIManager").GetComponent <SelectionUI> ().target.GetComponent <Target> () != null)
                {
                    GameObject.Find("UIManager").GetComponent <SelectionUI> ().target.GetComponent <Target> ().indicator.Activate(false);
                }
                //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target.GetComponent<Selection>() != null) GameObject.Find("UIManager").GetComponent<SelectionUI>().target.GetComponent<Selection>().select = false;
            }
            GameObject.Find("UIManager").GetComponent <SelectionUI> ().target = null;
        }
    }
Пример #5
0
    public void _SpawnPlayer()
    {
        //spawnManager.refreshSpawnPoints();
        spawnIndex = spawnManager.FindSpawnByName(spawnManager.spawnName);

        // Debug.Log("called _SpawnPlayer() method");
        mainCamera  = GameObject.Find("MainCamera").GetComponent <Camera> ();
        mapCamera   = GameObject.Find("MapCamera").GetComponent <Camera> ();
        selectionUI = GameObject.Find("UIManager").GetComponent <SelectionUI> ();
        GameObject[] find = GameObject.FindGameObjectsWithTag("Player");
        foreach (GameObject tmp in find)
        {
            if (tmp)
            {
                Destroy(tmp);
            }
        }
        selectionUI.FindSelectionObjects();
        //SpawnPoints = GameObject.FindGameObjectsWithTag ("SpawnPoint");

        // if (isLanding)
        // {

        spawnIndex = spawnManager.FindSpawnByName(spawnManager.spawnName);
        //spawnName = "none";

        //camOffset = mainCamOffset;
        if (spawnIndex != -1)
        {
            player = GameObject.FindWithTag("Player");
            if (playerLocation == locationType.Space)
            {
                //     //Vector3 spawn = new Vector3()

                player = Instantiate(prefabManager.spacePrefab, spawnManager.SpawnPoints[spawnIndex].transform.position - (hoverPlayer * 2), spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                //currentPrefab = Instantiate(spacePrefab, SpawnPoints[spawnIndex].transform.position, SpawnPoints[spawnIndex].transform.rotation);
                shipControls = player.GetComponent <ShipControls>();
                //characterManager.characterData.shipControls = shipControls;
                shipControls.hoverHeight = hoverHeight;
            }

            if (playerLocation == locationType.Air)
            {
                player       = Instantiate(prefabManager.spacePrefab, spawnManager.SpawnPoints[spawnIndex].transform.position - hoverPlayer, spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                shipControls = player.GetComponent <ShipControls>();
                //characterManager.characterData.shipControls = shipControls;
                shipControls.hoverHeight = airHoverHeight;
                //GameObject.Find(spawnName).SetActive(true);
            }

            if (playerLocation.Equals(locationType.Ground))
            {
                landPlayerShip();
            }

            if (playerLocation == locationType.Building)
            {
                player = Instantiate(prefabManager.groundPrefab, spawnManager.SpawnPoints[spawnIndex].transform.position, spawnManager.SpawnPoints[spawnIndex].transform.rotation);
                //camOffset = buildingCamOffset;
                follow.offset_move = new Vector3(0, _buildingOffset, 0);
            }

            if (playerLocation != locationType.Building)
            {
            }
            //Debug.Log("player prefab -> " + player);

            prefabManager.currentPrefab = player;
            follow.target    = player.transform;
            mapFollow.target = player.transform;

            mainCamera.transform.position = player.transform.position + mainOffset;
            mapCamera.transform.position  = player.transform.position + mapOffset;
        }
        else
        {
        }
    }