示例#1
0
    /// <summary>
    /// 更新星球归属
    /// </summary>
    /// <param name="playerId"></param>
    /// <param name="starId"></param>
    public void UpdateStarBelongTo(uint playerId, int starId)
    {
        //Debug.Log("playerId:" + playerId + "   starId:" + starId);
        UnitStar updateStar = GetUnitStarById(starId);
        bool     _isOccupy  = false;

        if (updateStar.BelongTo != null && updateStar.BelongTo.ID != playerId && playerId == MogoWorld.thePlayer.ID)
        {
            //LoggerHelper.Error("ddd");
            _isOccupy = true;
        }

        GroupData data = GetGroupByPalyerId(playerId);//先设置阵营信息

        updateStar.SetGroup(data);
        if (MogoWorld.thePlayer.ID == playerId)
        {
            SoundManager.PlaySound("tree grow 1.ogg");
            updateStar.BelongTo = MogoWorld.thePlayer;
            if (CurStarID == starId)
            {
                EventDispatcher.TriggerEvent(Events.StarUIEvent.AddBuildingEvent); //发送我方当前星球添加建筑的消息
            }
            foreach (UnitStar star in m_starDataManager.StarList)                  //添加我方星球移动范围
            {
                if (updateStar.CheckStarReachByDistance(star) == true && ReachStarList.IndexOf(star) == -1)
                {
                    ReachStarList.Add(star);
                }
            }
        }
        else
        {
            if (updateStar.BelongTo != null && updateStar.BelongTo.ID == MogoWorld.thePlayer.ID)//之前是我方星球,被攻占了
            {
                RemoveStarRangle(updateStar);
            }
            updateStar.BelongTo = MogoWorld.Entities.Get(playerId);
        }
        //攻占成功
        if (AttackStar.Contains(updateStar))
        {
            if (!updateStar.IsInAttackStar())
            {
                AttackStar.Remove(updateStar);
            }
        }

        if (_isOccupy)//占领成功 自动送一个建筑
        {
            //updateStar.CurEnergy = updateStar.BaseData.energy / 2;
            //LoggerHelper.Error("占领成功 自动送一个建筑");
            //MogoWorld.thePlayer.RpcCall("AddBuilding", playerId, starId, 1, 100);//key为建筑类型

            updateStar.RecoveryBuilding();
        }
    }
示例#2
0
    /*private void SoldierCallback(UnitStar _star)
     * {
     *  LoggerHelper.Error("SoldierCallback");
     *  m_starDataManager.StarTogether(_star);
     * }*/

    private void IsAttackStar(UnitStar _star)
    {
        //是否在占领星球
        if (!AttackStar.Contains(_star))
        {
            if (_star.IsInAttackStar())
            {
                AttackStar.Add(_star);
            }
        }
        else//在攻占星球
        {
            //士兵全军覆没,登陆不成功
            if (!_star.IsInAttackStar())
            {
                AttackStar.Remove(_star);
            }
        }
    }