Exemplo n.º 1
0
        public PostureTransform GetPosture(PosturePoint point)
        {
            PostureTransform posture = null;

            this.PostureDic.TryGetValue(point, out posture);
            return(posture);
        }
Exemplo n.º 2
0
        public void SetQuaternion(PosturePoint point, int index, UnityEngine.Quaternion quo)
        {
            if (this.PostureDic.ContainsKey(point) == false)
            {
                return;
            }

            this.PostureDic[point].SetQuaternion(index, quo);
        }
Exemplo n.º 3
0
        //public PostureTransform GetPosture(PosturePoint point)
        //{
        //    PostureTransform posture = null;
        //    this.PostureDic.TryGetValue(point, out posture);
        //    return posture;
        //}

        //Dictionary<PosturePoint,CannonTransform> cannonDic = null;
        //public CannonTransform GetCannonTransform(PosturePoint point)
        //{
        //    cannonDic = cannonDic ?? new Dictionary<PosturePoint,CannonTransform>();
        //    if (cannonDic.ContainsKey(point) == false)
        //    {
        //        var cannon = this.GetTerminal<CannonTransform>(point);
        //        if (cannon == null)
        //            return null;
        //
        //        cannonDic.Add(point, cannon);
        //    }
        //
        //    return cannonDic[point];
        //}

        //public void Clear()
        //{
        //    postureDic?.Clear();
        //    cannonDic?.Clear();
        //}

        public T GetTerminal <T>(PosturePoint point) where T : AttachedTransform
        {
            if (this.PostureDic.ContainsKey(point))
            {
                return(this.PostureDic[point].TerminalAttached as T);
            }

            return(null);
        }
Exemplo n.º 4
0
        public void OnFire(PosturePoint point)
        {
            if (this.SpatialComp == null || this.BulletWriter == null)
            {
                return;
            }

            var time = Time.time;

            if (time - fireTime <= interval)
            {
                return;
            }

            var muzzle = GetMuzzleTransform(point);

            if (muzzle == null)
            {
                return;
            }

            fireTime = time;

            var pos = muzzle.position - origin;
            var vec = muzzle.forward;

            vec *= bulletSpeed;

            var id   = this.BulletWriter.Data.CurrentId;
            var fire = new BulletFireInfo()
            {
                Power           = 1,
                Type            = 1,
                Alignment       = 3,
                LaunchPosition  = pos.ToFixedPointVector3(),
                InitialVelocity = vec.ToFixedPointVector3(),
                LaunchTime      = Time.time,
                LifeTime        = lifeTime,
                GunId           = 0,
                ShooterEntityId = SpatialComp.EntityId.Id,
                BulletId        = id,
            };

            this.BulletWriter.SendUpdate(new BulletComponent.Update
            {
                CurrentId = id + 1
            });
            this.BulletWriter.SendFiresEvent(fire);
        }
Exemplo n.º 5
0
        public CannonTransform GetCannonTransform(PosturePoint point)
        {
            cannonDic = cannonDic ?? new Dictionary <PosturePoint, CannonTransform>();
            if (cannonDic.ContainsKey(point) == false)
            {
                var cannon = this.GetTerminal <CannonTransform>(point);
                if (cannon == null)
                {
                    return(null);
                }

                cannonDic.Add(point, cannon);
            }

            return(cannonDic[point]);
        }
Exemplo n.º 6
0
        void CommonUpdate(PosturePoint attached, int num)
        {
            var     dic = gunWriter.Data.GunsDic;
            GunInfo gun;

            if (dic.TryGetValue(attached, out gun) == false)
            {
                return;
            }

            gun.StockBullets = Mathf.Clamp(gun.StockBullets + num, 0, gun.StockMax);

            gunWriter.SendUpdate(new GunComponent.Update
            {
                GunsDic = dic
            });
        }
Exemplo n.º 7
0
        protected Transform GetMuzzleTransform(PosturePoint point)
        {
            var cannon = unitTransform.GetCannonTransform(point);

            return(cannon == null ? null: cannon.Muzzle);
        }