Ejemplo n.º 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();
            }
        }
    }
Ejemplo n.º 2
0
 void Awake()
 {
     m_CEO = GetComponentInChildren <CSEntityObject>();
     if (null != m_CEO)
     {
         m_CEO.m_BoundState = 0;
     }
 }
    public void OnOpen()
    {
        CSEntityObject ceo = GetComponent <CSEntityObject>();

        if (CSUI_MainWndCtrl.Instance != null && ceo != null)
        {
            //CSUI_MainWndCtrl.Instance.AwakeWindow();
            CSUI_MainWndCtrl.Instance.ShowWndPart(ceo.m_Entity);
        }

        HideItemOpGui();

        OnItemOpGUIHide();
    }
    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();
    }
    public override void OnGetBtn()
    {
        //base.OnGetBtn ();
        //if (!GameConfig.IsMultiMode)
        //{
        CSEntityObject ceo = GetComponent <CSEntityObject>();

        if (ceo == null)
        {
            return;
        }

        if (EntityMonsterBeacon.IsRunning())
        {
            PeTipMsg.Register(PELocalization.GetString(8000622), PeTipMsg.EMsgLevel.Warning);
            CloseOn();
            return;
        }

        if (ceo.m_Entity.BaseData.m_Durability < ceo.m_Entity.m_Info.m_Durability * 0.15f)
        {
            MessageBox_N.ShowOkBox(PELocalization.GetString(8000084));
        }
        else
        {
            if (ceo as CSDwellingsObject != null)
            {
                MessageBox_N.ShowYNBox(PELocalization.GetString(8000085), GetOn, CloseOn);
            }
            else
            {
                MessageBox_N.ShowYNBox(PELocalization.GetString(8000086), GetOn, CloseOn);
            }
        }
        //}
    }
    public override void DoGetItem()
    {
        if (null == pkg || null == itemObj || !pkg.CanAdd(itemObj))
        {
            PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning);
            return;
        }
        CSEntityObject ceo = GetComponent <CSEntityObject>();

        if (ceo != null)
        {
            float dura    = ceo.m_Entity.BaseData.m_Durability;
            float maxDura = ceo.m_Entity.m_Info.m_Durability;
            ceo.m_Entity.BaseData.m_Durability = dura - Mathf.Floor(maxDura * 0.1f);
            if (ceo.m_Creator.RemoveEntity(ceo.m_Entity.ID, false) != null)
            {
                base.DoGetItem();
            }
        }
        if (!PeGameMgr.IsMulti)
        {
            SendMessage("OnRemoveGo", itemObjectId, SendMessageOptions.DontRequireReceiver);
        }
    }
Ejemplo n.º 7
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);
        }
    }