コード例 #1
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
        internal static SkFuncInOutPara TstColLayer(SkInst inst, System.Object strColDesc)
        {
            SkFuncInOutPara funcOut = new SkFuncInOutPara(inst, strColDesc);

            if (inst._colInfo == null)
            {
                return(funcOut);
            }

            SkCondColDesc cols = funcOut.GetColDesc();

            cols.colTypes[0] = cols.colTypes[1] = SkCondColDesc.ColType.ColLayer;
            if (cols.Contain(inst._colInfo))
            {
                SkEntity curTar = (SkEntity)inst._colInfo.hitTrans;
                if (curTar != null)
                {
                    funcOut._para = new List <SkEntity>()
                    {
                        curTar
                    };
                }
                funcOut._ret = true;
            }
            return(funcOut);
        }
コード例 #2
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
        internal static SkFuncInOutPara TstInRange(SkInst inst, System.Object para)
        {
            SkFuncInOutPara funcOut = new SkFuncInOutPara(inst, para);

            // TODO code inst._caster.TstInRange(funcPara);
            return(funcOut);
        }
コード例 #3
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
        public bool Tst(SkInst inst)
        {
            SkFuncInOutPara funcOut = _cond(inst, _para);

            _retTars = funcOut._ret ? (funcOut._para as List <SkEntity>) : null;
            return(funcOut._ret);
        }
コード例 #4
0
        // skill instances management
        //============================
        public static SkInst StartSkill(SkEntity caster, SkEntity target, int skId, ISkPara para = null, bool bStartImm = true)
        {
            SkData skData = null;

            if (!SkData.s_SkillTbl.TryGetValue(skId, out skData))
            {
                Debug.LogError("[SkInst]:Invalid skill id:" + skId);
                return(null);
            }

                        #if DBG_COL_ATK
            //if(!SkDebug.IsDebuggingID(skId))	return null;
                        #endif
            // cool check
            SkCoolInfo cinfo = GetSkillCoolingInfo(caster, skData);
            if (cinfo != null && cinfo._fLeftTime > 0)
            {
                //Debug.LogError("[SkInst]:Skill id:" + skId +" in cooling..");
                return(null);
            }

            SkInst inst = new SkInst();
            SkInstPool.Instance._skInsts.Add(inst);
            inst._skData    = skData;
            inst._para      = para;
            inst._caster    = caster;
            inst._target    = target;
            inst._coroutine = bStartImm ? new CoroutineStoppable(caster, inst.Exec()) : null;
            return(inst);
        }
コード例 #5
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
        // TBD : add external func for target???
        internal static SkFuncInOutPara TstExternalFunc(SkInst inst, System.Object para)
        {
            string[]        condDesc  = para as string[];
            SkFuncInOutPara funcInOut = new SkFuncInOutPara(inst, condDesc.Length < 2 ? null : condDesc[1]);

            inst._caster.SendMessage(condDesc[0], funcInOut, SendMessageOptions.DontRequireReceiver);
            return(funcInOut);
        }
コード例 #6
0
 public void CancelAllSkills()
 {
     SkInst.StopSkill((inst) => { return(inst.Caster == this); });
     _skCanLoop.Reset();
     if (IsController())
     {
         _net.RPCServer(EPacketType.PT_InGame_SKStopSkill, -1 /*Tmp use -1, id*/, PlayerNetwork.mainPlayerId);
     }
 }
コード例 #7
0
 public void CancelSkill(SkInst inst)
 {
     inst.Stop();
     _skCanLoop.Reset();
     if (IsController())
     {
         _net.RPCServer(EPacketType.PT_InGame_SKStopSkill, inst.SkillID, PlayerNetwork.mainPlayerId);
     }
 }
コード例 #8
0
 public void CancelSkillById(int id)
 {
     SkInst.StopSkill((inst) => { return(inst.Caster == this && inst.SkillID == id); });
     _skCanLoop.Reset();
     if (IsController())
     {
         _net.RPCServer(EPacketType.PT_InGame_SKStopSkill, id, PlayerNetwork.mainPlayerId);
     }
 }
コード例 #9
0
        // Get first matched skill
        public static SkInst GetSkill(Func <SkInst, bool> match)
        {
            List <SkInst> insts = SkInstPool.Instance._skInsts;
            int           n     = insts.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                SkInst inst = insts[i];
                if (match(inst))
                {
                    return(inst);
                }
            }
            return(null);
        }
コード例 #10
0
        public static int StopSkill(Func <SkInst, bool> match)
        {
            List <SkInst> insts = SkInstPool.Instance._skInsts;
            int           n     = insts.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                SkInst inst = insts[i];
                if (match(inst))
                {
                    inst.Stop();
                }
            }
            return(insts.Count - n);
        }
コード例 #11
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
        internal static SkFuncInOutPara TstColInfo(SkInst inst, System.Object para)
        {
            SkFuncInOutPara funcOut = new SkFuncInOutPara(inst, para);

            if (inst._colInfo == null)
            {
                return(funcOut);
            }

            SkEntity curTar = (SkEntity)inst._colInfo.hitTrans;

            if (curTar != null)
            {
                funcOut._para = new List <SkEntity>()
                {
                    curTar
                };
                funcOut._ret = true;
            }
            return(funcOut);
        }
コード例 #12
0
        public void GetHurt(float dmg)
        {
            SkInst skInst = SkRuntimeInfo.Current as SkInst;

            if (null != skInst)
            {
                if (skInst._colInfo != null && skInst._colInfo.damageScale > PETools.PEMath.Epsilon)
                {
                    dmg *= skInst._colInfo.damageScale;
                }
            }

            SkEntity caster = SkRuntimeInfo.Current.Caster;
            SkEntity target = SkRuntimeInfo.Current.Target;

            _parent.raws[(int)Pathea.AttribType.Hp]    -= dmg;
            _parent.sums[(int)Pathea.AttribType.Hp]    -= dmg;
            _parent.modflags[(int)Pathea.AttribType.Hp] = false;

            float curTime = Time.time;

            if (caster != null)
            {
                caster._lastestTimeOfHurtingSb = curTime;
            }
            if (target != null)
            {
                target._lastestTimeOfGettingHurt = curTime;
            }

            SkInst inst = SkRuntimeInfo.Current as SkInst;

            if (inst != null)
            {
                inst.Caster.OnHurtSb(inst, dmg);
                inst.Target.OnGetHurt(inst, dmg);
            }
        }
コード例 #13
0
        public virtual SkInst StartSkill(SkEntity target, int id, ISkPara para = null, bool bStartImm = true)
        {
            SkInst inst = SkInst.StartSkill(this, target, id, para, bStartImm);

            if (inst != null)
            {
                if (IsController())
                {
                    if (para is ISkParaNet)
                    {
                        SendStartSkill(target, id, ((ISkParaNet)para).ToFloatArray());
                    }
                    else if (para == null)
                    {
                        SendStartSkill(target, id);
                    }
                    else
                    {
                        Debug.LogError("error skill para");
                    }
                }
            }
            return(inst);
        }
コード例 #14
0
        private string PickAnim(SkEntity entity, SkRuntimeInfo info)
        {
            SkInst inst = info as SkInst;

            if (inst != null)
            {
                switch (_anms [0].ToLower())
                {
                case "rnd":
                    return(_anms [SkInst.s_rand.Next(1, _anms.Length)]);

                case "inc":
                {
                    int idx = inst.GuideCnt - 1;
                    idx %= (_anms.Length - 1);
                    return(_anms [idx + 1]);                            //1+(GuideCnt-1)
                }

                case "dir":
                    return(_anms [1 + inst.GetAtkDir()]);
                }
            }
            return(_anms[0]);
        }
コード例 #15
0
 public void RegisterInstFromExt(SkInst inst)
 {
     _instsActFromExt.Add(inst);
 }
コード例 #16
0
 public bool IsSkillRunnable(int id)
 {
     return(SkInst.IsSkillRunnable(this, id));
 }
コード例 #17
0
 public bool IsSkillRunning(bool cdInclude = true)
 {
     return(null != SkInst.GetSkill((inst) => { return inst.Caster == this && (cdInclude || inst.IsActive); }));
 }
コード例 #18
0
 public SkInst GetSkInst(int id)
 {
     return(SkInst.GetSkill((inst) => { return inst.Caster == this && inst.SkillID == id; }));
 }
コード例 #19
0
        public void TryGetHurt(float dmg, float exp = 0)
        {
            SkInst skInst = SkRuntimeInfo.Current as SkInst;

            if (null != skInst)
            {
                if (skInst._colInfo != null && skInst._colInfo.damageScale > PETools.PEMath.Epsilon)
                {
                    dmg *= skInst._colInfo.damageScale;
                }
            }

            SkEntity caster = SkRuntimeInfo.Current.Caster;
            SkEntity target = SkRuntimeInfo.Current.Target;

            if (CanDamage(caster, target))
            {
                if (caster is Pathea.Projectile.SkProjectile)
                {
                    Pathea.Projectile.SkProjectileDamageScale damageScale = caster.GetComponent <Pathea.Projectile.SkProjectileDamageScale>();
                    if (null != damageScale)
                    {
                        dmg *= damageScale.damageScale;
                    }
                }

                float shield = _parent.sums[(int)Pathea.AttribType.Shield];
                if (shield > 0 && caster is Pathea.Projectile.SkProjectile)
                {
                    if (shield * ShieldToHP < dmg)
                    {
                        _parent.sums[(int)Pathea.AttribType.Shield] = 0;
                        _parent.raws[(int)Pathea.AttribType.Hp]    -= dmg - shield * ShieldToHP;
                        _parent.sums[(int)Pathea.AttribType.Hp]    -= dmg - shield * ShieldToHP;
                        _parent.modflags[(int)Pathea.AttribType.Hp] = false;
                    }
                    else
                    {
                        _parent.sums[(int)Pathea.AttribType.Shield] -= dmg / ShieldToHP;
                    }
                }
                else
                {
                    _parent.raws[(int)Pathea.AttribType.Hp]    -= dmg;
                    _parent.sums[(int)Pathea.AttribType.Hp]    -= dmg;
                    _parent.modflags[(int)Pathea.AttribType.Hp] = false;
                }

                float curTime = Time.time;
                if (caster != null)
                {
                    caster._lastestTimeOfHurtingSb = curTime;
                }
                if (target != null)
                {
                    target._lastestTimeOfGettingHurt = curTime;
                }

                SkInst inst = SkRuntimeInfo.Current as SkInst;
                if (inst != null)
                {
                    inst.Caster.OnHurtSb(inst, dmg);
                    inst.Target.OnGetHurt(inst, dmg);
                }
            }

            if (exp > PETools.PEMath.Epsilon)
            {
                SkEntity parentCaster = caster;
                if (caster is Pathea.Projectile.SkProjectile)
                {
                    parentCaster = (parentCaster as Pathea.Projectile.SkProjectile).parentSkEntity;
                }
                parentCaster.SetAttribute((int)Pathea.AttribType.Exp, parentCaster.GetAttribute((int)Pathea.AttribType.Exp) + exp, false);
            }
        }
コード例 #20
0
 public virtual void OnGetHurt(SkInst inst, float dmg)
 {
 }
コード例 #21
0
 public void ShieldOn(PeEntity monster, int skillId)
 {
     SkillSystem.SkInst skill = _skEntity.StartSkill(monster.skEntity, skillId);
     monsterSkillDict[monster] = skill;
 }
コード例 #22
0
 public SkColliderTracker(SkInst inst)
 {
     _inst = inst;
     _inst._caster.StartCoroutine(Exec());
 }
コード例 #23
0
ファイル: SkCond.cs プロジェクト: shrubba/planetexplorers
 public SkFuncInOutPara(SkInst inst, System.Object para, bool ret = false)
 {
     _inst = inst;
     _para = para;
     _ret  = ret;
 }
コード例 #24
0
 public void UnRegisterInstFromExt(SkInst inst)
 {
     _instsActFromExt.Remove(inst);
 }
コード例 #25
0
        public bool Exec(SkInst inst)
        {
            bool ret = false;

            SkRuntimeInfo.Current = inst;

            if (_cond.Tst(inst))
            {
                inst._forceMagnitude = _force;
                if (inst._target != null)
                {
                    if (_modsCaster != null)
                    {
                        _modsCaster.Exec(inst._caster.attribs, inst._caster.attribs, inst._target.attribs, inst._para as ISkAttribsModPara);
                    }
                    if (_modsTarget != null)
                    {
                        _modsTarget.Exec(inst._target.attribs, inst._caster.attribs, inst._target.attribs, inst._para as ISkAttribsModPara);
                    }
                    if (_force > 0.0f)
                    {
                        inst._forceDirection = inst.GetForceVec();
                    }
                    if (_effOnHitCaster != null)
                    {
                        _effOnHitCaster.Apply(inst._caster, inst);
                    }
                    if (_effOnHitTarget != null)
                    {
                        _effOnHitTarget.Apply(inst._target, inst);
                    }
                }
                else
                {
                    inst._tmpTar = null;
                    if (_effOnHitCaster != null)
                    {
                        _effOnHitCaster.Apply(inst._caster, inst);
                    }
                    if (_cond._retTars != null && _cond._retTars.Count > 0)
                    {
                        foreach (SkEntity target in _cond._retTars)
                        {
                            inst._tmpTar = target;
                            if (_modsCaster != null)
                            {
                                _modsCaster.Exec(inst._caster.attribs, inst._caster.attribs, target.attribs, inst._para as ISkAttribsModPara);
                            }
                            if (_modsTarget != null)
                            {
                                _modsTarget.Exec(target.attribs, inst._caster.attribs, target.attribs, inst._para as ISkAttribsModPara);
                            }
                            if (_effOnHitTarget != null)
                            {
                                if (_force > 0.0f)
                                {
                                    inst._forceDirection = inst.GetForceVec();
                                }
                                _effOnHitTarget.Apply(target, inst);
                            }
                        }
                    }
                    else
                    {
                        if (_modsCaster != null)
                        {
                            _modsCaster.Exec(inst._caster.attribs, inst._caster.attribs, null, inst._para as ISkAttribsModPara);
                        }
                    }
                }
                ret = true;
            }
            SkRuntimeInfo.Current = null;
            return(ret);
        }
コード例 #26
0
 public virtual void OnHurtSb(SkInst inst, float dmg)
 {
 }