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


C# Weapon.GetWeaponSprite方法代码示例

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


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

示例1: SwapWeapon

    public void SwapWeapon()
    {
        if(Time.time - lastWeaponSwapTime > weaponSwapDelay) {
            // swap the currentyl equiped (null or not) with the backup
            Weapon currentMain = mechComponent.leftWeapon;
            if(currentMain != null) {
                currentMain.EndFire();
                currentMain.GetRenderer().enabled = false;
            }

            if(backupWeapon != null) {
                backupWeapon.GetRenderer().enabled = true;
            }

            if(laserSightRenderer != null) {
                laserSightRenderer.enabled = false;
            }

            mechComponent.leftWeapon = backupWeapon;
            backupWeapon = currentMain;

            // set backup image
            if(backupWeapon != null && playerHUD != null) {
                playerHUD.secondarydWeaponElement.enabled = true;
                playerHUD.secondarydWeaponElement.sprite = backupWeapon.GetWeaponSprite();
            }
            else if(playerHUD != null) {
                playerHUD.secondarydWeaponElement.enabled = false;
            }

            // set laser sight and main image
            if(mechComponent.leftWeapon != null) {
                NewWeaponAttached(mechComponent.leftWeapon);
            }
            else {
                playerHUD.equippedWeaponElement.enabled = false;
            }

            WorldManager.instance.PlayGlobalSound(weaponSwapSound, 1.0f, 0.5f);

            lastWeaponSwapTime = Time.time;
            Debug.Log("Weapon swapped to " + (mechComponent.leftWeapon != null? mechComponent.leftWeapon.name : "null"));
        }
    }
开发者ID:tedmunds,项目名称:HavokGear,代码行数:44,代码来源:PlayerController.cs

示例2: NewWeaponAttached

    public override void NewWeaponAttached(Weapon attached)
    {
        base.NewWeaponAttached(attached);

        attached.ResetRefireDelay();

        // Cache ref to photon whip when it is attached (on spawn usually)
        if(attached != null && attached.GetType() == typeof(Whip_PhotonWhip)) {
            whipAttachment = (Whip_PhotonWhip)attached;
            Debug.Log("Player has photon whip attachment");
        }

        // check if the weapon wants a laser sight or not
        if(attached != null && attached.GetType() != typeof(Whip_PhotonWhip)) {
            if(attached.hasLaserSight && laserSightRenderer != null) {
                laserSightRenderer.enabled = true;
            }
            else if(laserSightRenderer != null) {
                laserSightRenderer.enabled = false;
            }
        }

        // update the hud images
        if(playerHUD != null && playerHUD.equippedWeaponElement != null) {
            Sprite weaponSprite = attached.GetWeaponSprite(); ;
            playerHUD.equippedWeaponElement.sprite = weaponSprite;
            playerHUD.equippedWeaponElement.enabled = weaponSprite != null? true : false;
        }
        if(playerHUD != null && playerHUD.damageTypeElement != null) {
            playerHUD.SetDamageTypeDisplay(attached.damageTypeList);
        }

        // if there was a detached eapon, to attach this one, then swap it into the seconrady slot if there is nothing there
        if(backupWeapon == null && detachedWeapon != null) {
            // need to bring the detatched weapon back fromn the dead
            detachedWeapon.transform.SetParent(mechComponent.leftAttachPoint);
            detachedWeapon.gameObject.SetActive(true);
            detachedWeapon.GetRenderer().enabled = false;

            // cahche the weapon
            backupWeapon = detachedWeapon;

            // and update hud
            playerHUD.secondarydWeaponElement.enabled = true;
            playerHUD.secondarydWeaponElement.sprite = backupWeapon.GetWeaponSprite();
        }

        // Send a message to the HUD to display on screen
        if(playerHUD != null) {
            playerHUD.DoOnScreenAnnouncement(attached.weaponName);
        }

        detachedWeapon = null;
    }
开发者ID:tedmunds,项目名称:HavokGear,代码行数:54,代码来源:PlayerController.cs


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