Example #1
0
    /// <summary>
    /// 伤害目标
    /// </summary>
    public virtual void DamageTarget(GameObject user, ItemsBean itemsData, Collider[] targetArray)
    {
        if (targetArray.IsNull())
        {
            return;
        }
        //获取武器伤害
        ItemsInfoBean itemsInfo = GetItemsInfo(itemsData.itemId);

        CreatureCptBase selfCreature = user.GetComponent <CreatureCptBase>();

        for (int i = 0; i < targetArray.Length; i++)
        {
            Collider itemCollider = targetArray[i];
            //获取目标生物
            CreatureCptBase creatureCpt = itemCollider.GetComponent <CreatureCptBase>();
            if (creatureCpt == null)
            {
                continue;
            }
            if (creatureCpt == selfCreature)
            {
                continue;
            }
            creatureCpt.creatureBattle.UnderAttack(user, itemsInfo.atk);
        }
    }
Example #2
0
    /// <summary>
    /// 播放使用动画
    /// </summary>
    public virtual void UseForAnim(GameObject user, ItemsBean itemsData)
    {
        //播放使用动画
        ItemsInfoBean   itemsInfo = GetItemsInfo(itemsData.itemId);
        CreatureCptBase creature  = user.GetComponentInChildren <CreatureCptBase>();

        if (itemsInfo.anim_use.IsNull())
        {
            //如果没有动画 则播放默认的使用动画
            creature.creatureAnim.PlayUse(true);
        }
        else
        {
            //如果可以转换成int 说明是use的另外一种类型
            if (int.TryParse(itemsInfo.anim_use, out int reslut))
            {
                creature.creatureAnim.PlayUse(true, reslut);
            }
            else
            {
                //如果该道具指定播放指定动画
                creature.creatureAnim.PlayAnim(itemsInfo.anim_use);
            }
        }
    }
Example #3
0
    /// <summary>
    /// 创建生物
    /// </summary>
    public void CreateCreature(long creatureId, Vector3 position)
    {
        CreatureInfoBean creatureInfo = manager.GetCreatureInfo(creatureId);

        if (creatureInfo == null)
        {
            return;
        }
        manager.GetCreatureModel(creatureInfo.model_name, (data) =>
        {
            //创建生物
            GameObject objCreature = Instantiate(gameObject, data);
            //设置生物位置
            objCreature.transform.position = position;
            //获取生物组件
            CreatureCptBase creatureCpt = objCreature.GetComponent <CreatureCptBase>();
            //设置生物信息
            creatureCpt.SetData(creatureInfo);
        });
    }
Example #4
0
 public CreatureBattle(CreatureCptBase creature, Rigidbody rbCreature) : base(creature)
 {
     this.rbCreature = rbCreature;
 }
 public CreatureCollisionAndTrigger(CreatureCptBase creature) : base(creature)
 {
 }
Example #6
0
 public CreatureAnim(CreatureCptBase creature, Animator animator) : base(creature)
 {
     this.animator = animator;
 }
Example #7
0
 public CreatureBase(CreatureCptBase creature)
 {
     this.creature = creature;
 }