public PostureTransform GetPosture(PosturePoint point) { PostureTransform posture = null; this.PostureDic.TryGetValue(point, out posture); return(posture); }
public void SetQuaternion(PosturePoint point, int index, UnityEngine.Quaternion quo) { if (this.PostureDic.ContainsKey(point) == false) { return; } this.PostureDic[point].SetQuaternion(index, quo); }
//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); }
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); }
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]); }
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 }); }
protected Transform GetMuzzleTransform(PosturePoint point) { var cannon = unitTransform.GetCannonTransform(point); return(cannon == null ? null: cannon.Muzzle); }