Пример #1
0
    private void RealRemoveEntity(TileEntity entity)
    {
        int entity_id = entity.GetHashCode();

        Assert.Should(m_entityHash.ContainsKey(entity_id));

        m_entities[(int)entity.GetOwner()].Remove(entity);
        m_entityHash.Remove(entity_id);
        FillBuildingMapData(entity, 0);
    }
Пример #2
0
    private void RealAddEntity(TileEntity entity)
    {
        //  先初始化(否则在后面添加墙数据时没有精灵会导致空引用)
        entity.AddedToWorld();

        int entity_id = entity.GetHashCode();

        Assert.Should(!m_entityHash.ContainsKey(entity_id));

        //  添加到列表和Hash表
        m_entities[(int)entity.GetOwner()].Add(entity);
        m_entityHash.Add(entity_id, entity);
        FillBuildingMapData(entity, entity_id);
    }
Пример #3
0
    /// <summary>
    /// 有单位死亡了
    /// </summary>
    /// <param name="entity"></param>
    public void OnEntityDestroy(TileEntity entity)
    {
        //如果死亡的是建筑
        if (EntityTypeUtil.IsAnyNonWallBuilding(entity.entityType))
        {
            defenderBuildingCount--;
            DestroyBuildingPercent = (float)(totalDefenderBuildingCount - defenderBuildingCount) / totalDefenderBuildingCount;
            //摧毁50% 获得一颗星
            if (!hasGotHalfDestroyStar && DestroyBuildingPercent > 0.5f)
            {
                hasGotHalfDestroyStar = true;
                BattleStar++;
            }
            Debug.Log("摧毁:" + DestroyBuildingPercent + "%");

            //摧毁基地 获得一颗星
            if (EntityTypeUtil.IsCenterBuilding(entity.model))
            {
                BattleStar++;
            }
            //摧毁100% 获得一颗星
            if (defenderBuildingCount == 0)
            {
                BattleStar++;
            }

            EventDispather.DispatherEvent(GameEvents.BATTLE_PROGRESS_CHANGE);
        }
        else if (entity.GetOwner() == OwnerType.Attacker && EntityTypeUtil.IsAnyActor(entity.entityType))
        {
            attackerArmyCount--;
            if (EntityTypeUtil.IsCurer(entity.model))
            {
                attackerCurerCount--;
            }
        }
        else if (entity.GetOwner() == OwnerType.Defender)
        {
            if (EntityTypeUtil.IsAnyActor(entity.entityType))
            {
                if (entity.Friendly)
                {
                    var found = false;
                    foreach (var killedDefenderDonatedArmy in killedDefenderDonatedArmies)
                    {
                        if (killedDefenderDonatedArmy.cid == entity.model.baseId)
                        {
                            killedDefenderDonatedArmy.amount++;
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        killedDefenderDonatedArmies.Add(new ArmyVO()
                        {
                            amount = 1, cid = entity.model.baseId
                        });
                    }
                }
            }
            else if (EntityTypeUtil.IsAnyTrap(entity.model))
            {
                brokenTraps.Add(entity.buildingVO.sid);
            }
        }
        CheckBattleEnd();
    }
Пример #4
0
 public bool Contains(TileEntity entity)
 {
     return(m_entities[(int)entity.GetOwner()].Contains(entity));
 }