コード例 #1
0
    void Update()
    {
        if (keyBinds.GetButtonDown("Jump"))
        {
            characterSwapper.currentCharacter.GetComponent <PlayerController>().jump();
        }
        ;

        if (Input.GetButtonDown("Character1"))
        {
            characterSwapper.switchToCharacter1();
        }

        if (Input.GetButtonDown("Character2"))
        {
            characterSwapper.switchToCharacter2();
        }

        if (Input.GetButtonDown("Character3"))
        {
            characterSwapper.switchToCharacter3();
        }

        if (Input.GetButtonDown("Character4"))
        {
            characterSwapper.switchToCharacter4();
        }
    }
コード例 #2
0
    public void LoadData()
    {
        AliceController.incrementHealth(AliceData[0]);
        BobController.incrementHealth(BobData[0]);
        CharlieController.incrementHealth(CharlieData[0]);
        DaveController.incrementHealth(DaveData[0]);
        AliceController.decrementMana(999);
        BobController.decrementMana(999);
        CharlieController.decrementMana(999);
        DaveController.decrementMana(999);

        AliceController.incrementMana(AliceData[1]);
        BobController.incrementMana(BobData[1]);
        CharlieController.incrementMana(CharlieData[1]);
        DaveController.incrementMana(DaveData[1]);

        AliceController.setMaxHealth(AliceData[2]);
        BobController.setMaxHealth(BobData[2]);
        CharlieController.setMaxHealth(CharlieData[2]);
        DaveController.setMaxHealth(DaveData[2]);

        AliceController.setMaxMana(AliceData[3]);
        BobController.setMaxMana(BobData[3]);
        CharlieController.setMaxMana(CharlieData[3]);
        DaveController.setMaxMana(DaveData[3]);

        StartCoroutine(LoadSaveScene());

        switch (characterAtSave)
        {
        case 1:
            characterSwapper.switchToCharacter1();
            break;

        case 2:
            characterSwapper.switchToCharacter2();
            break;

        case 3:
            characterSwapper.switchToCharacter3();
            break;

        case 4:
            characterSwapper.switchToCharacter4();
            break;

        default:
            break;
        }

        //LOADING ITEMS
        if (saveItems.Count != 0)
        {
            gameManagerGO.GetComponent <GameManager>().items.Clear();
            for (int i = 0; i < saveItems.Count; i++)
            {
                gameManagerGO.GetComponent <GameManager>().items.Add(saveItems[i]);
                // Debug.Log("LOAD: " + saveItems[i].itemName);
            }
            for (int i = 0; i < gameManagerGO.GetComponent <GameManager>().items.Count; i++)
            {
                //  Debug.Log("LOAD: " + gameManagerGO.GetComponent<GameManager>().items[i].itemName);
            }
            gameManagerGO.GetComponent <GameManager>().itemNumbers.Clear();
            for (int i = 0; i < saveitemNumbers.Count; i++)
            {
                gameManagerGO.GetComponent <GameManager>().itemNumbers.Add(saveitemNumbers[i]);
                //  Debug.Log("LOAD: " + saveitemNumbers[i]);
            }

            gameManagerGO.GetComponent <GameManager>().slots = saveSlots;
            gameManagerGO.GetComponent <GameManager>().DisplayItems();
        }
        //LOADING ITEMS WORKING

        //LOADING COIN COUNTER
        coinCounterM.GetComponent <ScoreManager>().setValueAndText(savedCoinCounter);
        Debug.Log("Coins Loaded: " + coinCounterM.GetComponent <ScoreManager>().score);
        //COIN COUNTER LOADED


        //LOADING EQUIPMENT ITEMS
        //gameManagerGO.GetComponent<GameManager>().equipmentItems.Clear();



        //LOADING EQUIPMENT HELMET
        // gameManagerGO.GetComponent<GameManager>().equipmentHelmets.Clear();

        /*for (int i = 0; i < gameManager.GetComponent<GameManager>().equipmentHelmets.Count; i++)
         * {
         *  gameManager.GetComponent<GameManager>().RemoveEquipmentItem(gameManager.GetComponent<GameManager>().equipmentHelmets[i]);
         * }*/
        //            Debug.Log("HELMETS BEFORE: " + gameManager.GetComponent<GameManager>().equipmentHelmets.Count);

        /*    for (int i = 0; i < savedEquipmentHelmets.Count; i++)
         *  {
         *      gameManagerGO.GetComponent<GameManager>().equipmentHelmets.Add(savedEquipmentHelmets[i]);
         *  }*/
        //LOADING EQUIPMENT BODY
        //gameManagerGO.GetComponent<GameManager>().equipmentChest.Clear();

        /*for (int i = 0; i < gameManager.GetComponent<GameManager>().equipmentChest.Count; i++)
         * {
         *  gameManager.GetComponent<GameManager>().RemoveEquipmentItem(gameManager.GetComponent<GameManager>().equipmentChest[i]);
         * }
         * // Debug.Log("BODY BEFORE: " + gameManager.GetComponent<GameManager>().equipmentChest.Count);
         *//* for (int i = 0; i < savedEquipmentChest.Count; i++)
         * {
         *  gameManagerGO.GetComponent<GameManager>().equipmentChest.Add(savedEquipmentChest[i]);
         * }*//*
         * //LOADING EQUIPMENT PANTS
         * // gameManagerGO.GetComponent<GameManager>().equipmentPants.Clear();
         * for (int i = 0; i < gameManager.GetComponent<GameManager>().equipmentPants.Count; i++)
         * {
         *  gameManager.GetComponent<GameManager>().RemoveEquipmentItem(gameManager.GetComponent<GameManager>().equipmentPants[i]);
         * }
         * // Debug.Log("PANTS BEFORE: " + gameManager.GetComponent<GameManager>().equipmentPants.Count);
         *//*  for (int i = 0; i < savedEquipmentPants.Count; i++)
         * {
         *  gameManagerGO.GetComponent<GameManager>().equipmentPants.Add(savedEquipmentPants[i]);
         * }*//*
         * //LOADING EQUIPMENT BOOTS
         * // gameManagerGO.GetComponent<GameManager>().equipmentBoots.Clear();
         * for (int i = 0; i < gameManager.GetComponent<GameManager>().equipmentBoots.Count; i++)
         * {
         *  gameManager.GetComponent<GameManager>().RemoveEquipmentItem(gameManager.GetComponent<GameManager>().equipmentBoots[i]);
         * }
         * //Debug.Log("BOOTS BEFORE: " + gameManager.GetComponent<GameManager>().equipmentBoots.Count);
         *//*    for (int i = 0; i < savedEquipmentBoots.Count; i++)
         *  {
         *      gameManagerGO.GetComponent<GameManager>().equipmentBoots.Add(savedEquipmentBoots[i]);
         *  }*//*
         * //LOADING EQUIPMENT WEAPON
         * //gameManagerGO.GetComponent<GameManager>().equipmentWeapon.Clear();
         * for (int i = 0; i < gameManager.GetComponent<GameManager>().equipmentWeapon.Count; i++)
         * {
         *  gameManager.GetComponent<GameManager>().RemoveEquipmentItem(gameManager.GetComponent<GameManager>().equipmentWeapon[i]);
         * }*/
        //  Debug.Log("WEAPONS BEFORE: " + gameManager.GetComponent<GameManager>().equipmentWeapon.Count);

        /* for (int i = 0; i < savedEquipmentWeapon.Count; i++)
         * {
         *  gameManagerGO.GetComponent<GameManager>().equipmentWeapon.Add(savedEquipmentWeapon[i]);
         * }*/
        //Debug.Log("EITEMS BEFORE loop: " + gameManagerGO.GetComponent<GameManager>().equipmentItems.Count);
        for (int i = 0; i < gameManagerGO.GetComponent <GameManager>().equipmentItems.Count; i++)
        {
            gameManagerGO.GetComponent <GameManager>().RemoveEquipmentItem(gameManager.GetComponent <GameManager>().equipmentItems[i]);
        }
        for (int i = 0; i < gameManagerGO.GetComponent <GameManager>().equipmentItems.Count; i++)
        {
            Debug.Log("EITEM NOT DELETED: " + gameManagerGO.GetComponent <GameManager>().equipmentItems[i]);
        }
        Debug.Log("EITEMS BEFORE after loop: " + gameManagerGO.GetComponent <GameManager>().equipmentItems.Count);
        for (int i = 0; i < savedEquipmentItems.Count; i++)
        {
            gameManagerGO.GetComponent <GameManager>().AddEquipmentItem(savedEquipmentItems[i]);
        }
        Debug.Log("EITEMS AFTER : " + gameManager.GetComponent <GameManager>().equipmentItems.Count);


        gameManagerGO.GetComponent <GameManager>().equipmentSlots = savedEquipmentSlots;
        characterSwapper.currentCharacter.transform.position      = saveLocation;
    }