当前位置: 首页>>代码示例>>C#>>正文


C# Inventory.inventorySwitchWeapon方法代码示例

本文整理汇总了C#中Inventory.inventorySwitchWeapon方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.inventorySwitchWeapon方法的具体用法?C# Inventory.inventorySwitchWeapon怎么用?C# Inventory.inventorySwitchWeapon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory.inventorySwitchWeapon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    /// <summary>
    /// The initializer for this object.
    /// </summary>
    protected override void Start()
    {
        //Grab the weapon switcher
        wepSwitcher = gameObject.GetComponentInChildren<WeaponModelSwitcher>();

        //Grab an instance of the inventory
        inventory = Inventory.getInstance();

        //Add the default weapons
        ItemEquipment myFirstPickaxe = new ItemWeapon(1, 1.0f, 0, 0, 0.0f, "Rusty Pickaxe", ItemWeapon.tWeaponType.WeaponPickaxe, "A slightly worn, but reliable pickaxe.", ItemBase.tOreType.Copper);

        string bladeCode = ItemComponent.generateComponentCode(ItemComponent.tAttributeType.Normal, ItemBase.tOreType.Bone, ItemWeapon.tWeaponType.WeaponSword,
                                                               ItemComponent.tComponentPart.Blade);
        string handleCode = ItemComponent.generateComponentCode(ItemComponent.tAttributeType.Normal, ItemBase.tOreType.Bone, ItemWeapon.tWeaponType.WeaponSword,
                                                                ItemComponent.tComponentPart.Handle);
        ItemWeapon myFirstSword = ItemFactory.createWeapon(ItemFactory.createComponent(bladeCode), ItemFactory.createComponent(handleCode));

        inventory.inventoryAddItem(myFirstPickaxe);
        inventory.inventoryAddItem(myFirstSword);

        cheat(cheatAmount.a_little);//add all weapons
        //cheat(cheatAmount.a_lot);//add all weapons and make them top tier

        base.Start();

        inventory.initialize();//calling initialize here ensures inventory Character field is set before it is used
        inventory.inventorySwitchWeapon();

        //Create a new gameobejct with a GUITexture attached to it
        damageTexture = new GameObject();
        damageTexture.AddComponent("GUITexture");

        //Store away the color struct that gets returned and change it before saving it back again. Can't change color.a in one line
        Color damageTextureColor = damageTexture.guiTexture.color;
        damageTextureColor.a = 0;

        //Get the texture that should take up the whole screen
        Texture2D hurtScreen = (Texture2D)Resources.Load("HurtScreen");

        //Center the damageTexture
        Vector3 damagePos = damageTexture.transform.position;
        damagePos.x = 0.5f; //GUITexture corrdinates are a bit different than usual ones
        damagePos.y = 0.5f;
        damagePos.z = 0f;
        damageTexture.transform.position = damagePos;

        damageTexture.guiTexture.texture = hurtScreen;
        damageTexture.guiTexture.color = damageTextureColor;
    }
开发者ID:ZavaStudios,项目名称:SeniorCapstone,代码行数:52,代码来源:UnitPlayer.cs


注:本文中的Inventory.inventorySwitchWeapon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。