예제 #1
0
        public virtual void UnEquipDecoration(DecorationData decorationData)
        {
            RoleData.EquipData.DecorationDataList.Remove(decorationData);

            // 转杯添加buff add by TangJian 2017/11/20 21:55:28
            BuffController.RemoveBuff(decorationData.id + "-" + decorationData.buffId);
        }
예제 #2
0
        public override void OnFixedUpdate()
        {
            // 刷新角色是否站在地面 add by TangJian 2018/05/03 21:14:27
//            _characterController.Move(new Vector3(0, -0.01f, 0));
//            isGrounded = _characterController.isGrounded;
//            UpdateGround();
            //isGrounded = _characterController.isGrounded;

            // 刷新增益 add by TangJian 2017/10/09 20:17:27
            BuffController.Update(Time.deltaTime);
        }
예제 #3
0
 // 装备饰品 add by TangJian 2017/11/20 21:51:54
 public virtual bool EquipDecoration(DecorationData decorationData)
 {
     if (RoleData.EquipData.DecorationDataList.Count < 4)
     {
         RoleData.EquipData.DecorationDataList.Add(decorationData);
         // 转杯添加buff add by TangJian 2017/11/20 21:55:28
         BuffController.AddEquipBuff(decorationData.buffId, decorationData.buffId);
         return(true);
     }
     return(false);
 }
예제 #4
0
        public override void Use()
        {
            ConsumableData consumableData = RoleData.GetCurrConsumableItem();

            if (consumableData != null)
            {
                RoleData.SubConsumableItem(consumableData.id);
                BuffController.AddBuff(consumableData.buffId);
            }
            else
            {
                Debug.Log("身上没有消耗品");
            }
        }
예제 #5
0
        private void InitBuff()
        {
            // 增益控制器 add by TangJian 2017/10/09 20:12:56
            BuffController.SetRoleBuffData(RoleData.RoleBuffData);
            BuffController.RegisterBuffEvent(BuffEventType.OnBuffBegin, (BuffData buff, object[] objs) =>
            {
                OnBuffBegin(buff);
                return(true);
            });
            BuffController.RegisterBuffEvent(BuffEventType.OnBuffUpdate, (BuffData buff, object[] objs) =>
            {
                OnBuffUpdate(buff);
                return(true);
            });
            BuffController.RegisterBuffEvent(BuffEventType.OnBuffEnd, (BuffData buff, object[] objs) =>
            {
                OnBuffEnd(buff);
                return(true);
            });
            BuffController.RegisterBuffEvent(BuffEventType.OnHurt, (BuffData buff, object[] objs) =>
            {
                if (buff.buffEvents.ContainsKey(BuffEventType.OnHurt))
                {
                    ActionDataExecutor.ExecuteRoleActions(this, buff.buffEvents[BuffEventType.OnHurt]);
                }
                return(true);
            });

            BuffController.RegisterBuffEvent(BuffEventType.OnHit, (BuffData buff, object[] objs) =>
            {
                if (buff.buffEvents.ContainsKey(BuffEventType.OnHit))
                {
                    ActionDataExecutor.ExecuteRoleActions(this, buff.buffEvents[BuffEventType.OnHit]);
                }
                return(true);
            });
        }
예제 #6
0
        public override void Interact()
        {
            TriggerController selfTriggerController  = gameObject.GetChild("InteractiveCube").GetComponent <TriggerController>();
            TriggerController otherTriggerController = selfTriggerController.GetFirstKeepingTriggerController();

            if (selfTriggerController != null && otherTriggerController != null && otherTriggerController.ITriggerDelegate != null)
            {
                GameObject interactObject = otherTriggerController.ITriggerDelegate.GetGameObject();

                if (interactObject.tag == "NPC")
                {
                    RolePromptController rolePromptController = GetComponentInChildren <RolePromptController>();
                    rolePromptController.killtalk();
                    OnInteractAction(interactObject);
                    AnimManager.Instance.PrintBubble("[color=#FFFFFF,#000000]fgtdfg[/color]", interactObject);
                }
                else if (interactObject.tag == "Ladder")
                {
                    LadderController ladderController = interactObject.GetComponent <LadderController>();
                    BoxCollider      boxCollider      = otherTriggerController.gameObject.GetComponent <BoxCollider>();
                    Bounds           bou = boxCollider.bounds;
                    gameObject.layer = LayerMask.NameToLayer("Default");
                    if ((interactObject.transform.position.y + bou.center.y + ((bou.size.y / 2) - 1.6f)) < transform.position.y)
                    {
                        switch (ladderController.laddertype)
                        {
                        case laddertype.Left:
                            transform.position = new Vector3(interactObject.transform.position.x + CharacterController.radius, transform.position.y - 1.6f, interactObject.transform.position.z);
                            break;

                        case laddertype.Right:
                            transform.position = new Vector3(interactObject.transform.position.x - CharacterController.radius, transform.position.y - 1.6f, interactObject.transform.position.z);
                            break;

                        case laddertype.Center:
                            transform.position = new Vector3(interactObject.transform.position.x, transform.position.y - 1.6f, interactObject.transform.position.z - 0.1f);
                            break;
                        }
                    }
                    else
                    {
                        switch (ladderController.laddertype)
                        {
                        case laddertype.Left:
                            transform.position = new Vector3(interactObject.transform.position.x + CharacterController.radius, transform.position.y, interactObject.transform.position.z);
                            break;

                        case laddertype.Right:
                            transform.position = new Vector3(interactObject.transform.position.x - CharacterController.radius, transform.position.y, interactObject.transform.position.z);
                            break;

                        case laddertype.Center:
                            transform.position = new Vector3(interactObject.transform.position.x, transform.position.y, interactObject.transform.position.z - 0.1f);
                            break;
                        }
                    }
                    if (animatorParams.ContainsKey("ladder_type"))
                    {
                        _animator.SetInteger("ladder_type", (int)ladderController.laddertype);
                    }
                    if (animatorParams.ContainsKey("start_climb_ladder"))
                    {
                        _animator.SetBool("start_climb_ladder", true);
                    }
                }
                else if (interactObject.GetComponent <IInteractable>() != null)
                {
                    IInteractable interactable = interactObject.GetComponent <IInteractable>();
                    if (interactable.CanInteract())
                    {
                        interactable.Interact();
                    }
                }
                else if (interactObject.GetComponent <PortalController>())
                {
                    PortalController portalController = interactObject.GetComponent <PortalController>();
                    if (portalController)
                    {
                        this.OpenPortal(portalController);
                    }
                }
                else if (interactObject.GetComponent <FenceDoorController>())
                {
                    FenceDoorController fenceDoorController = interactObject.GetComponent <FenceDoorController>();
                    if (fenceDoorController)
                    {
                        fenceDoorController.OpenPortal();
                    }
                }
                else
                {
                    if (interactObject != null && interactObject.Equals(null) == false)
                    {
                        DropItemController dropItemController = interactObject.GetComponent <DropItemController>();
                        if (dropItemController != null)
                        {
                            var itemData = ItemManager.Instance.getItemDataById <ItemData>(dropItemController.ItemId);
                            GameManager.Instance.PickupTips("Textures/Icon/" + itemData.icon, itemData.name, itemData.count.ToString());
                            switch (itemData.itemType)
                            {
                            case ItemType.Consumable:
                                Debug.Log("捡到消耗品 id = " + itemData.id);

                                Destroy(interactObject);
                                ConsumableData consumableData = ItemManager.Instance.getItemDataById <ConsumableData>(itemData.id);
                                if (consumableData != null)
                                {
                                    switch (consumableData.consumableUseType)
                                    {
                                    case ConsumableUseType.deposit:
                                        RoleData.AddConsumableItem(itemData.id, itemData.count);
                                        PickupConsumable();
                                        break;

                                    case ConsumableUseType.ImmediateUse:
                                        BuffController.AddBuff(consumableData.buffId);
                                        break;
                                    }
                                }
                                break;

                            case ItemType.Other:
                                RoleData.OtherItemList.Add(itemData);
                                dropItemController.RemoveSelf();
                                break;

                            case ItemType.Equip:
                                var weaponData = ItemManager.Instance.getItemDataById <WeaponData>(dropItemController.ItemId);
                                if (weaponData != null)
                                {
                                    this.JuageEquipPossessType(weaponData);
                                }
                                else
                                {
                                    var equipData = ItemManager.Instance.getItemDataById <EquipData>(itemData.id);
                                    RoleData.EquipData.UseEquip(equipData, interactObject.transform.localPosition + new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(1.0f, 1.5f), Random.Range(-0.5f, 0.5f)));
                                }
                                Destroy(interactObject);
                                break;
                            }
                        }
                        else
                        {
                            var interactive = interactObject.GetComponent <ITriggerDelegate>();
                            if (interactive != null)
                            {
                                Event evt = new Event();
                                evt.Type = EventType.Interact;
                                evt.Data = GetGameObject();
                                interactive.OnEvent(evt);
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
        public virtual bool OnHit(DamageData damageData)
        {
            // 事件分发
            if (OnHitEvent != null)
            {
                OnHitEvent(damageData);
            }

            // buff刷新
            BuffController.TriggerBuffEvent(BuffEventType.OnHit, damageData);

            // 代理执行击中 add by TangJian 2019/5/10 17:20
            _hitAndHurtDelegate.Hit(damageData);

            // 空中击中对象, 自己浮空
            if (isGrounded == false)
            {
                if (damageData.itriggerDelegate is HurtAble && damageData.itriggerDelegate is IObjectController objectController)
                {
                    //击退 add by TangJian 2018/12/8 14:55
                    if (damageData.targetMoveBy.magnitude > 0.01f)
                    {
                        speed.y = (damageData.targetMoveBy *
                                   (1f - (objectController.IsDefending ? objectController.DefenseRepellingResistance : objectController.RepellingResistance))
                                   ).MoveByToSpeed().y;
                    }
                }
            }

            // 添加碰撞伤害
//            if (damageData.hitType == (int) HitType.Fly)
//            {
//                this.DelayToDo(0.1f, () =>
//                {
//                    if (damageData.hitGameObject.GetComponent<RoleController>() is IObjectController otherObjController)
//                    {
//                        var damageSize = new Vector3(1, 1, 1);
//                        HitType hittype = HitType.Fly;
//
//                        string damageControllerId = Tools.getOnlyId().ToString();
//                        string damageId = Tools.getOnlyId().ToString();
//
//                        var damageController = FrameEventMethods.RoleAtk((ITriggerDelegate) otherObjController, damageControllerId, damageId,
//                            _roleData.TeamId, FrameEventInfo.ParentType.Transform
//                            , PrimitiveType.Cube
//                            , Vector3.zero
//                            , damageSize
//                            , new Vector3(GetDirectionInt(), 0, 0)
//                            , hittype
//                            , Vector3.zero
//                            , DamageDirectionType.UseSpeed
//                            , DamageEffectType.Strike
//                            , AtkPropertyType.physicalDamage
//                            , 1
//                            , 1);
//
//                        damageController.SetId(damageControllerId);
//
//                        // 设计击飞攻击效果为其他
//                        damageController.damageData.HitEffectType = HitEffectType.Other;
//
//                        // 绑定到攻击对象的身上
//                        damageController.bindType = FrameEventInfo.RoleAtkFrameEventData.BindType.BindObjectController;
//                        damageController.ObjectController = otherObjController;
//
//                        damageController.NeedRemoveSelf = () => otherObjController.Speed.y <= 0 && otherObjController.IsGrounded();
//                    }
//
//                });
//            }
            return(true);
        }
예제 #8
0
        // 受伤 add by TangJian 2018/12/8 1:54
        public virtual bool Hurt(DamageData damageData)
        {
            Direction oldDirection = GetDirection();

            // 扣血 add by TangJian 2017/07/14 18:02:17
            if (IsDefending

                && damageData.ignoreShield == false // 不无视防御 add by TangJian 2019/4/3 17:16

                )
            {
                //方向判断
                AnimationSwitch(damageData, false, true);

                //体力判断
                {
                    // 伤害计算和扣血 add by TangJian 2019/4/2 16:44
                    float HurtNum = this.DoLoseHp(damageData.atk);

                    // 自身动画状态设置 add by TangJian 2019/4/2 16:44
                    {
                        if (animatorParams.ContainsKey("NoDefence"))
                        {
                            _animator.SetBool("NoDefence", true);
                        }

                        _animator.SetInteger("Defence_hurt_type", 3);
                        AnimManager.Instance.WeaponCremaShake(FrameEventInfo.CameraShakeType.mediumshape);
                        if (RoleData.Hp <= 0)
                        {
                            WeaponByDieAni(damageData.WeapondeadType, HurtNum);
                        }
                        else
                        {
                            _animator.SetTrigger("hurt");
                        }
                    }

                    // 额外效果 add by TangJian 2019/4/2 16:44
                    {
                        float   angle           = damageData.SpecialEffectRotation;
                        Bounds  bounds          = new Bounds(transform.position + RoleData.DefendBoundcenter, RoleData.DefendBoundsize);
                        Vector3 localPos        = transform.InverseTransformPoint(damageData.collideBounds.center);
                        Vector3 posse           = transform.position + localPos;
                        Vector3 overpos         = bounds.ClosestPoint(posse);
                        Vector3 moveOrientation = Quaternion.AngleAxis(angle, Vector3.forward) * Vector3.right;
                        moveOrientation.y = Mathf.Abs(moveOrientation.y);
                    }
                }
            }
            else
            {
                // 伤害计算和扣血 add by TangJian 2019/4/2 16:44
                float HurtNum = this.DoLoseHp(damageData.atk);

                #region //2019.3.29// 动画状态机设置
                {
                    // 设置无视防御状态 add by TangJian 2019/4/3 17:50
                    if (damageData.ignoreShield)
                    {
                        RoleAnimator.SetTrigger("ignore_shield");
                    }

                    if (RoleData.Hp <= 0)
                    {
                        WeaponByDieAni(damageData.WeapondeadType, HurtNum);
                    }

                    //地面血迹 2019.3.29
                    AnimManager.Instance.PlayAnimEffect("BloodSubface", transform.position, 0, damageData.direction.x < 0, Vector3.right, transform);

                    //判断是否需要转身 2019.4.4
                    bool IsneedTurnback = RoleData.NeedTurnBack;
                    if (IsneedTurnback)
                    {
                        if (damageData.hitType != (int)HitType.Fly)
                        {
                            IsneedTurnback = false;
                        }
                    }
                    AnimationSwitch(damageData, IsneedTurnback);
                }
                #endregion

                // 额外动画
                {
                    // 播放掉血动画
                    if (HurtNum > 0)
                    {
                        this.PlayLoseHpAnim(HurtNum, damageData.isCritical);
                    }
                }

                // 使用代理实现受伤 add by TangJian 2019/5/10 17:56
                _hitAndHurtDelegate.Hurt(damageData);
            }

            // 霸体状态处理 add by TangJian 2018/12/8 14:56
            if (RoleData.IsSuperArmor)
            {
                SetDirection(oldDirection); // 霸体被攻击不转面 add by TangJian 2019/3/25 10:54
                _animator.SetBool("hurt", false);
            }
            else
            {
                if (OnHurtEvent != null)
                {
                    OnHurtEvent(damageData);
                }
            }

            //击退 add by TangJian 2018/12/8 14:55
            if (damageData.targetMoveBy.magnitude > 0.01f)
            {
                Speed = (damageData.targetMoveBy * (1f - (IsDefending ? RoleData.DefenseRepellingResistance : RoleData.RepellingResistance))).MoveByToSpeed();
            }

            // 触发受伤事件 add by TangJian 2018/05/14 20:09:38
            BuffController.TriggerBuffEvent(BuffEventType.OnHurt);
            return(true);
        }