Ejemplo n.º 1
0
        public override void ModuleInitialize(WeaponBase weapon)
        {
            base.ModuleInitialize(weapon);

            Owner.Subscribe(item =>
            {
                if (!item)
                {
                    return;
                }
                var playerID = item.GetMyProvider.MyID;
                manager      = FindObjectOfType <NetworkEventManager>();
                manager.AddSyncEvent(playerID, "ShotModule_Shot" + _myID, (data) => {
                    var p        = (Vector3)(data[0]);
                    var r        = (Quaternion)(data[1]);
                    var b        = Instantiate(_bullet, p, r);
                    b.Owner      = Owner.Value;
                    b.ModuleData = _moduleData;

                    var e = Instantiate(_muzzle, p, r);
                    e.transform.SetParent(_shotAnchor);
                    e.transform.localPosition = new Vector3();
                    e.PlayEffect();

                    Observable.Timer(System.TimeSpan.FromSeconds(1)).Subscribe(_ => {
                        e.DestroyEffect();
                    }).AddTo(this);

                    Audio.AudioManager.PlaySE(ShotSEName, position: p);
                });
            });

            var transforms = weapon.transform.GetComponentsInChildren <Transform>();

            foreach (Transform item in transforms)
            {
                if (item.name == "[ShotAnchor]")
                {
                    _shotAnchor = item;
                    return;
                }
            }

            Debug.LogWarning("not found child object. name : [ShotAnchor]");
        }
Ejemplo n.º 2
0
        public override void ModuleInitialize(WeaponBase weapon)
        {
            base.ModuleInitialize(weapon);

            _prevPosition = transform.position;
            _samples      = new List <Vector3>();

            Owner.Subscribe(item =>
            {
                Debug.Log("OwnerSet :" + item);

                if (!item)
                {
                    return;
                }
                var playerID = item.GetMyProvider.MyID;
                manager      = FindObjectOfType <NetworkEventManager>();
                manager.AddSyncEvent(playerID, "ThrowModule_Throw" + _myID, (data) => {
                    var p           = (Vector3)(data[0]);
                    var r           = (Quaternion)(data[1]);
                    var v           = (Vector3)(data[2]);
                    var b           = Instantiate(_bomb, p, r);
                    b.Owner         = Owner.Value;
                    b.ModuleData    = _moduleData;
                    b.Modular.Speed = v.magnitude;

                    Audio.AudioManager.PlaySE("whip-gesture1", position: p);
                });
            });

            var transforms = weapon.transform.GetComponentsInChildren <Transform>();

            foreach (Transform item in transforms)
            {
                if (item.name == "[ShotAnchor]")
                {
                    _throwAnchor = item;
                    return;
                }
            }

            Debug.LogWarning("not found child object. name : [ShotAnchor]");
        }