Inheritance: MonoBehaviour
コード例 #1
0
        public void ReserveInventory(Cart cart)
        {
            foreach(var item in cart.Items)
            {
                try
                {
                    var inventorySystem = new InventorySystem();
                    inventorySystem.Reserve(item.Sku, item.Quantity);

                }
                catch (InsufficientInventoryException ex)
                {
                    throw new OrderException("Insufficient inventory for item " + item.Sku, ex);
                }
                catch (Exception ex)
                {
                    throw new OrderException("Problem reserving inventory", ex);
                }
            }
        }
コード例 #2
0
ファイル: KeyPad.cs プロジェクト: Roba25/MiniJam-Underground
 void Start()
 {
     inventory       = GameObject.FindGameObjectWithTag("Player").GetComponent <InventorySystem>();
     dialogueManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <DialogueManager>();
 }
コード例 #3
0
 private void OnEnable()
 {
     inventorySystem = (InventorySystem)target;
 }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     invenSys       = FindObjectOfType <InventorySystem>().GetComponent <InventorySystem>();
     fader          = FindObjectOfType <Fader>();
     playerAnimator = playerCharacter.GetComponent <Animator>();
 }
コード例 #5
0
 private void SetSpeedBoost(InventorySystem inventory)
 {
     speedBoostBar.Initialize(inventory.SpeedBoost.Amount, inventory.SpeedBoost.Capacity, inventory.SpeedBoost.AmountChanged);
 }
コード例 #6
0
 private void SetHealthBar(InventorySystem inventory)
 {
     healthBar.Initialize(inventory.Health.Amount, inventory.Health.Capacity, inventory.Health.AmountChanged);
 }
コード例 #7
0
 public void TestSetup()
 {
     _inv = new InventorySystem <IItemInfo>();
 }
コード例 #8
0
ファイル: RayCast.cs プロジェクト: theiis/PGP2
 void Start()
 {
     //sqnPzl = GameObject.Find("Cogwheel Puzzle").GetComponent<SequencePuzzle>();
     arms = GameObject.FindGameObjectWithTag("Arm");
     inventory = GameObject.FindGameObjectWithTag("Bagpack").GetComponent<InventorySystem>();
 }
コード例 #9
0
ファイル: ArmsScript.cs プロジェクト: JesterJ/PGP2
 void Start()
 {
     handSpeed = 1.2f;
     inventory = GameObject.FindGameObjectWithTag("Bagpack").GetComponent<InventorySystem>();
     bagSlots = GameObject.FindGameObjectsWithTag("BagSlot");
 }
コード例 #10
0
ファイル: NBTStairs.cs プロジェクト: wetstreet/Theircraft
    public override void OnAddBlock(RaycastHit hit)
    {
        Vector3Int pos = WireFrameHelper.pos + Vector3Int.RoundToInt(hit.normal);

        if (CanAddBlock(pos))
        {
            PlayerController.instance.PlayHandAnimation();

            byte type = NBTGeneratorManager.id2type[id];
            byte data = 0;

            Vector3 playerPos = PlayerController.instance.position;
            Vector2 dir       = (new Vector2(playerPos.x, playerPos.z) - new Vector2(pos.x, pos.z)).normalized;
            if (dir.x > 0)
            {
                if (dir.y > 0)
                {
                    if (dir.y > dir.x)
                    {
                        // positive z
                        data = 3;
                    }
                    else
                    {
                        // positive x
                        data = 1;
                    }
                }
                else
                {
                    if (-dir.y > dir.x)
                    {
                        // negative z
                        data = 2;
                    }
                    else
                    {
                        // positive x
                        data = 1;
                    }
                }
            }
            else
            {
                if (dir.y > 0)
                {
                    if (dir.y > -dir.x)
                    {
                        // positive z
                        data = 3;
                    }
                    else
                    {
                        // negative x
                        data = 0;
                    }
                }
                else
                {
                    if (-dir.y > -dir.x)
                    {
                        // negative z
                        data = 2;
                    }
                    else
                    {
                        // negative x
                        data = 0;
                    }
                }
            }

            if (hit.point.y - pos.y > 0)
            {
                data += 4;
            }

            NBTHelper.SetBlockData(pos, type, data);

            InventorySystem.DecrementCurrent();
            ItemSelectPanel.instance.RefreshUI();
        }
    }
コード例 #11
0
 void Start()
 {
     inventory   = GameObject.FindGameObjectWithTag("Player").GetComponent <InventorySystem>();
     gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
     codePeice   = new Item("Peice of the code!", "Code Peice", icon);
 }
コード例 #12
0
 void Start()
 {
     _inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <InventorySystem>();
 }
コード例 #13
0
 // Start is called before the first frame update
 void Start()
 {
     inventory = GameObject.Find("Canvas").GetComponentInChildren <InventorySystem>();
     wallet    = inventory.transform.FindChild("Gold").GetComponent <Gold>();
     wallet.EarnGold(500);
 }
コード例 #14
0
    // Use this for initialization
    void Start()
    {
        player1 = GameObject.Find("Player1");
        player2 = GameObject.Find("Player2");
        managerSys = GameObject.Find("Manager").GetComponent<ManagerSystem>();
        inventSys = GameObject.Find("Manager").GetComponent<InventorySystem>();
        player1AP = player1.GetComponent<PlayerComponent>().actionPoints;
        player2AP = player2.GetComponent<PlayerComponent>().actionPoints;

        //test angaben
        isPlayer1 = managerSys.getPlayerTurn();

        //setStyle
        style = new GUIStyle();

        dijkstra = (DijkstraSystem)FindObjectOfType(typeof(DijkstraSystem));

        if (isPlayer1)
            input = player1.GetComponent<inputSystem>();
        else
            input = player2.GetComponent<inputSystem>();

        figureUpdate();
    }
コード例 #15
0
 private void Start()
 {
     inventorySystem = InventorySystem.GetInstance();
 }
コード例 #16
0
    public void Load_(string scene_name)
    {
        if (File.Exists(Application.persistentDataPath + "/save.dat"))
        {
            isys   = GameObject.FindGameObjectWithTag("Player").GetComponent <InventorySystem>();
            hud    = GameObject.FindGameObjectWithTag("HUD").GetComponent <HUDSystem>();
            player = GameObject.FindGameObjectWithTag("Player");
            misc   = player.GetComponent <Misc>();
            //AxeSpawn =GameObject.FindGameObjectWithTag("AxeEnemySpawn");
            //PistolSpawn = GameObject.FindGameObjectWithTag("PistolEnemySpawn"); ;
            //ChainSpawn = GameObject.FindGameObjectWithTag("ChainEnemySpawn"); ;
            //CutterSpawn = GameObject.FindGameObjectWithTag("CutterEnemySpawn"); ;
            //SmgSpawn = GameObject.FindGameObjectWithTag("SmgEnemySpawn"); ;

            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      file      = File.Open(Application.persistentDataPath + "/save.dat", FileMode.Open);

            SceneData data = (SceneData)formatter.Deserialize(file);
            file.Close();

            isys.LoadPlayer(data.pdata);

            //Valido per il primo livello
            if (scene_name.Equals("Scena 1 - Il massiccio"))
            {
                Save.AxeSpawnActive = data.spawn.AxeSpawnActive;
                if (data.spawn.AxeSpawnActive)
                {
                    AxeSpawn.SetActive(true);
                }
                else
                {
                    AxeSpawn.SetActive(false);
                }

                Save.PistolSpawnActive = data.spawn.PistolSpawnActive;
                if (data.spawn.PistolSpawnActive)
                {
                    PistolSpawn.SetActive(true);
                }
                else
                {
                    PistolSpawn.SetActive(false);
                }

                Save.ChainSpawnActive = data.spawn.ChainSpawnActive;
                if (data.spawn.ChainSpawnActive)
                {
                    ChainSpawn.SetActive(true);
                }
                else
                {
                    ChainSpawn.SetActive(false);
                }

                Save.CutterSpawnActive = data.spawn.CutterSpawnActive;
                if (data.spawn.CutterSpawnActive)
                {
                    CutterSpawn.SetActive(true);
                }
                else
                {
                    CutterSpawn.SetActive(false);
                }

                Save.SmgSpawnActive = data.spawn.SmgSpawnActive;
                if (data.spawn.SmgSpawnActive)
                {
                    SmgSpawn.SetActive(true);
                }
                else
                {
                    SmgSpawn.SetActive(false);
                }
            }

            //Per ogni nemico nella scena (inizialmente sono tutti attivi, anche quelli da spawnare via script)
            foreach (GameObject nemico in GameObject.FindGameObjectsWithTag("Enemy"))
            {
                //Per ogni enemydata presente nella lista degli enemy salvatii
                foreach (Enemy enemy in data.edata)
                {
                    //Se il nome del nemico è presente nella lista, allora carico le sue info
                    if (nemico.gameObject.name.Equals(enemy.name))
                    {
                        nemico.GetComponent <EnemyController>().loadEnemy(enemy);
                        nemico.GetComponent <EnemyController>().loaded = true;
                    }
                }
            }

            //Elimino i nemici che non sono stati caricati
            foreach (GameObject nemico in GameObject.FindGameObjectsWithTag("Enemy"))
            {
                if (nemico.GetComponent <EnemyController>().loaded == false)
                {
                    Destroy(nemico);
                }
            }

            //Trovo gli elementi da mantenere nella scena, impostando a true loaded (quelli a false andranno eliminati nel prossimo ciclo for)
            foreach (string nome in data.idata)
            {
                foreach (GameObject kitmedico in GameObject.FindGameObjectsWithTag("FirstAid"))
                {
                    if (kitmedico.gameObject.name.Equals(nome))
                    {
                        kitmedico.GetComponent <Pickup>().loaded = true;
                    }
                }

                foreach (GameObject ammo_9mm in GameObject.FindGameObjectsWithTag("Ammo_9mm"))
                {
                    if (ammo_9mm.gameObject.name.Equals(nome))
                    {
                        ammo_9mm.GetComponent <Pickup>().loaded = true;
                    }
                }

                foreach (GameObject ammo_smg in GameObject.FindGameObjectsWithTag("Ammo_smg"))
                {
                    if (ammo_smg.gameObject.name.Equals(nome))
                    {
                        ammo_smg.GetComponent <Pickup>().loaded = true;
                    }
                }

                if (torcia != null && torcia.gameObject.name.Equals(nome))
                {
                    torcia.GetComponent <Pickup>().loaded = true;
                }

                if (ascia != null && ascia.gameObject.name.Equals(nome))
                {
                    ascia.GetComponent <Pickup>().loaded = true;
                }

                if (pistola != null && pistola.gameObject.name.Equals(nome))
                {
                    pistola.GetComponent <Pickup>().loaded = true;
                }

                if (smg != null && smg.gameObject.name.Equals(nome))
                {
                    smg.GetComponent <Pickup>().loaded = true;
                }

                //Valido per il primo livello
                if (scene_name.Equals("Scena 1 - Il massiccio"))
                {
                    if (final_key != null && final_key.gameObject.name.Equals(nome))
                    {
                        final_key.GetComponent <KeyScript>().loaded = true;
                    }

                    if (cutter != null && cutter.gameObject.name.Equals(nome))
                    {
                        cutter.GetComponent <KeyScript>().loaded = true;
                    }
                }
            }

            //Elimino gli oggetti che non servono
            foreach (GameObject kitmedico in GameObject.FindGameObjectsWithTag("FirstAid"))
            {
                if (kitmedico.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(kitmedico);
                }
            }

            foreach (GameObject ammo_9mm in GameObject.FindGameObjectsWithTag("Ammo_9mm"))
            {
                if (ammo_9mm.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(ammo_9mm);
                }
            }

            foreach (GameObject ammo_smg in GameObject.FindGameObjectsWithTag("Ammo_smg"))
            {
                if (ammo_smg.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(ammo_smg);
                }
            }


            //Valido per il primo livello
            if (scene_name.Equals("Scena 1 - Il massiccio"))
            {
                if (torcia != null && torcia.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(torcia);
                }

                if (ascia != null && ascia.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(ascia);
                }

                if (pistola != null && pistola.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(pistola);
                }

                if (smg != null && smg.GetComponent <Pickup>().loaded == false)
                {
                    Destroy(smg);
                }

                if (final_key != null && final_key.GetComponent <KeyScript>().loaded == false)
                {
                    Destroy(final_key);
                }

                if (cutter != null && cutter.GetComponent <KeyScript>().loaded == false)
                {
                    Destroy(cutter);
                }
            }

            //Setto gli eventi
            if (data.checkpoint_name.Equals("Pre-MiniBoss"))
            {
                GameObject.FindGameObjectWithTag("Recinzione").GetComponent <Animator>().SetBool("Open", true);
            }

            if (data.checkpoint_name.Equals("Post-MiniBoss"))
            {
                Destroy(GameObject.FindGameObjectWithTag("MiniBoss"));
                boss_door1.GetComponent <Animator>().SetTrigger("Boss dies");
            }

            if (data.checkpoint_name.Equals("Pre-Boss"))
            {
                foreach (GameObject porta in GameObject.FindGameObjectsWithTag("Porta"))
                {
                    if (porta.GetComponent <DoorBrokenDown>() != null)
                    {
                        porta.GetComponent <DoorBrokenDown>().brokenOnLoading();
                    }
                }

                Destroy(GameObject.Find("WeaponsCrate"));
                Destroy(GameObject.Find("crate"));
            }

            if (data.checkpoint_name.Equals("Checkpoint1"))
            {
                foreach (GameObject porta in GameObject.FindGameObjectsWithTag("PortaCheckpoint"))
                {
                    if (porta != null && porta.name.Equals("PortaPostCheckpoint1"))
                    {
                        porta.GetComponentInChildren <OpenCloseDoor>().unlocked = false;
                        porta.GetComponentInChildren <Animator>().SetBool("open", false);
                    }
                }

                if (GameObject.FindGameObjectWithTag("Porta") != null)
                {
                    GameObject.FindGameObjectWithTag("Porta").GetComponent <OpenCloseDoor>().unlocked = true;
                }
            }
            if (data.checkpoint_name.Equals("Checkpoint2"))
            {
                print("we");
                foreach (GameObject porta in GameObject.FindGameObjectsWithTag("PortaCheckpoint"))
                {
                    if (porta != null && porta.name.Equals("PortaPostCheckpoint2"))
                    {
                        porta.GetComponentInChildren <OpenCloseDoor>().unlocked = false;
                        porta.GetComponentInChildren <Animator>().SetBool("open", false);
                    }
                }
            }

            Destroy(GameObject.Find(data.checkpoint_name));

            foreach (GameObject checkpoint_scena in GameObject.FindGameObjectsWithTag("Checkpoint"))
            {
                foreach (string checkpoint_save in data.check_data)
                {
                    print(checkpoint_save);
                    if (checkpoint_scena.name.Equals(checkpoint_save))
                    {
                        checkpoint_scena.GetComponent <Save>().loaded = true;
                    }
                }
            }

            foreach (GameObject checkpoint_scena in GameObject.FindGameObjectsWithTag("Checkpoint"))
            {
                if (checkpoint_scena.GetComponent <Save>().loaded == false)
                {
                    Destroy(checkpoint_scena);
                }
                else
                {
                    //Valido per il primo livello
                    if (scene_name.Equals("Scena 1 - Il massiccio"))
                    {
                        checkpoint_scena.GetComponent <Save>().AxeSpawn = AxeSpawn;
                        print(checkpoint_scena.GetComponent <Save>().AxeSpawn);
                        checkpoint_scena.GetComponent <Save>().PistolSpawn = PistolSpawn;
                        checkpoint_scena.GetComponent <Save>().ChainSpawn  = ChainSpawn;
                        checkpoint_scena.GetComponent <Save>().CutterSpawn = CutterSpawn;
                        checkpoint_scena.GetComponent <Save>().SmgSpawn    = SmgSpawn;
                    }
                }
            }
        }
    }
コード例 #17
0
ファイル: ItemData.cs プロジェクト: 5TEV3N/UnionGameJam
 void Start()
 {
     inv     = GameObject.Find("Inventory Master").GetComponent <InventorySystem>();
     tooltip = inv.GetComponent <Tooltip>();
 }
コード例 #18
0
 void Start()
 {
     _inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <InventorySystem>();
     key.SetActive(false);
     doorCollider.SetActive(true);
 }
コード例 #19
0
 public void DisplayInventory(InventorySystem isys)
 {
     text.text = isys.ReportContents();
 }
コード例 #20
0
ファイル: C_Hero.cs プロジェクト: Sanchoserik/Adventure
        //starting initialisation
        public C_Hero()
        {
            inventorySystem = new InventorySystem();
            effectsStorage  = new List <A_Effect>();

            baseHP              = 200;
            currentHP           = 200;
            baseENE             = 100;
            currentENE          = 100;
            level               = 0;
            currExp             = 0;
            nextLevelExp        = 100;
            freeSkillPoints     = 1;
            freeAttributePoints = 4;

            basePhysAtk = 25;

            baseStrength  = 0;
            baseEndurance = 0;
            baseKnowledge = 0;
            baseCharisma  = 0;

            physDef      = new DefenceParam();
            fireDef      = new DefenceParam();
            airDef       = new DefenceParam();
            lightningDef = new DefenceParam();
            earthDef     = new DefenceParam();
            waterDef     = new DefenceParam();
            lifeDef      = new DefenceParam();
            deathDef     = new DefenceParam();
            lightDef     = new DefenceParam();
            darknessDef  = new DefenceParam();

            bonusPhysDef      = new DefenceParam();
            bonusFireDef      = new DefenceParam();
            bonusAirDef       = new DefenceParam();
            bonusLightningDef = new DefenceParam();
            bonusEarthDef     = new DefenceParam();
            bonusWaterDef     = new DefenceParam();
            bonusLifeDef      = new DefenceParam();
            bonusDeathDef     = new DefenceParam();
            bonusLightDef     = new DefenceParam();
            bonusDarknessDef  = new DefenceParam();

            totalPhysDef      = new DefenceParam();
            totalFireDef      = new DefenceParam();
            totalAirDef       = new DefenceParam();
            totalLightningDef = new DefenceParam();
            totalEarthDef     = new DefenceParam();
            totalWaterDef     = new DefenceParam();
            totalLifeDef      = new DefenceParam();
            totalDeathDef     = new DefenceParam();
            totalLightDef     = new DefenceParam();
            totalDarknessDef  = new DefenceParam();

            money  = 0;
            baseAP = 4;

            baseCritChance = 1;
            critDamageMod  = 2.0f;
        }
コード例 #21
0
 private void Start()
 {
     _inventorySystem = GetComponent <InventorySystem>();
     _inventorySystem.onImprovementAdd += RedrawInventory;
 }
コード例 #22
0
 private void SetAmmoBar(InventorySystem inventory)
 {
     ammoBar.Initialize(inventory.Ammo.Amount, inventory.Ammo.Capacity, inventory.Ammo.AmountChanged);
 }
コード例 #23
0
ファイル: Clicking.cs プロジェクト: ezecoen/Within
    void OnMouseDown()
    {
        GameObject      global = GameObject.Find("ScriptGlobal");
        Global          sglob  = global.GetComponent <Global> ();
        InventorySystem invs   = GameObject.Find("ScriptGlobal").GetComponent <InventorySystem> ();

        switch (this.name)
        {
        case "Placa":
            if (invs.IsInInventory("Llave") && sglob.Selected == "Llave")
            {
                GameObject key    = gl.GameObjectFinder("Llave");
                GameObject newPos = gl.GameObjectFinder("KeyHolder");
                key.transform.parent   = newPos.transform.parent;
                key.transform.position = newPos.transform.position;
                key.transform.rotation = newPos.transform.rotation;
                key.GetComponent <Clicked>().enabled         = false;
                key.GetComponent <InventorySystem>().enabled = false;
                sglob.Selected           = "Llave";
                objetoquevaalpresionarse = gl.GameObjectFinder("Llave");
                Messenger.Message("MUY BIEN!!!", 0.01f, Color.green, true, true);
            }
            else
            {
                Messenger.Message("Necesitas una llave para abrir esto", 0.01f, Color.red, true, false);
                Debug.Log("You need a key to open this.");
            }
            break;

        case "LlaveHole":
            if (invs.IsInInventory("Vela prendida") && sglob.Selected == "Vela prendida")
            {
                //gl.GameObjectFinder ("Llave").SetActive (true); //TODO: <--
                sglob.Selected           = "Vela prendida";
                objetoquevaalpresionarse = gl.GameObjectFinder("Vela prendida");
                GameObject vp = gl.GameObjectFinder("Vela prendida");
                vp.SetActive(true);
                vp.GetComponent <Clicked>().enabled = false;
                //sglob.SacardelInventario(vp.name);
                //sglob.desobjeto(vp.name);
                //vp.transform.position = Posiciondelobjetonuevo;
                Debug.Log(vp.transform.position.ToString() + "0333");
                //vp.transform.GetChild(0).gameObject.SetActive(true); //Este es el plano de LlenadoCeraUnique ("LlenadoCeraUnique"). DEJAR SIEMPRE EN INDEX 0 !important
                gl.GameObjectFinder("LlenadoCeraUnique").SetActive(true);
                vp.GetComponent <Animator>().SetBool("openNow", true);
                Debug.Log("aiofhasfhasuioh " + vp.GetComponent <Animator>().GetBool("openNow").ToString());
                timerAnimation = Time.time;
                //UNITY ANIMATION ENDER
                //Debug.Log ("unity sucks " + vp.GetComponent<Animator>().playbackTime.ToString()); //TODO: <--
                timer = Time.time;                         //TODO: <--
                vp.GetComponent <Animator>().StartRecording(0);
                //UNITY ANIMATION ENDER
                vp.transform.position   = GameObject.Find("VelaPrendidaHolder").transform.position;
                vp.transform.rotation   = GameObject.Find("VelaPrendidaHolder").transform.rotation;
                vp.transform.localScale = GameObject.Find("VelaPrendidaHolder").transform.localScale;
                Messenger.Message("MUY BIEN!!!", 0.01f, Color.green, true, true);
            }
            else
            {
                Messenger.Message("Necesitas una vela y fuego.", 0.01f, Color.red, true, false);
                Debug.Log("You need a fire and some wax.");
            }
            break;

        case "Cabeza":
            //Debug.Log(invs.IsInInventory ("lasers juntos").ToString() + "; " + sglob.Selected + ";");
            Debug.Log("Lasers position before activating: " + gl.GameObjectFinder("lasers").transform.position.ToString());
            if (invs.IsInInventory("lasers juntos") && sglob.Selected == "lasers juntos")
            {
                gl.GameObjectFinder("lasers").SetActive(true);
                sglob.Selected           = "lasers juntos";
                objetoquevaalpresionarse = gl.GameObjectFinder("lasers juntos");
                GameObject ls = gl.GameObjectFinder("lasers");
                ls.SetActive(true);
                Posiciondelobjetonuevo = ls.transform.localPosition;
                gl.GameObjectFinder("lasers").SetActive(true);                 //PORQUE NO ANDASSSSSSS??????

                /*while (!ls.activeSelf)
                 *      ls.SetActive(true);*/
                //Debug.Log("Next laser position: " + Posiciondelobjetonuevo.ToString() + "; Supposed: " + ls.transform.localPosition.ToString() + ";");
                //Debug.Log(ls.transform.position.ToString() + "0352");
                Debug.Log("Lasers position after activating: " + gl.GameObjectFinder("lasers").transform.position.ToString());
                Messenger.Message("MUY BIEN!!!", 0.01f, Color.green, true, true);
            }
            else
            {
                Debug.Log("You need the lasers.");
                Messenger.Message("Necesitas 3 lasers.", 0.01f, Color.red, true, false, true);
            }
            break;

        case "Computadora":
            if (invs.IsInInventory("CD") && sglob.Selected == "CD")
            {
                GameObject cd     = gl.GameObjectFinder("CD");
                GameObject newPos = gl.GameObjectFinder("Computadora");
                cd.transform.parent   = newPos.transform.parent;
                cd.transform.position = newPos.transform.position;
                cd.transform.rotation = newPos.transform.rotation;
                cd.GetComponent <Clicked>().enabled         = false;
                cd.GetComponent <InventorySystem>().enabled = false;
                cd.SetActive(false);
                sglob.Selected   = "CD";
                candadito.active = true;
                gl.GameObjectFinder("pantallaComp").transform.GetChild(0).gameObject.SetActive(true);
                gl.GameObjectFinder("pantallaComp").transform.GetChild(1).gameObject.SetActive(true);
                objetoquevaalpresionarse = gl.GameObjectFinder("CD");
            }
            else
            {
                Messenger.Message("Hmm, necesito un CD para esto...", 0.01f, Color.red, true, false);
                Debug.Log("Hmm, there should be a CD for this...");
            }
            break;
        }

        if (sglob.Selected == objetoquevaalpresionarse.name)
        {
            try {
                sglob.SacardelInventario(objetoquevaalpresionarse.name);
                sglob.desobjeto(objetoquevaalpresionarse.name);
                //objetoquevaalpresionarse.GetComponent<Renderer>().enabled=true;
                objetoquevaalpresionarse.SetActive(true);
                objetoquevaalpresionarse.transform.localPosition = Posiciondelobjetonuevo;
                //objetoquevaalpresionarse.transform.localRotation = Quaternion.Euler(0, 0, 0);
                sglob.Selected = "";
                Clicked sc = objetoquevaalpresionarse.GetComponent <Clicked>();
                sc.visible = true;
            } catch {}
        }
    }
コード例 #24
0
    public void BuyItem()
    {
        InventorySystem Inventory = GameObject.Find("Inventory").GetComponent <InventorySystem>();

        if (!Inventory)
        {
            Debug.LogError("Inventory Not Found");
            return;
        }
        if (SelectItem == int.MaxValue)
        {
            Debug.LogError("don't Selection Item");
            return;
        }

        int[] Inven_ItemID = Inventory.InventoryItemSearch();
        float requireGold  = ItemList[SelectItem].Gold;
        float Gold         = Inventory.GetGold();

        bool IsEmptySlot = false;

        for (int i = 0; i < Inven_ItemID.Length; i++)
        {
            if (Inven_ItemID[i] == int.MaxValue)
            {
                IsEmptySlot = true;
                break;
            }
        }
        if (ItemList[SelectItem].itemTag == Scriptable_Item.tag_item.equipment)
        {
            if (ItemList[SelectItem].ItemForCraft == 0)
            {
                if (!IsEmptySlot)
                {
                    //error
                }

                if (requireGold < Gold)
                {
                    Inventory.Equipitem(ItemList[SelectItem], requireGold);
                }
                else
                {
                    // error
                }
            }
            else
            {
                requireGold = CalculationPrice(Inven_ItemID, SelectItem);
                IsEmptySlot = false;

                for (int i = 0; i < Inven_ItemID.Length; i++)
                {
                    if (Inven_ItemID[i] == int.MaxValue ||
                        Inven_ItemID[i] == int.MinValue)
                    {
                        IsEmptySlot = true;
                        break;
                    }
                }

                if (IsEmptySlot && requireGold < Gold)
                {
                    Inventory.Equipitem(ItemList[SelectItem], requireGold);
                }
                else
                {
                    //error
                }
            }
        }
        else //
        {
            if (requireGold > Gold)
            {
                //error
                Debug.Log("RequireGold");
                return;
            }

            int ItemSlotNum = int.MaxValue;
            for (int i = 0; i < Inven_ItemID.Length; i++)
            {
                if (ItemList[SelectItem].Id == Inven_ItemID[i])
                {
                    ItemSlotNum = i;
                    break;
                }
            }

            if (ItemSlotNum != int.MaxValue &&
                Inventory.ExpendableItemCount(ItemSlotNum) < ItemList[SelectItem].Overlap)
            {
                Inventory.Expendableitem(ItemSlotNum, requireGold);
            }
            else if (ItemSlotNum == int.MaxValue && IsEmptySlot)
            {
                Inventory.Equipitem(ItemList[SelectItem], requireGold);
            }
            else
            {
                //error max
                Debug.Log("Error");
            }
        }
    }
コード例 #25
0
 void Start()
 {
     BrewingTime = GameObject.Find("Inventory_System").GetComponent <InventorySystem> ();
     //CheckPotion = GameObject.Find ("CheckPotion");
     //CheckPotion.gameObject.SetActive (false);
 }
コード例 #26
0
 // Use this for initialization
 void Start()
 {
     _inventory = GameObject.Find("InventoryManager").GetComponent <InventorySystem> ();
 }
コード例 #27
0
ファイル: ArmsScript.cs プロジェクト: theiis/PGP2
 void Start()
 {
     handSpeed = 1.2f;
     inventory = GameObject.FindGameObjectWithTag("Bagpack").GetComponent<InventorySystem>();
     bagSlots = GameObject.FindGameObjectsWithTag("BagSlot");
     playerObject = GameObject.FindGameObjectWithTag("MainCamera");
     retreiveSound = GameObject.Find ("BackpackRetreiveItemSound");
 }
コード例 #28
0
 void Start()
 {
     ItemMan = FindObjectOfType <InventorySystem>();
     Player  = FindObjectOfType <PlayerController>();
 }
コード例 #29
0
 void Awake()
 {
     _slot      = 0;
     _inventory = GetComponent <InventorySystem>();
     PM         = GameObject.Find("PlayersManager").GetComponent <PlayersManager>();
 }
コード例 #30
0
 protected override void Collect()
 {
     InventorySystem.GetInstance().ChangeWaterLevel(1);
     base.Collect();
 }
コード例 #31
0
 /// Called whenever the inventory is updated to refresh the UI
 ///
 public void OnInventoryUpdated()
 {
     m_coinText.text = string.Format("Coins: {0}", InventorySystem.Get().GetAmount(InventorySystem.k_coinsId));
     m_gemText.text  = string.Format("Gems: {0}", InventorySystem.Get().GetAmount(InventorySystem.k_gemsId));
 }
コード例 #32
0
 public static string ViewInventory()
 {
     return(InventorySystem.ViewStock());
 }
コード例 #33
0
        public IState UpdateState(ref GameSettings gameSettings, GameTime gameTime, Camera camera, KeyboardState currentKey, KeyboardState prevKey, MouseState currentMouse, MouseState prevMouse)
        {
            Guid playerId = this._components.Entities.Where(c => c.HasComponents(ComponentFlags.IS_PLAYER)).FirstOrDefault().Id;

            // Level input
            if (currentKey.IsKeyDown(Keys.Escape) && prevKey.IsKeyUp(Keys.Escape))
            {
                return(new PauseState(this._content, this));
            }
            if (currentKey.IsKeyDown(Keys.Q) && prevKey.IsKeyUp(Keys.Q))
            {
                return(new TestLevel(this._content, camera));
            }

            if (currentKey.IsKeyDown(Keys.F) && prevKey.IsKeyUp(Keys.F))
            {
                this._components.DelayedActions.Add(new Action(() =>
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Guid testId = ArkCreation.SpawnEntityWithOverrides(Constants.Ark.Monsters.TestNpc, ref this._components, new BaseEntity(ComponentFlags.POSITION)
                        {
                            Position = new Position()
                            {
                                OriginPosition = new Vector2(Constants.Random.Next(20, this._gridCols * 48), Constants.Random.Next(0, this._gridRows * 48))
                            }
                        });
                        InventorySystem.GenerateRandomInventoryItemsForEntity(this._components, testId);
                    }
                }));
            }
            if (currentKey.IsKeyDown(Keys.E) && prevKey.IsKeyUp(Keys.E))
            {
                this._components.DelayedActions.Add(new Action(() =>
                {
                    Guid testId = ArkCreation.SpawnEntityWithOverrides(Constants.Ark.Monsters.TestNpc, ref this._components, new BaseEntity(ComponentFlags.POSITION)
                    {
                        Position = new Position()
                        {
                            OriginPosition = this._components.Positions[playerId].OriginPosition
                        }
                    });
                    InventorySystem.GenerateRandomInventoryItemsForEntity(this._components, testId);
                }));
            }
            if (currentKey.IsKeyDown(Keys.R) && prevKey.IsKeyUp(Keys.R))
            {
                this._components.DelayedActions.Add(new Action(() =>
                {
                    Guid id = this._components.Entities.Where(x => x.HasDrawableSprite() && !x.HasComponents(ComponentFlags.IS_PLAYER) && x.HasComponents(ComponentFlags.INVENTORY)).First().Id;
                    InventorySystem.DropEntityInventory(this._components, id);
                    this._components.DestroyEntity(id);
                }));
            }

            // Camera Updates
            CameraSystem.ControlCamera(currentKey, prevKey, camera, gameTime);
            CameraSystem.PanCamera(camera, gameTime);

            // Entity Movement Updates
            this._components.Entities.ForEach(c =>
            {
                if (c.IsMovable())
                {
                    switch (this._components.Movements[c.Id].MovementType)
                    {
                    case MovementType.AI:
                        //AI Movement System Call
                        break;

                    case MovementType.INPUT:
                        MovementSystem.InputMovement(currentKey, prevKey, gameTime, this._components.Positions[c.Id], this._components.Movements[c.Id]);
                        break;

                    case MovementType.DIRECTED:
                        MovementSystem.UpdateMovingEntities(this._components.Movements[c.Id], this._components.Positions[c.Id], gameTime, this._components, c);
                        break;
                    }
                }
            });

            // Entity Information Updates
            // Collision
            CollisionSystem.CheckForCollisions(this._components, this._collisionPartition);
            CollisionSystem.HandleCollisions(this._components);

            // Set up for next frame
            CameraSystem.UpdateCameraTarget(this._components, camera);
            CollisionSystem.ResetCollisions(ref this._components);
            this._components.InvokeDelayedActions();

            return(this);
        }
コード例 #34
0
 void Start()
 {
     textObject.SetActive(false);
     invSys = GameObject.FindGameObjectWithTag("Player").GetComponent <InventorySystem>();
 }
コード例 #35
0
ファイル: PlayerControl.cs プロジェクト: chryses46/RPG-Game
 void Start()
 {
     inventory = FindObjectOfType <InventorySystem>();
 }