Beispiel #1
0
    protected void launchMissile()
    {
        // 发射导弹
        bool success = false;

        if (mAimTarget != null)
        {
            MissileParam param = new MissileParam();
            param.mPosition = mPlayer.getPosition() + new Vector3(0.0f, 2.5f, 0.0f);
            param.mTarget   = mAimTarget;
            SceneMissile missile = mItemManager.createItem <SceneMissile>(SCENE_ITEM.SI_MISSILE, param);
            if (mPlayer.isType(CHARACTER_TYPE.CT_MYSELF))
            {
                GameTools.PLAY_AUDIO_OBJECT(missile, SOUND_DEFINE.SD_FIRE_MISSILE);
            }
            // 通知锁定玩家
            CommandCharacterNotifyMissileLocked cmdLock = newCmd(out cmdLock);
            cmdLock.mLocked  = true;
            cmdLock.mMissile = missile;
            pushCommand(cmdLock, mAimTarget);
            success = true;
        }
        // 移除瞄准状态
        CommandCharacterRemoveState cmdState = newCmd(out cmdState);

        cmdState.mState = mType;
        pushCommand(cmdState, mPlayer);
        // 发射成功后移除角色背包中的导弹道具
        if (success)
        {
            CommandCharacterRemoveItem cmdRemove = newCmd(out cmdRemove);
            cmdRemove.mItem = mPlayer.getPlayerPack().getCurItem();
            pushCommand(cmdRemove, mPlayer);
        }
    }
Beispiel #2
0
 public override void destroy()
 {
     base.destroy();
     // 如果导弹销毁时仍然锁定了玩家,则通知被导弹锁定的玩家导弹解除锁定
     if (mTarget != null && mTarget as CharacterOther != null)
     {
         CommandCharacterNotifyMissileLocked cmdLocked = newCmd(out cmdLocked);
         cmdLocked.mLocked  = false;
         cmdLocked.mMissile = this;
         pushCommand(cmdLocked, mTarget);
         mTarget = null;
     }
 }
Beispiel #3
0
    public override void onEffective(Character player)
    {
        // 通知角色被攻击
        CommandCharacterAttacked cmdAttack = newCmd(out cmdAttack);

        cmdAttack.mAttackSource = mType;
        pushCommand(cmdAttack, player);
        if (player.isType(CHARACTER_TYPE.CT_MYSELF))
        {
            GameTools.PLAY_AUDIO_OBJECT(this, SOUND_DEFINE.SD_MISSILE_HIT);
        }
        // 通知被导弹锁定的玩家导弹解除锁定
        if (mTarget != null && mTarget as CharacterOther != null)
        {
            CommandCharacterNotifyMissileLocked cmdLocked = newCmd(out cmdLocked);
            cmdLocked.mLocked = false;
            pushCommand(cmdLocked, mTarget);
        }
        mTarget = null;
        // 开始销毁导弹
        mItemManager.destroyItem(this);
    }