예제 #1
0
    public override void SwipeUp()
    {
        base.SwipeUp();

        // Open Inventory if in Main
        if (currentScreen == GameStates.gameScreens.mainGame)
        {
            currentScreen = GameStates.gameScreens.inventory;
            MM.OpenInventory();
        }
    }
예제 #2
0
    public void SetScreen(GameStates.gameScreens screen) // Called when click on Interactive
    {
        currentScreen = screen;

        switch (currentScreen)
        {
        case GameStates.gameScreens.laptop:
            MM.OpenLaptop();
            break;
        }

        return;
    }
예제 #3
0
    void MoveWorldItemToInventory()
    {
        Debug.Log("World Item To Inventory = " + heldObject.name);
        if (heldObject.GetComponent <WorldItem>().myGameItem.itemProperties.itemType != ItemProperties.itemTypes.potWithPlant)
        {
            MM.OpenInventory();
            currentScreen        = GameStates.gameScreens.inventory;
            holdingInventoryItem = true;
            Inventory inv = GetComponent <Inventory>();


            // Create new Inventory UI object
            GameItem   gi         = heldObject.GetComponent <WorldItem>().myGameItem;
            GameObject newInvItem = Instantiate(inv.inventoryItemPrefab);
            newInvItem.GetComponent <InventoryItem>().myGameItem = gi;
            Debug.Log("World Item to Inv, new Inv Item Created");

            // Open correct Inventory tab and child new Inventory item
            switch (gi.itemProperties.itemType)
            {
            case ItemProperties.itemTypes.plant:
                if (gi.itemProperties.currentStage == ItemProperties.itemStage.seed)     // Can't put a full plant into inventory! Seeds only
                {
                    InvUI.GoToScreen(0);
                    newInvItem.transform.SetParent(inv.panelSeeds);
                }
                break;

            case ItemProperties.itemTypes.pot:
                InvUI.GoToScreen(1);
                newInvItem.transform.SetParent(inv.panelPots);
                break;

            case ItemProperties.itemTypes.potion:
                InvUI.GoToScreen(1);
                newInvItem.transform.SetParent(inv.panelPots);
                break;

            case ItemProperties.itemTypes.decor:
                InvUI.GoToScreen(2);
                newInvItem.transform.SetParent(inv.panelDecor);
                break;
            }

            // Set held object to Inv Item UI, destroy old world object
            GameObject temp = heldObject.gameObject;
            heldObject = newInvItem.transform;
            Destroy(temp);
            Debug.Log("Old World Item destroyed");
        }
    }
예제 #4
0
    private void Start()
    {
        MM            = GetComponent <MenuManager>();
        InvUI         = InventoryUI.FindObjectOfType(typeof(InventoryUI)) as InventoryUI;
        currentScreen = GameStates.gameScreens.mainGame;
        mainCam       = Camera.main.transform;

        // Update Sprite Dictionary before loading the player data
        foreach (Item itemPot in allPotTypes)
        {
            spriteDictionary.Add(itemPot.itemProperties.itemID, itemPot.itemSprites);
        }

        foreach (Item itemPlant in allPlantTypes)
        {
            spriteDictionary.Add(itemPlant.itemProperties.itemID, itemPlant.itemSprites);
        }

        //Start Loading Player Data. Includes Updating GameDateTime
        GetComponent <XMLSaveLoad>().LoadGame();
        Debug.Log("Loading going to the next stage...");

        // If New Game, Do stuff...
        if (playerData.newGame)
        {
            NewGame();
        }

        // Update Currencies
        Currencies.OverrideFlorets(playerData.playerFlorets);
        Currencies.OverrideCrystals(playerData.playerCrystals);

        // Update WorldItems
        foreach (WorldItem wi in allWorldItemsInScene)
        {
            wi.UpdateWorldItemStats();
        }

        // Turn off PlacePoint Icons
        placePoints.AddRange(GameObject.FindObjectsOfType <PlacePoint>());
        foreach (PlacePoint p in placePoints)
        {
            p.HidePointer();
        }


        // TESTING DateTime stuff
        GameDateTime.LogCurrentDateTime();
        Debug.Log("Finished Updating DateTime");
    }
예제 #5
0
    public override void SwipeDown()
    {
        base.SwipeDown();

        // Close Inventory if in Inventory
        if (currentScreen == GameStates.gameScreens.inventory)
        {
            currentScreen = GameStates.gameScreens.mainGame;
            MM.CloseInventory();
        }

        // Exit Sell Mode if in Sell Mode
        if (currentScreen == GameStates.gameScreens.selling)
        {
            FindObjectOfType <Shop>().ExitSellMode();
        }
    }
예제 #6
0
    void PlaceInventoryItemInWorld()
    {
        if (heldObject == null)
        {
            return;
        }

        // Get Holding Position
        Transform selectedObject = GetSelectedObject();

        Debug.Log("Trying to place inv item to... " + selectedObject.name);
        // Splits two ways: Either placing a Pot or Decor item to a Position Point
        // OR placing a Seed into an empty Pot

        GameItem itemBeingPlaced = heldObject.GetComponent <InventoryItem>().myGameItem;

        // ----- PLACING POT OR DECOR ITEM INTO WORLD --------
        if (itemBeingPlaced.itemProperties.itemType == ItemProperties.itemTypes.pot ||
            itemBeingPlaced.itemProperties.itemType == ItemProperties.itemTypes.decor)
        {
            // Check if being placed correctly
            if (selectedObject != null && selectedObject.CompareTag("placePoint"))
            {
                if (selectedObject.GetComponent <PlacePoint>().empty)
                {
                    GameItem currentHeldGameItem = heldObject.GetComponent <InventoryItem>().myGameItem;

                    currentHeldGameItem.placedPointName = selectedObject.name;
                    Vector3 placePointPos = selectedObject.position;
                    currentHeldGameItem.placedPointX = placePointPos.x;
                    currentHeldGameItem.placedPointY = placePointPos.y;
                    currentHeldGameItem.placedPointZ = placePointPos.z;

                    LoadItemToWorld(currentHeldGameItem);


                    //heldObject.gameObject.SetActive(false);

                    // Remove the item from Inventory Item lists, as it is now in the World
                    GetComponent <Inventory>().RemoveItemFromInventory(currentHeldGameItem);

                    // Delete the bit of UI floating around
                    Destroy(heldObject.gameObject);

                    ClearHeldObject();
                    HidePlacePointMarkers();

                    Debug.Log("Inv Item Dropped In World");
                }
            }
            // Else send it back to inventory slot
            else
            {
                PlaceInventoryObjectInSlot(InvUI.lastUsedSlot);
                currentScreen = GameStates.gameScreens.inventory;
                MM.OpenInventory();
            }
        }

        // --------- PLACING SEED INTO POT -----------
        //
        if (itemBeingPlaced.itemProperties.itemType == ItemProperties.itemTypes.plant)
        {
            WorldItem targetPot;

            if (selectedObject.GetComponent <WorldItem>())
            {
                targetPot = selectedObject.GetComponent <WorldItem>();
            }
            else
            {
                targetPot = null;
            }

            if (targetPot != null)
            {
                if (targetPot.myGameItem.itemProperties.itemType == ItemProperties.itemTypes.pot)
                {
                    PlaceSeedInPot(itemBeingPlaced, targetPot);
                }

                Debug.Log("Inv Seed Dropped In World Pot");
            }

            else
            {
                PlaceInventoryObjectInSlot(InvUI.lastUsedSlot);
                currentScreen = GameStates.gameScreens.inventory;
                MM.OpenInventory();
            }
        }
    }
예제 #7
0
    public override void HoldDown()
    {
        if (currentScreen == GameStates.gameScreens.mainGame && cameraEngaged == false)
        {
            if (heldObject == null)
            {
                Transform heldItem = GetSelectedObject();

                //FOR DEBUG ONLY
                if (heldItem != null)
                {
                    debugText.text = "Held item: " + heldItem.name;
                }

                if (heldItem != null && heldItem.CompareTag("moveable") && !holdingMoveable)
                {
                    PickUpObject(heldItem);
                }
            }

            // If held in lower third of screen, move world item to inventory
            if (holdingMoveable && screenTouchPos.y < Screen.height / 3)
            {
                MoveWorldItemToInventory();
            }
            // If player takes inv item out of inv but wants to return it without placing in world...
            else if (holdingInventoryItem && screenTouchPos.y < Screen.height / 3)
            {
                MM.OpenInventory();
                currentScreen = GameStates.gameScreens.inventory;
            }

            else if (holdingMoveable || holdingInventoryItem)
            {
                // if item held on side of screen, move
                //if (!cameraMoving && screenTouchPos.x < 20)
                //{
                //    SwipeLeft();
                //}
                //if (!cameraMoving && screenTouchPos.x > (Screen.width -20))
                //{
                //    SwipeRight();
                //}
            }
        }

        else if (currentScreen == GameStates.gameScreens.inventory)
        {
            if (heldObject == null && GetSelectedGUIObject() != null)
            {
                if (GetSelectedGUIObject().GetComponent <InventoryUISlot>())
                {
                    InventoryUISlot targetUISlot = GetSelectedGUIObject().GetComponent <InventoryUISlot>();
                    InvUI.lastUsedSlot = targetUISlot; // To record where to send the item if dropped somewhere invalid

                    heldObject           = targetUISlot.TakeItemFromSlot();
                    holdingInventoryItem = true;
                }
            }

            // For taking Inv Item into the world
            if (holdingInventoryItem && screenTouchPos.y > Screen.height / 2)
            {
                MM.CloseInventory();
                currentScreen = GameStates.gameScreens.mainGame;

                ShowPlacePointMarkers();
            }
        }
    }