Beispiel #1
0
    public void InitCharGunObject(string gunId)
    {
        if (charaData.IsDead || string.IsNullOrEmpty(gunId))
        {
            return;
        }

        GunData gunData = GunDataTableObject.Instance.GetParams(gunId);

        _gunObject       = ((GameObject)Instantiate((GameObject)Resources.Load("Prefabs/Items/Guns/" + gunData.GunPrefab))).GetComponent <GunObject>();
        _gunObject.Owner = gameObject;
        //ソードを持ってる手のgameObjectを取得
        if (weaponPosObj == null)
        {
            weaponPosObj = Utils.getChildGameObject(gameObject, "weapon");
        }
        _gunObject.transform.SetParent(weaponPosObj.transform);
        _gunObject.transform.localPosition = Vector3.zero;

        //ポジションとレンダーオーダーを整える。
        _gunObject.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 90.0f));
        _gunObject.GetComponent <SpriteRenderer> ().sortingLayerName = GetSortingLayerName();
        _gunObject.GetComponent <SpriteRenderer> ().sortingOrder     = 59;

        _gunObject.CopyParamsFrom(gunId);

        //gunをdisable
        _gunObject.DisplaySprite(false);
    }
Beispiel #2
0
 public void Attack()
 {
     //Swordオブジェクトはキャラに既に付いているのでNullチェックだけでは装備してるかわからない。
     //Owner、SwingEffectをチェック
     if (this.SwordObject != null && SwordObject.SwingEffectPrefab != null && this.SwordObject.CanReachEnemy())
     {
         SwordObject.DisplaySprite(true);
         if (GunObject != null)
         {
             GunObject.DisplaySprite(false);
         }
         SwordObject.Slash();
     }
     else if (this.GunObject != null)
     {
         if (SwordObject != null)
         {
             SwordObject.DisplaySprite(false);
         }
         GunObject.DisplaySprite(true);
         GunObject.Fire();
     }
 }