示例#1
0
        public void Initialize(LogicUnit owner, ProjectileProto proto, long id, FixVector3 position, LogicUnit target)
        {
            this.id       = id;
            this.type     = LogicUnitType.Projectile;
            this.owner    = owner;
            this.mark     = owner.mark;
            this.position = position;
            this.target   = target;
            targetId      = target.id;

            metaId      = proto.ID;
            modelId     = proto.Projectile_ResouceId;
            hitEffectId = proto.HitEffect_ResourceId;

            speedFactor = ConvertUtils.ToLogicInt(proto.SpeedFactor);

            damage = owner.damage;

            projectileType     = (ProjectileType)proto.ProjectileType;
            startPosition      = position;
            targetPosition     = target.position;
            speed              = (targetPosition - position).normalized * speedFactor;
            transform.position = position.vector3;
            state              = ProjectileState.Flying;
            targetDistance     = 0;
            destination        = target.position;

            // Temp data
            hurtType = AttackPropertyType.PhysicalAttack;

            DebugUtils.Log(DebugUtils.Type.AI_Projectile, "the projectile " + id + "'s target is " + target.id + ", speed = " + position);
        }
示例#2
0
        public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
        {
            if (Alive())
            {
                int value = GetActualHurtValue(hurtType, hurtValue);
                hp -= value;

                RenderMessage message = new RenderMessage();
                message.type     = RenderMessage.Type.NpcHurt;
                message.ownerId  = id;
                message.position = transform.position;
                message.arguments.Add("value", value);
                PostRenderMessage(message);

                if (hp <= 0)
                {
                    injurer.OnKillEnemy(killReward, injurer, this);
                    Dying();
                }
                else
                {
                    Attack(injurer);
                }
            }
        }
示例#3
0
        private void InitializedData()
        {
            UnitProto proto = DataManager.GetInstance().unitsProtoData.Find(p => p.ProfessionType == (int)ProfessionType.TramcarType);

            metaId         = proto.ID;
            modelId        = proto.Model;
            iconId         = proto.Icon;
            modelRadius    = ConvertUtils.ToLogicInt(proto.ModelRadius);
            deploymentCost = proto.DeploymentCost;
            maxHp          = proto.Health;
            armor          = proto.Armor;
            magicResist    = proto.MagicResist;
            speedFactor    = ConvertUtils.ToLogicInt(proto.MoveSpeed);
            moveMode       = (PathType)proto.MoveMode;
            chaseArea      = 100;// defalut whole map
            attackArea     = ConvertUtils.ToLogicInt(proto.AttackRange);
            miningInterval = ConvertUtils.ToLogicInt(proto.AttackInterval);
            emberHarvest   = proto.EmberHarvest;
            attackRadius   = ConvertUtils.ToLogicInt(proto.AttackRadius);
            killReward     = proto.killReward;
            healthRegen    = proto.HealthRegen;

            hurtType = AttackPropertyType.None;
            hp       = maxHp;

            healthRegenInterval = GameConstants.HP_RECOVERY_INTERVAL_MILLISECOND;
        }
示例#4
0
        private void InitializedData()
        {
            UnitProto proto = DataManager.GetInstance().unitsProtoData.Find(p => p.ProfessionType == (int)ProfessionType.DemolisherType);

            metaId         = proto.ID;
            modelId        = proto.Model;
            iconId         = proto.Icon;
            modelRadius    = ConvertUtils.ToLogicInt(proto.ModelRadius);
            deploymentCost = proto.DeploymentCost;
            maxHp          = proto.Health;
            armor          = proto.Armor;
            magicResist    = proto.MagicResist;
            speedFactor    = ConvertUtils.ToLogicInt(proto.MoveSpeed);
            moveMode       = (PathType)proto.MoveMode;
            chaseArea      = 100;// default all unit
            attackArea     = ConvertUtils.ToLogicInt(proto.AttackRange);
            attackInterval = ConvertUtils.ToLogicInt(proto.AttackInterval);
            damage         = (int)proto.PhysicalAttack;
            damageVar      = ConvertUtils.ToLogicInt(proto.MeleeDmgVar);
            attackRadius   = ConvertUtils.ToLogicInt(proto.AttackRadius);
            structAddition = ConvertUtils.ToLogicInt(proto.StrctDmgMult);
            killReward     = proto.killReward;
            healthRegen    = proto.HealthRegen;

            hurtType = AttackPropertyType.PhysicalAttack;
            hp       = maxHp;

            healthRegenInterval = GameConstants.HP_RECOVERY_INTERVAL_MILLISECOND;
        }
示例#5
0
        public void Initialize(long id, NpcData proto, FixVector3 p, FixVector3 r)
        {
            this.id = id;

            type = LogicUnitType.NPC;

            position = p;

            transform.position = p.vector3;
            transform.rotation = Quaternion.Euler(r.vector3);

            brithPosition  = p;
            brithDirection = r;
            hurtType       = AttackPropertyType.PhysicalAttack;

            npcProto       = proto;
            iconId         = -1;
            metaId         = proto.ID;
            modelId        = proto.ModelID;
            modelRadius    = ConvertUtils.ToLogicInt(proto.ModelRadius);
            npcType        = (NpcType)proto.NPCType;
            attackType     = (NpcAttackType)proto.StandardAttack;
            rebornInterval = ConvertUtils.ToLogicInt(proto.RebornInterval);
            physicasAttack = (int)proto.PhysicsAttack;
            armor          = (int)proto.Armor;
            magicResist    = (int)proto.MagicResist;
            speedFactor    = ConvertUtils.ToLogicInt(proto.Speed);
            healthRegen    = proto.HealthRegen;

            maxHp            = proto.Health;
            chaseArea        = ConvertUtils.ToLogicInt(proto.TargetDetectRange);
            maxChaseDistance = ConvertUtils.ToLogicInt(proto.MaxChaseDistance);
            emberOutPut      = proto.EmberOutPut;
            projectileId     = proto.ProjectileId;
            attackRange      = ConvertUtils.ToLogicInt(proto.AttackRange);
            killReward       = proto.KillReward;
            attackDuration   = ConvertUtils.ToLogicInt(proto.AttackDuration);
            attackHitTime    = ConvertUtils.ToLogicInt(proto.AttackHitDuration);
            fightInterval    = 1;

            hp     = maxHp;
            damage = physicasAttack;
            healthRecoverInterval = GameConstants.HP_RECOVERY_INTERVAL_MILLISECOND;

            InitializeState();
            InitializePathAgent();

            debuffHandler = new DebuffHandler();
            buffHandler   = new BuffHandler();

            state      = NpcState.IDLE;
            currentFsm = fsmIdle;
        }
示例#6
0
        protected int GetActualHurtValue(AttackPropertyType type, int hurtValue)
        {
            int value = 0;

            if (type == AttackPropertyType.PhysicalAttack)
            {
                value = Formula.ActuallyPhysicalDamage(hurtValue, armor);
            }
            else if (type == AttackPropertyType.MagicAttack)
            {
                value = Formula.ActuallyMagicDamage(hurtValue, magicResist);
            }
            else
            {
                DebugUtils.LogError(DebugUtils.Type.AI_Npc, string.Format("Can't handle this hurtType {0} now!", type));
            }

            return(value);
        }
示例#7
0
        private int GetTowerActualHurtValue(AttackPropertyType type, int hurtValue)
        {
            int value = 0;

            if (type == AttackPropertyType.PhysicalAttack)
            {
                value = Formula.ActuallyPhysicalDamage(hurtValue, physicalResistance);
            }
            //else if ( type == HurtType.MagicAttack )
            //{
            //	value = (int)( hurtValue / ( magicResistance / 100 + 1 ) );
            //}
            else
            {
                DebugUtils.LogError(DebugUtils.Type.AI_Tower, string.Format("Can't handle this hurtType {0} now!", type));
            }

            return(value);
        }
示例#8
0
        public void Initialize(long id, NpcData proto, FixVector3 p, FixVector3 r)
        {
            this.id = id;

            type = LogicUnitType.Idol;

            position           = p;
            transform.position = p.vector3;
            brithPosition      = p;
            brithDirection     = r;
            hurtType           = AttackPropertyType.PhysicalAttack;

            npcProto         = proto;
            metaId           = proto.ID;
            iconId           = -1;
            modelId          = proto.ModelID;
            modelRadius      = ConvertUtils.ToLogicInt(proto.ModelRadius);
            npcType          = (NpcType)proto.NPCType;
            attackType       = (NpcAttackType)proto.StandardAttack;
            rebornInterval   = ConvertUtils.ToLogicInt(proto.RebornInterval);
            physicasAttack   = (int)proto.PhysicsAttack;
            armor            = (int)proto.Armor;
            magicResist      = (int)proto.MagicResist;
            speedFactor      = proto.Speed;
            healthRegen      = proto.HealthRegen;
            maxHp            = proto.Health;
            chaseArea        = proto.TargetDetectRange;
            maxChaseDistance = proto.MaxChaseDistance;
            emberOutPut      = proto.EmberOutPut;
            projectileId     = proto.ProjectileId;
            attackRange      = proto.AttackRange;
            killReward       = proto.KillReward;
            fightInterval    = 1;

            hp     = maxHp;
            damage = physicasAttack;

            InitializeState();

            state      = IdolState.IDLE;
            currentFsm = fsmIdle;
            ChangeState(IdolState.IDLE, fsmIdle);
        }
示例#9
0
        public override void Hurt(int hurtValue, AttackPropertyType type, bool isCrit, LogicUnit injurer)
        {
            if (Alive())
            {
                int value = GetActualHurtValue(hurtValue, hurtType);
                hp -= value;
                RenderMessage message = new RenderMessage();
                message.type    = RenderMessage.Type.DemolisherHurt;
                message.ownerId = id;
                message.arguments.Add("value", hurtValue);
                PostRenderMessage(message);

                if (hp <= 0)
                {
                    injurer.OnKillEnemy(killReward, injurer, this);
                    ChangeState(DemolisherState.DYING, fsmDying);
                }
            }
        }
示例#10
0
        private int GetInstituteActualHurtValue(AttackPropertyType type, int hurtValue)
        {
            int value = 0;

            if (type == AttackPropertyType.PhysicalAttack)
            {
                value = Formula.ActuallyPhysicalDamage(hurtValue, physicalResistance);
            }
            //Building can't be magicAttack( design ),When we need open here
            //else if ( type == HurtType.MagicAttack )
            //{
            //	value = (int)( hurtValue / ( magicResistance / 100 + 1 ) );
            //}
            else
            {
                DebugUtils.LogError(DebugUtils.Type.Building, string.Format("Can't handle this hurtType {0} now!", type));
            }

            return(value);
        }
示例#11
0
        public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
        {
            if (Alive())
            {
                int value = GetInstituteActualHurtValue(hurtType, hurtValue);
                hp -= value;
                RenderMessage message = new RenderMessage();
                message.type     = RenderMessage.Type.InstituteHurt;
                message.ownerId  = this.id;
                message.position = position.vector3;
                message.arguments.Add("value", value);
                PostRenderMessage(message);

                if (hp <= 0)
                {
                    injurer.OnKillEnemy(destroyReward, injurer, this);
                    Destroy();
                }
            }
        }
示例#12
0
        public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
        {
            if (Alive())
            {
                if (hurtType == AttackPropertyType.PhysicalAttack)
                {
                    int v = GetTowerActualHurtValue(hurtType, hurtValue);
                    hp -= v;

                    RenderMessage message = new RenderMessage();
                    message.type     = RenderMessage.Type.TowerHurt;
                    message.ownerId  = id;
                    message.position = position.vector3;
                    message.arguments.Add("value", v);
                    PostRenderMessage(message);

                    if (hp <= 0)
                    {
                        injurer.OnKillEnemy(killReward, injurer, this);
                        Destroy();
                    }
                }
            }
        }
示例#13
0
 public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
 {
     DebugUtils.Assert(false, "Hurt() in Trap is not implemented!");
 }
示例#14
0
 public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
 {
     DebugUtils.Assert(false, "Movable unit didn't implement Hurt()");
 }
示例#15
0
 public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
 {
 }
示例#16
0
 public abstract void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer);