Ejemplo n.º 1
0
    public void OnClientSummonMechRequest(SummonMechRequest r)
    {
        ClientA.CurrentClientRequestResponseBundle = new SummonMechRequest_ResponseBundle();
        ClientB.CurrentClientRequestResponseBundle = new SummonMechRequest_ResponseBundle();

        BattlePlayer  sp                 = GetPlayerByClientId(r.clientId);
        CardInfo_Mech info               = (CardInfo_Mech)sp.HandManager.GetHandCardInfo(r.handCardInstanceId);
        List <int>    targetMechIds      = r.targetMechIds;
        List <int>    targetMechIds_real = new List <int>();

        for (int i = 0; i < targetMechIds.Count; i++)
        {
            bool isTemp     = r.isTargetMechIdTempIds[i];
            int  realMechId = r.targetMechIds[i];
            if (isTemp)
            {
                realMechId = sp.BattleGroundManager.GetMechIdByClientMechTempId(realMechId);
            }

            if (realMechId != -1)
            {
                targetMechIds_real.Add(realMechId);
            }
        }

        sp.HandManager.UseCard(r.handCardInstanceId, targetMechIds);
        sp.BattleGroundManager.AddMech(info, r.battleGroundIndex, targetMechIds_real, r.clientMechTempId, r.handCardInstanceId);

        Broadcast_SendOperationResponse();
    }
Ejemplo n.º 2
0
    public void AddMech(CardInfo_Mech mechCardInfo, int mechPlaceIndex, List <int> targetMechIds, int clientMechTempId, int handCardInstanceId)
    {
        if (BattleGroundIsFull)
        {
            return;
        }
        int mechId = BattlePlayer.GameManager.GenerateNewMechId();
        BattleGroundAddMechRequest request = new BattleGroundAddMechRequest(BattlePlayer.ClientId, mechCardInfo, mechPlaceIndex, mechId, clientMechTempId);

        BattlePlayer.MyClientProxy.BattleGameManager.Broadcast_AddRequestToOperationResponse(request);

        ModuleMech mech = new ModuleMech();

        mech.M_MechID             = mechId;
        mech.M_ClientTempMechID   = clientMechTempId;
        mech.OriginCardInstanceId = handCardInstanceId;
        mech.Initiate(mechCardInfo, BattlePlayer);

        BattlePlayer.CardDeckManager.CardDeck.AddCardInstanceId(mechCardInfo.CardID, handCardInstanceId);

        BattleGroundAddMech(mechPlaceIndex, mech);

        ExecutorInfo info = new ExecutorInfo(clientId: BattlePlayer.ClientId, mechId: mechId, targetMechIds: targetMechIds);

        if (mechCardInfo.MechInfo.IsSoldier)
        {
            BattlePlayer.GameManager.EventManager.Invoke(SideEffectExecute.TriggerTime.OnSoldierSummon, info);
        }
        else
        {
            BattlePlayer.GameManager.EventManager.Invoke(SideEffectExecute.TriggerTime.OnHeroSummon, info);
        }
    }
 public BattleGroundAddMechRequest(int clientId, CardInfo_Mech cardInfo, int battleGroundIndex, int mechId, int clientMechTempId)
 {
     this.clientId          = clientId;
     this.cardInfo          = cardInfo;
     this.battleGroundIndex = battleGroundIndex;
     this.mechId            = mechId;
     this.clientMechTempId  = clientMechTempId;
 }
 public override void Deserialize(DataStream reader)
 {
     base.Deserialize(reader);
     clientId          = reader.ReadSInt32();
     cardInfo          = (CardInfo_Mech)(CardInfo_Base.Deserialze(reader));
     battleGroundIndex = reader.ReadSInt32();
     mechId            = reader.ReadSInt32();
     clientMechTempId  = reader.ReadSInt32();
 }
Ejemplo n.º 5
0
    public override CardInfo_Base Clone()
    {
        CardInfo_Mech cb = new CardInfo_Mech(
            cardID: CardID,
            baseInfo: BaseInfo,
            upgradeInfo: UpgradeInfo,
            lifeInfo: LifeInfo,
            battleInfo: BattleInfo,
            mechInfo: MechInfo,
            sideEffectBundle: SideEffectBundle.Clone(),
            sideEffectBundle_BattleGroundAura: SideEffectBundle_BattleGroundAura.Clone());

        return(cb);
    }
Ejemplo n.º 6
0
    public ModuleMech AddMech_PrePass(CardInfo_Mech mechCardInfo, int mechId, int clientMechTempId)
    {
        if (ClientPlayer == null)
        {
            return(null);
        }
        previewMechPlace = PREVIEW_MECH_PLACES_NO_PREVIEW_MECH_NOW;

        bool isSummonedBeforeByPreview = false;

        if (clientMechTempId != (int)Const.SpecialMechID.ClientTempMechIDNormal)
        {
            foreach (ModuleMech moduleMech in Mechs)
            {
                if (moduleMech.M_ClientTempMechID == clientMechTempId)                               //匹配
                {
                    moduleMech.M_MechID           = mechId;                                          //赋予正常ID
                    moduleMech.M_ClientTempMechID = (int)Const.SpecialMechID.ClientTempMechIDNormal; //恢复普通
                    isSummonedBeforeByPreview     = true;
                    break;
                }
            }
        }

        if (!isSummonedBeforeByPreview)
        {
            ModuleMech mech = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.ModuleMech].AllocateGameObject <ModuleMech>(transform);
            mech.transform.position = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.ModuleMech].transform.position;
            mech.Initiate(mechCardInfo, ClientPlayer);
            mech.transform.Rotate(Vector3.up, 180);
            mech.M_MechID = mechId;
            AddPrePassMechQueue.Enqueue(mech);
            MechCount++;
            if (!mechCardInfo.MechInfo.IsSoldier)
            {
                HeroCount++;
            }
            else
            {
                SoldierCount++;
            }

            return(mech);
        }

        return(null);
    }
Ejemplo n.º 7
0
    public static CardInfo_Base ConvertCardInfo(CardInfo_Base src, CardTypes cardType)
    {
        switch (src)
        {
        case CardInfo_Mech ci:
        {
            switch (cardType)
            {
            case CardTypes.Mech:
            {
                return((CardInfo_Mech)ci.Clone());
            }

            case CardTypes.Equip:
            {
                CardInfo_Base res = new CardInfo_Equip(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    new EquipInfo(SlotTypes.Weapon),
                    new WeaponInfo(1, 1, 1, WeaponTypes.Sword, false, false),
                    new ShieldInfo(),
                    new PackInfo(),
                    new MAInfo(),
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Equip;
                return((CardInfo_Equip)res);
            }

            case CardTypes.Spell:
            {
                CardInfo_Base res = new CardInfo_Spell(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Spell;
                return((CardInfo_Spell)res);
            }

            case CardTypes.Energy:
            {
                CardInfo_Base res = new CardInfo_Spell(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Energy;
                return((CardInfo_Spell)res);
            }
            }

            break;
        }

        case CardInfo_Equip ci:
        {
            switch (cardType)
            {
            case CardTypes.Mech:
            {
                CardInfo_Base res = new CardInfo_Mech(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    new LifeInfo(1, 1),
                    new BattleInfo(0, 0, 0),
                    new MechInfo(false, false, false, false, false, false, SlotTypes.None, SlotTypes.None, SlotTypes.None, SlotTypes.None),
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Mech;
                return((CardInfo_Mech)res);
            }

            case CardTypes.Equip:
            {
                return((CardInfo_Equip)ci.Clone());
            }

            case CardTypes.Spell:
            {
                CardInfo_Base res = new CardInfo_Spell(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Spell;
                return((CardInfo_Spell)res);
            }

            case CardTypes.Energy:
            {
                CardInfo_Base res = new CardInfo_Spell(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Energy;
                return((CardInfo_Spell)res);
            }
            }

            break;
        }

        case CardInfo_Spell ci:
        {
            switch (cardType)
            {
            case CardTypes.Mech:
            {
                CardInfo_Base res = new CardInfo_Mech(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    new LifeInfo(1, 1),
                    new BattleInfo(0, 0, 0),
                    new MechInfo(false, false, false, false, false, false, SlotTypes.None, SlotTypes.None, SlotTypes.None, SlotTypes.None),
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Mech;
                return((CardInfo_Mech)res);
            }

            case CardTypes.Equip:
            {
                CardInfo_Base res = new CardInfo_Equip(
                    ci.CardID, ci.BaseInfo, ci.UpgradeInfo,
                    new EquipInfo(SlotTypes.Weapon),
                    new WeaponInfo(1, 1, 1, WeaponTypes.Sword, false, false),
                    new ShieldInfo(),
                    new PackInfo(),
                    new MAInfo(),
                    ci.SideEffectBundle.Clone(),
                    ci.SideEffectBundle_BattleGroundAura.Clone());
                res.BaseInfo.CardType = CardTypes.Equip;
                return((CardInfo_Equip)res);
            }

            case CardTypes.Spell:
            {
                CardInfo_Spell cis = (CardInfo_Spell)ci.Clone();
                cis.BaseInfo.CardType = CardTypes.Spell;
                return(cis);
            }

            case CardTypes.Energy:
            {
                CardInfo_Spell cis = (CardInfo_Spell)ci.Clone();
                cis.BaseInfo.CardType = CardTypes.Energy;
                return(cis);
            }
            }

            break;
        }
        }

        return(null);
    }
Ejemplo n.º 8
0
 public void AddMech(CardInfo_Mech mechCardInfo)
 {
     AddMech(mechCardInfo, Mechs.Count, targetMechIds: null, clientMechTempId: (int)Const.SpecialMechID.ClientTempMechIDNormal, handCardInstanceId: -1);
 }