Example #1
0
    void Awake()
    {
        name = photonView.Owner.NickName;
        MessageBroker.Default.Receive <ResData>().Subscribe(x =>
        {
            if (GameConst.ResPlayerRemote == x.Type && x.Data != null && !photonView.IsMine && _remote == null)
            {
                var asset = x.Data.LoadAsset("RemotePlayer");
                asset.SetParent(transform, false);
                _message = new MessageBroker();
                _remote  = asset.GetComponent <RemotePlayer>();
                _remote.Setup(_message, transform.position, transform.rotation);
            }
            if (GameConst.ResPlayerLocal == x.Type && x.Data != null && photonView.IsMine && _local == null)
            {
                var asset = x.Data.LoadAsset("LocalPlayer");
                asset.SetParent(transform, false);
                Setup(asset);
            }
        }).AddTo(this);
        var msg = new MsgData()
        {
            Type = GameConst.MsgEnterGame, Data = photonView.IsMine
        };

        MessageBroker.Default.Publish(msg);
    }
Example #2
0
    void Awake()
    {
        name     = GameSetting.Instance.Bot.Name;
        _message = new MessageBroker();
        _route   = GameObject.Find("Position/Bot").transform;

        MessageBroker.Default.Receive <ResData>().Subscribe(x =>
        {
            if (GameConst.ResPlayerRemote == x.Type && x.Data != null)
            {
                var asset = x.Data.LoadAsset("RemoteBot");
                asset.SetParent(transform, false);
                _bot = asset.GetComponent <RemotePlayer>();
                _bot.Setup(_message, transform.position + Vector3.one * 0.0001f, transform.rotation);
            }
        }).AddTo(this);
    }