Esempio n. 1
0
    private void RemoveMech(ModuleMech mech)
    {
        int battleGroundIndex = Mechs.IndexOf(mech);

        if (battleGroundIndex == -1)
        {
            BattlePlayer.GameManager.DebugLog.PrintWarning("BattleGroundRemoveMech not exist mech:" + mech.M_MechID);
            return;
        }

        Mechs.Remove(mech);
        MechCount = Mechs.Count;
        if (mech.CardInfo.MechInfo.IsSoldier)
        {
            Soldiers.Remove(mech);
            SoldierCount = Soldiers.Count;
        }
        else
        {
            Heroes.Remove(mech);
            HeroCount = Heroes.Count;
        }

        if (!mech.CardInfo.BaseInfo.IsTemp)
        {
            BattlePlayer.CardDeckManager.CardDeck.RecycleCardInstanceID(mech.OriginCardInstanceId);
        }
        mech.UnRegisterSideEffect();
    }
Esempio 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);
        }
    }
Esempio n. 3
0
        public override bool Execute(ExecutorInfo executorInfo)
        {
            if (!base.Execute(executorInfo))
            {
                return(false);
            }
            BattlePlayer player      = (BattlePlayer)Player;
            int          healPercent = M_SideEffectParam.GetParam_MultipliedInt("Percent");

            if (TargetRange == TargetRange.Self) // 对自身
            {
                ModuleMech mech      = player.BattleGroundManager.GetMech(executorInfo.MechId);
                int        healValue = (int)Math.Ceiling((float)healPercent * mech.M_MechTotalLife / 100);
                player.BattleGroundManager.GetMech(executorInfo.MechId).Heal(healValue);
            }
            else
            {
                player.GameManager.SideEffect_ILifeAction(
                    delegate(ILife life)
                {
                    int healValue = (int)Math.Ceiling((float)healPercent * life.GetTotalLife() / 100);
                    life.Heal(healValue);
                },
                    player,
                    ChoiceCount,
                    TargetRange,
                    TargetSelect,
                    executorInfo.TargetClientIds,
                    executorInfo.TargetMechIds
                    );
            }
            return(true);
        }
Esempio n. 4
0
 public void Initialize(ClientPlayer clientPlayer, ModuleMech mech, SlotTypes slotType)
 {
     ClientPlayer            = clientPlayer;
     Mech                    = mech;
     MSlotTypes              = slotType;
     SlotBoxCollider.enabled = Mech != null;
 }
Esempio n. 5
0
    //装备武器
    private void summonEquipRequest(ModuleMech moduleMech, Vector3 dragLastPosition)
    {
        switch (M_EquipType)
        {
        case SlotTypes.Weapon:
        {
            EquipWeaponRequest request = new EquipWeaponRequest(Client.Instance.Proxy.ClientID, M_CardInstanceId, moduleMech.M_MechID);
            Client.Instance.Proxy.SendMessage(request);
            break;
        }

        case SlotTypes.Shield:
        {
            EquipShieldRequest request = new EquipShieldRequest(Client.Instance.Proxy.ClientID, M_CardInstanceId, moduleMech.M_MechID);
            Client.Instance.Proxy.SendMessage(request);
            break;
        }

        case SlotTypes.Pack:
        {
            EquipPackRequest request = new EquipPackRequest(Client.Instance.Proxy.ClientID, M_CardInstanceId, moduleMech.M_MechID);
            Client.Instance.Proxy.SendMessage(request);
            break;
        }

        case SlotTypes.MA:
        {
            EquipMARequest request = new EquipMARequest(Client.Instance.Proxy.ClientID, M_CardInstanceId, moduleMech.M_MechID);
            Client.Instance.Proxy.SendMessage(request);
            break;
        }
        }

        Usable = false;
    }
Esempio n. 6
0
    private void OnMechDie(MechDieRequest r)
    {
        List <ModuleMech> dieMechs = new List <ModuleMech>();

        foreach (int mechId in r.mechIds)
        {
            ModuleMech mech = SelfClientPlayer.BattlePlayer.BattleGroundManager.GetMech(mechId);
            if (mech != null)
            {
                dieMechs.Add(mech);
            }
            else
            {
                mech = EnemyClientPlayer.BattlePlayer.BattleGroundManager.GetMech(mechId);
                if (mech != null)
                {
                    dieMechs.Add(mech);
                }
            }
        }

        foreach (ModuleMech moduleMech in dieMechs)
        {
            moduleMech.OnDie();
        }

        BattleEffectsManager.Instance.Effect_Main.EffectsShow(Co_MechDieShock(dieMechs), "Co_MechDieShock");
    }
Esempio n. 7
0
    private void OnMechCardInfoSync(MechCardInfoSyncRequest r)
    {
        ClientPlayer cp   = GetPlayerByClientId(r.clientId);
        ModuleMech   mech = cp.BattlePlayer.BattleGroundManager.GetMech(r.instanceId);

        mech.CardInfo = r.cardInfo.Clone();
    }
Esempio n. 8
0
    private void OnMechCanAttackChange(MechCanAttackRequest r)
    {
        ClientPlayer cp   = GetPlayerByClientId(r.clientId);
        ModuleMech   mech = cp.BattlePlayer.BattleGroundManager.GetMech(r.mechId);

        mech.SetCanAttack(r.canAttack);
    }
Esempio n. 9
0
    private void OnMechImmuneChange(MechImmuneStateRequest r)
    {
        ClientPlayer cp   = GetPlayerByClientId(r.clientId);
        ModuleMech   mech = cp.BattlePlayer.BattleGroundManager.GetMech(r.mechId);

        mech.M_ImmuneLeftRounds = r.immuneRounds;
    }
Esempio n. 10
0
    /// <summary>
    /// 当对方场上有机甲,剑及近战攻击无法攻击ship;当对方场上有Defence,枪无法攻击ship;SniperGun随时可以攻击Ship
    /// </summary>
    /// <param name="attackMech"></param>
    /// <returns></returns>
    public AttackFactor CheckModuleMechCanAttackMe(ModuleMech attackMech)
    {
        if (attackMech.ClientPlayer == ClientPlayer)
        {
            return(AttackFactor.None);
        }
        if (attackMech.MechEquipSystemComponent.M_Weapon)
        {
            switch (attackMech.MechEquipSystemComponent.M_Weapon.M_WeaponType)
            {
            case WeaponTypes.Sword:
                if (ClientPlayer.BattlePlayer.BattleGroundManager.BattleGroundIsEmpty)
                {
                    return(AttackFactor.Sword);
                }
                return(0);

            case WeaponTypes.Gun:
                if (attackMech.M_MechWeaponEnergy != 0)
                {
                    if (ClientPlayer.BattlePlayer.BattleGroundManager.HasDefenceMech)
                    {
                        return(0);
                    }
                    return(AttackFactor.Gun);
                }
                else
                {
                    if (ClientPlayer.BattlePlayer.BattleGroundManager.BattleGroundIsEmpty)
                    {
                        return(AttackFactor.Sword);
                    }
                    return(0);
                }

            case WeaponTypes.SniperGun:
                if (attackMech.M_MechWeaponEnergy != 0)
                {
                    return(AttackFactor.Gun);
                }
                else
                {
                    if (ClientPlayer.BattlePlayer.BattleGroundManager.BattleGroundIsEmpty)
                    {
                        return(AttackFactor.Sword);
                    }
                    return(0);
                }
            }
        }
        else
        {
            if (ClientPlayer.BattlePlayer.BattleGroundManager.BattleGroundIsEmpty)
            {
                return(AttackFactor.Sword);
            }
        }

        return(AttackFactor.None);
    }
Esempio n. 11
0
    private void OnMechShieldDefence(MechShieldDefenseRequest r)
    {
        ClientPlayer cp   = GetPlayerByClientId(r.clientId);
        ModuleMech   mech = cp.BattlePlayer.BattleGroundManager.GetMech(r.mechId);

        mech.MechSwordShieldArmorComponent.ShieldDefenceDamage(r.decreaseValue, r.shieldValue);
    }
Esempio n. 12
0
    IEnumerator Co_RefreshBattleGroundAnim(BattleEffectsManager.Effects myParentEffects, int mechPlaceIndex = (int)mechPlaceIndex.NoNewMech)
    {
        bool isAddMech = mechPlaceIndex != (int)BattleGroundManager.mechPlaceIndex.NoNewMech;

        if (isAddMech) //新增机甲
        {
            ModuleMech mech = AddPrePassMechQueue.Dequeue();

            Mechs.Insert(mechPlaceIndex, mech);
            if (mech.CardInfo.MechInfo.IsSoldier)
            {
                Soldiers.Add(mech);
            }
            else
            {
                Heros.Add(mech);
            }

            mech.OnSummon();
            mech.transform.position = DefaultMechPivot.transform.position;
            mech.transform.transform.Translate(Vector3.left * (Mechs.IndexOf(mech) - Mechs.Count / 2.0f + 0.5f) * MECH_INTERVAL, Space.Self);
        }

        float duration = 0.1f;

        Vector3[] targetPos        = new Vector3[Mechs.Count];
        int       actualPlaceCount = previewMechPlace == PREVIEW_MECH_PLACES_NO_PREVIEW_MECH_NOW ? Mechs.Count : Mechs.Count + 1;

        for (int i = 0; i < Mechs.Count; i++)
        {
            int actualPlace = i;
            if (previewMechPlace != PREVIEW_MECH_PLACES_NO_PREVIEW_MECH_NOW && i >= previewMechPlace)
            {
                actualPlace += 1;
            }

            Vector3 ori    = Mechs[i].transform.position;
            Vector3 offset = Vector3.left * (actualPlace - actualPlaceCount / 2.0f + 0.5f) * MECH_INTERVAL;

            Mechs[i].transform.position = DefaultMechPivot.transform.position;
            Mechs[i].transform.Translate(offset, Space.Self);

            targetPos[i] = Mechs[i].transform.position;
            Mechs[i].transform.position = ori;
            Mechs[i].transform.DOMove(targetPos[i], duration).SetEase(Ease.Linear);
        }

        ClientPlayer.BattlePlayer.HandManager.RefreshAllCardUsable();

        yield return(new WaitForSeconds(duration));

        if (isAddMech && DragManager.Instance.IsSummonPreview)
        {
            DragManager.Instance.IsArrowShowBegin = true;
        }

        yield return(null);

        myParentEffects.EffectEnd();
    }
Esempio n. 13
0
    private void OnMechInactivityChange(MechInactivityStateRequest r)
    {
        ClientPlayer cp   = GetPlayerByClientId(r.clientId);
        ModuleMech   mech = cp.BattlePlayer.BattleGroundManager.GetMech(r.mechId);

        mech.M_InactivityRounds = r.inactivityRounds;
    }
    IEnumerator Co_MechAttackChange(int mechAttackValue, int mechEnergy, int mechEnergyMax, int change, float duration, bool cur_IsInitializing)
    {
        if (!cur_IsInitializing)
        {
            string text = LanguageManager.Instance.GetText("ModuleMech_AttackChangeNumberFly");

            if (change > 0)
            {
                WeaponAttackChangeNumberFly.SetText(text + "+" + change, "#FFF500", "#FFF500", TextFly.FlyDirection.Up);
                FXManager.Instance.PlayFX(SwordBar.transform, FXManager.FXType.FX_WeaponEnergyUp, "#FFFFFF", 0.3f);
            }
            else if (change < 0)
            {
                WeaponAttackChangeNumberFly.SetText(text + change, "#FFF500", "#FFF500", TextFly.FlyDirection.Down);
            }
        }

        int finalAttack = ModuleMech.CalculateFinalAttack(mechAttackValue, mechEnergy);

        SwordText.text    = finalAttack > 0 ? finalAttack.ToString() : "";
        SwordTrough.color = finalAttack > 0 ? ClientUtils.HTMLColorToColor("#ffffff") : ClientUtils.HTMLColorToColor("#333333");
        RefreshSwordBarMask(mechEnergy, mechEnergyMax);
        yield return(new WaitForSeconds(duration));

        BattleEffectsManager.Instance.Effect_Main.EffectEnd();
    }
Esempio n. 15
0
    private void OnMechAttackShip(MechAttackShipServerRequest r)
    {
        ClientPlayer cp_attack   = GetPlayerByClientId(r.AttackMechClientId);
        ClientPlayer cp_beAttack = cp_attack.WhichPlayer == Players.Self ? EnemyClientPlayer : SelfClientPlayer;
        ModuleMech   attackMech  = cp_attack.BattlePlayer.BattleGroundManager.GetMech(r.AttackMechId);

        attackMech.AttackShip(cp_beAttack);
    }
Esempio n. 16
0
    private void OnMechOnAttack(MechOnAttackRequest r)
    {
        ClientPlayer cp         = GetPlayerByClientId(r.clientId);
        ModuleMech   mech       = FindMech(r.mechId);
        ModuleMech   targetMech = FindMech(r.targetMechId);

        mech.OnAttack(r.weaponType, targetMech, targetMech.IsDead);
    }
Esempio n. 17
0
    private void OnMechOnAttackShip(MechOnAttackShipRequest r)
    {
        ClientPlayer cp        = GetPlayerByClientId(r.clientId);
        ClientPlayer cp_target = GetPlayerByClientId(r.targetClientId);
        ModuleMech   mech      = FindMech(r.mechId);

        mech.OnAttackShip(r.weaponType, cp_target.BattlePlayer.Ship);
    }
Esempio n. 18
0
    public void SummonMechPreview(CardMech mechCard, int mechPlaceIndex, TargetRange targetRange) //用于具有指定目标的副作用的机甲的召唤预览、显示指定箭头
    {
        currentSummonPreviewMechCard = mechCard;
        ModuleMech mech = AddMech_PrePass((CardInfo_Mech)mechCard.CardInfo, (int)Const.SpecialMechID.Empty, (int)Const.SpecialMechID.ClientTempMechIDNormal);

        CurrentSummonPreviewMech = mech;
        AddMech(mechPlaceIndex);
        DragManager.Instance.StartSummonMechTargetArrowAiming(mech, targetRange);
    }
Esempio n. 19
0
    private void summonSpellRequestToMech(ModuleMech targetModuleMech)
    {
        UseSpellCardToMechRequest request = new UseSpellCardToMechRequest(Client.Instance.Proxy.ClientID, M_CardInstanceId, new List <ValueTuple <int, bool> > {
            targetModuleMech.M_TargetMechID
        });

        Client.Instance.Proxy.SendMessage(request);
        Usable = false;
    }
Esempio n. 20
0
    public void OnMechAttackMech(MechAttackMechServerRequest r)
    {
        ClientPlayer cp_attack    = GetPlayerByClientId(r.AttackMechClientId);
        ClientPlayer cp_beAttack  = GetPlayerByClientId(r.BeAttackedMechClientId);
        ModuleMech   attackMech   = cp_attack.BattlePlayer.BattleGroundManager.GetMech(r.AttackMechId);
        ModuleMech   beAttackMech = cp_beAttack.BattlePlayer.BattleGroundManager.GetMech(r.BeAttackedMechId);

        attackMech.Attack(beAttackMech, false);
    }
Esempio n. 21
0
    public bool CheckModuleMechCanAttackMe(ModuleMech attackMech)
    {
        if (attackMech.M_Weapon != null)
        {
            switch (attackMech.M_Weapon.M_WeaponType)
            {
            case WeaponTypes.Sword:
                if (BattleGroundManager.BattleGroundIsEmpty)
                {
                    return(true);
                }
                return(false);

            case WeaponTypes.Gun:
                if (attackMech.M_MechWeaponEnergy != 0)
                {
                    if (BattleGroundManager.HasDefenseMech)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (BattleGroundManager.BattleGroundIsEmpty)
                    {
                        return(true);
                    }
                    return(false);
                }

            case WeaponTypes.SniperGun:
                if (attackMech.M_MechWeaponEnergy != 0)
                {
                    return(true);
                }
                else
                {
                    if (BattleGroundManager.BattleGroundIsEmpty)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }
        else
        {
            if (BattleGroundManager.BattleGroundIsEmpty)
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 22
0
    public ModuleMech GetMechOnBattleGround(int mechId)
    {
        ModuleMech mech = PlayerA.BattleGroundManager.GetMech(mechId);

        if (mech == null)
        {
            mech = PlayerB.BattleGroundManager.GetMech(mechId);
        }
        return(mech);
    }
Esempio n. 23
0
 public void SetSlot(ClientPlayer clientPlayer, ModuleMech mech, MechInfo mechInfo)
 {
     for (int i = 0; i < Slots.Length; i++)
     {
         if (Slots[i] != null)
         {
             Slots[i].Initialize(clientPlayer, mech, mechInfo.Slots[i]);
         }
     }
 }
Esempio n. 24
0
 public void RemoveMechs(List <int> mechIds)
 {
     foreach (int mechId in mechIds)
     {
         ModuleMech mech = GetMech(mechId);
         if (mech != null)
         {
             RemoveMech(mech);
         }
     }
 }
Esempio n. 25
0
    private static void GetAffixTypeByMech(HashSet <AffixType> affixTypes, ModuleMech mech)
    {
        if (mech.M_ImmuneLeftRounds != 0)
        {
            affixTypes.Add(AffixType.Immune);
        }

        if (mech.M_InactivityRounds != 0)
        {
            affixTypes.Add(AffixType.Inactivity);
        }
    }
Esempio n. 26
0
    public void EquipWeapon(EquipWeaponRequest r, CardInfo_Base cardInfo)
    {
        ModuleWeapon   weapon          = new ModuleWeapon();
        CardInfo_Equip cardInfo_Weapon = (CardInfo_Equip)cardInfo;
        ModuleMech     mech            = GetMech(r.mechId);

        weapon.M_ModuleMech = mech;
        weapon.M_EquipID    = BattlePlayer.GameManager.GenerateNewEquipId();
        weapon.Initiate(cardInfo_Weapon, BattlePlayer);
        weapon.OriginCardInstanceId = r.handCardInstanceId;
        mech.M_Weapon = weapon;
        BattlePlayer.CardDeckManager.CardDeck.AddCardInstanceId(cardInfo.CardID, r.handCardInstanceId);
    }
Esempio n. 27
0
    public void EquipPack(EquipPackRequest r, CardInfo_Base cardInfo)
    {
        ModulePack     pack          = new ModulePack();
        CardInfo_Equip cardInfo_Pack = (CardInfo_Equip)cardInfo;
        ModuleMech     mech          = GetMech(r.mechID);

        pack.M_ModuleMech = mech;
        pack.M_EquipID    = BattlePlayer.GameManager.GenerateNewEquipId();
        pack.Initiate(cardInfo_Pack, BattlePlayer);
        pack.OriginCardInstanceId = r.handCardInstanceId;
        mech.M_Pack = pack;
        BattlePlayer.CardDeckManager.CardDeck.AddCardInstanceId(cardInfo.CardID, r.handCardInstanceId);
    }
Esempio n. 28
0
    public void EquipMA(EquipMARequest r, CardInfo_Base cardInfo)
    {
        ModuleMA       ma          = new ModuleMA();
        CardInfo_Equip cardInfo_MA = (CardInfo_Equip)cardInfo;
        ModuleMech     mech        = GetMech(r.mechID);

        ma.M_ModuleMech = mech;
        ma.M_EquipID    = BattlePlayer.GameManager.GenerateNewEquipId();
        ma.Initiate(cardInfo_MA, BattlePlayer);
        ma.OriginCardInstanceId = r.handCardInstanceId;
        mech.M_MA = ma;
        BattlePlayer.CardDeckManager.CardDeck.AddCardInstanceId(cardInfo.CardID, r.handCardInstanceId);
    }
Esempio n. 29
0
    public void EquipShield(EquipShieldRequest r, CardInfo_Base cardInfo)
    {
        ModuleShield   shield          = new ModuleShield();
        CardInfo_Equip cardInfo_Shield = (CardInfo_Equip)cardInfo;
        ModuleMech     mech            = GetMech(r.mechID);

        shield.M_ModuleMech = mech;
        shield.M_EquipID    = BattlePlayer.GameManager.GenerateNewEquipId();
        shield.Initiate(cardInfo_Shield, BattlePlayer);
        shield.OriginCardInstanceId = r.handCardInstanceId;
        mech.M_Shield = shield;
        BattlePlayer.CardDeckManager.CardDeck.AddCardInstanceId(cardInfo.CardID, r.handCardInstanceId);
    }
Esempio n. 30
0
 public void OnMousePressEnterImmediately()
 {
     if (DragManager.Instance.CurrentDrag)
     {
         ModuleMech mr = DragManager.Instance.CurrentDrag_ModuleMech;
         CardSpell  cs = DragManager.Instance.CurrentDrag_CardSpell;
         if (mr != null && Mech.CheckModuleMechCanAttackMe(mr))
         {
             OnAttrShapeHoverShow();
         }
         else if (cs != null && Mech.CheckCardSpellCanTarget(cs))
         {
             OnAttrShapeHoverShow();
         }
     }
 }