Example #1
0
 // Use this for initialization
 void Start()
 {
     img          = GetComponent <Image>();
     weaponButton = GetComponent <Button>();
     weaponButton.onClick.AddListener(TaskOnClick);
     pi = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();
 }
Example #2
0
    // On trigger switch the alocated item and the one carried by the player
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            items = other.GetComponent("Player_Inventory") as Player_Inventory;


            temporal = items.getCurrentObject();
            items.setInvetory(availbleItem);
            availbleItem = temporal;


            switch (availbleItem)
            {
            case Items.NullItem: tile.SetThisTiles(0, (int)Items.NullItem); break;

            case Items.DoorKey1: tile.SetThisTiles(0, (int)Items.DoorKey1); break;

            case Items.DoorKey2: tile.SetThisTiles(0, (int)Items.DoorKey2); break;

            case Items.DoorKey3: tile.SetThisTiles(0, (int)Items.DoorKey3); break;

            case Items.DoorKey4: tile.SetThisTiles(0, (int)Items.DoorKey4); break;

            case Items.DoorKey5: tile.SetThisTiles(0, (int)Items.DoorKey5); break;

            case Items.DoorKey6: tile.SetThisTiles(0, (int)Items.DoorKey6); break;

            case Items.DoorKey7: tile.SetThisTiles(0, (int)Items.DoorKey7); break;
            }
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        //gameObject.GetComponent<Player_HUD>().showFix();

        playerInventory = GetComponent <Player_Inventory>();
        uiController    = GameObject.Find("UI_Controller").GetComponent <UI_Controller>();

        fixEngine      = uiController.fixEngine;
        fixLifeSupport = uiController.fixLifeSupport;
        fixReactor     = uiController.fixReactor;
        fixControls    = uiController.fixControls;
        fixBattery     = uiController.fixBattery;

        reqExt     = uiController.reqExt;
        reqHammer  = uiController.reqHammer;
        reqPipe    = uiController.reqPipe;
        reqSpanner = uiController.reqSpanner;
        reqSpring  = uiController.reqSpring;

        engineFixed      = uiController.engineFixed;
        lifeSupportFixed = uiController.lifeSupportFixed;
        reactorFixed     = uiController.reactorFixed;
        controlsFixed    = uiController.controlsFixed;
        batteryFixed     = uiController.batteryFixed;
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        playerInventory = GetComponent <Player_Inventory>();

        slotAmount     = playerInventory.Items().Count;
        InventoryPanel = GameObject.Find("Inventory Panel");
        SlotPanel      = InventoryPanel.transform.FindChild("Slot Panel").gameObject;

        itemsList = playerInventory.Items();

        for (int i = 0; i < slotAmount; i++)
        {
            InventoryItems.Add(new HP_Item());
            InventorySlots.Add(Instantiate(InventorySlot));
            InventorySlots[i].transform.SetParent(SlotPanel.transform);
        }

        foreach (Item i in itemsList.ToList())
        {
            AddItem(i.ItemID);
        }

        InventoryPanel.SetActive(false);

        //Debug.Log(itemsList.Count);

        //AddItem(1);
        //AddItem(2);
        //AddItem(3);
        //AddItem(4);
        //AddItem(5);
    }
Example #5
0
    public void savePlayerDataToFile()
    {
        //fetching and creating references to players current scripts
        player_log       = gameObject.GetComponent <Player_Log>();
        characterStats   = gameObject.GetComponent <CharacterStats>();
        player_Inventory = gameObject.GetComponent <Player_Inventory>();
        skillsManager    = gameObject.GetComponent <SkillsManager>();

        //creating scriptable instance of the PlayerObjectData that will be saved as JSON
        Data = (PlayerObjectData)ScriptableObject.CreateInstance("PlayerObjectData");

        //adding Data from different classes

        //adding Data from CharacterStats
        Data.saveCharacterStatData(characterStats.getStatBaseValue("HP"), characterStats.getCurrentHP(), characterStats.getStatBaseValue("Attack"), characterStats.getStatBaseValue("Defence"),
                                   characterStats.getStatBaseValue("Agility"), characterStats.CharacterLevel, characterStats.getExperiencePoints(), characterStats.Level_Experience_Required);

        //adding Data from inventory
        Data.saveInventoryItems(player_Inventory.getInventory());

        //Adding Data from SkillManager
        Data.saveSkillManager(skillsManager.getAllPlayerSkills(), skillsManager.getSlot1Skill(), skillsManager.getSlot2Skill());

        //Adding Data from Attacklog
        Data.savePlayerLog(player_log);

        //Saving instance to new file
        File.WriteAllText(Application.dataPath + "/Resources/SaveData/FloorTransitionData.txt",
                          JsonUtility.ToJson(Data));

        if (!transitionFloorInt.Equals(-1))
        {
            SceneManager.LoadScene(transitionFloorInt, LoadSceneMode.Single);
        }
    }
    public bool isTeleporting = false;     // Currently teleporting (to block movement etc)


    // Use this for initialization
    void Start()
    {
        if ((movementHandler = GetComponent <Player_Movement>()) == null)
        {
            Debug.LogError("You need to add a player movement script to this game object");
        }

        if ((animationHandler = GetComponent <Player_Animation_Controller>()) == null)
        {
            Debug.LogError("You need to add a player animation handler script to this game object");
        }

        if ((manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <Game_Manager>()) == null)
        {
            Debug.LogError("You're missing a Game Manager with a game manager script in your scene");
        }

        if ((inventoryHandler = GetComponent <Player_Inventory>()) == null)
        {
            Debug.LogError("You need to add a player inventory script to this game object");
        }

        if ((GameObject.FindGameObjectWithTag("Hand") == null))
        {
            Debug.LogError("You need to add a hand tag to a part of the player body (weapon pickup)");
        }

        height = GetComponent <MeshRenderer> ().bounds.size.y;
        state  = PLAYER_STATE.ALIVE;

        transform.position = determineRespawnPos(spawnPos.position, 15);
    }
Example #7
0
    //this method is used to fetch and load data from the JSON text file
    public void loadPlayerDataFromFile()
    {
        if (File.Exists(Application.dataPath + "/Resources/SaveData/FloorTransitionData.txt"))
        {
            //fetching and creating references to players current scripts
            player_log       = gameObject.GetComponent <Player_Log>();
            characterStats   = gameObject.GetComponent <CharacterStats>();
            player_Inventory = gameObject.GetComponent <Player_Inventory>();
            skillsManager    = gameObject.GetComponent <SkillsManager>();

            Data = (PlayerObjectData)ScriptableObject.CreateInstance("PlayerObjectData");
            TextAsset jsonFile = Resources.Load("SaveData/FloorTransitionData") as TextAsset;
            JsonUtility.FromJsonOverwrite(jsonFile.text, Data);

            characterStats.loadData(Data);
            skillsManager.loadData(Data);
            player_log.loadData(Data);
            player_Inventory.loadData(Data);

            Debug.Log("Data Loaded from previous Floor");
        }
        else
        {
            Debug.Log("Transition Save Data not found");
        }
    }
    private void Start()
    {
        // Reference to the UI_Controller script
        uiController    = GameObject.Find("UI_Controller").GetComponent <UI_Controller>();
        playerInventory = GetComponent <Player_Inventory>();

        // Setting the pickup item text objects
        pickupFood       = uiController.pickupFood;
        pickupOxygenTank = uiController.pickupOxygenTank;
        pickupPowerCell  = uiController.pickupPowerCell;

        pickupFireExt = uiController.pickupFireExt;
        pickupHammer  = uiController.pickupHammer;
        pickupPipe    = uiController.pickupPipe;
        pickupSpanner = uiController.pickupSpanner;
        pickupSpring  = uiController.pickupSpring;

        invFoodFull   = uiController.invFoodFull;
        invPowerFull  = uiController.invPowerFull;
        invOxygenFull = uiController.invOxygenFull;

        invExtFull     = uiController.invExtFull;
        invHammerFull  = uiController.invHammerFull;
        invPipeFull    = uiController.invPipeFull;
        invSpannerFull = uiController.invSpannerFull;
        invSpringFull  = uiController.invSpringFull;
    }
Example #9
0
    // If the payer collides with the door
    void OnTriggerEnter(Collider other)
    {
        // if is locked, ask for if the player carries the required item to open the door
        if (!locked)
        {
            if (other.gameObject.tag == "Player")
            {
                if (RequiresUseOfItem)
                {
                    inventory = other.GetComponent("Player_Inventory") as Player_Inventory;
                    if (inventory.getCurrentObject() == RequiredItem)
                    {
                        openprocess       = true;
                        RequiresUseOfItem = false;

                        /*if(inventory.getCurrentObject() == Items.DoorKey0) {
                         *      this.transform.position = new Vector3(-100,-100,0);
                         * }*/
                    }
                }
                else
                {
                    openprocess = true;
                }
            }
        }

        if (other.gameObject.tag == "Enemy")
        {
            openprocess = true;
        }
    }
    // Use this for initialization
    void Start()
    {
        anim            = GetComponent <Animator>();
        player          = GetComponent <Player_Movement>();
        playerInventory = GetComponent <Player_Inventory>();

        state = animationState.IDLE;
    }
Example #11
0
    private void Start()
    {
        inventoryScript   = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();
        gameManagerMaster = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager_Master>();
        playerInventory   = inventoryScript.inventory;

        CreateDisplay();
    }
Example #12
0
 void Awake()
 {
     pS = GetComponent <Player_Stats>();
     pI = GetComponent <Player_Inventory>();
     pE = GetComponent <Player_Equipped>();
     pM = GetComponent <Player_Movement>();
     //movC = GetComponent<Collider2D>();
 }
 // Use this for initialization
 void Start()
 {
     pInv      = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();
     img       = GetComponent <Image>();
     keyButton = GetComponent <Button>();
     keyButton.onClick.AddListener(TaskOnClick);
     numHPs.text = "" + pInv.getNumHealthPacks();
 }
Example #14
0
    private void Start()
    {
        _itemsToDetect   = new List <GameObject>();
        _playerInventory = GetComponent <Player_Inventory>();
        _playerActionBar = GetComponent <Player_ActionBar>();

        Debug.Assert(_playerActionBar != null);
        Debug.Assert(_playerInventory != null);
    }
Example #15
0
    void UpdateUI()
    {
        Player_Inventory pi = GetComponent <Player_Inventory>();

        pstats.SetMain(playerName, className, playerLevel.ToString(), pi.playerMoney);
        pstats.SetVitals(minDamage_P.ToString("0"), maxDamage_P.ToString("0"), armor.ToString("0"), currentShield.ToString("0"), shieldPoints.ToString("0"), currentHP.ToString("0"), healthPoints.ToString("0"), currentSP.ToString("0"), spellPoints.ToString("0"), currentEP.ToString("0"), energyPoints.ToString("0"));
        pstats.SetPrimaries(mstrength.ToString("0"), mdexterity.ToString("0"), mintellect.ToString("0"), mendurance.ToString("0"), mvitality.ToString("0"), magility.ToString("0"), mluck.ToString("0"));
        pstats.SetSecondaries(perception.ToString("0"), ferocity.ToString("0"), speed.ToString("0"), evasion.ToString("0"), spirit.ToString("0"), wisdom.ToString("0"), armorPen.ToString("0"));
        pstats.SetTertiaries(magicFindP.ToString("0"), moneyFindP.ToString("0"), damageP.ToString("0"), healthPointsP.ToString("0"), spellPointsP.ToString("0"), energyPointsP.ToString("0"), lifestealP.ToString("0"));
    }
    void Update()
    {
        //in case we like to use it
        //movement_clickToMove();

        if (player_active_bl)
        {
            movement_arrowKeys();
        }
        p_inv = GetComponent <Player_Inventory>();
    }
 private void Start()
 {
     itemDetector      = GetComponent <Player_DetectItem>();
     inventory         = GetComponent <Player_Inventory>();
     equipment         = GetComponent <Player_EquipmentManager>();
     gameManagerMaster = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager_Master>();
     playerAnimation   = GetComponent <Player_Animation>();
     isSwinging        = false;
     collider          = null;
     Audio_manager     = GameObject.FindWithTag("Audio");
     audio_manager     = Audio_manager.transform.GetComponent <Audio_manager>();
 }
Example #18
0
    void Start()
    {
        _inventory = GetComponent<Player_Inventory>();
        Debug.Assert(_inventory != null);

        _stateChanger = GetComponent<Player_StateChanger>();

        Debug.Assert(_stateChanger != null);

        _hudModel = GetComponent<HUD_Model>();
        Debug.Assert(_hudModel != null);
    }
    private void Start()
    {
        p_inv = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();

        if (tag != "LockUnlockDoor")
        {
            Debug.LogError("You need to add a LockUnlockDoor tag to this object");
        }
        if (DoorID == -1)
        {
            Debug.LogError("You forgot to assign a door ID to match with a key ID");
        }
    }
Example #20
0
    //this method is for rendering/filling the inventory grid
    public void RenderInventoryUIGrid(Player_Inventory playerInventoryScript)
    {
        playerInventoryReference = playerInventoryScript;
        string slotName = "";

        for (int i = 0; ((i < playerInventoryReference.getTotalInventoryItemAmount()) && (i < 15)); i++)
        {
            slotName = ("Slot" + i.ToString());
            inventorySlots.transform.Find(slotName).gameObject.GetComponent <Image>().enabled             = true;
            inventorySlots.transform.Find(slotName).gameObject.GetComponent <Button>().enabled            = true;
            inventorySlots.transform.Find(slotName).Find("Text").gameObject.GetComponent <Text>().enabled = true;
            inventorySlots.transform.Find(slotName).Find("Text").gameObject.GetComponent <Text>().text    = playerInventoryReference.getItemNameFromList(i);
        }
    }
Example #21
0
    void Start()
    {
        CreateAchievement("ContentAchievements", "Collect Laser Gun", "Congrats ! You have collected the laser gun", 5, 2);
        CreateAchievement("ContentAchievements", "Collect Wheels", "Congrats ! You have collected wheels", 5, 2);
        CreateAchievement("ContentAchievements", "Collect Springs", "Congrats ! You have collected springs", 5, 2);
        CreateAchievement("ContentAchievements", "Collect All Powerups", "Congrats ! You have collected all the objects ", 5, 1, new string[] { "Collect Laser Gun", "Collect Wheels", "Collect Springs" });

        CreateAchievement("ContentAchievements", "Collect Battery", "Congrats ! You have collected battery", 5, 2);
        CreateAchievement("ContentAchievements", "Collect Fuel", "Congrats ! You have collected fuel", 5, 2);

        _playerInventory = GameObject.FindObjectOfType <Player_Inventory>();

        ///THIS SHOULD BE REMOVED
        PlayerPrefs.DeleteAll();
    }
Example #22
0
    public bool CanPlayerSurvive()
    {
        Player_Inventory inventory = GetComponent <Player_Inventory>();

        if (inventory != null)
        {
            if (!inventory.HasItemWithTagInInventory(GameManager_References.wheelsTag))
            {
                StartCoroutine(ModifyPower(PowerTypes.POWER_ENERGY, -energyDrainAmount, powerDrainTimer));
                return(false);
            }
        }

        return(true);
    }
    // Use this for initialization
    void Start()
    {
        if (GetComponent <Camera_Manager> () != null)
        {
            cameraManager = GetComponent <Camera_Manager> ();
        }
        else
        {
            Debug.LogError("You need to add a camera manager to the game manager");
        }

        pInv = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();
        // Change later to main menu instead of loading into game
        view = ViewState.GAME;
    }
Example #24
0
    // Start is called before the first frame update
    void Start()
    {
        p_inv = GetComponent <Player_Inventory>();

        /*
         * Purpose:                It's a backup in case we forget to set the tree's health.
         * Effects:                Set's a tree's health to 3 in case we forget.
         * Input/Output:           N/A.
         * Global Variables Used:  Tree_HP.
         */

        if (Tree_HP == 0)
        {
            Tree_HP = 5;
            Debug.Log("You silly goose you, you forgot to set the Tree HP");
        }
    }
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         if (RequiresUseOfItem)
         {
             inventory = other.GetComponent("Player_Inventory") as Player_Inventory;
             if (inventory.getCurrentObject() == RequiredItem)
             {
                 door.unlockdoor();
             }
         }
         else
         {
             door.unlockdoor();
         }
     }
 }
Example #26
0
    protected override void SetupComponents()
    {
        base.SetupComponents();

        m_playerRotator = GetComponent <Player_Rotator>();
        Debug.Assert(m_playerRotator != null, "Player Rotator Is Null");

        m_playerWeaponHolder = GetComponent <Player_WeaponHolder>();
        Debug.Assert(m_playerWeaponHolder != null, "Player Weapon Holder Is Null");

        m_playerInventory = GetComponent <Player_Inventory>();
        Debug.Assert(m_playerInventory != null, "Player Inventory Is Null");

        m_playerAugmentHandler = GetComponent <Player_AugmentHandler>();
        Debug.Assert(m_playerAugmentHandler != null, "Player Augment Handler Is Null");


        Debug.Assert(m_playerInteractionArea != null, "Player Interaction Area Is Null");
    }
Example #27
0
        public override void OnCollisionEnter(Collision collision)
        {
            Player_Inventory playerInventory = new Player_Inventory();

            if (collision.gameObject.tag == "Player")
            {
                if (this.gameObject.tag == "Banana")
                {
                    AddItemFromMapToList(1, collision);
                }

                else if (this.gameObject.tag == "Apple")
                {
                    AddItemFromMapToList(5, collision);
                }

                else if (this.gameObject.tag == "Cumcumber")
                {
                    AddItemFromMapToList(3, collision);
                }
            }
        }
    void Start()
    {
        if (tag != "Item")
        {
            Debug.LogError("You need to add the Item tag to this object. You've added a pickup item script");
        }

        if ((item = GetComponent <Item>()) == null)
        {
            Debug.Log("You need to add an Item script");
        }

        if ((rangeCheck = GetComponent <Item_Range>()) == null)
        {
            Debug.Log("You need to add a Item Range script");
        }

        if (GetComponent <Item_Pickup>() == null)
        {
            Debug.LogError("You need to add an item pickup script");
        }

        p_inv = GameObject.FindGameObjectWithTag("Player").GetComponent <Player_Inventory>();
    }
Example #29
0
 public void OnEnable()
 {
     _inventory = GetComponent <Player_Inventory>();
     Debug.Assert(_inventory != null);
 }
 void Start()
 {
     _audioSource       = gameObject.GetComponent <AudioSource>();
     pickUpText.enabled = false;
     _pInventory        = transform.root.gameObject.GetComponent <Player_Inventory>();
 }
Example #31
0
    // Use this for initialization
    void Start()
    {
        if (!isLocalPlayer)
            return;

        inventoryScript = this.GetComponent<Player_Inventory> ();
        timerScript = this.GetComponent<Player_Timer> ();
    }
Example #32
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
 // Use this for initialization
 void Start()
 {
     inventoryScript = this.gameObject.GetComponent<Player_Inventory> ();
     itemsInRange = new LinkedList<GameObject> ();
     closestItem = null;
 }