コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        Assert.IsNotNull(PanelMelee, "The Melee Panel has not been added to the Weapon UI.");
        Assert.IsNotNull(PanelRange, "The Range Panel has not been added to the Weapon UI.");
        Assert.IsNotNull(InputStrength, "The Strength Input has not been added to the Weapon UI.");
        Assert.IsNotNull(DropdownStrength, "The Strength Dropdown has not been added to the Weapon UI.");
        Assert.IsNotNull(InputAP, "The AP Input has not been added to the Weapon UI.");
        Assert.IsNotNull(DropdownAP, "The AP Dropdown has not been added to the Weapon UI.");
        Assert.IsNotNull(InputDamage, "The Damage Input has not been added to the Weapon UI.");
        Assert.IsNotNull(DropdownDamage, "The Damage Dropdown has not been added to the Weapon UI.");
        Assert.IsNotNull(InputRange, "The Range Input has not been added to the Weapon UI.");
        Assert.IsNotNull(DropdownRange, "The Range Dropdown has not been added to the Weapon UI.");
        Assert.IsNotNull(InputShots, "The Shots Input has not been added to the Weapon UI.");
        Assert.IsNotNull(DropdownShots, "The Shots Dropdown has not been added to the Weapon UI.");
        Assert.IsNotNull(panelAddRules, "The Rules Panel has not been added to the Weapon UI.");
        Assert.IsNotNull(contentRules, "The Rules Content ui object has not been added to the Weapon UI.");
        Assert.IsNotNull(buttonWeaponRule, "The Rule Button has not been added to the Weapon UI.");
        Assert.IsNotNull(panelRulesAdded, "The Rules Added panel has not been added to the Weapon UI.");
        Assert.IsNotNull(panelRemoveRule, "The Remove Rule panel has not been added to the Weapon UI.");
        Assert.IsNotNull(buttonSave, "The Save Button has not been added to the Weapon UI.");
        Assert.IsNotNull(panelNameCheck, "The Name Check Panel has not been added to the Weapon UI.");
        Assert.IsNotNull(buttonLoad, "The Load Button has not been added to the Weapon UI.");
        Assert.IsNotNull(panelLoad, "The Load Panel has not been added to the Weapon UI.");
        Assert.IsNotNull(contentLoad, "The Load Content ui object has not been added to the Weapon UI.");

        instance = GameManager.instance;
        Assert.IsNotNull(instance, "The Weapon UI could not find the Game Manager.");
        loader = gameObject.GetComponent <WeaponLoader>();
        Assert.IsNotNull(loader, "The Weapon UI could not find the Weapon Loader.");
        manager = gameObject.GetComponent <WeaponRuleManager>();
        Assert.IsNotNull(manager, "The Weapon UI could not find the Weapon Rule Manager.");
        messenger = FindObjectOfType <WeaponMessenger>();
        Assert.IsNotNull(messenger, "The Weapon UI could not find the Weapon Messenger.");
        setter = gameObject.GetComponent <WeaponSetter>();
        Assert.IsNotNull(setter, "The Weapon UI could not find the Weapon Setter.");
        defaultColor = InputRange.GetComponentInChildren <Text>().color;

        if (instance.Weapons.Count > 0)
        {
            buttonLoad.interactable = true;
        }

        StartCoroutine(messenger.DisplayMessage("Fill in the weapon's profile."));
    }
コード例 #2
0
    public void ResetLoad(int weaponToLoad)
    {
        Weapon weapon = instance.Weapons[weaponToLoad];

        setter.Name       = weapon.Name;
        ui.InputName.text = setter.Name;
        Debug.Log("Weapon name is " + setter.Name);

        setter.Type = (int)weapon.WeaponType;

        ui.DropdownType.value = setter.Type;

        setter.StrengthIsVar = weapon.StrengthIsVar;
        if (setter.StrengthIsVar)
        {
            setter.VarStrength = (int)weapon.VarStrength;
        }
        else
        {
            setter.Strength = weapon.Strength;
        }

        setter.APIsVar = weapon.APIsVar;
        if (setter.APIsVar)
        {
            setter.VarAP = (int)weapon.VarAP;
        }
        else
        {
            setter.AP = weapon.AP;
        }

        setter.DamageIsVar = weapon.DamageIsVar;
        if (setter.DamageIsVar)
        {
            setter.VarDamage = (int)weapon.VarDamage;
        }
        else
        {
            setter.Damage = weapon.Damage;
        }

        if (setter.Type >= 2)
        {
            setter.RangeIsVar = weapon.RangeIsVar;
            if (setter.RangeIsVar)
            {
                setter.VarRange = (int)weapon.VarRange;
            }
            else
            {
                setter.Range = weapon.Range;
            }

            setter.ShotsAreVar = weapon.ShotsAreVar;
            if (setter.ShotsAreVar)
            {
                setter.VarShots = (int)weapon.VarShots;
            }
            else
            {
                setter.Shots = weapon.Shots;
            }
        }

        ui.ClearRulePanel();
        ui.LoadRulesIntoRulePanel(weapon);

        ui.UpdateUI();
        ui.ManageRulePanel();
        messenger.DisplayMessage("Weapon loaded.");
    }
コード例 #3
0
    bool DataCheck()
    {
        if (setter.Name.Length == 0)
        {
            StartCoroutine(messenger.DisplayMessage("You must enter a Name for the weapon.", WeaponMessenger.MessageType.error));
            return(false);
        }

        if (setter.Type == 0)
        {
            StartCoroutine(messenger.DisplayMessage("You must select the weapon's type.", WeaponMessenger.MessageType.error));
            return(false);
        }

        if (!setter.StrengthIsVar)
        {
            if (setter.Strength <= 0)
            {
                StartCoroutine(messenger.DisplayMessage("Strength must be a positive number.", WeaponMessenger.MessageType.error));
                return(false);
            }
        }

        if (!setter.APIsVar)
        {
            if (setter.AP > 0)
            {
                StartCoroutine(messenger.DisplayMessage("AP cannot be a positive number.", WeaponMessenger.MessageType.error));
                return(false);
            }
        }

        if (setter.DamageIsVar)
        {
            if (setter.VarDamage == 0)
            {
                StartCoroutine(messenger.DisplayMessage("You must select the weapon's Damage.", WeaponMessenger.MessageType.error));
                return(false);
            }
        }
        else
        {
            if (setter.Damage <= 0)
            {
                StartCoroutine(messenger.DisplayMessage("Damage must be a positive number.", WeaponMessenger.MessageType.error));
                return(false);
            }
        }

        if (setter.Type >= 2)
        {
            if (setter.RangeIsVar)
            {
                if (setter.VarRange == 0)
                {
                    StartCoroutine(messenger.DisplayMessage("You must select the weapon's Range.", WeaponMessenger.MessageType.error));
                    return(false);
                }
            }
            else
            {
                if (setter.Range <= 0)
                {
                    StartCoroutine(messenger.DisplayMessage("Range must be a positive number.", WeaponMessenger.MessageType.error));
                    return(false);
                }
            }

            if (!setter.ShotsAreVar)
            {
                if (setter.Shots <= 0)
                {
                    StartCoroutine(messenger.DisplayMessage("Shots must be a positive number.", WeaponMessenger.MessageType.error));
                    return(false);
                }
            }
        }

        return(true);
    }