void TryRegister()
    {
        if (mainPlayerAliveEntity != null)
        {
            hp = mainPlayerAliveEntity.HPPercent;
            grayScale.saturate = Mathf.Lerp(grayScale.saturate, hp < 0.000001f ? 0f : 1f, 0.02f);
        }

        if (registed)
        {
            return;
        }

        if (Pathea.PeCreature.Instance == null)
        {
            return;
        }

        if (Pathea.PeCreature.Instance.mainPlayer == null)
        {
            return;
        }

        mainPlayerAliveEntity = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.SkAliveEntity>();

        if (mainPlayerAliveEntity == null)
        {
            return;
        }

        mainPlayerAliveEntity.onHpChange += HandleAliveEntityHpChange;

        registed = true;
    }
Beispiel #2
0
    public static void OnMonsterAdd(int id, AiNetwork ai, Pathea.PeEntity entity)
    {
        EntityMonsterBeacon mbEntity = Pathea.EntityMgr.Instance.Get(id) as EntityMonsterBeacon;

        if (null != mbEntity)
        {
            mbEntity.OnMonsterCreated(entity);
        }
        else
        {
            if (null != entity)
            {
                Pathea.CommonCmpt cc = entity.GetCmpt <Pathea.CommonCmpt>();
                if (cc != null)
                {
                    AiTowerDefense td = AiTowerDefense.Get <AiTowerDefense>(id);
                    if (null != td)
                    {
                        cc.TDpos = td._pos;
                    }
                }

                Pathea.SkAliveEntity sae = entity.GetCmpt <Pathea.SkAliveEntity>();
                if (sae != null)
                {
                    sae.SetAttribute(Pathea.AttribType.DefaultPlayerID, 8);
                    sae.SetAttribute(Pathea.AttribType.CampID, 26);
                }
            }
        }
    }
Beispiel #3
0
    protected override void OnStart()
    {
        base.OnStart();

        Pathea.SkAliveEntity alive = GetComponent <Pathea.SkAliveEntity> ();
        if (alive != null)
        {
            alive.deathEvent += OnDeath;
        }
    }
    void ApplyPackDropItem(List <DropItemInfo> itemList)
    {
        //lz-2017.01.03 crash bug 错误 #8002
        if (null == itemList)
        {
            return;
        }
        if (null == GameUI.Instance || null == GameUI.Instance.mMainPlayer)
        {
            return;
        }

        Pathea.SkAliveEntity skEntity = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.SkAliveEntity>();
        if (skEntity == null || null == skEntity.Entity)
        {
            return;
        }

        mDropReq.Clear();
        foreach (DropItemInfo itemInfo in itemList)
        {
            if (null != itemInfo && null != itemInfo.mDropItemObj)
            {
                mDropReq.Add(itemInfo.mDropItemObj.instanceId);
            }
        }
        MapObj[]   mapObjs = new MapObj[1];
        RaycastHit hitInfo;
        int        count = 0;

        while (count++ < 100)
        {
            if (skEntity.Entity)
            {
                Vector3 offsetPos = new Vector3(Random.Range(-2f, 2f), 2f, Random.Range(-2f, 2f));
                if (Physics.Raycast(skEntity.Entity.position + offsetPos, Vector3.down, out hitInfo, 10f, mItemDroplayer))
                {
                    if (!hitInfo.collider.isTrigger && hitInfo.distance < 10f)
                    {
                        mapObjs[0]       = new MapObj();
                        mapObjs[0].pos   = hitInfo.point;
                        mapObjs[0].objID = skEntity.GetId();
                        break;
                    }
                }
            }
        }
        if (mapObjs[0] != null)
        {
            PlayerNetwork.mainPlayer.CreateMapObj((int)DoodadType.DoodadType_Drop, mapObjs);
        }
    }
Beispiel #5
0
    void CreateDroppableItemList()
    {
        if (_itemListsUpdated)
        {
            return;
        }

        _itemListsUpdated = true;

        //_itemLists.Add(this); // this will be added at the end of this method(foreach)

        Pathea.PeEntity entity = GetComponent <Pathea.PeEntity>();
        if (null == entity)
        {
            return;
        }
        _skAlive = entity.GetCmpt <Pathea.SkAliveEntity>();
        if (_skAlive == null || !_skAlive.isDead)
        {
            return;
        }

        if (Pathea.PeGameMgr.IsMulti)
        {
            return;
        }
        Pathea.CommonCmpt common = entity.GetCmpt <Pathea.CommonCmpt>();
        if (common != null)
        {
            List <ItemSample> items = ItemDropData.GetDropItems(common.ItemDropId);
            if (common.entityProto.proto == Pathea.EEntityProto.Monster)
            {
                if (items == null)
                {
                    items = GetSpecialItem.MonsterItemAdd(common.entityProto.protoId);
                }
                else
                {
                    items.AddRange(GetSpecialItem.MonsterItemAdd(common.entityProto.protoId));   //特殊道具添加
                }
            }
            if (items != null)
            {
                foreach (ItemSample item in items)
                {
                    AddDroppableItem(item);
                }
            }
        }

        return;
    }
 public static void AttachMonsterDeathEvent(PeEntity entity)
 {
     Pathea.SkAliveEntity skAlive = entity.GetCmpt <Pathea.SkAliveEntity>();
     if (skAlive != null)
     {
         skAlive.deathEvent += skAlive.OnDeathProcessBuff;
         skAlive.deathEvent += (a, b) => {
             if (commonDeathEvent != null)
             {
                 commonDeathEvent(a, b);
             }
         };
     }
 }
Beispiel #7
0
        public override void DoAction(PEActionParam para = null)
        {
            PEActionParamVQNS paramVQNS = para as PEActionParamVQNS;

            if (null != trans)
            {
                m_StartPos       = trans.position;
                m_StartRot       = trans.rotation;
                m_TargetPos      = paramVQNS.vec;
                m_TargetRot      = paramVQNS.q;
                m_MoveElapseTime = 0;
            }
            m_AnimName = paramVQNS.str;
            if (null != anim)
            {
                anim.SetBool(m_AnimName, true);
                anim.ResetTrigger("ResetFullBody");
            }


            m_BuffID = paramVQNS.n;

            if (null != skillCmpt && 0 != m_BuffID)
            {
                SkAliveEntity.MountBuff(skillCmpt, m_BuffID, new System.Collections.Generic.List <int>(), new System.Collections.Generic.List <float>());
            }

            m_EndAnim   = false;
            m_EndAction = false;

            if (null != ikCmpt)
            {
                ikCmpt.ikEnable = false;
            }

            if (null != m_PhyCtrl)
            {
                m_PhyCtrl.velocity = Vector3.zero;
                m_PhyCtrl.CancelMoveRequest();
            }

            if (null != startSleepEvt)
            {
                startSleepEvt(m_BuffID);
            }
        }
    private bool CanCmd()
    {
        if (null != SelectItem_N.Instance && SelectItem_N.Instance.HaveOpItem())
        {
            return(false);
        }

        if (DistanceInRange(_playerPos, base.operateDistance))
        {
            Pathea.SkAliveEntity alive = GetComponent <Pathea.SkAliveEntity>();
            if (alive != null && alive.isDead)
            {
                return(false);
            }
            return(true);
        }
        return(false);
    }
        public override void Start()
        {
            base.Start();
            //mView = Entity.peTrans;
            mCommon      = Entity.GetCmpt <CommonCmpt>();
            mAliveEntity = Entity.GetCmpt <SkAliveEntity>();

            if (mAliveEntity != null)
            {
                //mAliveEntity.onHpChange += mHeadInfo.OnHpChange;
                mAliveEntity.deathEvent += OndeathEnvent;
            }

            // mHeadInfo.SetTheEntity(Entity);
            //mHeadInfo.InitTheentity(Entity);
            SyncObjectName();
            SetVisiable(true);
            // SyncInfo();
        }
        public void SetDamagable(int campId, int damageId, int playerId)
        {
            SkAliveEntity skAlive = Entity.aliveEntity;

            if (skAlive != null)
            {
                skAlive.SetAttribute(AttribType.CampID, campId);
                skAlive.SetAttribute(AttribType.DamageID, damageId);
                _bDamagable = campId != SceneDoodadDesc.c_neutralCamp || damageId != SceneDoodadDesc.c_neutralDamage;
//				if(_bDamagable){
//					skAlive.deathEvent += DoodadEntityCreator.OnDoodadDeath;
//				} else {
//					skAlive.deathEvent -= DoodadEntityCreator.OnDoodadDeath;
//				}
                if (playerId >= 0)
                {
                    skAlive.SetAttribute(AttribType.DefaultPlayerID, playerId);
                }
            }
        }
Beispiel #11
0
        public override void Start()
        {
            base.Start();
            m_SkillCmpt = Entity.aliveEntity;
            m_PeTrans   = Entity.peTrans;

            m_Repulsed.m_Behave = Entity.GetCmpt <BehaveCmpt>();
            m_Repulsed.m_Move   = Entity.GetCmpt <Motion_Move_Motor>();

            m_MotionMgr = Entity.motionMgr;
            if (null != m_MotionMgr)
            {
                m_MotionMgr.AddAction(m_Whacked);
                m_MotionMgr.AddAction(m_Repulsed);
                m_MotionMgr.AddAction(m_Wentfly);
                m_MotionMgr.AddAction(m_Knocked);
                m_MotionMgr.AddAction(m_GetUp);
                m_MotionMgr.AddAction(m_Death);
                m_MotionMgr.AddAction(m_AlienDeath);
                m_MotionMgr.AddAction(m_Revive);
            }
        }
Beispiel #12
0
 public virtual bool CanCmd()
 {
     if (null != SelectItem_N.Instance && SelectItem_N.Instance.HaveOpItem())
     {
         return(false);
     }
     //float dis = Vector3.Distance(playerPos, GetPos());
     if (DistanceInRange(playerPos, operateDistance))
     {
         Pathea.SkAliveEntity alive = GetComponent <Pathea.SkAliveEntity> ();
         if (alive != null && alive.isDead)
         {
             return(false);
         }
         if (!cancmd)
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
Beispiel #13
0
    public ItemBox AddItemMultiPlay(int id, int opID, Vector3 pos, MapObjNetwork netWork = null)
    {
        ItemBox newBox = CreateItemBox();

        newBox.transform.parent = transform;
        newBox.mID           = id;
        newBox.mPos          = pos;
        newBox.mNetWork      = netWork;
        mItemBox[newBox.mID] = newBox;

        if (null != Pathea.PeCreature.Instance.mainPlayer)
        {
            Pathea.SkAliveEntity sk = GameUI.Instance.mMainPlayer.GetCmpt <Pathea.SkAliveEntity>();
            if (sk != null)
            {
                if (opID == sk.GetId())
                {
                    newBox.InsertItem(mDropReq);
                    mDropReq.Clear();
                }
            }
        }
        return(newBox);
    }
        public void OnHpChange(SkEntity self, SkEntity caster, float hpChange)
        {
            if (null == self)
            {
                return;
            }
            SkAliveEntity skAlive = self as SkAliveEntity;

            if (null != skAlive)
            {
                PeTrans    trans  = skAlive.Entity.peTrans;
                CommonCmpt common = skAlive.Entity.commonCmpt;
                if (null != trans)
                {
                    HPChangeEventData data = new HPChangeEventData();
                    data.m_Self      = self;
                    data.m_HPChange  = hpChange;
                    data.m_Transfrom = trans.trans;
                    data.m_Proto     = (null != common && null != common.entityProto)?common.entityProto.proto:EEntityProto.Doodad;
                    data.m_AddTime   = Time.realtimeSinceStartup;
                    _datas.Push(data);
                }
            }
        }
Beispiel #15
0
    string DoEntityCmd(int id, string funcName, string[] args)
    {
        Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(id);
        if (null == entity)
        {
            return("can't find entity by id:" + id);
        }

        switch (funcName)
        {
        case "servant":
            Pathea.NpcCmpt npcCmpt = entity.GetCmpt <Pathea.NpcCmpt>();
            if (npcCmpt == null)
            {
                return("no NpcCmpt.");
            }

            Pathea.ServantLeaderCmpt leader = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.ServantLeaderCmpt>();
            if (leader == null)
            {
                return("no ServantLeaderCmpt");
            }

            leader.AddServant(npcCmpt);
            npcCmpt.SetServantLeader(leader);
            return("ok");

        case "start_skill":
            int targetId;
            if (!int.TryParse(args[0], out targetId))
            {
                return("get target id failed");
            }
            Pathea.PeEntity      targetEntity = Pathea.EntityMgr.Instance.Get(targetId);
            Pathea.SkAliveEntity skillCmpt    = targetEntity.GetCmpt <Pathea.SkAliveEntity>();
            if (null == skillCmpt)
            {
                return("target have no SkillCmpt");
            }
            int skillId;
            if (!int.TryParse(args[1], out skillId))
            {
                return("get skill id failed");
            }
            skillCmpt.StartSkill(skillCmpt, skillId);
            return("ok");

        case "Kill":
            Pathea.PeEntity killEntity = Pathea.EntityMgr.Instance.Get(id);
            if (killEntity == null)
            {
                return("get entity failed with id : " + id);
            }
            killEntity.SetAttribute(Pathea.AttribType.Hp, 0.0f, false);
            return("ok");

        //case "SetBool":
        //    string animationName = args[0];
        //    bool value;
        //    if (!bool.TryParse(args[1], out value))
        //    {
        //        return "get value failed";
        //    }

        //    entity.SetBool(animationName, value);
        //    return "ok";
        default:
            return("not implementd cmd");
        }
    }
Beispiel #16
0
        void ApplyMoveEffect(SkEntity skEntity, Transform trans, Vector3 forceDir, float forcePower)
        {
            if (null == m_Param)
            {
                return;
            }
            float angle          = Vector3.Angle(m_PeTrans.existent.forward, forceDir);
            float thresholdScale = m_Param.m_AngleThresholdScale.Evaluate(angle);

            forcePower *= m_Param.m_AngleForceScale.Evaluate(angle);

            thresholdScale *= m_MotionMgr.GetMaskState(PEActionMask.InAir) ? m_Param.m_ThresholdScaleInAir : 1f;

            EffectType spType = EffectType.Repulsed;

            if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdWhacked) * thresholdScale)
            {
                spType = EffectType.Null;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdRepulsed) * thresholdScale)
            {
                spType = EffectType.Whacked;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdWentfly) * thresholdScale)
            {
                spType = EffectType.Repulsed;
            }
            else if (forcePower < m_SkillCmpt.GetAttribute(AttribType.ThresholdKnocked) * thresholdScale)
            {
                spType = EffectType.Wentfly;
            }
            else
            {
                spType = EffectType.Knocked;
            }

#if UNITY_EDITOR
            if (m_WriteLog)
            {
                Debug.LogError("ForcePower:" + forcePower);
                Debug.LogError("ThresholdRepulsed:" + m_SkillCmpt.GetAttribute(AttribType.ThresholdRepulsed).ToString());
                Debug.LogError(spType.ToString());
            }
#endif
            SkAliveEntity skAliveEntity = skEntity as SkAliveEntity;
            if (null != skAliveEntity)
            {
                switch (spType)
                {
                case EffectType.Null:
                    ApplyHitEffect(trans, forceDir, forcePower);
                    break;

                case EffectType.Whacked:
                    m_MotionMgr.DoAction(PEActionType.Whacked);
                    break;

                case EffectType.Repulsed:
                    ApplyHitEffect(trans, forceDir, forcePower);
                    PEActionParamVVF param = PEActionParamVVF.param;
                    param.vec1 = m_PeTrans.position;
                    param.vec2 = forceDir;
                    param.f    = forcePower;
                    m_MotionMgr.DoAction(PEActionType.Repulsed, param);
                    break;

                case EffectType.Wentfly:
                case EffectType.Knocked:
                    PEActionParamVFNS paramVFNS = PEActionParamVFNS.param;
                    paramVFNS.vec = forceDir;
                    paramVFNS.f   = forcePower;
                    paramVFNS.n   = skAliveEntity.Entity.Id;
                    if (null != trans)
                    {
                        paramVFNS.str = trans.name;
                    }
                    else
                    {
                        paramVFNS.str = "";
                    }
                    m_MotionMgr.DoAction(PEActionType.Wentfly, paramVFNS);
                    break;
                }
            }
        }
        public void OnDeathProcessBuff(SkEntity cur, SkEntity caster)
        {
            if (caster == null || cur == null)
            {
                return;
            }
            SkAliveEntity killer = caster as SkAliveEntity;

            if (killer == null)
            {
                if (caster is SkProjectile)
                {
                    killer = (caster as SkProjectile).GetSkEntityCaster() as SkAliveEntity;
                }
                if (killer == null)
                {
                    return;
                }
            }

            SkAliveEntity victem = cur as SkAliveEntity;

            if (victem == null)
            {
                return;
            }
            MonsterProtoDb.Item protoItem = MonsterProtoDb.Get(victem.Entity.entityProto.protoId);
            if (protoItem == null || protoItem.deathBuff.Length == 0)
            {
                return;
            }
            if (killer.Entity.NpcCmpt != null)
            {
                if (killer.Entity.NpcCmpt.Master != null && killer.Entity.NpcCmpt.Master.Entity != null && killer.Entity.NpcCmpt.Master.Entity.aliveEntity != null)
                {
                    killer = killer.Entity.NpcCmpt.Master.Entity.aliveEntity;
                }
            }
            if (PeGameMgr.IsMulti)
            {
                if (killer.IsController())
                {
                    string[]     args1    = protoItem.deathBuff.Split(',');
                    int          buffid   = Convert.ToInt32(args1[0]);
                    List <int>   atrtype  = new List <int>();
                    List <float> atrvalue = new List <float>();
                    for (int i = 1; i < args1.Length; i = i + 2)
                    {
                        atrtype.Add(Convert.ToInt32(args1[i]));
                        atrvalue.Add(Convert.ToSingle(args1[i + 1]));
                    }
                    if (atrtype.Count > 0 && atrvalue.Count > 0)
                    {
                        //remove old buff
                        SkEntity.UnmountBuff(killer, buffid);
                        //add buff
                        SkEntity.MountBuff(killer, buffid, atrtype, atrvalue);
                    }
                }
            }
            else
            {
                string[]     args1    = protoItem.deathBuff.Split(',');
                int          buffid   = Convert.ToInt32(args1[0]);
                List <int>   atrtype  = new List <int>();
                List <float> atrvalue = new List <float>();
                for (int i = 1; i < args1.Length; i = i + 2)
                {
                    atrtype.Add(Convert.ToInt32(args1[i]));
                    atrvalue.Add(Convert.ToSingle(args1[i + 1]));
                }
                if (atrtype.Count > 0 && atrvalue.Count > 0)
                {
                    //remove old buff
                    SkEntity.UnmountBuff(killer, buffid);
                    //add buff
                    SkEntity.MountBuff(killer, buffid, atrtype, atrvalue);
                }
            }
            victem.deathEvent -= OnDeathProcessBuff;
        }
Beispiel #18
0
        void InitAction()
        {
            m_Trans = Entity.peTrans;
            m_Skill = Entity.aliveEntity;
            m_Skill.onSheildReduce += OnSheildReduce;
            m_View      = Entity.biologyViewCmpt;
            m_EquipCmpt = Entity.equipmentCmpt;
            m_Package   = Entity.packageCmpt;
            m_NPC       = Entity.NpcCmpt;
            m_Anim      = Entity.animCmpt;
            m_MotionMgr = Entity.motionMgr;
            Invoke("CheckGloves", 0.5f);

            m_HeavyEquipmentCtrl.moveCmpt  = Entity.motionMove as Motion_Move_Human;
            m_HeavyEquipmentCtrl.ikCmpt    = Entity.IKCmpt;
            m_HeavyEquipmentCtrl.motionMgr = m_MotionMgr;

//			m_ChainSawActive.anim = anim;
            m_SwordAttack.m_UseStamina         = isMainPlayer;
            m_TwoHandWeaponAttack.m_UseStamina = isMainPlayer;
            //Gun
            m_GunFire.m_gunHold = m_GunHold;

            m_HandChangeHold.onActiveEvt   += OnActiveEquipment;
            m_HandChangeHold.onDeactiveEvt += OnDeactiveEquipment;

            m_TwoHandWeaponHold.onActiveEvt   += OnActiveEquipment;
            m_TwoHandWeaponHold.onDeactiveEvt += OnDeactiveEquipment;

            m_GunHold.onActiveEvt   += OnActiveEquipment;
            m_GunHold.onDeactiveEvt += OnDeactiveEquipment;

            m_BowHold.onActiveEvt   += OnActiveEquipment;
            m_BowHold.onDeactiveEvt += OnDeactiveEquipment;

            m_AimEquipHold.onActiveEvt   += OnActiveEquipment;
            m_AimEquipHold.onDeactiveEvt += OnDeactiveEquipment;

            if (null != m_MotionMgr)
            {
                m_MotionMgr.onActionEnd += OnActionEnd;
                m_MotionMgr.AddAction(m_HandChangeHold);
                m_MotionMgr.AddAction(m_HandChangePutOff);
                m_MotionMgr.AddAction(m_SwordAttack);
                m_MotionMgr.AddAction(m_TwoHandWeaponHold);
                m_MotionMgr.AddAction(m_TwoHandWeaponPutOff);
                m_MotionMgr.AddAction(m_TwoHandWeaponAttack);
                m_MotionMgr.AddAction(m_SheildHold);
                m_MotionMgr.AddAction(m_GunHold);
                m_MotionMgr.AddAction(m_GunPutOff);
                m_MotionMgr.AddAction(m_GunFire);
                m_MotionMgr.AddAction(m_GunReload);
                m_MotionMgr.AddAction(m_GunMelee);
                m_MotionMgr.AddAction(m_BowHold);
                m_MotionMgr.AddAction(m_BowPutOff);
                m_MotionMgr.AddAction(m_BowShoot);
                m_MotionMgr.AddAction(m_BowReload);
                m_MotionMgr.AddAction(m_AimEquipHold);
                m_MotionMgr.AddAction(m_AimEquipPutOff);
                m_MotionMgr.AddAction(m_DigTerrain);
                m_MotionMgr.AddAction(m_Fell);
                m_MotionMgr.AddAction(m_JetPackAction);
                m_MotionMgr.AddAction(m_ParachuteAction);
                m_MotionMgr.AddAction(m_GliderAction);
                m_MotionMgr.AddAction(m_DrawWater);
                m_MotionMgr.AddAction(m_PumpWater);
                m_MotionMgr.AddAction(m_ThrowGrenade);
                m_MotionMgr.AddAction(m_FlashLightAction);
                m_MotionMgr.AddAction(m_RopeGunAction);
            }
        }
 public override void Start()
 {
     base.Start();
     m_SkEntity = Entity.aliveEntity;
     m_View     = Entity.biologyViewCmpt;
 }