public ITrajectory Get(TrajectoryType trajectoryType) { ITrajectory trajectory = null; traj.TryGetValue((int)trajectoryType, out trajectory); return(trajectory); }
public Trajectory setTrajectory(TrajectoryType type) { this.removeTrajectories(); if (_possibleTrajectories.ContainsKey(type)) { return((Trajectory)gameObject.AddComponent(_possibleTrajectories[type])); } return(null); }
public void LateInit() { long f = this.Position.Distance(this.TargetPosition); this.timeToHit = f.ToFloat() / this.Speed.ToFloat(); if (this.TargetingBehavior != TargetingType.Timed) { this.cachedTransform.position = this.Position.ToVector3(this.CurrentHeight); this.speedPerFrame = this.Speed / 32L; } TrajectoryType trajectory = this.Trajectory; if (trajectory != TrajectoryType.Linear) { if (trajectory == TrajectoryType.Arc) { this.arcStartHeight = this.CurrentHeight; this.arcStartVerticalSpeed = (this.TargetHeight - this.CurrentHeight) / this.timeToHit - -9.8f * this.timeToHit; Vector2 vector = (this.TargetPosition.ToVector2() - this.Position.ToVector2()) / this.timeToHit; this.arcStartVelocity = new Vector3(vector.x, this.arcStartVerticalSpeed, vector.y); } } else { this.HeightSpeed = (this.TargetHeight - this.CurrentHeight) / this.timeToHit; } switch (this.TargetingBehavior) { case TargetingType.Timed: if (this.Delay == 0) { this.CountDown--; this.Hit(); } else { this.CountDown = this.Delay; } break; case TargetingType.Positional: this.targetDirection = this.TargetPosition - this.Position; this.targetDirection.Normalize(); this.targetDirection *= this.speedPerFrame; if (this.CanRotate) { this.cachedTransform.LookAt(this.TargetPosition.ToVector3(this.TargetHeight)); } break; } if (this.onInitialize.IsNotNull()) { this.onInitialize.Invoke(); } EffectManager.LazyCreateEffect(this.StartEffect, this.Source.CachedTransform.position); }
/// <summary> /// Получение параметров модели для определенного типа частицы /// </summary> /// <param name="particleType">Тип частицы</param> /// <param name="trajectoryType">Тип траектории движения частицы</param> /// <param name="useRandom"> /// Требуется ли вектора индукции магнитного поля и /// начальной скорости частицы генерировать случайно /// </param> /// <returns>Параметры модели для заданного типа частицы</returns> public static TrajectoryCalculatorArgs GetArgs(ParticleType particleType, TrajectoryType trajectoryType, bool useRandom) { var r0 = new Vector3D(0, 0, 0); var(q, m) = particleType switch { ParticleType.AlphaParticle => (3.218e-19, 6.645e-27), ParticleType.Electron => (-1.602e-19, 9.109e-31), ParticleType.Proton => (1.602e-19, 1.673e-27) }; var n = 100000; var(v0, t) = particleType switch { ParticleType.AlphaParticle => (new Vector3D(Sqrt(Pow(15000000, 2) / 3)), 3e-6), ParticleType.Electron => (new Vector3D(Sqrt(Pow(5000000, 2) / 3)), 1e-9), ParticleType.Proton => (new Vector3D(Sqrt(Pow(1000000, 2) / 3)), 3e-6) }; var b = new Vector3D(Sqrt(Pow(0.25, 2) / 3)); b = trajectoryType switch { TrajectoryType.Straight => b, TrajectoryType.Circle => new Vector3D(b.X, -b.Y / 2, -b.Z / 2), TrajectoryType.Spiral => b.RotateE1(180) }; if (useRandom) { var random = new Random(); var xAngle = random.NextDouble() * 90; var yAngle = random.NextDouble() * 90; var zAngle = random.NextDouble() * 90; switch (trajectoryType) { case TrajectoryType.Straight: case TrajectoryType.Circle: v0 = v0.RotateE1(xAngle).RotateE2(yAngle).RotateE3(zAngle); b = b.RotateE1(xAngle).RotateE2(yAngle).RotateE3(zAngle); break; case TrajectoryType.Spiral: v0 = v0.RotateE1(xAngle).RotateE2(yAngle); b = b.RotateE2(yAngle).RotateE3(zAngle); break; } ; } v0 = RoundVector(v0, 2); b = RoundVector(b, 5); return(new TrajectoryCalculatorArgs(m, q, t, n, r0, v0, b)); }
public List <Vector3> GetTrajectory(TrajectoryType trajectoryType = TrajectoryType.PreOptimazation) { switch (trajectoryType) { case TrajectoryType.PreOptimazation: lock (_Frames) { return(_Frames.Where(d => d != null).Select(c => c.T_cam_world.Inverse().Translation).ToList()); } case TrajectoryType.Optimazation: lock (_KeyFrames) { return(_KeyFrames.Where(d => d != null).Select(c => c.Frame.T_cam_world.Inverse().Translation).ToList()); } default: return(new List <Vector3>()); } }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); //Targeting EditorGUILayout.LabelField("Targeting Settings", EditorStyles.boldLabel); so.PropertyField("_targetingBehavior"); TargetingType targetingBehavior = (TargetingType)so.FindProperty("_targetingBehavior").enumValueIndex; switch (targetingBehavior) { case TargetingType.Positional: case TargetingType.Seeking: so.PropertyField("_speed"); break; case TargetingType.Timed: so.PropertyField("_delay"); break; } EditorGUILayout.Space(); //Damage EditorGUILayout.LabelField("Damage Settings", EditorStyles.boldLabel); so.PropertyField("_damageBehavior"); switch ((DamageType)so.FindProperty("_damageBehavior").enumValueIndex) { case DamageType.Cone: so.PropertyField("_angle"); break; case DamageType.Area: so.PropertyField("_radius"); break; case DamageType.Single: break; } EditorGUILayout.Space(); //Trajectory EditorGUILayout.LabelField("Trajectory Settings", EditorStyles.boldLabel); so.PropertyField("_trajectoryBehavior"); TrajectoryType trajectoryBehavior = (TrajectoryType)so.FindProperty("_trajectoryBehavior").enumValueIndex; switch (trajectoryBehavior) { case TrajectoryType.Linear: break; case TrajectoryType.Interpolated: so.PropertyField("_interpolationRate"); break; case TrajectoryType.Arc: so.PropertyField("_arcHeight"); break; } EditorGUILayout.Space(); //Visuals EditorGUILayout.LabelField("Visuals Settings", EditorStyles.boldLabel); so.PropertyField("_startEffect"); so.PropertyField("_endEffect"); so.PropertyField("_attachEndEffectToTarget"); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); } }
public void SetFreedomTrajectory(TrajectoryType t, List<AttackMagic> enemyAttackMagicList) { if(AuraManager.Instance.E02Enemy==true) { foreach (AttackMagic a in enemyAttackMagicList) { a.trajectory = t; } } foreach (AttackMagic a in enemyAttackMagicList) { if (a.waitToFire == FireThisTurn && a.HasEffect("Freedom")) { a.trajectory = t; } } }
public void SetFreedomTrajectory(TrajectoryType t,AttackMagic atk) { atk.trajectory = t; }
public void OnTrajectoryChange(int attackID, TrajectoryType trajectory) { networkView.RPC("TrajectoryChange", RPCMode.Others, Client.Instance.GetLocalIp(), attackID, trajectory); }
void UseCard2Def(int defenceNow,int atkPermit,int atk,TrajectoryType tra) { Card card = FindDefenceCard(defenceNow,atkPermit, atk); CastShield_Destroy(card, tra); }
//从头开始一个一个拉出来,如果超过了就继续,同时加强该路的防御 void DefenseTheWay(int defencePower, int atkPower, TrajectoryType way) { Debug.Log("DTW:" + way.ToString()+"def:"+defencePower.ToString()+"atk:"+atkPower.ToString() +" NUM:"+freedomList.Count.ToString()); int def = 0; for (int i = freedomList.Count - 1; i >= 0; i--) { def += freedomList[i].magicValue; AttackManager.Instance.SetFreedomTrajectory(way, freedomList[i]); freedomList.RemoveAt(i); if (def + defencePower > atkPower) { break; } } switch(way) { case TrajectoryType.Left: EL_Shield += def; break; case TrajectoryType.Middle: EM_Shield += def; break; case TrajectoryType.Right: ER_Shield += def; break; } }
void Trajectory2Def(int damagePermit,TrajectoryType tra,bool E02) { if (RefreshFreedomEnough(tra, E02)) return; switch(tra) { case TrajectoryType.Middle: if(E02==true) { UseCard2Def( EM_Shield, damagePermit, herosMiddle + herosFreedom, TrajectoryType.Middle); return; } UseCard2Def(EM_Shield, damagePermit + enemyMiddle, herosMiddle + herosFreedom, TrajectoryType.Middle); return; case TrajectoryType.Left: UseCard2Def( EL_Shield, damagePermit, herosFreedom, TrajectoryType.Left); return; case TrajectoryType.Right: UseCard2Def( ER_Shield, damagePermit, herosFreedom, TrajectoryType.Right); return; } }
bool RefreshFreedomEnough(TrajectoryType tra,bool E02) { switch(tra) { case TrajectoryType.Middle: if (EM_Refresh == false) return false; if(E02) return Damage(enemyMiddle+EM_Shield+enemyFreedom,herosMiddle+herosFreedom)<=0;//要改 else return Damage(enemyMiddle + EM_Shield + enemyFreedom, herosMiddle + herosFreedom) <= 0; case TrajectoryType.Left: if (EL_Refresh == false) return false; if (E02) return Damage(EL_Shield + enemyFreedom, herosFreedom) <= 0;//要改 else return Damage(enemyMiddle + EL_Shield + enemyFreedom, herosFreedom) <= 0; case TrajectoryType.Right: if (ER_Refresh == false) return false; if (E02) return Damage(ER_Shield + enemyFreedom, herosFreedom) <= 0;//要改 else return Damage(enemyMiddle + ER_Shield + enemyFreedom, herosFreedom) <= 0; } return true; }
void CastShield_Destroy(Card card,TrajectoryType tra) { // Debug.Log("CastShield"); if (card == null) return; int trajectory=0; switch(tra) { case TrajectoryType.Left: trajectory = -1; break; case TrajectoryType.Middle: trajectory = 0; break; case TrajectoryType.Right: trajectory = 1; break; } EnergyManager.Instance.EMinusEnergy(card.cost); DrawCard.Instance.Cast(card.ID, trajectory); UpdateEShieldInfo(card, tra); DestroyUsedCard(card); }
void UpdateEShieldInfo(Card card,TrajectoryType tra) { switch (tra) { case TrajectoryType.Left: EL_Shield = card.magicValue; EL_Refresh = card.HasEffect("Refresh"); break; case TrajectoryType.Middle: EM_Shield = card.magicValue; EM_Refresh = card.HasEffect("Refresh"); break; case TrajectoryType.Right: ER_Shield = card.magicValue; ER_Refresh = card.HasEffect("Refresh"); break; } }
public void SetTrajectory() { //Debug.Log("SetTrajectory"); trajectory = (TrajectoryType)TrajectoryPosition.Instance.ID; if (LevelManager.Instance.IsOnline) { int tempT=(int)trajectory; tempT=-tempT; Client.Instance.OnTrajectoryChange(attackID, (TrajectoryType)tempT); } TrajectoryPosition.Instance.HidePosition(); TrajectoryPosition.Instance.SetTrajectory -= this.SetTrajectory; chooseTrajectory = false; if (LevelManager.Instance.level == 1 && LevelManager.Instance.key.Contains("MouseOver")) { GuideText.Instance.ReturnText(20); LevelManager.Instance.key.Remove("MouseOver"); } }