void Update()
 {
     if (Input.GetMouseButtonDown(0) && Camera.main != null)
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 300))
         {
             if (hit.transform.gameObject.tag.Contains("Island"))
             {
                 string firstSplit = hit.transform.gameObject.name.Split(new[] { "Island" }, StringSplitOptions.None)[1];
                 string level      = firstSplit.Split(new[] { "(Clone)" }, StringSplitOptions.None)[0];
                 recruitmentController.OpenShop(Convert.ToInt32(level));
             }
             if (hit.transform.gameObject.tag.Contains("BattleEvent"))
             {
                 pDataController.PlayerData.EventDifficulty = UnityEngine.Random.Range(1, 3);
                 //SaveData
                 pDataController.Save();
                 //Load new Scene with Parameters
                 confirmationScreen.ActivateCanvas(SceneNames.BATTLE_SCENE, languageController.GetTextById("confirmation.battleLevel") + " " + pDataController.PlayerData.EventDifficulty);
                 pDataController.RemoveEventAt(hit.transform.gameObject.transform.position, hit.transform.gameObject.transform.rotation);
             }
             if (hit.transform.gameObject.tag.Contains("WreckageEvent"))
             {
                 pDataController.PlayerData.EventDifficulty = UnityEngine.Random.Range(1, 3);
                 //SaveData
                 pDataController.Save();
                 //Load new Scene with Parameters
                 confirmationScreen.ActivateCanvas(SceneNames.SINK_SCENE, languageController.GetTextById("confirmation.sinkLevel") + " " + pDataController.PlayerData.EventDifficulty);
                 pDataController.RemoveEventAt(hit.transform.gameObject.transform.position, hit.transform.gameObject.transform.rotation);
             }
         }
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        switch (BattleHasEnded())
        {
        case EEndBattleStatus.Ongoing:
            switch (battleStatus)
            {
            case EBattleStatus.PreparingTurn:
                PrepareTurn();
                break;

            case EBattleStatus.ActiveTurn:
                DoBattle(playerTeamTurn, enemyTeamTurn);
                break;

            case EBattleStatus.NpcAttacking:
                break;

            case EBattleStatus.EndTurn:
                PrintTurn();
                print("End of Turn: " + turn);
                turn++;
                battleStatus = EBattleStatus.PreparingTurn;
                break;
            }
            break;

        case EEndBattleStatus.PlayerWon:
            foreach (NpcBase npc in playerTeam)
            {
                npc.stats.GainExperience(enemyTeam.Count * 5);
            }
            playerDataController.Save();
            sceneLoader.LoadScene(SceneNames.MAIN_SCENE);
            print("Battle has ended!, the player Won, do something!");
            break;

        case EEndBattleStatus.PlayerLost:
            playerDataController.Save();
            sceneLoader.LoadScene(SceneNames.MAIN_SCENE);
            print("Battle has ended!, the player Lost, do something!");
            break;

        default:
            break;
        }
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Awake()
    {
        saveLoadService      = new SaveLoadService();
        playerDataController = FindObjectOfType <PlayerDataController>().GetComponent <PlayerDataController>();
        uiController         = FindObjectOfType <UIController>();
        if (!PlayerPrefs.HasKey(Constants.NEWGAME) || PlayerPrefs.GetInt(Constants.NEWGAME) == 1)
        {
            seaWrapper    = GameObject.FindGameObjectWithTag("SeaWrapper");
            seaPrefab     = Resources.Load("Prefabs/Procedural/OceanTile") as GameObject;
            borderPrefab1 = Resources.Load("Prefabs/Procedural/Border1") as GameObject;
            borderPrefab2 = Resources.Load("Prefabs/Procedural/Border2") as GameObject;
            borderPrefab3 = Resources.Load("Prefabs/Procedural/Border3") as GameObject;
            borderPrefab4 = Resources.Load("Prefabs/Procedural/Border4") as GameObject;
            loadWater();

            bottomWrapper    = GameObject.FindGameObjectWithTag("BottomWrapper");
            sandPrefab       = Resources.Load("Prefabs/Procedural/SandTile") as GameObject;
            decorationPrefab = Resources.Load("Prefabs/Procedural/BottomDecoration1") as GameObject;
            loadBottom();

            mapWrapper  = GameObject.FindGameObjectWithTag("MapWrapper");
            islandArray = new List <Island>();
            generateIslands(9, 1);
            generateIslands(6, 2);
            generateIslands(3, 3);
            loadIslands();

            battleEventHolderPrefab   = Resources.Load("Prefabs/Procedural/BattleEventHolder") as GameObject;
            wreckageEventHolderPrefab = Resources.Load("Prefabs/Procedural/WreckageEventHolder") as GameObject;
            loadEvents(15);

            playerShipPrefab = Resources.Load("Prefabs/Procedural/PlayerShip") as GameObject;

            eventsWrapper = GameObject.FindGameObjectWithTag("EventsWrapper");
            //Default resources when creating a new game
            SetInitialPlayerData();
            loadPlayerShipPrefab();
            playerDataController.Save();
            uiController.ResourcesChanged(playerDataController.PlayerData);
        }
        else
        {
            playerDataController.Load();
        }
    }
Exemplo n.º 4
0
    private void addRandomResources()
    {
        int quantity     = Random.Range(1, 6);
        int resourceType = Random.Range(1, 11);

        switch (resourceType)
        {
        case 1:     // water
        case 2:
        case 3:
            pDController.PlayerData.CurrentWater += quantity * 2;
            break;

        case 4:     // food
        case 5:
        case 6:
            pDController.PlayerData.CurrentFood += quantity * 2;
            break;

        case 7:     // Medicine
            pDController.PlayerData.CurrentMedicine += quantity;
            break;

        case 8:     // Gold
            pDController.PlayerData.CurrentGold += quantity * 10;
            break;

        default:
            // No encuentra nada, puede pasar.
            break;
        }

        Debug.Log("quedan: " + numberOfDebris);
        if (numberOfDebris == 0)
        {
            pDController.Save();
            SceneLoaderService sceneLoaderService = new SceneLoaderService();
            sceneLoaderService.LoadScene(SceneNames.MAIN_SCENE);
        }
    }
Exemplo n.º 5
0
 public void LoadMainMenu()
 {
     playerDataController.Save();
     sceneLoaderService.LoadScene(SceneNames.MAIN_MENU);
 }