예제 #1
0
 public static bool CanAttack(VBio attacker, VBio target, CampType campType, EntityFlag targetFlag)
 {
     return(!target.isDead &&
            target.property.stealth <= 0 &&                 //不在隐身状态下
            CheckCampType(attacker, campType, target) &&
            CheckTargetFlag(targetFlag, target));
 }
예제 #2
0
 public FlagEntityPacketOut(Entity e, EntityFlag flag, double value)
 {
     UsageType = NetUsageType.ENTITIES;
     ID = ServerToClientPacket.FLAG_ENTITY;
     Data = new byte[8 + 1 + 4];
     Utilities.LongToBytes(e.EID).CopyTo(Data, 0);
     Data[8] = (byte)flag;
     Utilities.FloatToBytes((float)value).CopyTo(Data, 8 + 1);
 }
예제 #3
0
 public FlagEntityPacketOut(Entity e, EntityFlag flag, double value)
 {
     UsageType = NetUsageType.ENTITIES;
     ID        = ServerToClientPacket.FLAG_ENTITY;
     Data      = new byte[8 + 1 + 4];
     Utilities.LongToBytes(e.EID).CopyTo(Data, 0);
     Data[8] = (byte)flag;
     Utilities.FloatToBytes((float)value).CopyTo(Data, 8 + 1);
 }
예제 #4
0
        public void LoadFromDef(string id)
        {
            this.id = id;

            Hashtable def = Defs.GetSkill(this.id);

            this.name            = def.GetString("name");
            this.desc            = def.GetString("desc");
            this.isCommon        = def.GetBoolean("is_common");
            this.castType        = ( CastType )def.GetInt("cast_type");
            this.campType        = ( CampType )def.GetInt("camp_type");
            this.rangeType       = ( RangeType )def.GetInt("range_type");
            this.targetFlag      = ( EntityFlag )def.GetInt("target_flag");
            this.canInterrupt    = def.GetBoolean("can_interrupt");
            this.ignoreObstacles = def.GetBoolean("ignore_obstacles");
            this.icon            = def.GetString("icon");
            this.passiveBuffs    = def.GetStringArray("passive_buffs");
            this.buffs           = def.GetStringArray("buffs");

            ArrayList lvls = def.GetList("level");

            if (lvls != null)
            {
                int count = lvls.Count;
                this.levels = new Level[count];
                for (int i = 0; i < count; i++)
                {
                    Level     lvl  = this.levels[i] = new Level();
                    Hashtable ldef = ( Hashtable )lvls[i];
                    lvl.atkTime        = ldef.GetFloat("atk_time");
                    lvl.sufTime        = ldef.GetFloat("suf_time");
                    lvl.action         = ldef.GetString("action");
                    lvl.actionLength   = ldef.GetFloat("action_length");
                    lvl.dashStartSpeed = ldef.GetFloat("dash_start_speed");
                    float[] c = ldef.GetFloatArray("dash_speed_curve");
                    if (c != null && c.Length > 0)
                    {
                        AnimationCurve curve = new AnimationCurve();
                        for (int j = 0; j < c.Length; j += 4)
                        {
                            curve.AddKey(new Keyframe(c[j + 0], c[j + 1], c[j + 2], c[j + 3]));
                        }
                        lvl.dashSpeedCurve = curve;
                    }
                    lvl.distance   = ldef.GetFloat("distance");
                    lvl.cooldown   = ldef.GetFloat("cooldown");
                    lvl.manaCost   = ldef.GetFloat("mana");
                    lvl.atkFx      = ldef.GetString("atk_fx");
                    lvl.atkFxTime  = ldef.GetFloat("atk_fx_time");
                    lvl.atkSound   = ldef.GetString("atk_sound");
                    lvl.missile    = ldef.GetString("missile");
                    lvl.firingTime = ldef.GetFloat("firing_time");
                }
            }
        }
예제 #5
0
        public void LoadFromDef(string id)
        {
            this.id = id;

            Hashtable def = Defs.GetBuff(this.id);

            this.name = def.GetString("name");

            this.campType        = ( CampType )def.GetInt("camp_type");
            this.targetFlag      = ( EntityFlag )def.GetInt("target_flag");
            this.rangeType       = ( RangeType )def.GetInt("range_type");
            this.spawnPoint      = ( SpawnPoint )def.GetInt("spawn_point");
            this.deadType        = ( DeadType )def.GetInt("dead_type");
            this.orbit           = ( Orbit )def.GetInt("orbit");
            this.autoScaleAreaFx = def.GetBoolean("auto_scale_area_fx");
            this.canInterrupt    = def.GetBoolean("can_interrupt");
            this.enterStates     = def.GetStringArray("enter_states");
            this.triggerStates   = def.GetStringArray("trigger_states");

            ArrayList lvls = def.GetList("level");

            if (lvls != null)
            {
                int count = lvls.Count;
                this.levels = new Level[count];
                for (int i = 0; i < count; i++)
                {
                    Level     lvl  = this.levels[i] = new Level();
                    Hashtable ldef = ( Hashtable )lvls[i];
                    lvl.radius   = ldef.GetFloat("radius");
                    lvl.areaFx   = ldef.GetString("area_fx");
                    lvl.extra    = ldef.GetFloatArray("extra");
                    lvl.extra_s  = ldef.GetStringArray("extra_s");
                    lvl.duration = ldef.GetFloat("duration");
                    lvl.speed    = ldef.GetFloat("speed");
                    int n = ldef.GetInt("max_trigger_targets");
                    lvl.maxTriggerTargets = n == 0 ? int.MaxValue : n;
                    n = ldef.GetInt("per_target_trigger_count");
                    lvl.perTargetTriggerCount = n == 0 ? int.MaxValue : n;
                    lvl.maxTriggerCount       = ldef.GetInt("max_trigger_count");
                    if (ldef.ContainsKey("trigger"))
                    {
                        lvl.trigger = new Trigger(ldef.GetMap("trigger"));
                    }
                    else if (this.triggerStates != null)
                    {
                        lvl.trigger = new Trigger();
                    }
                }
            }
        }
예제 #6
0
    public void SetFlag(string flagName, bool value)  //sets or creates a new flag with a name
    {
        EntityFlag newFlag = new EntityFlag(flagName, value);

        for (int i = 0; i < flagData.Count; i++)
        {
            if (flagData[i].name == newFlag.name)
            {
                flagData[i] = newFlag;
                return;
            }
        }
        flagData.Add(newFlag);
        return;
    }
예제 #7
0
    public virtual void UpdateDirty(Entity entity)
    {
        EntityFlag dirty = entity.Dirty;

        Dirty = dirty;

        if (dirty.HasFlag(EntityFlag.position))
        {
            Position = entity.Position;
            Rotation = entity.Rotation;
        }
        if (dirty.HasFlag(EntityFlag.visual))
        {
            MeshID     = entity.MeshID;
            MaterialID = entity.MaterialID;
        }
    }
예제 #8
0
        public static void FilterTarget(Bio self, CampType campType, EntityFlag targetFlag, ref List <Entity> targets, ref List <Entity> results)
        {
            int count = targets.Count;

            for (int i = 0; i < count; i++)
            {
                Bio target = targets[i] as Bio;
                if (target == null || target.isDead)
                {
                    continue;
                }

                //作为buff选择范围来进行筛选,隐身等状态应该被选中,因此这里不能使用CanAttack方法
                if (CheckCampType(self, campType, target) &&
                    CheckTargetFlag(targetFlag, target))
                {
                    results.Add(target);
                }
            }
        }
예제 #9
0
        public static bool CheckTargetFlag(EntityFlag targetFlag, VBio target)
        {
            if ((targetFlag & EntityFlag.Hero) > 0 &&
                (target.flag & EntityFlag.Hero) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.SmallPotato) > 0 &&
                (target.flag & EntityFlag.SmallPotato) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Structure) > 0 &&
                (target.flag & EntityFlag.Structure) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Missile) > 0 &&
                (target.flag & EntityFlag.Missile) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Effect) > 0 &&
                (target.flag & EntityFlag.Effect) > 0)
            {
                return(true);
            }

            if ((targetFlag & EntityFlag.Item) > 0 &&
                (target.flag & EntityFlag.Item) > 0)
            {
                return(true);
            }

            return(false);
        }
예제 #10
0
        // Flags
        // TODO: Code generation?

        public bool ContainsFlag(EntityFlag flag)
        {
            return(Bitmask.CheckBit(EntityFlags, (int)flag));
        }
        public Entity(EntityFlag Flag, bool companion)
        {
            Statistics = new StatusStatics();
            Companion = companion;
            this.EntityFlag = Flag;
            Mode = Enums.Mode.None;
            update = new PhoenixProject.Network.GamePackets.Update(true);
            update.UID = UID;
            switch (Flag)
            {
                case EntityFlag.Player:
                   /* MyTimer = new System.Timers.Timer(200);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack);
                    MyTimer.Start();

                    MyTimer = new System.Timers.Timer(1000);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack2);
                    MyTimer.Start();

                    MyTimer = new System.Timers.Timer(1000);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack3);
                    MyTimer.Start();

                      MyTimer = new System.Timers.Timer(1000);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack4);
                    MyTimer.Start();

                    MyTimer = new System.Timers.Timer(1000);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack5);
                    MyTimer.Start();

                    MyTimer = new System.Timers.Timer(100);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack6);
                    MyTimer.Start();*/

                    MapObjType = Game.MapObjectType.Player;
                    break;
                case EntityFlag.Monster:
                   /*  MyTimer = new System.Timers.Timer(200);
                    MyTimer.AutoReset = true;
                    MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack);
                    MyTimer.Start();*/
                    MapObjType = Game.MapObjectType.Monster;
                    break;
            }
        }
예제 #12
0
        internal void LoadFromDef(string id)
        {
            this.id = id;
            Hashtable def       = Defs.GetEntity(this.id);
            string    reference = def.GetString("ref");

            while (!string.IsNullOrEmpty(reference))
            {
                Hashtable refdef = Defs.GetEntity(reference);
                reference = refdef.GetString("ref");
                def.Concat(refdef);
            }
            this.name       = def.GetString("name");
            this.model      = def.GetString("model");
            this.noShadow   = def.GetBoolean("no_shadow");
            this.flag       = ( EntityFlag )def.GetInt("flag");
            this.size       = def.GetVec3("size");
            this.mass       = def.GetFloat("mass");
            this.volumetric = def.GetBoolean("volumetric");
            this.fov        = def.GetFloat("fov");
            this.speed      = def.GetFloat("speed");
            this.rotSpeed   = def.GetFloat("rot_speed");
            this.scale      = def.GetFloat("scale");
            if (this.scale <= 0)
            {
                this.scale = 1;
            }
            this.trackDistance  = def.GetFloat("track_distance");
            this.goldBase       = def.GetInt("gold_base");
            this.skillPointBase = def.GetInt("skill_point_base");
            if (def.ContainsKey("firing_point"))
            {
                this.firingPoint = def.GetVec3("firing_point");
            }
            if (def.ContainsKey("hit_point"))
            {
                this.hitPoint = def.GetVec3("hit_point");
            }
            this.destructImmediately = def.GetBoolean("destruct_immediately");
            this.lifeTime            = def.GetFloat("life_time");

            this.skills = def.GetStringArray("skills");

            ArrayList lvls = def.GetList("level");

            if (lvls != null)
            {
                int count = lvls.Count;
                this.levels = new Level[count];
                for (int i = 0; i < count; i++)
                {
                    Level     lvl  = this.levels[i] = new Level();
                    Hashtable ldef = ( Hashtable )lvls[i];
                    lvl.mhp                       = ldef.GetFloat("hp");
                    lvl.mmana                     = ldef.GetFloat("mana");
                    lvl.hpRegen                   = ldef.GetFloat("hp_regen");
                    lvl.manaRegen                 = ldef.GetFloat("mana_regen");
                    lvl.ad                        = ldef.GetFloat("ad");
                    lvl.armor                     = ldef.GetFloat("armor");
                    lvl.armorPenFlat              = ldef.GetFloat("armor_pen_flat");
                    lvl.armorPen                  = ldef.GetFloat("armor_pen");
                    lvl.ap                        = ldef.GetFloat("ap");
                    lvl.magicResist               = ldef.GetFloat("magic_resist");
                    lvl.magicPenFlat              = ldef.GetFloat("magic_pen_flat");
                    lvl.magicPen                  = ldef.GetFloat("magic_pen");
                    lvl.reliveTime                = ldef.GetInt("relive_time");
                    lvl.reliveGold                = ldef.GetInt("relive_gold");
                    lvl.goldBountyAwarded         = ldef.GetInt("gold_bounty_awarded");
                    lvl.expBountyAwarded          = ldef.GetInt("exp_bounty_awarded");
                    lvl.upgradeExpNeeded          = ldef.GetInt("upgrade_exp_needed");
                    lvl.upgradeSkillPointObtained = ldef.GetInt("upgrade_skill_point_obtained");
                    lvl.upgradeGoldObtained       = ldef.GetInt("upgrade_gold_obtained");
                }
            }

            this.aiDatas = AIData.Parse(def.GetList("ai"));
            this.script  = def.GetString("script");

            //missile
            this.flightType = ( FlightType )def.GetInt("flight_type");
            this.duration   = def.GetFloat("duration");
            this.arc        = def.GetFloat("arc");
            this.hitFx      = def.GetString("hit_fx");

            //effect
            this.shaderName    = def.GetString("shader_name");
            this.shadowVisible = def.GetBoolean("shadow_visible");
            this.positionType  = ( EffectPositionType )def.GetInt("position_type");
            this.rotationType  = ( EffectRotationType )def.GetInt("rotation_type");
            this.spare         = ( Spare )def.GetInt("spare");
        }
예제 #13
0
 public static int SetBit(int value, EntityFlag flag)
 {
     return(value |= (int)flag);
 }
예제 #14
0
 public static int ResetBit(int value, EntityFlag flag)
 {
     return(value &= ~(int)flag);
 }
예제 #15
0
 public static bool CheckBit(int value, EntityFlag flag)
 {
     return((value & (int)flag) != 0);
 }
예제 #16
0
        public static Bio GetNearestTarget(List <Entity> entities, Bio self, float radius, CampType campType, EntityFlag targetFlag)
        {
            GetEntitiesInCircle(entities, self.property.position, radius, ref _temp);

            float minDistance = float.MaxValue;
            Bio   nearest     = null;
            int   count       = _temp.Count;

            for (int i = 0; i < count; i++)
            {
                Bio target = _temp[i] as Bio;
                if (target == null || !CanAttack(self, target, campType, targetFlag))
                {
                    continue;
                }

                float d = (self.property.position - target.property.position).SqrMagnitude();
                if (d < minDistance)
                {
                    minDistance = d;
                    nearest     = target;
                }
            }

            _temp.Clear();
            return(nearest);
        }
예제 #17
0
파일: Entity.cs 프로젝트: AiiMz/PserverWork
        public Entity(EntityFlag Flag, bool companion)
        {
            Statistics = new StatusStatics();
            Companion = companion;
            this.EntityFlag = Flag;
            Mode = Enums.Mode.None;
            update = new Conquer_Online_Server.Network.GamePackets.Update(true);
            update.UID = UID;
            switch (Flag)
            {
                case EntityFlag.Player:
                       MyTimer = new System.Timers.Timer(interval);
                        MyTimer.AutoReset = true;
                        MyTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerCallBack);
                        MyTimer.Start();

                    MapObjType = Game.MapObjectType.Player;
                    break;
                case EntityFlag.Monster: MapObjType = Game.MapObjectType.Monster; break;
            }
        }
예제 #18
0
 public void SetFlag(EntityFlag flag, bool value)
 {
     EntityFlags = Bitmask.SetBitTo(EntityFlags, (int)flag, value ? 1 : 0);
 }
예제 #19
0
        public override bool ParseBytesAndExecute(byte[] data)
        {
            if (data.Length != 8 + 1 + 4)
            {
                return(false);
            }
            long   eid = Utilities.BytesToLong(Utilities.BytesPartial(data, 0, 8));
            Entity e   = TheClient.TheRegion.GetEntity(eid);

            if (e == null)
            {
                return(true); // Don't disconnect, could be a minor flaw.
            }
            EntityFlag flag  = (EntityFlag)data[8];
            float      value = Utilities.BytesToFloat(Utilities.BytesPartial(data, 8 + 1, 4));

            // TODO: Registry -> byte -> Func<Entity, float>
            switch (flag)
            {
            case EntityFlag.FLYING:
                if (e is PlayerEntity)
                {
                    if (value > 0.5f)
                    {
                        ((PlayerEntity)e).Fly();
                    }
                    else
                    {
                        ((PlayerEntity)e).Unfly();
                    }
                }
                else if (e is CharacterEntity)
                {
                    // TODO

                    /*
                     * if (value > 0.5f)
                     * {
                     *  ((CharacterEntity)e).Fly();
                     * }
                     * else
                     * {
                     *  ((CharacterEntity)e).Unfly();
                     * }
                     */
                }
                else
                {
                    throw new Exception("Flagged non-player entity as flying!");
                }
                break;

            case EntityFlag.MASS:
                if (e is PhysicsEntity)
                {
                    ((PhysicsEntity)e).SetMass(value);
                }
                else
                {
                    throw new Exception("Flagged non-physics entity with a specific mass!");
                }
                break;

            case EntityFlag.HAS_FUEL:
                if (e is CharacterEntity)
                {
                    ((CharacterEntity)e).HasFuel = value >= 0.5f;
                }
                else
                {
                    throw new Exception("Flagged non-charcter entity with a specific mass!");
                }
                break;

            case EntityFlag.HELO_TILT_MOD:
                if (e is ModelEntity)
                {
                    ((ModelEntity)e).HeloTiltMod = value;
                }
                else
                {
                    throw new Exception("Flagged non-model entity with a specific helo tilt mod!");
                }
                break;

            default:
                throw new Exception("Unknown flag!");
            }

            return(true);
        }