示例#1
0
        public override void collide(ScreenObject collider, TimeSpan timeSpan)
        {
            float shimmy = (float)timeSpan.TotalMilliseconds * _speed;

            if (collider == _killer || _state == STATE_DEAD || _state == STATE_DYING)
                return;
            if (collider is Terrain)
            {
                terrainCollider = (Terrain)collider;
            }
            else if (collider is Shot && collider.getSide() != _side && !(collider is Pavise) && collider.getState() != STATE_DEAD && collider.getState() != Shot.STATE_GROUND)
            {
                if (this is Targeteer)
                {
                    if (collider is ArquebusierShot || (collider is CrossbowShot && collider.getSide() == BattleScreen.SIDE_PLAYER))
                        ((Targeteer)this).shieldBreak();
                    else
                        ((Targeteer)this).shieldBlock();
                }
                else if (this is CrossbowmanPavise)
                {
                    if (_side == BattleScreen.SIDE_PLAYER)
                        ((CrossbowmanPavise)this).shieldBlock();
                    else
                        hit();
                }
                else if (!(this is Leader) && (this._side == BattleScreen.SIDE_ENEMY || _screen.getPlayerFormation() == this.myFormation))
                    hit();

                ((Shot)collider).hit();

                _killer = collider;
            }
            else if ((collider is PikeTip && collider.getSide() != _side) && (_state != STATE_DEAD && _state != STATE_DYING && _state != STATE_ROUTE && _state != STATE_ROUTED))
            {
                if (((PikeTip)collider).getSoldierState() == Pikeman.STATE_LOWERED)
                {
                    if (!(this is Targeteer) && !(this is Wolf) && _side != BattleScreen.SIDE_NEUTRAL)
                    {
                        hit();
                        _killer = collider;
                        ((PikeTip)collider).getPikeman().recoil();
                    }
                    else if (this is Targeteer)
                    {
                        if ( (!(this is Colmillos) && ((Targeteer)this)._hasShield) || (this is Colmillos && !((ColmillosFormation)((Colmillos)this).myFormation).attacked))
                        {
                            ((Targeteer)this).shield();
                            this.setReactionDest(collider.getCenter().X + 50f);//((collider.getSide() == BattleScreen.SIDE_ENEMY? 1 : -1 ) * collider.getWidth() * 0.5f + Soldier.WIDTH * 0.35f
                        }
                        else
                        {
                            hit();
                            _killer = collider;
                            ((PikeTip)collider).getPikeman().recoil();
                        }
                    }
                }
            }
            else if ((collider is WeaponSwing && collider.getSide() != _side) && (_state != STATE_DEAD && _state != STATE_DYING && _state != STATE_ROUTE && _state != STATE_ROUTED))
            {
                if (((WeaponSwing)collider).getSoldier() is Colmillos)
                {
                    if (!((WeaponSwing)collider).hit)
                    {
                        if (this is Targeteer)
                            ((Targeteer)this).shieldBreak();
                        else
                        {
                            hit();
                            _killer = collider;
                        }
                        ((WeaponSwing)collider).hit = true;
                        _screen.removeScreenObject(collider);
                    }

                }
                else if (this is Targeteer)
                    ((Targeteer)this).shieldBreak();
                else
                {
                    hit();
                    _killer = collider;
                }
            }
            else if ((collider is LanceTip && collider.getSide() != _side) && (_state != STATE_DEAD && _state != STATE_DYING && _state != STATE_MELEE_WIN && _state != STATE_MELEE_LOSS && _state != STATE_ROUTE && _state != STATE_ROUTED))
            {
                if (this is Targeteer)
                    ((Targeteer)this).shieldBreak();
                else
                    hit();
                ((LanceTip)collider).getCavalry().recoil();
                _killer = collider;
            }
            else if (collider is Soldier)
            {
                bool colliderInFormation = false;
                bool thisInFormation = false;
                if (_screen.getPlayerFormation() != null && _screen.getPlayerFormation().getSoldiers() != null)
                {
                    colliderInFormation = ((Soldier)collider).myFormation == _screen.getPlayerFormation();
                    thisInFormation = myFormation == _screen.getPlayerFormation();
                }
                if (_state != STATE_DEAD && _state != STATE_DYING && _state != STATE_MELEE_WIN && _state != STATE_MELEE_LOSS && (!(this is Targeteer) || _state != Targeteer.STATE_SHIELDBREAK) && (!(this is DismountedCavalry) || _state != DismountedCavalry.STATE_FALLING))
                {
                    if (this is CrossbowmanPavise && collider is CrossbowmanPavise
                        && (this._state == STATE_CHARGING || this._state == STATE_RELOADING || this._state == STATE_ATTACKING || this._state == CrossbowmanPavise.STATE_PLACING || this._state == CrossbowmanPavise.STATE_RETRIEVING)
                        && (collider.getState() == STATE_CHARGING || collider.getState() == STATE_RELOADING || collider.getState() == STATE_ATTACKING || collider.getState() == CrossbowmanPavise.STATE_PLACING || collider.getState() == CrossbowmanPavise.STATE_RETRIEVING))
                    {
                        Vector2 changeVector = new Vector2(0f, (float)timeSpan.TotalMilliseconds * _speed);
                        ((CrossbowmanPavise)this).postRetrieveState = _state;
                        ((CrossbowmanPavise)this).paviseRetrieve();
                        if (this._position.Y < collider._position.Y)
                        {
                            this._position -= changeVector;
                            ((CrossbowmanPavise)this)._meleeDestination -= changeVector;
                            ((CrossbowmanPavise)this).chargePosition -= changeVector;
                        }
                        else
                        {
                            this._position += changeVector;
                            ((CrossbowmanPavise)this)._meleeDestination += changeVector;
                            ((CrossbowmanPavise)this).chargePosition += changeVector;
                        }
                    }
                    //push from collisions with other charging enemy soldiers
                    else if (myFormation == null && ((Soldier)collider).myFormation == null
                        && _side == BattleScreen.SIDE_ENEMY && collider.getSide() == BattleScreen.SIDE_ENEMY
                        && (collider.getState() != STATE_DYING && collider.getState() != STATE_DEAD))
                    {
                        if (this._position.Y < collider._position.Y)
                        {
                            this._position -= new Vector2(0f, (float)timeSpan.TotalMilliseconds * _speed);
                        }
                        else
                        {
                            this._position += new Vector2(0f, (float)timeSpan.TotalMilliseconds * _speed);
                        }
                    }
                    else
                    {
                        if (!((collider.getSide() == BattleScreen.SIDE_NEUTRAL && _side == BattleScreen.SIDE_PLAYER) || (collider.getSide() == BattleScreen.SIDE_PLAYER && _side == BattleScreen.SIDE_NEUTRAL)))
                        {
                            //fighting
                            if (_side != collider.getSide() && !(this is Leader || collider is Leader) && collider.getState() != STATE_DEAD && collider.getState() != STATE_DYING && collider.getState() != STATE_MELEE_WIN && collider.getState() != STATE_MELEE_LOSS && (!(collider is Targeteer) || collider.getState() != Targeteer.STATE_SHIELDBREAK) && (!(collider is DismountedCavalry) || collider.getState() != DismountedCavalry.STATE_FALLING) && (!(collider is Wolf) || collider.getState() != Wolf.STATE_KILL) && (!(this is Wolf) || this._state != Wolf.STATE_KILL))
                            {
                                bool rescueFight = (_side == BattleScreen.SIDE_PLAYER && !thisInFormation) ||
                                                    (collider.getSide() == BattleScreen.SIDE_PLAYER && !colliderInFormation);

                                if (this is Colmillos)
                                {
                                    if (_state != Colmillos.STATE_ATTACK)
                                        attack();
                                    _destination = _position;
                                }
                                else if (collider is Colmillos)
                                {
                                    if (collider.getState() != Colmillos.STATE_ATTACK)
                                        ((Colmillos)collider).attack();

                                    ((Colmillos)collider)._destination = ((Colmillos)collider)._position;
                                }
                                else if (this is Dopple)
                                {
                                    if (_state != STATE_ATTACKING)
                                        attack();
                                    ((Soldier)collider).engage(false, _position, this, rescueFight);
                                }
                                else if (collider is Dopple)
                                {
                                    if (collider.getState() != STATE_ATTACKING)
                                        ((Dopple)collider).attack();
                                    engage(false, collider.getPosition(), (Soldier)collider, rescueFight);
                                }
                                else if (_side == BattleScreen.SIDE_ENEMY || this is Wolf)
                                {
                                    engage(true, collider.getPosition(), (Soldier)collider, rescueFight);
                                    ((Soldier)collider).engage(false, _position, this, rescueFight);
                                }
                                else
                                {
                                    engage(false, collider.getPosition(), (Soldier)collider, rescueFight);
                                    ((Soldier)collider).engage(true, _position, this, rescueFight);
                                }
                            }
                            //rescue
                            else if (_side == BattleScreen.SIDE_PLAYER && collider.getSide() == BattleScreen.SIDE_PLAYER && (thisInFormation != colliderInFormation))
                            {
                                if (thisInFormation &&
                                    collider.getState() != STATE_CHARGING && collider.getState() != STATE_DYING
                                    && collider.getState() != STATE_DEAD
                                    && collider.getState() != STATE_MELEE_LOSS && collider.getState() != STATE_MELEE_WIN
                                    && collider.getState() != STATE_ATTACKING && collider.getState() != STATE_RELOADING)
                                {
                                    ((Soldier)collider)._state = STATE_READY;
                                    ((Soldier)collider)._reacting = false;
                                    if (((Soldier)collider).myFormation != null && ((Soldier)collider).myFormation != _screen.getPlayerFormation())
                                        ((Soldier)collider).myFormation.removeSoldier(((Soldier)collider));
                                    _screen.getPlayerFormation().addSoldier((Soldier)collider);
                                    _screen.removeLooseSoldier((Soldier)collider);
                                }
                                else if (colliderInFormation &&
                                    this.getState() != STATE_CHARGING && this.getState() != STATE_DYING
                                    && this.getState() != STATE_DEAD
                                    && this.getState() != STATE_MELEE_LOSS && this.getState() != STATE_MELEE_WIN
                                    && this.getState() != STATE_ATTACKING && this.getState() != STATE_RELOADING)
                                {
                                    _reacting = false;
                                    _state = STATE_READY;
                                    if (myFormation != null)
                                        myFormation.removeSoldier(this);
                                    _screen.getPlayerFormation().addSoldier(this);
                                    _screen.removeLooseSoldier(this);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 public override void collide(ScreenObject collider, TimeSpan timeSpan)
 {
     if (collider is PikeTip)
     {
         Pikeman pikeman = ((PikeTip)collider).getPikeman();
         if (pikeman.getState() != Pikeman.STATE_RECOILING &&
             pikeman.getState() != STATE_DYING &&
             pikeman.getState() != STATE_DEAD &&
             pikeman.getState() != Soldier.STATE_MELEE_LOSS &&
             pikeman.getState() != Soldier.STATE_MELEE_WIN &&
             pikeman.getState() != Pikeman.STATE_RAISING &&
             pikeman.guardTarget == this._pikeman)
         {
             pikeman.recoil();
             if (_pikeman is Colmillos)
             {
                 _pikeman._destination.X = collider.getCenter().X + (collider.getSide() == BattleScreen.SIDE_ENEMY ? 1 : -1) * collider.getWidth() * 0.5f + Soldier.WIDTH * 0.35f;
             }
             ((Targeteer)_pikeman).setReactionDest(collider.getCenter().X + (collider.getSide() == BattleScreen.SIDE_ENEMY ? 1 : -1) * collider.getWidth() * 0.5f + Soldier.WIDTH * 0.35f);
             ((Targeteer)_pikeman).resetDefendTimer();
         }
     }
 }
示例#3
0
 public override void collide(ScreenObject collider, TimeSpan timeSpan)
 {
     if (collider is PikeTip && _side != collider.getSide())
     {
         Pikeman pikeman = ((PikeTip)collider).getPikeman();
         if (pikeman.getState() != Pikeman.STATE_RECOILING && pikeman.getState() != STATE_DYING && pikeman.getState() != STATE_DEAD && pikeman.getState() != Soldier.STATE_MELEE_LOSS && pikeman.getState() != Soldier.STATE_MELEE_WIN)
             pikeman.recoil();
     }
 }
示例#4
0
 public override void collide(ScreenObject collider, TimeSpan timeSpan)
 {
     if (_state != STATE_GROUND)
     {
         if ((collider is Shot || collider is WeaponAttack) && collider.getSide() != _side && collider.getState() != STATE_DEAD && collider.getState() != STATE_DYING && _state != STATE_GROUND && _state != STATE_GETTINGHIT)
         {
             if (collider is PikeTip)
             {
                 Pikeman pikeman = ((PikeTip)collider).getPikeman();
                 if (pikeman.getState() != Pikeman.STATE_RECOILING && pikeman.getState() != STATE_DYING && pikeman.getState() != STATE_DEAD && pikeman.getState() != Soldier.STATE_MELEE_LOSS && pikeman.getState() != Soldier.STATE_MELEE_WIN)
                 {
                     pikeman.recoil();
                     ground();
                 }
             }
             else if (collider is LanceTip)
             {
                 Cavalry pikeman = ((LanceTip)collider).getCavalry();
                 if (pikeman.getState() != Cavalry.STATE_RECOILING && pikeman.getState() != STATE_DYING && pikeman.getState() != STATE_DEAD && pikeman.getState() != Soldier.STATE_MELEE_LOSS && pikeman.getState() != Soldier.STATE_MELEE_WIN)
                 {
                     pikeman.recoil();
                     ground();
                 }
             }
             else if (collider is Shot)
             {
                 collider.setState(STATE_DEAD);
                 ground();
             }
         }
         else if ((collider is Soldier) && collider.getSide() != _side && collider.getState() != STATE_DEAD && collider.getState() != STATE_DEAD && collider.getState() != STATE_DYING && collider.getState() != Soldier.STATE_ONEATTACK && _state != STATE_GROUND && _state != STATE_GETTINGHIT)
         {
             ((Soldier)collider).oneAttack(this);
             _state = STATE_GETTINGHIT;
             _stateTimer = ((Soldier)collider).getOneAttackTime();
         }
     }
 }