예제 #1
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
     town.OnKillEnemy(emberReward, this, dead);
 }
예제 #2
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
     DebugUtils.Assert(false, " Idol didn't implement OnKillEnemy() method ");
 }
예제 #3
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();
                    }
                }
            }
        }
예제 #4
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
     DebugUtils.Assert(false, "OnKillEnemy() in Institute is not implemented!");
 }
예제 #5
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
     // TODO: Idol Guard will do nothing when kill enemy
 }
예제 #6
0
        private void BattryFight(int deltaTime)
        {
            if (inFightInterval)
            {
                // Timing interval
                fightIntervalTimer += deltaTime;

                if (fightIntervalTimer >= fightInterval)
                {
                    // Enter fight
                    fightState         = FightState.StartSwingPoint;
                    fightIntervalTimer = 0;
                    fightInterval      = 0;
                    inFightInterval    = false;
                }
            }
            else
            {
                fightState          = GetCurrentState(fightDurationTimer);
                fightDurationTimer += deltaTime;

                if (fightState == FightState.StartSwingPoint)
                {
                    DebugUtils.Assert(target.id == targetId, string.Format("Fight Status : the soldier {0}'s targetId = {1}, but its target's id = {2}!", owner.id, targetId, target.id));

                    if (owner.stateListener.PostFightEvent())
                    {
                        // Trigger skill, will interrupt fight.
                        return;
                    }
                    else
                    {
                        hitTime       = owner.attackHitTime;
                        fightDuration = owner.attackDuration;

                        // Reset direction at attack begin.
                        FixVector3 direction = target.position - owner.position;
                        owner.direction = direction;

                        RenderMessage rm = new RenderMessage();
                        rm.type      = RenderMessage.Type.SoldierBatteryFire;
                        rm.ownerId   = owner.id;
                        rm.direction = direction.vector3;
                        rm.arguments.Add("projectileMetaId", owner.projectileId);
                        rm.arguments.Add("intervalRate", 1);
                        owner.PostRenderMessage(rm);
                    }
                }
                else if (fightState == FightState.HitPoint)
                {
                    bool isCrit = Formula.TriggerCritical(owner.GetRandomNumber(), owner.GetCriticalChance());
                    owner.Fight(isCrit);
                    owner.stateListener.PostUnitFightAfter();
                }
                else if (fightState == FightState.BackSwing)
                {
                    if (fightDurationTimer >= fightDuration)
                    {
                        fightDurationTimer = 0;

                        fightInterval   = owner.GetAttackInterval() - fightDuration;
                        inFightInterval = true;
                    }
                }
            }

            long distance       = FixVector3.SqrDistance(target.position, owner.position);
            long attackDistance = owner.GetAttackArea();

            if (distance >= attackDistance)
            {
                if ((target.position - owner.targetPosition).magnitude > attackDistance)
                {
                    target = null;
                }
                else
                {
                    // continue fight
                }
            }
        }
예제 #7
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.CrystalCarHurt;
                message.ownerId = id;
                message.arguments.Add("value", value);
                PostRenderMessage(message);

                if (hp <= 0)
                {
                    injurer.OnKillEnemy(killReward, injurer, this);
                    Dying();
                }
            }
        }
예제 #8
0
 public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
 {
 }
예제 #9
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
 }
예제 #10
0
        private void SprintState(int deltaTime)
        {
            LogicUnit  target   = owner.target;
            FixVector3 position = owner.position;
            PathAgent  agent    = owner.pathAgent;

            if (target != null && target.Alive() && target.id == owner.target.id)
            {
                if (FixVector3.SqrDistance(target.position, owner.targetPosition) > GameConstants.BEGINCHASE_DISTANCE)     // 5f is a testing distance
                {
                    // if target leave the position too far, need to refresh chase path
                    owner.targetPosition = target.position;
                    owner.FindChasePath(owner.target.position);
                    return;
                }

                if (TargetWithInAttackArea())
                {
                    if (target != null && target.Alive() && target.id == owner.target.id)
                    {
                        if (playerOwner)
                        {
                            FixVector3 direction   = (target.position - position).normalized;
                            FixVector3 destination = owner.position + direction * 5f;// Temp distance.

                            FixVector3 hitPosition      = FixVector3.zero;
                            FixVector3 simpleOnMapPoint = FixVector3.zero;

                            // mapping destination on navmesh
                            bool sampleResult = agent.SamplePosition(destination, out simpleOnMapPoint);
                            if (sampleResult)
                            {
                                destination = simpleOnMapPoint;
                            }

                            bool result = agent.Raycast(destination, out hitPosition);
                            if (result)
                            {
                                destination = hitPosition;
                            }

                            DataManager clientData = DataManager.GetInstance();

                            UpdateC2S message = new UpdateC2S();
                            message.timestamp = clientData.GetFrame();
                            Operation op = new Operation();
                            op.playerId       = clientData.GetPlayerId();
                            op.unitId         = id;
                            op.targetId       = owner.id;                              // test
                            op.unitMetaId     = metaId;                                // test
                            op.opType         = OperationType.SyncSkillTargetPosition; // wrong type
                            op.x              = destination.vector3.x;
                            op.y              = destination.vector3.y;
                            op.z              = destination.vector3.z;
                            message.operation = op;
                            PostBattleMessage(MsgCode.UpdateMessage, message);

                            DebugUtils.Log(DebugUtils.Type.AI_Skill, string.Format("YueGuangChongCi sync destination : {0}", destination));
                        }
                    }
                    else
                    {
                        Stop();
                    }
                }
                else
                {
                    if (!owner.CurrentPathAlreadyFinished())
                    {
                        owner.WaypointHandler();
                        FixVector3 d = owner.speed * deltaTime;
                        agent.Move(d);
                    }
                    else
                    {
                        // wait for chase path
                    }
                }
            }
            else
            {
                // Skill will be shut down when target death.
                Stop();
                owner.Idle();
            }
        }
예제 #11
0
 public virtual void Attack(LogicUnit unit)
 {
     target = unit;
     ChangeState(SummonedUnitState.Fight);
 }
예제 #12
0
 public abstract void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead);
예제 #13
0
 public abstract void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer);
예제 #14
0
 public override void Hurt(int hurtValue, AttackPropertyType hurtType, bool isCrit, LogicUnit injurer)
 {
     DebugUtils.Assert(false, " Skill didn't implement Hurt ");
 }
예제 #15
0
        public override void Update(int deltaTime)
        {
            int state = owner.state;

            DebugUtils.Assert(state == SoldierState.CHASING, string.Format("Soldier {0} is in state {1} when updating in FsmChase!", owner.id, state));

            LogicUnit  target   = owner.target;
            FixVector3 position = owner.position;
            PathAgent  agent    = owner.pathAgent;

            if (target != null && target.Alive() && target.id == owner.targetId)
            {
                long mag = FixVector3.SqrDistance(target.position, owner.targetPosition);
                //Debug.LogWarning( string.Format( "current position:{0} record position:{1} length:{2}", target.position, owner.targetPosition, mag ) );

                if (mag > GameConstants.BEGINCHASE_DISTANCE)   // 5f is a testing distance
                {
                    //Debug.Log( string.Format( "current position:{0} record position:{1} length:{2}", target.position, owner.targetPosition, mag ) );
                    owner.Chase(owner.target);
                    return;
                }

                owner.WaypointHandler();

                FixVector3 d           = owner.speed * deltaTime;
                FixVector3 newPosition = position + d * FixVector3.PrecisionFactor * FixVector3.PrecisionFactor * FixVector3.PrecisionFactor;
                FixVector3 avoidance   = owner.CalculateAvoidance(owner, newPosition);

                if (avoidance != FixVector3.zero && subState != CHASE2AVOIDANCE)
                {
                    DebugUtils.LogWarning(DebugUtils.Type.AI_Soldier, string.Format("soldier {0} enters CHASE2AVOIDANCE.", owner.id));
                    subState = CHASE2AVOIDANCE;
                    DebugUtils.Log(DebugUtils.Type.Avoidance, string.Format("CHASE : soldier {0} has received an avoidance ({1}, {2}, {3}), he's speed is ({4}, {5}, {6})!", owner.id, avoidance.x, avoidance.y, avoidance.z, owner.speed.x, owner.speed.y, owner.speed.z));
                    avoidSpeed = d + avoidance * deltaTime;
                    FixVector3 pos  = position + avoidSpeed * FixVector3.PrecisionFactor * FixVector3.PrecisionFactor;
                    bool       pass = agent.DirectPassToPosition(pos, NavMesh.AllAreas);
                    if (pass)
                    {
                        agent.Move(avoidSpeed);
                        DebugUtils.Log(DebugUtils.Type.Avoidance, string.Format("CHASE : soldier {0} has received an avoidance and moved to ({1}, {2}, {3})!", owner.id, owner.position.x, owner.position.y, owner.position.z));
                    }
                    else
                    {
                        //still here.
                        DebugUtils.Log(DebugUtils.Type.Avoidance, string.Format("CHASE : soldier {0} has stopped when avoiding others!", owner.id));
                    }
                }
                else
                {
                    if (subState == CHASE2AVOIDANCE)
                    {
                        if (avoidance != FixVector3.zero)
                        {
                            avoidSpeed = d + avoidance * deltaTime;
                            //Vector3 pos = position + avoidSpeed * FixVector3.PrecisionFactor * FixVector3.PrecisionFactor;
                            //bool pass = agent.DirectPassToPosition( pos, NavMesh.AllAreas );
                            if (true)  //pass )
                            {
                                agent.ToughMove(avoidSpeed);
                                DebugUtils.Log(DebugUtils.Type.Avoidance, string.Format("CHASE : soldier {0} has received an avoidance and moved to ({1}, {2}, {3})!", owner.id, owner.position.x, owner.position.y, owner.position.z));
                            }
                            else
                            {
                                //still here.
                                DebugUtils.Log(DebugUtils.Type.Avoidance, string.Format("CHASE : soldier {0} has stopped when avoiding others!", owner.id));
                            }
                        }
                        else
                        {
                            DebugUtils.LogWarning(DebugUtils.Type.AI_Soldier, string.Format("soldier {0} enters AVOIDANCE2CHASE.", owner.id));
                            subState = AVOIDANCE2CHASE;

                            agent.Move(d);
                        }
                    }
                    else
                    {
                        agent.Move(d);
                    }
                }

                position = owner.position;
                FixVector3 v              = target.position;
                long       distance       = FixVector3.SqrDistance(target.position, position);
                long       attackDistance = owner.GetAttackArea();

                if (distance < attackDistance)
                {
                    owner.Attack(owner.target);
                }

                /*
                 * else if( distance > chaseArea * chaseArea * 1.5f )
                 * {
                 *  DebugUtils.LogWarning( DebugUtils.Type.AI_Soldier, string.Format( "soldier {0}'s target {1} has escaped! distance = {2}, chaseArea * chaseArea * 1.5f = {3}", id, target.id, distance, chaseArea * chaseArea * 1.5f ) );
                 *  //Idle();
                 *  Walk( destination );
                 * }
                 */

                if (owner.stateListener.PostMoveDistanceChanged(d.magnitude))
                {
                    return;
                }

                owner.stateListener.PostChasingStateChanged(distance);
            }
            else
            {
                owner.Idle();
                //Walk( destination );
            }
        }
예제 #16
0
 public override void Reset()
 {
     PostDestroy = null;
     target      = null;
 }
예제 #17
0
        public override void Attach(LogicUnit g, LogicUnit t)
        {
            base.Attach(g, t);

            // TODO: about this debuff need more detail
        }
예제 #18
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();
                }
            }
        }
예제 #19
0
 public override void Hurt(int hurtValue, AttackPropertyType type, bool isCrit, LogicUnit injurer)
 {
     DebugUtils.Assert(false, "Hurt() in Projectile is not implemented!");
 }
예제 #20
0
 public override void OnKillEnemy(int emberReward, LogicUnit killer, LogicUnit dead)
 {
     town.AddCoin(emberReward);
 }