Пример #1
0
    protected override void RPC_S2C_Turn(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        transform.rotation = stream.Read <Quaternion>();

        //if (null != _viewTrans)
        //    _viewTrans.rotation = transform.rotation;
        CSBuildingLogic csbl = Runner.GetComponent <CSBuildingLogic>();

        if (csbl != null)
        {
            DragItemAgent dia = DragItemAgent.GetById(csbl.id);
            dia.rotation = transform.rotation;
        }

        if (null != Runner)
        {
            CSEntityObject ceo = Runner.GetComponentInChildren <CSEntityObject>();
            if (ceo != null)
            {
                if (csbl != null)
                {
                    ceo.Init(csbl, ceo.m_Creator, false);
                }
            }

            DragItemMousePickColony itemscript = Runner.GetComponentInChildren <DragItemMousePickColony>();
            if (itemscript != null)
            {
                itemscript.OnItemOpGUIHide();
            }
        }
    }
Пример #2
0
    public override int Init(CSBuildingLogic csbl, CSCreator creator, bool bFight)
    {
        int a = 0;

        a++;
        return(base.Init(csbl, creator, bFight));
    }
Пример #3
0
    public override int Init(CSBuildingLogic csbul, CSCreator creator, bool bFight = true)
    {
        int r = base.Init(csbul, creator, bFight);

        if (r == CSConst.rrtSucceed)
        {
            CreateEnergySheild();
        }

        return(r);
    }
Пример #4
0
    void OnExitTrigger(PeEntity monster)
    {
        if (m_Assembly != null && m_Assembly.gameLogic != null)
        {
            CSBuildingLogic csb = m_Assembly.gameLogic.GetComponent <CSBuildingLogic>();

            csb.ShieldOff(monster);

//			if(PeNpcGroup.Instance != null)
//				PeNpcGroup.Instance.OnCsAttackEnd();
        }
    }
Пример #5
0
    void OnEnterTrigger(PeEntity monster, int skillId)
    {
        if (m_Assembly != null && m_Assembly.gameLogic != null)
        {
            CSBuildingLogic csb = m_Assembly.gameLogic.GetComponent <CSBuildingLogic>();

            csb.ShieldOn(monster, skillId);

            PeEntity buidEntity = m_Assembly.gameLogic.GetComponent <PeEntity>();
            if (buidEntity != null && PeNpcGroup.Instance != null)
            {
                PeNpcGroup.Instance.OnCSAttackEnmey(buidEntity, monster);
            }
        }
    }
 public override bool CanCmd()
 {
     if (csbl == null)
     {
         csbl = GetComponentInParent <CSBuildingLogic>();
     }
     if (PeGameMgr.IsMulti && csbl != null)
     {
         if (BaseNetwork.MainPlayer.TeamId != csbl.network.TeamId)
         {
             return(false);
         }
     }
     return(base.CanCmd());
 }
Пример #7
0
    protected override void RPC_S2C_InitData(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        ItemObject item = stream.Read <ItemObject>();
        float      rotY = stream.Read <float>();

        rot = transform.rotation = Quaternion.Euler(0, rotY, 0);

        //InitData parameter member
        //and add data to creator
        _ColonyObj._RecordData.m_Position = transform.position;//network's position
        _ColonyObj._RecordData.ItemID     = ExternId;
        _ColonyObj._RecordData.ID         = Id;

        MultiColonyManager.Instance.AddDataToCreator(this, TeamId);
//        if(Application.isEditor)
//            Debug.Log("<color=red>Get colony InitData!</color>");

        if (null == item)
        {
            return;
        }

        Drag drag = item.GetCmpt <Drag>();

        if (null == drag)
        {
            return;
        }

        DragArticleAgent dragItem = DragArticleAgent.Create(drag, transform.position, transform.localScale, transform.rotation, Id, this);

        if (dragItem.itemLogic != null)
        {
            CSBuildingLogic csbl = dragItem.itemLogic as CSBuildingLogic;
            if (csbl != null)
            {
                csbl.InitInMultiMode(m_Entity, _ownerId);
                OnTeamChange();
                _entity = Pathea.EntityMgr.Instance.Get(Id);
                OnSpawned(csbl.gameObject);
            }
        }
    }
Пример #8
0
    // Simulator if need
    //	public CSSimulator m_Simulator;

    public virtual int Init(CSBuildingLogic csbl, CSCreator creator, bool bFight = true)
    {
        this.csbl = csbl;
        CSEntityAttr attr = new CSEntityAttr();

        attr.m_InstanceId   = csbl.InstanceId;
        attr.m_protoId      = csbl.protoId;
        attr.m_Type         = (int)csbl.m_Type;
        attr.m_Pos          = csbl.transform.position;
        attr.m_LogicObj     = csbl.gameObject;
        attr.m_Obj          = gameObject;
        attr.m_Bound        = GetObjectBounds();
        attr.m_Bound.center = transform.TransformPoint(attr.m_Bound.center);
        attr.m_ColonyBase   = _ColonyObj;

        int r;

        r = creator.CreateEntity(attr, out m_Entity);

        if (r != CSConst.rrtSucceed)
        {
            return(r);
        }

        m_Creator  = creator;
        m_ObjectId = csbl.InstanceId;

        // Add ColonyRunner
        if (bFight)
        {
            //--to do: Detectable.cs, if the entity can be attack
//            if (gameObject.GetComponent<ColonyRunner>() == null)
//            {
//                ColonyRunner cr = gameObject.AddComponent<ColonyRunner>();
//                cr.m_Entity = m_Entity;
//            }
        }
        return(r);
    }
Пример #9
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);
                }
            }
        }
    }
    public override void Turn90Degree()
    {
        base.Turn90Degree();
        if (!GameConfig.IsMultiMode)
        {
            CSEntityObject ceo = GetComponent <CSEntityObject>();
            if (ceo != null)
            {
                csbl = GetComponentInParent <CSBuildingLogic>();
                if (csbl != null)
                {
                    ceo.Init(csbl, ceo.m_Creator, false);

                    csbl.m_Entity.AfterTurn90Degree();
                }

                //else{
                //        ceo.Init(itemObjectId, ceo.m_Creator, false);
                //    }
            }
        }

        OnItemOpGUIHide();
    }
Пример #11
0
 public virtual void AddLogic(int id, CSBuildingLogic csb)
 {
 }
Пример #12
0
 public override void AddLogic(int id, CSBuildingLogic csb)
 {
     allBuildingLogic.Add(id, csb);
 }
Пример #13
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
        //{

        //}
    }
Пример #14
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);
    }
Пример #15
0
    public override void OnConstruct()
    {
        base.OnConstruct();
        csbl = GetComponentInParent <CSBuildingLogic>();
        if (!GameConfig.IsMultiMode)
        {
            CSMgCreator creator = CSMain.s_MgCreator;
            if (creator != null)
            {
                CSEntityObject ceo = GetComponent <CSEntityObject>();
                int            r;
                if (csbl != null)
                {
                    r = ceo.Init(csbl, creator);
                }
                else
                {
                    r = ceo.Init(itemObjectId, creator);
                }

                if (r != CSConst.rrtSucceed)
                {
                    Debug.LogError("Error with Init Entities");
                }
                else
                {
                    if (ceo.m_Type == CSConst.ObjectType.Assembly)
                    {
                        CSMain.SinglePlayerCheckClod();

                        //--to do: attack
                        //ColonyRunner cr = gameObject.GetComponent<ColonyRunner>();
                        //if (cr != null)
                        //{
                        //    cr.DeathHandlerEvent += OnTowerDeath;
                        //}
                    }

//					SendMessage("OnPutGo", mItemObj.instanceId);
                }
            }

//		    SendMessage("OnCreatedGo", mItemObj.instanceId);
        }
        else
        {
            int buildingTeam;
            if (csbl != null)
            {
                buildingTeam = csbl.TeamId;
            }
            else
            {
                buildingTeam = mNetlayer.TeamId;
            }
            ;
            CSMgCreator creator;
            if (buildingTeam == BaseNetwork.MainPlayer.TeamId)
            {
                creator = CSMain.s_MgCreator;
            }
            else
            {
                creator = CSMain.Instance.MultiGetOtherCreator(buildingTeam) as CSMgCreator;
            }
            if (creator != null)
            {
                CSEntityObject ceo           = GetComponent <CSEntityObject>();
                ColonyNetwork  colonyNetwork = mNetlayer as ColonyNetwork;
                ceo._ColonyObj = colonyNetwork._ColonyObj;
                int r;
                if (csbl != null)
                {
                    r = ceo.Init(csbl, creator);
                }
                else
                {
                    r = ceo.Init(itemObjectId, creator);
                }

                if (r != CSConst.rrtSucceed)
                {
                    Debug.LogError("Error with Init Entities");
                    //				Debug.Break();
                }
                else
                {
                    if (ceo.m_Type == CSConst.ObjectType.Assembly)
                    {
                        CSMain.SinglePlayerCheckClod();

                        //--to do: attack
                        //ColonyRunner cr = gameObject.GetComponent<ColonyRunner>();
                        //if (cr != null)
                        //{
                        //    cr.DeathHandlerEvent += OnTowerDeath;
                        //}
                    }

                    //SendMessage("OnPutGo", mItemObj.instanceId);
                }
            }
            //SendMessage("OnCreatedGo", itemObj.instanceId);
        }
    }