private void CalcDirection(Vector3 from, Vector3 to) { Vector3 vector = Mathe.Direction(from, to); switch (Math.Sign(vector.x)) { case -1: _iStartDirection = UISortieShip.Direction.Left; _uiAircraft.transform.localEulerAnglesY(180f); break; case 1: _iStartDirection = UISortieShip.Direction.Right; _uiAircraft.transform.localEulerAnglesY(0f); break; } }
public static int NextElement(int now, int min, int max, bool isFoward, Predicate <int> notConditions) { int num = (!isFoward) ? -1 : 1; int num2 = now + num; num2 = Mathe.MinMax2(num2, min, max); while (!notConditions.Invoke(num2)) { if (num2 == min || num2 == max) { num2 = (notConditions.Invoke(num2) ? num2 : now); break; } num2 += num; num2 = Mathe.MinMax2(num2, min, max); } return(num2); }
public Camera(Vektor lookfrom, Vektor lookat, Vektor vup, double vfov, double aspect_ratio, double aperture, double focus_dist) { var theta = Mathe.ToRad(vfov); var h = Math.Tan(theta / 2); var viewport_height = 2 * h; var viewport_width = aspect_ratio * viewport_height; w = Vektor.unit_Vektor(lookfrom - lookat); u = Vektor.unit_Vektor(Vektor.cross(vup, w)); v = Vektor.cross(w, u); origin = lookfrom; horizontal = focus_dist * viewport_width * u; vertical = focus_dist * viewport_height * v; lower_left_corner = origin - horizontal / 2 - vertical / 2 - focus_dist * w; lens_radius = aperture / 2; }
public override void Play(Action callback) { base.get_transform().set_localScale(Vector3.get_one()); this._actCallback = callback; if (this._nFromHP <= 0) { return; } if (this._nDamage >= 0) { base.get_transform().LTValue(0f, (float)this._nDamage, 0.65f).setEase(LeanTweenType.easeOutExpo).setOnUpdate(delegate(float x) { int damageSprite = (int)Math.Round((double)x); this.setDamageSprite(damageSprite); }).setOnComplete(new Action(this.compGaugeDamage)); this._animeDamage.Stop(); if (this._hitType == BattleHitStatus.Clitical) { this._animeDamage.Play("ShowDamageCriticall"); } else { this._animeDamage.Play("ShowDamageNormal"); } } base.get_transform().LTValue((float)this._nFromHP, (float)this._nToHP, 0.7f).setEase(LeanTweenType.easeOutExpo).setOnUpdate(delegate(float x) { int num = (int)Math.Round((double)x); this._uiHPLabel.textInt = num; this._uiForeground.fillAmount = Mathe.Rate(0f, (float)this._nMaxHP, x); this._uiForeground.color = Util.HpGaugeColor2(this._nMaxHP, num); this._uiHPLabel.color = Util.HpLabelColor(this._nMaxHP, num); }).setOnComplete(new Action(this.onAnimationFinished)); switch (this._hitType) { case BattleHitStatus.Miss: this.PlayMiss(); break; case BattleHitStatus.Clitical: this.PlayCriticall(); break; } }
public override void Steer() { if (stateMachine.isSeeking) { Vector3 desired = target.position - transform.position; distanceToTarget = desired.magnitude - PlayerOffset; if (distanceToTarget < MaxSlowDistance) { float mappedSpeed = Mathe.Map(distanceToTarget, 0, MaxSlowDistance, 0, maxSpeed); desired = desired.normalized * mappedSpeed; } else { desired = desired.normalized * maxSpeed; } Vector3 steering = desired - velocity; steering = Vector3.ClampMagnitude(steering, maxForce); vehicle.ApplyForce(steering); } }
public virtual IObservable <bool> Play(Action onPlayBufferEffect, Action onCalcInitLineRotation, Action onPlayLineAnimation, Action onNextFocusShipAnimation, int nBufferCnt) { this._nBufferCnt = Mathe.MinMax2(nBufferCnt, 0, 4); this._clsCameraBezier = new Bezier(Bezier.BezierType.Quadratic, this._vStartCameraPivot, this._listEndCameraPivot.get_Item(this._nBufferCnt), this._vMidCameraPivot, Vector3.get_zero()); this._clsFleetBezier = new Bezier(Bezier.BezierType.Quadratic, this._vStartFleetPivot, this._vEndFleetPivot, this._vMidFleetPivot, Vector3.get_zero()); BattleField battleField = BattleTaskManager.GetBattleField(); this._traFleetAnchorFriend = battleField.dicFleetAnchor.get_Item(FleetType.Friend); this._traFleetAnchorEnemy = battleField.dicFleetAnchor.get_Item(FleetType.Enemy); this._traFleetAnchorEnemy.get_transform().set_localScale(Vector3.get_one() * 0.8f); BattleCameras battleCameras = BattleTaskManager.GetBattleCameras(); battleCameras.SetVerticalSplitCameras(false); battleCameras.fieldDimCamera.maskAlpha = 0f; battleCameras.SwitchMainCamera(FleetType.Enemy); BattleFieldCamera battleFieldCamera = battleCameras.fieldCameras.get_Item(1); battleFieldCamera.ReqViewMode(CameraActor.ViewMode.FixChasing); battleFieldCamera.eyePosition = this._clsCameraBezier.Interpolate(0f); battleFieldCamera.pointOfGaze = Vector3.Lerp(this._clsFleetBezier.Interpolate(0f), this._listEnemyFleetPivot.get_Item(this._nBufferCnt), 0.5f); battleFieldCamera.get_transform().LookAt(battleFieldCamera.pointOfGaze); BattleShips battleShips = BattleTaskManager.GetBattleShips(); battleShips.SetBollboardTarget(battleFieldCamera.get_transform()); battleShips.SetLayer(Generics.Layers.ShipGirl); BattleCutInEffectCamera cutInEffectCamera = BattleTaskManager.GetBattleCameras().cutInEffectCamera; UITexture component = cutInEffectCamera.get_transform().FindChild("TorpedoLine/OverlayLine").GetComponent <UITexture>(); if (component != null) { component.alpha = 0f; } this._actOnPlayBufferEffect = onPlayBufferEffect; this._actOnNextFocusShipAnimation = onNextFocusShipAnimation; Observable.NextFrame(FrameCountType.Update).Subscribe(delegate(Unit x) { Dlg.Call(ref onCalcInitLineRotation); Dlg.Call(ref onPlayLineAnimation); }); return(Observable.FromCoroutine <bool>((IObserver <bool> observer) => this.AnimationObserver(observer))); }
public virtual UniRx.IObservable <bool> Play(Action onPlayBufferEffect, Action onCalcInitLineRotation, Action onPlayLineAnimation, Action onNextFocusShipAnimation, int nBufferCnt) { _nBufferCnt = Mathe.MinMax2(nBufferCnt, 0, 4); _clsCameraBezier = new Bezier(Bezier.BezierType.Quadratic, _vStartCameraPivot, _listEndCameraPivot[_nBufferCnt], _vMidCameraPivot, Vector3.zero); _clsFleetBezier = new Bezier(Bezier.BezierType.Quadratic, _vStartFleetPivot, _vEndFleetPivot, _vMidFleetPivot, Vector3.zero); BattleField battleField = BattleTaskManager.GetBattleField(); _traFleetAnchorFriend = battleField.dicFleetAnchor[FleetType.Friend]; _traFleetAnchorEnemy = battleField.dicFleetAnchor[FleetType.Enemy]; _traFleetAnchorEnemy.transform.localScale = Vector3.one * 0.8f; BattleCameras battleCameras = BattleTaskManager.GetBattleCameras(); battleCameras.SetVerticalSplitCameras(isSplit: false); battleCameras.fieldDimCamera.maskAlpha = 0f; battleCameras.SwitchMainCamera(FleetType.Enemy); BattleFieldCamera battleFieldCamera = battleCameras.fieldCameras[1]; battleFieldCamera.ReqViewMode(CameraActor.ViewMode.FixChasing); battleFieldCamera.eyePosition = _clsCameraBezier.Interpolate(0f); battleFieldCamera.pointOfGaze = Vector3.Lerp(_clsFleetBezier.Interpolate(0f), _listEnemyFleetPivot[_nBufferCnt], 0.5f); battleFieldCamera.transform.LookAt(battleFieldCamera.pointOfGaze); BattleShips battleShips = BattleTaskManager.GetBattleShips(); battleShips.SetBollboardTarget(battleFieldCamera.transform); battleShips.SetLayer(Generics.Layers.ShipGirl); BattleCutInEffectCamera cutInEffectCamera = BattleTaskManager.GetBattleCameras().cutInEffectCamera; UITexture component = ((Component)cutInEffectCamera.transform.FindChild("TorpedoLine/OverlayLine")).GetComponent <UITexture>(); if (component != null) { component.alpha = 0f; } _actOnPlayBufferEffect = onPlayBufferEffect; _actOnNextFocusShipAnimation = onNextFocusShipAnimation; Observable.NextFrame().Subscribe(delegate { Dlg.Call(ref onCalcInitLineRotation); Dlg.Call(ref onPlayLineAnimation); }); return(Observable.FromCoroutine((UniRx.IObserver <bool> observer) => AnimationObserver(observer))); }
public void SetHPGauge(int maxHP, int beforeHP, int afterHP, int damage, BattleHitStatus status, bool isFriend) { this._uiHPLabel.textInt = beforeHP; this._nMaxHP = maxHP; this._nFromHP = beforeHP; this._nToHP = ((afterHP <= 0) ? 0 : afterHP); this._nDamage = ((damage < 100000) ? damage : 99999); this._hitType = ((this._nDamage <= 0) ? status : status); base.get_transform().set_localPosition((!isFriend) ? (Vector3.get_left() * 200f) : (Vector3.get_right() * 200f)); if (this._hitType == BattleHitStatus.Miss) { this._nDamage = -1; } int now = (int)Math.Floor((double)((float)this._nFromHP)); this._uiHPLabel.textInt = this._nFromHP; this._uiForeground.color = Util.HpGaugeColor2(this._nMaxHP, now); this._uiHPLabel.color = Util.HpLabelColor(this._nMaxHP, now); this._uiForeground.fillAmount = Mathe.Rate(0f, (float)this._nMaxHP, (float)this._nFromHP); this.setDamageLabelPos(); }
public void Extend(bool isVec, Action callback) { _actCallback = callback; base.transform.LookAt(_vecTorpedoTarget); Vector3 vector = Mathe.Direction(base.transform.position, _vecTorpedoTarget); Hashtable hashtable = new Hashtable(); if (isVec) { hashtable.Add("z", vector.z); } else { hashtable.Add("z", vector.z * -1f); } hashtable.Add("isLocal", false); hashtable.Add("time", _moveTime); hashtable.Add("delay", _delayTime); hashtable.Add("easeType", iTween.EaseType.linear); base.gameObject.ScaleTo(hashtable); }
public void SetHPGauge(int maxHP, int beforeHP, int afterHP, int damage, BattleHitStatus status, bool isFriend) { _uiHPLabel.textInt = beforeHP; _nMaxHP = maxHP; _nFromHP = beforeHP; _nToHP = ((afterHP > 0) ? afterHP : 0); _nDamage = ((damage < 100000) ? damage : 99999); _hitType = ((_nDamage <= 0) ? status : status); base.transform.localPosition = ((!isFriend) ? (Vector3.left * 200f) : (Vector3.right * 200f)); if (_hitType == BattleHitStatus.Miss) { _nDamage = -1; } int now = (int)Math.Floor((float)_nFromHP); _uiHPLabel.textInt = _nFromHP; _uiForeground.color = Util.HpGaugeColor2(_nMaxHP, now); _uiHPLabel.color = Util.HpLabelColor(_nMaxHP, now); _uiForeground.fillAmount = Mathe.Rate(0f, _nMaxHP, _nFromHP); setDamageLabelPos(); }
public void SetShipData(ShipModel model, int nIndex) { base.SetShipData(model); if (model == null) { this._uiStarManager.SetStar(0); if (this._bunnerShutter != null) { this._bunnerShutter.SetActive(true); if (this._shipState != null) { UISelectedObject.SelectedOneObjectBlink(this._uiBackground.get_gameObject(), false); this._shipState.SetActive(false); } } else { base.get_transform().localScaleZero(); } return; } if (this._shipState != null) { this._shipState.SetActive(true); } base.get_transform().localScaleOne(); if (this._bunnerShutter != null) { this._bunnerShutter.SetFocusLight(false); this._bunnerShutter.SetActive(false); } this._uiIndex.textInt = nIndex; this._uiHpSlider.value = Mathe.Rate(0f, (float)model.MaxHp, (float)model.NowHp); this._uiHpSlider.foregroundWidget.color = Util.HpLabelColor(model.MaxHp, model.NowHp); this._uiLv.textInt = model.Level; this._uiName.text = model.Name; this._uiSupplyState.setSupplyState(model); this._uiSupplyState.SetActive(this._uiSupplyState.isEitherSupplyNeeds); this._uiStarManager.SetStar(model.Srate); }
public void PlayWarVateransGauge(Action callback) { _uiWarVateransSlider.transform.LTValue(0f, 1f, 0.5f).setEase(LeanTweenType.linear).setOnUpdate(delegate(float x) { _uiWarVateransSlider.alpha = x; }); Vector3 to = _uiWarVateransSlider.transform.localPosition + ((fleetType != 0) ? Vector3.right : Vector3.left) * _fWarVateransSliderOffs; _uiWarVateransSlider.transform.LTMoveLocal(to, 0.5f).setEase(LeanTweenType.linear); _uiWarVateransSlider.transform.LTValue(0f, warVateransVal[1], 0.5f).setDelay(1f).setEase(LeanTweenType.linear) .setOnUpdate(delegate(float x) { _uiWarVateransSlider.value = Mathe.Rate(0f, warVateransVal[0], x); }) .setOnComplete((Action) delegate { Observable.Timer(TimeSpan.FromSeconds(0.5)).Subscribe(delegate { Dlg.Call(ref callback); }); }); }
private Color GetSeaColor(TimeZone iTime, SkyType iSkyType) { Color result = Color.get_white(); if (iSkyType == SkyType.Normal) { result = KCVColor.ConvertColor(90f, 173f, 177f, 255f); } else { int length = Enum.GetValues(typeof(SkyType)).get_Length(); SkyType skyType; switch (iSkyType) { case SkyType.FinalArea171: skyType = SkyType.FinalArea172; break; case SkyType.FinalArea172: skyType = SkyType.FinalArea173; break; case SkyType.FinalArea173: skyType = SkyType.FinalArea174; break; case SkyType.FinalArea174: skyType = SkyType.FinalArea174; break; default: skyType = SkyType.FinalArea174; break; } float t = (float)skyType / (float)(length - 1); result = KCVColor.ConvertColor(Mathe.Lerp(90f, 255f, t), Mathe.Lerp(173f, 68f, t), Mathe.Lerp(177f, 68f, t), 255f); } return(result); }
protected override void SetShipInfos(ShipModel_BattleResult model) { this.SetShipName(model.Name); this.SetShipBannerTexture(ShipUtils.LoadBannerTextureInVeteransReport(model), model.DamagedFlgEnd, model.DmgStateEnd, model.IsEscape()); base.SetShipIcons(model.DmgStateEnd, model.IsGroundFacility(), model.IsEscape()); this.SetHPSliderValue(model.HpStart, model.MaxHp); this._uiLv.textInt = (this._nDrawNowLv = model.Level); if (!this.isFriend) { this._uiLv.SetActive(false); this._uiLvLabel.SetActive(false); this._uiShipName.SetActive(true); } else { this._uiEXPSlider.value = Mathe.Rate(0f, 100f, (float)model.ExpInfo.ExpRateBefore); this._uiEXPSlider.foregroundWidget.color = KCVColor.WarVateransEXPGaugeGreen; this._uiShipName.SetActive(false); } this._uiEXPSlider.alpha = 0f; this._uiHPSlider.alpha = 1f; }
private Color GetSeaColor(KCV.Battle.Utils.TimeZone iTime, SkyType iSkyType) { Color white = Color.white; if (iSkyType == SkyType.Normal) { return(KCVColor.ConvertColor(90f, 173f, 177f, 255f)); } int length = Enum.GetValues(typeof(SkyType)).Length; SkyType skyType; switch (iSkyType) { case SkyType.FinalArea171: skyType = SkyType.FinalArea172; break; case SkyType.FinalArea172: skyType = SkyType.FinalArea173; break; case SkyType.FinalArea173: skyType = SkyType.FinalArea174; break; case SkyType.FinalArea174: skyType = SkyType.FinalArea174; break; default: skyType = SkyType.FinalArea174; break; } float t = (float)skyType / (float)(length - 1); return(KCVColor.ConvertColor(Mathe.Lerp(90f, 255f, t), Mathe.Lerp(173f, 68f, t), Mathe.Lerp(177f, 68f, t), 255f)); }
public void PlayFocusCircleAnimation(bool isFocus) { if (isFocus) { base.transform.LTValue(1f, _strParam.focusCircleScale, _strParam.focusCircleScalingTime).setEase(LeanTweenType.linear).setOnUpdate(delegate(float x) { UIBufferCircle uIBufferCircle2 = this; _listMeshRenderer.ForEach(delegate(MeshRenderer obj) { ((Component)obj).transform.localScale = Vector3.one * x; }); ((Component)_mrGear).transform.localScale = Vector3.one * x; }); base.transform.LTValue(_cDefaultBaseColor, _strParam.focusCircleColor, _strParam.focusCircleColorlingTime).setEase(LeanTweenType.linear).setOnUpdate(delegate(Color x) { UIBufferCircle uIBufferCircle = this; _listMeshRenderer.ForEach(delegate(MeshRenderer y) { y.sharedMaterial.color = x; }); _mrGear.sharedMaterial.color = x; }); } else { Color baseColor = _cDefaultBaseColor; base.transform.LTValue(_cDefaultBaseColor.a, Mathe.Rate(0f, 255f, 70f), _strParam.focusCircleColorlingTime).setEase(LeanTweenType.linear).setOnUpdate(delegate(float x) { baseColor.a = x; _listMeshRenderer.ForEach(delegate(MeshRenderer y) { y.sharedMaterial.color = baseColor; }); _mrGear.sharedMaterial.color = baseColor; }); } }
private bool InitMoveCameraTo2D(object data) { BattleFieldCamera cam = BattleTaskManager.GetBattleCameras().fieldCameras[0]; BattleShips battleShips = BattleTaskManager.GetBattleShips(); ProdDetectionStartCutIn pdsc = ProdDetectionStartCutIn.Instantiate(((Component)BattleTaskManager.GetPrefabFile().prefabProdDetectionStartCutIn).GetComponent <ProdDetectionStartCutIn>(), BattleTaskManager.GetBattleCameras().cutInCamera.transform); ShipModel_Battle detectionPrimaryShip = ShipUtils.GetDetectionPrimaryShip(_clsSakuteki.planes_f, isFriend: true); UIBattleShip uIBattleShip = (detectionPrimaryShip == null) ? battleShips.flagShipFriend : battleShips.dicFriendBattleShips[detectionPrimaryShip.Index]; Vector3 vector = Mathe.NormalizeDirection(uIBattleShip.pointOfGaze, Vector3.zero) * 30f; Vector3 pointOfGaze = uIBattleShip.pointOfGaze; float x = pointOfGaze.x; Vector3 pointOfGaze2 = uIBattleShip.pointOfGaze; float y = pointOfGaze2.y; Vector3 pointOfGaze3 = uIBattleShip.pointOfGaze; Vector3 fixChasingCamera = new Vector3(x, y, pointOfGaze3.z + vector.z); cam.pointOfGaze = uIBattleShip.pointOfGaze; cam.ReqViewMode(CameraActor.ViewMode.FixChasing); cam.SetFixChasingCamera(fixChasingCamera); Vector3 pointOfGaze4 = uIBattleShip.pointOfGaze; float x2 = pointOfGaze4.x; Vector3 pointOfGaze5 = uIBattleShip.pointOfGaze; Vector3 endCamPos = new Vector3(x2, 50f, pointOfGaze5.z + vector.z * 6f); Transform transform = uIBattleShip.transform; Vector3 position = BattleTaskManager.GetBattleShips().dicFriendBattleShips[0].transform.position; _psDetectionRipple = Util.Instantiate(ParticleFile.Load(ParticleFileInfos.BattlePSDetectionRipple)).GetComponent <ParticleSystem>(); ((Component)_psDetectionRipple).transform.parent = transform; ((Component)_psDetectionRipple).transform.position = new Vector3(position.x, position.y + 0.01f, position.z); _psDetectionRipple.Play(); pdsc.Play().Subscribe(delegate { cam.transform.LTMove(endCamPos, 1.95f).setEase(LeanTweenType.easeInOutCubic); Mem.DelComponentSafe(ref pdsc); }); return(false); }
private void _fogSettings(KCV.Battle.Utils.TimeZone iTime) { Fog.fog = true; Fog.fogMode = FogMode.Linear; Fog.fogDensity = 0.14f; Fog.fogStartDistance = 20f; Fog.fogEndDistance = 130f; Color color2 = Fog.fogColor = ((iTime != 0) ? new Color(Mathe.Rate(0f, 255f, 65f), Mathe.Rate(0f, 255f, 129f), Mathe.Rate(0f, 255f, 161f), Mathe.Rate(0f, 255f, 255f)) : new Color(Mathe.Rate(0f, 255f, 187f), Mathe.Rate(0f, 255f, 229f), Mathe.Rate(0f, 255f, 240f), Mathe.Rate(0f, 255f, 255f))); }
private void _fogSettings(TimeZone iTime) { Fog.fog = true; Fog.fogMode = 1; Fog.fogDensity = 0.14f; Fog.fogStartDistance = 20f; Fog.fogEndDistance = 130f; Color fogColor = (iTime != TimeZone.DayTime) ? new Color(Mathe.Rate(0f, 255f, 65f), Mathe.Rate(0f, 255f, 129f), Mathe.Rate(0f, 255f, 161f), Mathe.Rate(0f, 255f, 255f)) : new Color(Mathe.Rate(0f, 255f, 187f), Mathe.Rate(0f, 255f, 229f), Mathe.Rate(0f, 255f, 240f), Mathe.Rate(0f, 255f, 255f)); Fog.fogColor = fogColor; }
public static byte GByte2ByteI(int Gbyte) { int num = (int)Mathe.MByte2ByteI(Gbyte) << 10; return((byte)num); }
protected virtual void SetHPSliderValue(int nNowHP, int nMaxHP) { _uiHPSlider.value = Mathe.Rate(0f, nMaxHP, nNowHP); _uiHPSlider.foregroundWidget.color = Util.HpGaugeColor2(nMaxHP, nNowHP); }
public static uint BitAryNum(int iArg) { return(Mathe.BitAryNumCalc(iArg, (int)Mathe.BitTypeNumBit)); }
public static byte Byte2GByteI(int by) { int num = (int)Mathe.Byte2MByteI(by); return((byte)num); }
public static float GByte2ByteF(float Gbyte) { return(Mathe.MByte2ByteF(Gbyte * 1024f)); }
public static float MByte2ByteF(float Mbyte) { return(Mathe.KByte2ByteF(Mbyte * 1024f)); }
protected virtual void _initCameraState() { this._fYAxisLimit = 0f; this._fSmoothCorrectionY = 0f; this._isThroughMaxY = false; CameraActor.ViewMode iViewMode = this._iViewMode; switch (iViewMode + 1) { case CameraActor.ViewMode.FixChasing: base.get_transform().set_position(this._vSrcPos); base.get_transform().set_rotation(this._quaSrcRot); this._vSmoothVelocity = Vector3.get_zero(); break; case CameraActor.ViewMode.FixChasingRot: base.get_transform().set_position(this._vDestPos); base.get_transform().LookAt(this._vPointOfGaze); break; case CameraActor.ViewMode.ZoomChasing: base.get_transform().set_position(this._vSrcPos); this._quaTempRot = base.get_transform().get_rotation(); break; case CameraActor.ViewMode.ZoomChasingUp: { float num = this._fSmoothDistance / Vector3.Distance(this._vPointOfGaze, base.get_transform().get_position()); this._vDestPos = this._vPointOfGaze + (base.get_transform().get_position() - this._vPointOfGaze) * num; this._vSmoothVelocity = Vector3.get_zero(); this._fSmoothTime = 0.2f; this._isAdjust = false; base.get_transform().LookAt(this._vPointOfGaze); break; } case CameraActor.ViewMode.SmoothMove: { float num2 = this._fSmoothDistance / Vector3.Distance(this._vPointOfGaze, base.get_transform().get_position()); this._vDestPos = this._vPointOfGaze + (base.get_transform().get_position() - this._vPointOfGaze) * num2; this._vSmoothVelocity = Vector3.get_zero(); this._fSmoothTime = 0.2f; this._isAdjust = false; this._fAdjustY = base.get_transform().get_position().y + 10f; base.get_transform().LookAt(this._vPointOfGaze); break; } case CameraActor.ViewMode.SmoothMoveKI2ndEdition: case CameraActor.ViewMode.FixedPositionChasing: base.get_transform().set_position(this._vSrcPos); base.get_transform().set_rotation(this._quaSrcRot); break; case CameraActor.ViewMode.RotateAroundObject: base.get_transform().set_position(this._vPointOfGaze + base.get_transform().TransformDirection(Vector3.get_back() * this._fSmoothDistance)); base.get_transform().set_rotation(this._quaDestRot); this._vSmoothVelocity = Vector3.get_zero(); this._fSmoothTime = 0.1f; this._fSmoothCorrectionY = 6f; break; case CameraActor.ViewMode.Rotation: { Vector3 vector = Mathe.Direction(this._vPointOfGaze, this._vDestPos); Vector3 vector2 = this._quaDestRot * vector; base.get_transform().set_position(this._vPointOfGaze + vector2); base.get_transform().LookAt(this._vPointOfGaze); this._vSmoothVelocity = Vector3.get_zero(); break; } case CameraActor.ViewMode.Bezier: base.get_transform().set_position(this._vSrcPos); base.get_transform().set_rotation(this._quaSrcRot); break; case (CameraActor.ViewMode) 11: this.eyePosition = this._vSrcPos; this.eyeRotation = this._quaSrcRot; this._fBezierTime = 0f; break; } }
private static void CalcFormationBrightPoint() { float num = 10f; using (IEnumerator enumerator = Enum.GetValues(typeof(BattleFormationKinds1)).GetEnumerator()) { while (enumerator.MoveNext()) { switch ((int)enumerator.get_Current()) { case 1: { Dictionary <int, Vector3[]> dictionary = new Dictionary <int, Vector3[]>(); for (int i = 1; i <= 6; i++) { Vector3[] array = Util.CalcNWayPosZ(Vector3.get_zero(), i, num); dictionary.Add(i, array); } BattleDefines.FORMATION_POSITION.Add(BattleFormationKinds1.TanJuu, dictionary); break; } case 2: { Dictionary <int, Vector3[]> dictionary2 = new Dictionary <int, Vector3[]>(); for (int j = 1; j <= 6; j++) { if (j <= 2) { Vector3[] array2 = Util.CalcNWayPosX(Vector3.get_zero(), j, num); dictionary2.Add(j, array2); } else if (j <= 4) { Vector3[] array3 = Util.CalcNWayPosX(Vector3.get_zero(), 2, num); Vector3[] array2 = new Vector3[j]; for (int k = 0; k < array2.Length; k++) { float num2 = (k >= 2) ? num : (-num); float z = (k % 2 != 0) ? array3[1].x : array3[0].x; array2[k].x = num2 / 2f; array2[k].y = array3[0].y; array2[k].z = z; } dictionary2.Add(j, array2); } else { Vector3[] array4 = Util.CalcNWayPosX(Vector3.get_zero(), 3, num); Vector3[] array2 = new Vector3[j]; for (int l = 0; l < array2.Length; l++) { float num3 = (l >= 3) ? num : (-num); array2[l].x = num3 / 2f; array2[l].y = array4[0].y; array2[l].z = array4[l % 3].x; } dictionary2.Add(j, array2); } } BattleDefines.FORMATION_POSITION.Add(BattleFormationKinds1.FukuJuu, dictionary2); break; } case 3: { Dictionary <int, Vector3[]> dictionary3 = new Dictionary <int, Vector3[]>(); for (int m = 1; m <= 6; m++) { Vector3[] array5; if (m <= 2) { array5 = Util.CalcNWayPosZ(Vector3.get_zero(), m, num); } else if (m <= 5) { int verNum = (m != 3) ? (m - 1) : m; Vector2[] array6 = Mathe.RegularPolygonVertices(verNum, num / 2f, -90f); array5 = new Vector3[m]; if (m == 3) { int num4 = 0; Vector2[] array7 = array6; for (int n = 0; n < array7.Length; n++) { Vector2 vector = array7[n]; array5[num4].x = array6[num4].x; array5[num4].y = 0f; array5[num4].z = array6[num4].y; num4++; } } else { array5[0] = Vector3.get_zero(); int num4 = 0; Vector2[] array8 = array6; for (int num5 = 0; num5 < array8.Length; num5++) { Vector2 vector2 = array8[num5]; array5[num4 + 1].x = array6[num4].x; array5[num4 + 1].y = 0f; array5[num4 + 1].z = array6[num4].y; num4++; } } } else { Vector3[] array9 = Util.CalcNWayPosZ(Vector3.get_zero(), 4, num); Vector3[] array10 = Util.CalcNWayPosX(Vector3.get_zero(), 3, num); array5 = new Vector3[m]; array5[0] = array9[1]; array5[1] = array9[2]; array5[2] = array9[3]; array5[3] = array9[0]; array5[4] = array10[0]; array5[5] = array10[2]; } dictionary3.Add(m, array5); } BattleDefines.FORMATION_POSITION.Add(BattleFormationKinds1.Rinkei, dictionary3); break; } case 4: { Dictionary <int, Vector3[]> dictionary4 = new Dictionary <int, Vector3[]>(); for (int num6 = 1; num6 <= 6; num6++) { Vector3[] array11 = Util.CalcNWayPosX(Vector3.get_zero(), num6, num / 2f); Vector3[] array12 = new Vector3[array11.Length]; int num7 = 0; Vector3[] array13 = array11; for (int num8 = 0; num8 < array13.Length; num8++) { Vector3 vector3 = array13[num8]; array12[num7].x = vector3.x; array12[num7].y = vector3.y; array12[num7].z = vector3.x; num7++; } dictionary4.Add(num6, array12); } BattleDefines.FORMATION_POSITION.Add(BattleFormationKinds1.Teikei, dictionary4); break; } case 5: { Dictionary <int, Vector3[]> dictionary5 = new Dictionary <int, Vector3[]>(); for (int num9 = 1; num9 <= 6; num9++) { Vector3[] array14 = Util.CalcNWayPosX(Vector3.get_zero(), num9, num); for (int num10 = 0; num10 < array14.Length; num10++) { Vector3 vector4 = array14[num10]; array14[num10].x = -vector4.x; array14[num10].y = vector4.y; array14[num10].z = vector4.z; } dictionary5.Add(num9, array14); } BattleDefines.FORMATION_POSITION.Add(BattleFormationKinds1.TanOu, dictionary5); break; } } } } }
public MainWindow() { InitializeComponent(); const int image_width = 400; const int image_height = 236; double aspect_ratio = (double)image_width / (double)image_height; const int samples_per_pixel = 10; const int max_depth = 50; //World var world = new hittable_list(); var material = new Metal(new Vektor(.7, .7, .7), 0.7); var material1 = new Metal(new Vektor(1, 0.32, 0.36), 0); var material2 = new Metal(new Vektor(0.90, 0.76, 0.46), 0); var material3 = new Metal(new Vektor(0.65, 0.77, 0.97), 0); var material4 = new Metal(new Vektor(0.90, 0.90, 0.90), 0); world.Add(new sphere(new Vektor(0.0, -10004, -20), 10000, material)); world.Add(new sphere(new Vektor(0, 0, -20), 4, material1)); world.Add(new sphere(new Vektor(5, -1, -15), 2, material2)); world.Add(new sphere(new Vektor(5, 0, -25), 3, material3)); world.Add(new sphere(new Vektor(-5.5, 0, -15), 3, material4)); //Camera Vektor lookfrom = new Vektor(0, 0, 0); Vektor lookat = new Vektor(0, 0, -1); Vektor vup = new Vektor(0, 1, 0); var dist_to_focus = 10; var aperture = 0.1; Camera cam = new Camera(lookfrom, lookat, vup, 50, aspect_ratio, aperture, dist_to_focus); Vektor[,] vArr = new Vektor[image_height, image_width]; Bitmap bmp = new Bitmap(image_width, image_height); Parallel.For(0, image_height, j => { for (int i = 0; i < image_width; i++) { Vektor pixel_color = new Vektor(0, 0, 0); for (int s = 0; s < samples_per_pixel; s++) { var u = ((double)i + Mathe.random_double()) / (image_width - 1); var v = ((double)j + Mathe.random_double()) / (image_height - 1); ray r = cam.get_ray(u, v); pixel_color += ray.ray_color(r, world, max_depth); } vArr[j, i] = pixel_color; } }); for (int j = 0; j < image_height; j++) { for (int i = 0; i < image_width; i++) { bmp.SetPixel(i, (j - (image_height - 1)) * -1, Vektor.toColor(vArr[j, i], samples_per_pixel)); } } image.Source = BitmapToImageSource(bmp); }
public static Vector2 NormalizeDirection(Vector2 from, Vector2 to) { return(Mathe.Direction(from, to).get_normalized()); }
public static byte MByte2ByteI(int Mbyte) { int num = (int)Mathe.KByte2ByteI(Mbyte) << 10; return((byte)num); }