Exemplo n.º 1
0
 public static bool ContainsIcon(Vector3 pos)
 {
     PeMap.ILabel pl = PeMap.LabelMgr.Instance.Find(item =>
     {
         ColonyLabel l = item as ColonyLabel;
         if (l != null && l.pos == pos)
         {
             return(true);
         }
         return(false);
     });
     if (pl != null)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 public static new bool Remove(Vector3 pos)
 {
     PeMap.ILabel pl = PeMap.LabelMgr.Instance.Find(item =>
     {
         ColonyLabel l = item as ColonyLabel;
         if (l != null && l.pos == pos)
         {
             return(true);
         }
         return(false);
     });
     if (pl != null)
     {
         return(PeMap.LabelMgr.Instance.Remove(pl));
     }
     return(false);
 }
Exemplo n.º 3
0
    void OnTeamChange()
    {
        if (null == ForceSetting.Instance || null == m_Entity)
        {
            return;
        }

        //lz-2018.02.02 基地核心才需要地图图标
        if (m_Entity.m_Type == CSConst.dtAssembly)
        {
            Vector3 travelPos = Vector3.zero;

            CSBuildingLogic csb = m_Entity.gameLogic == null ? null : m_Entity.gameLogic.GetComponent <CSBuildingLogic>();
            //lz-2017.01.17 基地逻辑预制物体加载成功并且有传送点就用配置的传送点的位置
            if (csb != null && csb.travelTrans != null)
            {
                travelPos = csb.travelTrans.position;
            }
            else
            {
                //lz-2017.01.17 否则就用基地核心向上偏移两米的位置
                travelPos = _pos + new Vector3(0, 2, 0);
            }

            if (ForceSetting.Instance.Conflict(TeamId, PlayerNetwork.mainPlayerId))
            {
                ColonyLabel.Remove(travelPos);
            }
            else
            {
                if (!ColonyLabel.ContainsIcon(_pos))
                {
                    new ColonyLabel(travelPos);
                }
            }
        }
    }
Exemplo n.º 4
0
    public override CSEntity RemoveEntity(int id, bool bRemoveData = true)
    {
        //if (!GameConfig.IsMultiMode)
        //{
        CSEntity cse = null;

        if (m_Assembly != null && m_Assembly.ID == id)
        {
            cse = m_Assembly;
            m_Assembly.Data.m_Alive = false;
            m_Assembly.RemoveErodeMap();

            if (bRemoveData)
            {
                m_Assembly.RemoveData();
            }
            if (CSMain.s_MgCreator == this)
            {
                Vector3 travelPos = Vector3.zero;

                CSBuildingLogic csb = m_Assembly.gameLogic.GetComponent <CSBuildingLogic>();
                //lz-2017.01.17 基地逻辑预制物体加载成功并且有传送点就用配置的传送点的位置
                if (csb != null && csb.travelTrans != null)
                {
                    travelPos = csb.travelTrans.position;
                    ColonyLabel.Remove(travelPos);
                }
                else
                {
                    //lz-2017.01.17 否则就用基地核心向上偏移两米的位置
                    travelPos = m_Assembly.Position + new Vector3(0, 2, 0);
                    ColonyLabel.Remove(travelPos);
                }
            }
            m_Assembly.DestroySelf();

            m_Assembly = null;
            ExecuteEvent(CSConst.cetRemoveEntity, cse);
        }
        else if (m_CommonEntities.ContainsKey(id))
        {
            cse = m_CommonEntities[id];
            cse.BaseData.m_Alive = false;

            if (bRemoveData)
            {
                m_CommonEntities[id].RemoveData();
            }
            m_CommonEntities.Remove(id);
            ExecuteEvent(CSConst.cetRemoveEntity, cse);
            cse.DestroySelf();
        }
        else
        {
            Debug.LogWarning("The Common Entity that you want to Remove is not contained!");
        }

        // Simulator
//        if (!GameConfig.IsMultiMode)
//		    m_SimulatorMgr.RemoveSimulator(id, true);
        return(cse);
        //}
        //else
        //{

        //}
    }
Exemplo n.º 5
0
    //
//	private CSSimulatorMgr m_SimulatorMgr;
//	public CSSimulatorMgr  SimulatorMgr     { get { return m_SimulatorMgr;} }

    // <CETC> Create Managed Entity
    public override int CreateEntity(CSEntityAttr attr, out CSEntity outEnti)
    {
        outEnti = null;
        if (attr.m_Type == CSConst.etAssembly)
        {
            Vector3 travelPos = Vector3.zero;

            CSBuildingLogic csb = attr.m_LogicObj == null ? null : attr.m_LogicObj.GetComponent <CSBuildingLogic>();
            //lz-2017.01.17 基地逻辑预制物体加载成功并且有传送点就用配置的传送点的位置
            if (csb != null && csb.travelTrans != null)
            {
                travelPos = csb.travelTrans.position;
            }
            //lz-2017.01.17 否则就用基地核心向上偏移两米的位置
            else
            {
                travelPos = m_Assembly.Position + new Vector3(0, 2, 0);
            }

            if (m_Assembly == null)
            {
                if (GameConfig.IsMultiMode && attr.m_ColonyBase == null)
                {
                    return(CSConst.rrtUnkown);
                }
                outEnti = _createEntity(attr);
                m_Assembly.ChangeState();

                if (CSMain.s_MgCreator == this)
                {
                    ColonyLabel.Remove(travelPos);
                    new ColonyLabel(travelPos);
                }
            }
            else if (m_Assembly.ID == attr.m_InstanceId)
            {
                outEnti                 = m_Assembly;
                outEnti.gameLogic       = attr.m_LogicObj;
                outEnti.gameObject      = attr.m_Obj;
                outEnti.Position        = attr.m_Pos;
                outEnti.ItemID          = attr.m_protoId;
                outEnti.Bound           = attr.m_Bound;
                m_Assembly.Data.m_Alive = true;
                if (CSMain.s_MgCreator == this)
                {
                    ColonyLabel.Remove(travelPos);
                    new ColonyLabel(travelPos);
                }
            }
            else
            {
                if (m_Assembly != null)
                {
                    return(CSConst.rrtHasAssembly);
                }
            }
        }
        else
        {
            if (m_CommonEntities.ContainsKey(attr.m_InstanceId))
            {
                outEnti                  = m_CommonEntities[attr.m_InstanceId];
                outEnti.gameLogic        = attr.m_LogicObj;
                outEnti.gameObject       = attr.m_Obj;
                outEnti.Position         = attr.m_Pos;
                outEnti.ItemID           = attr.m_protoId;
                outEnti.BaseData.m_Alive = true;
                outEnti.Bound            = attr.m_Bound;
            }
            else
            {
                if (m_Assembly == null)
                {
                    return(CSConst.rrtNoAssembly);
                }

                if (!m_Assembly.InRange(attr.m_Pos))
                {
                    return(CSConst.rrtOutOfRadius);
                }

                // Is powerplant ?
                CSConst.ObjectType obj_type;
//                if ((attr.m_Type & CSConst.etPowerPlant) != 0)
//                    obj_type = CSConst.ObjectType.PowerPlant;
//                else
                obj_type = (CSConst.ObjectType)attr.m_Type;

                if (!m_Assembly.OutOfCount(obj_type))
                {
                    return(CSConst.rrtOutOfRange);
                }

                if (GameConfig.IsMultiMode && attr.m_ColonyBase == null)
                {
                    return(CSConst.rrtUnkown);
                }
                outEnti = _createEntity(attr);
                CSCommon csc = outEnti as CSCommon;
                m_Assembly.AttachCommonEntity(csc);
            }
        }
        ExecuteEvent(CSConst.cetAddEntity, outEnti);
        return(CSConst.rrtSucceed);
    }