Пример #1
0
        /// <summary>Assigns all controls to something usable in code.</summary>
        private void AssignControls()
        {
            HeroInventory = (GridInventory)GetNode("HeroInventory");
            HeroEquipment = (GridEquipment)GetNode("HeroEquipment");

            LblName       = (Label)GetNode("Info/LblName");
            LblLevel      = (Label)GetNode("Info/LblLevel");
            LblExperience = (Label)GetNode("Info/LblExperience");
            LblHardcore   = (Label)GetNode("Info/LblHardcore");

            BtnStrengthMinus  = (Button)GetNode("Info/Vitals/Attributes/MinusButtons/BtnStrengthMinus");
            BtnVitalityMinus  = (Button)GetNode("Info/Vitals/Attributes/MinusButtons/BtnVitalityMinus");
            BtnDexterityMinus = (Button)GetNode("Info/Vitals/Attributes/MinusButtons/BtnDexterityMinus");
            BtnWisdomMinus    = (Button)GetNode("Info/Vitals/Attributes/MinusButtons/BtnWisdomMinus");

            LblStrength  = (Label)GetNode("Info/Vitals/Attributes/AttributeValues/LblStrength");
            LblVitality  = (Label)GetNode("Info/Vitals/Attributes/AttributeValues/LblVitality");
            LblDexterity = (Label)GetNode("Info/Vitals/Attributes/AttributeValues/LblDexterity");
            LblWisdom    = (Label)GetNode("Info/Vitals/Attributes/AttributeValues/LblWisdom");

            BtnStrengthPlus  = (Button)GetNode("Info/Vitals/Attributes/PlusButtons/BtnStrengthPlus");
            BtnVitalityPlus  = (Button)GetNode("Info/Vitals/Attributes/PlusButtons/BtnVitalityPlus");
            BtnDexterityPlus = (Button)GetNode("Info/Vitals/Attributes/PlusButtons/BtnDexterityPlus");
            BtnWisdomPlus    = (Button)GetNode("Info/Vitals/Attributes/PlusButtons/BtnWisdomPlus");

            LblSkillPoints = (Label)GetNode("Info/Vitals/Statistics/TextLabels/LblSkillPoints");
            LblHealth      = (Label)GetNode("Info/Vitals/Statistics/TextLabels/LblHealth");
            LblMagic       = (Label)GetNode("Info/Vitals/Statistics/TextLabels/LblMagic");

            LblGold   = (Label)GetNode("Info/LblGold");
            LblWeight = (Label)GetNode("LblWeight");
        }
Пример #2
0
        /// <summary>Sets the current inventory for a given <see cref="GridInventory"/>.</summary>
        /// <param name="inventory"><see cref="GridInventory"/> to set the inventory</param>
        /// <param name="hero">Is this being set for the <see cref="Hero"/>?</param>
        internal static void SetInventoryFromGrid(GridInventory inventory, bool hero = true)
        {
            Godot.Collections.Array allSlots = inventory.GetChild(0).GetChildren();
            List <Item>             allItems = new List <Item>();

            foreach (ItemSlot slot in allSlots)
            {
                if (slot?.Item?.Item != new Item() && slot.Item.Item.Name != "Fists")
                {
                    allItems.Add(slot?.Item?.Item);
                }
                else if (slot?.Item?.Item?.Name == "Fists")
                {
                    slot.RemoveChild(slot.GetChild(1));
                    slot.Item = new InventoryItem();
                }
            }
            if (hero)
            {
                CurrentHero.Inventory = allItems;
            }
            else
            {
                CurrentEnemy.Inventory = allItems;
            }
        }
Пример #3
0
 /// <summary>Assigns all controls.</summary>
 private void AssignControls()
 {
     HeroInventory  = (GridInventory)GetNode("HeroInventory");
     EnemyInventory = (GridInventory)GetNode("EnemyInventory");
     HeroEquipment  = (GridEquipment)GetNode("HeroEquipment");
     EnemyEquipment = (GridEquipment)GetNode("EnemyEquipment");
     BtnLootGold    = (Button)FindNode("BtnLootGold");
     LblGold        = (Label)FindNode("LblGold");
 }
Пример #4
0
 /// <summary>Assigns all controls to something usable in code.</summary>
 private void AssignControls()
 {
     HeroInventory     = (GridInventory)GetNode("HeroInventory");
     MerchantInventory = (MerchantInventory)GetNode("MerchantInventory");
     HeroEquipment     = (GridEquipment)GetNode("HeroEquipment");
     HeroInventory.SetUpInventory(GameState.CurrentHero.Inventory);
     HeroEquipment.SetUpEquipment(GameState.CurrentHero.Equipment, GameState.CurrentHero.Level, GameState.CurrentHero.Class);
     MerchantInventory.SetUpInventory(GameState.MerchantInventory.Where(itm => itm.IsSold).ToList());
 }
Пример #5
0
    public bool RegisterDragged(GridObject gridObj, GridInventory grid)
    {
        if (_currentDragged != null)
        {
            return(false);
        }


        _currentDragged = gridObj;
        return(true);
    }
Пример #6
0
    public void GenerateObject(GridSystem gSystem, Vector2Int pos, GridObjectData data, bool ignoreCollide = false, bool shouldBeOnCooldown = false)
    {
        GridInventory inventory = gSystem.Inventory;
        Quaternion    sampleOverrideRotation = Quaternion.identity;
        Vector3       worldPos = gSystem.GridToWorld(pos);
        GameObject    obj      = Instantiate(data.Prefab, worldPos, sampleOverrideRotation);

        GridObject gObj = obj.GetComponent <GridObject>();

        gObj.InitializeFromDataFile(data, shouldBeOnCooldown);

        inventory.AddObject(obj.GetComponent <GridObject>(), pos, ignoreCollide);
    }
Пример #7
0
        /// <summary>Assigns all controls to something usable in code.</summary>
        private void AssignControls()
        {
            BtnRepair     = (Button)GetNode("BtnRepair");
            BtnRepairAll  = (Button)GetNode("BtnRepairAll");
            HeroInventory = (GridInventory)GetNode("HeroInventory");
            HeroEquipment = (GridEquipment)GetNode("HeroEquipment");
            LblRepair     = (Label)GetNode("LblRepair");
            LblRepairAll  = (Label)GetNode("LblRepairAll");
            orphanage     = (Orphanage)GetNode("Orphanage");
            RepairSlot    = (ItemSlot)GetNode("RepairSlot");

            HeroInventory.SetUpInventory(GameState.CurrentHero.Inventory);
            HeroEquipment.SetUpEquipment(GameState.CurrentHero.Equipment, GameState.CurrentHero.Level, GameState.CurrentHero.Class);
        }
Пример #8
0
    public int ValidateObjectives(GridInventory outputInventory)
    {
        int points = 0;
        int objectivesCompleted = 0;

        foreach (ObjectiveSlot slot in ObjectivesSlots)
        {
            if (!slot.Occupied)
            {
                continue;
            }

            GridObject gObj = outputInventory.GetObjectWithData(slot.Configuration.Object);
            if (gObj != null)
            {
                Debug.Log("Completed objective for item " + gObj.name);
                outputInventory.RemoveObject(gObj, true);

                points += slot.Configuration.Points;
                ++objectivesCompleted;

                slot.Feedback.Complete();
                slot.Occupied      = false;
                slot.Configuration = null;
                slot.Feedback      = null;

                --ActiveObjectives;
            }
        }

        switch (objectivesCompleted)
        {
        case 2:
            points = (int)((float)points * 1.15f);
            break;

        case 3:
            points = (int)((float)points * 1.5f);
            break;

        case 4:
            points = (int)((float)points * 2f);
            break;
        }

        points -= outputInventory.FlushItems() * 10;
        return(points);
    }
Пример #9
0
        /// <summary>Assigns all controls to something usable in code.</summary>
        private void AssignControls()
        {
            EnemyInventory = (GridInventory)GetNode("EnemyInventory");
            EnemyEquipment = (GridEquipment)GetNode("EnemyEquipment");

            LblName       = (Label)GetNode("Info/LblName");
            LblLevel      = (Label)GetNode("Info/LblLevel");
            LblExperience = (Label)GetNode("Info/LblExperience");

            LblStrength  = (Label)GetNode("Info/LblStrength");
            LblVitality  = (Label)GetNode("Info/LblVitality");
            LblDexterity = (Label)GetNode("Info/LblDexterity");
            LblWisdom    = (Label)GetNode("Info/LblWisdom");

            LblHealth = (Label)GetNode("Info/LblHealth");
            LblMagic  = (Label)GetNode("Info/LblMagic");

            LblGold = (Label)GetNode("Info/LblGold");
            EnemyInventory.SetUpInventory(GameState.CurrentEnemy.Inventory, true);
            EnemyEquipment.SetUpEquipment(GameState.CurrentEnemy.Equipment, 0, null, true);
        }
Пример #10
0
 // Start is called before the first frame update
 void Awake()
 {
     Inventory = GetComponent <GridInventory>();
 }
Пример #11
0
    public bool EndMove(Vector2Int coords)
    {
        GridObject gObj = GridManager.Instance.UnregisterDragged();

        if (gObj == null)
        {
            Debug.LogWarning("Tried to end a move while no object was dragged", gameObject);
            return(false);
        }

        GridSystem startGrid;
        GridSystem destinationGrid;

        GridManager.Instance.GetGridCoords(gObj.initialDragPosition, out startGrid, out _);
        GridManager.Instance.GetGridCoords(gObj.transform.position, out destinationGrid, out _);
        if (destinationGrid == null || destinationGrid.Inventory.Type == GridType.Input)
        {
            return(false);
        }

        if (!ObjectPositionValid(gObj, coords))
        {
            // TODO feedback not in grid
            return(false);
        }

        GridObject collided = Collide(gObj, coords);

        if (collided != null)
        {
            if (startGrid.Inventory.Type == GridType.Input)
            {
                return(false);
            }

            if (InMenu)
            {
                MenuManager.Instance.Selected(collided);
                return(false);
            }
            return(RecipeManager.Instance.ApplyRecipe(gObj, collided));
            // TODO feedback collide, and eventual interaction
        }

        // If dragged object was not in the same grid
        if (!_objects.Contains(gObj))
        {
            GridInventory inventory = GridManager.Instance.FindGridWithObject(gObj);
            if (inventory == null)
            {
                Debug.LogError("Trying to move an object from an undefined grid");
                return(false);
            }

            Vector2Int oldPosition = gObj.Position;

            inventory.RemoveObject(gObj, false);
            AddObject(gObj, coords);

            if (inventory.Type == GridType.Input)
            {
                ObjectFactory.Instance.GenerateObject(GridManager.Instance.GetInputGridSystem(), oldPosition, gObj.Data, true, true);
            }
        }

        gObj.Position = coords;
        return(true);
    }