Exemplo n.º 1
0
 public static string GetItemIconByModel(EntityModel model)
 {
     if (EntityTypeUtil.IsSkill(model))
     {
         //技能
         return("UI_IconSkill_" + model.nameForResource);
     }
     else if (EntityTypeUtil.IsAnyActor(model.entityType))
     {
         //兵种
         return(model.nameForResource.Substring(0, model.nameForResource.Length - 2) + "_IconSmall");
     }
     return("");
 }
Exemplo n.º 2
0
    public void PlayerPlaceSoldierOrSkill(int entityId, int x, int y, bool record = true)
    {
        if (!IsBattleStarted)
        {
            return;
        }
        var model = DataCenter.Instance.FindEntityModelById(entityId);

        //是否是使用的援军
        if (entityId == Constants.DENOTED_ARMY_ID)
        {
            if (!useDonatedArmy)
            {
                if (IsoMap.Instance.CanPlaceSoldier(x, y))
                {
                    useDonatedArmy = true;
                    Debug.Log("使用的援军");
                    //  战斗模式 [录像] 记录操作数据
                    if (record)
                    {
                        GameRecord.RecordPlaceSoldier(x, y, Constants.DENOTED_ARMY_ID);
                    }
                    var spawnHelper = new SpawnDonatedArmyHelper(DataCenter.Instance.Attacker.donatedArmies.Clone(), x, y);
                    UpdateManager.Instance.AddUpdate(spawnHelper);

                    DataCenter.Instance.Attacker.donatedArmies.Clear();
                }
                else
                {
                    GameTipsManager.Instance.ShowGameTips(EnumTipsID.Fight_10301);
                    IsoMap.Instance.ShowGuardAreaMap(true);
                }
            }
        }
        else if (EntityTypeUtil.IsSkill(model))
        {
            if (IsoMap.Instance.CanPlaceSkill(x, y))
            {
                foreach (var skillVo in DataCenter.Instance.Attacker.skills)
                {
                    if (skillVo.cid == model.baseId && skillVo.amount > 0)
                    {
                        if (record)
                        {
                            GameRecord.RecordPlaceSoldier(x, y, model.baseId);
                        }
                        GameSkillManager.Instance.AddSkill(model, x, y);
                        skillVo.amount--;
                        break;
                    }
                }
            }
            else
            {
                GameTipsManager.Instance.ShowGameTips(EnumTipsID.Fight_10301);
            }
        }
        else
        {
            if (IsoMap.Instance.CanPlaceSoldier(x, y))
            {
                foreach (var armyVo in DataCenter.Instance.Attacker.armies)
                {
                    if (armyVo.cid == model.baseId && armyVo.amount > 0)
                    {
                        //  战斗模式 [录像] 记录操作数据
                        if (record)
                        {
                            GameRecord.RecordPlaceSoldier(x, y, model.baseId);
                        }
                        //  创建对象
                        IsoMap.Instance.CreateEntityAt(OwnerType.Attacker, model.baseId, x, y);
                        armyVo.amount--;
                        break;
                    }
                }
            }
            else
            {
                GameTipsManager.Instance.ShowGameTips(EnumTipsID.Fight_10301);
                IsoMap.Instance.ShowGuardAreaMap(true);
            }
        }
        EventDispather.DispatherEvent(GameEvents.BATTLE_SPAWN, entityId);
    }