public void SelectItem(Icon sourceIcon) { selectSFX.Play(); if (!second) { firstComponent = sourceIcon.pickupData; if (firstComponent == secondComponent) { if (firstComponent.amount <= 1) { secondComponent = null; secondItem.ResetIcon(); } } firstItem.UpdateCraftElement(firstComponent); craftItem.ResetIcon(); UpdateSelecItemText(firstComponent); CheckCombination(); second = true; } else { secondComponent = sourceIcon.pickupData; if (firstComponent == secondComponent) { if (firstComponent.amount <= 1) { firstComponent = null; firstItem.ResetIcon(); } } secondItem.UpdateCraftElement(secondComponent); craftItem.ResetIcon(); UpdateSelecItemText(secondComponent); CheckCombination(); second = false; } }
public void RandomizePickups() { foreach (GameObject pickup in m_CurrentPickups.ToList()) { m_CurrentPickups.Remove(pickup); Destroy(pickup); } foreach (Vector3 pickupStartingPosition in m_PickupStartingPositions) { PickupData pickupData = GetRandomPickupData(); GameObject pickupObject = Instantiate(Resources.Load(pickupData.PrefabPath), pickupStartingPosition, new Quaternion()) as GameObject; Pickup pickup = pickupObject.GetComponent <Pickup>(); pickup.Modifier = pickupData.Modifier.Clone(); pickup.RespawnTime = pickupData.RespawnTime; m_CurrentPickups.Add(pickupObject); } }
public bool AcquirePickup(PickupData pickupData, ActivatableObject[] activatableObjects) { Roost.Debug.Assert(pickupData != null); Roost.Debug.Assert(Singleton_MonoBehaviour <ConnectionManager> .Instance.IsServer); if (pickupData.IsKey) { if (!string.IsNullOrEmpty(this.m_playerData.KeyPickupDataID)) { return(false); } this.m_playerData.ClearKeyData(); this.m_playerData.KeyPickupDataID = pickupData.ID; if (activatableObjects != null) { int num = 0; for (int i = 0; i < 4; i++) { while (num < (int)activatableObjects.Length) { if (activatableObjects[num] == null) { num++; } else { this.m_playerData.ActivatableObjectViewIDs[i] = activatableObjects[num].photonView.viewID; num++; break; } } } } } if (pickupData.Award != null) { Singleton_MonoBehaviour <GameManager> .Instance.ApplyAward(this.Data, pickupData.Award, true); } base.photonView.RPC("AcquirePickup_RPC", base.photonView.owner, new object[] { pickupData.ID }); return(true); }
public static void GiveItemToPlayer(Player player, PickupData item, int amount) { if (player.playerData.storedPickups.Count == 0) { item.amount += amount; player.playerData.storedPickups.Add(item); } else { int i = 0; bool alreadyHadPickup = false; foreach (PickupData storedPickupData in player.playerData.storedPickups) { if (storedPickupData == item) { player.playerData.storedPickups[i].amount += amount; alreadyHadPickup = true; break; } i++; } if (!alreadyHadPickup) { item.amount += amount; player.playerData.storedPickups.Add(item); } } if (item.showsInPlayer) { Player.EquipEvent?.Invoke(item); } InventoryEvent?.Invoke(); }
private void InitPickup() { thisPickup = PickupDatabase.instance.GetPickupRandom(); switch (thisPickup.pickupType) { case PickupData.PickupType.Repair: pickupBoost = new PickupBoost(Repair); break; case PickupData.PickupType.Invincibility: pickupBoost = new PickupBoost(Invincibility); break; case PickupData.PickupType.Speed: pickupBoost = new PickupBoost(Speed); break; case PickupData.PickupType.Weapon: pickupBoost = new PickupBoost(WeaponPick); WeaponBool = true; break; } }
protected override void Update() { base.Update(); this.UpdateCharacterUpgrades(); this.m_playerPOI.Show = (this.IsControlledLocally ? false : !base.IsDead); bool flag = (this.Data == null ? false : this.Data.FuelCount > 0); this.m_personalPayloadFuelPOI.Show = (!flag ? false : this.IsControlledLocally); this.m_payloadFuelPOI.Show = (!flag ? false : !this.IsControlledLocally); PickupData pickupDatum = null; if (this.Data != null) { pickupDatum = Singleton_MonoBehaviour <GameManager> .Instance.GameplayDatabase.PickupDataDatabase.FindOrGetDefault(this.Data.KeyPickupDataID); } if (pickupDatum != null) { this.m_personalKeyPOI.SetOverridePOISprite(pickupDatum.KeyPOISprite); this.m_keyPOI.SetOverridePOISprite(pickupDatum.KeyPOISprite); } this.m_personalKeyPOI.Show = (pickupDatum == null ? false : this.IsControlledLocally); this.m_keyPOI.Show = (pickupDatum == null ? false : !this.IsControlledLocally); Roost.Debug.Assert(this.m_playerBlipTarget != null); this.m_playerBlipTarget.enabled = this.IsControlledLocally; Roost.Debug.Assert(this.m_teammateBlipTarget != null); this.m_teammateBlipTarget.enabled = !this.IsControlledLocally; PlayerCharacter mCanDodgeInAir = this; mCanDodgeInAir.m_canDodgeInAir = mCanDodgeInAir.m_canDodgeInAir | base.IsGrounded; PlayerCharacter mCanAttackInAir = this; mCanAttackInAir.m_canAttackInAir = mCanAttackInAir.m_canAttackInAir | base.IsGrounded; if (base.IsDead) { this.m_inAction = true; base.SetCurrentHitState(BaseEntity.HitState.Invincible); this.m_animation.CrossFade(this.m_playerAnimations.KOIdle.name, 0.1f); } if (this.IsControlledLocally && Singleton_MonoBehaviour <GameManager> .Instance.AllowPlayerControl && !Singleton_MonoBehaviour <GameManager> .Instance.State.ForcePlayerWalking()) { if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.CameraCenter.WasPressed) { Singleton_MonoBehaviour <GameManager> .Instance.PlayerCamera.CenterCamera(); } if (this.m_CounterTarget != null && !TargetingFilters.DoesTargetPassFilter(this, this.m_CounterTarget, this.m_playerAbilities.Counter.TargetingFilters)) { this.m_CounterTarget = null; } if (this.m_CounterTarget == null) { float lastCounterTime = Single.MaxValue; IEnumerator <BaseCharacter> enumerator = TargetingFilters.GetFilteredTargets(this, this.m_playerAbilities.Counter.TargetingFilters).OfType <BaseCharacter>().GetEnumerator(); try { while (enumerator.MoveNext()) { BaseCharacter current = enumerator.Current; if (current.LastCounterTime >= lastCounterTime) { continue; } lastCounterTime = current.LastCounterTime; this.m_CounterTarget = current; } } finally { if (enumerator == null) { } enumerator.Dispose(); } } this.m_TeamAttackTarget = ( from target in TargetingFilters.GetFilteredTargets(this, this.m_playerAbilities.TeamAttack.TargetingFilters).OfType <BaseCharacter>() orderby Vector3.Distance(base.transform.position, target.transform.position) select target).FirstOrDefault <BaseCharacter>(); PlayerCharacter.ActionType mQueuedCombo = this.m_queuedCombo; int mQueuedindex = this.m_queuedindex; if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Dodge.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.Dodge; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Counter.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.Counter; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Attack.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.LightAttack; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Heavy.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.HeavyAttack; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Shoot.WasPressed || Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Shoot.WasRepeated) { mQueuedCombo = PlayerCharacter.ActionType.RangedAttack; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Taunt.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.Taunt; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Interact.WasReleased) { mQueuedCombo = PlayerCharacter.ActionType.TeamAttack; } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Special_Keyboard.WasPressed) { mQueuedCombo = PlayerCharacter.ActionType.SpecialAttack; } if (base.Stats.CurrentSpecial > 0) { if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Special_Controller_LB.WasPressed) { if (this.m_specialRightButtonTimer == null || this.m_specialRightButtonTimer.HasElapsed) { this.m_specialLeftButtonTimer = new Timer(0.1f); } else { mQueuedCombo = PlayerCharacter.ActionType.SpecialAttack; } } if (Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Special_Controller_RB.WasPressed) { if (this.m_specialLeftButtonTimer == null || this.m_specialLeftButtonTimer.HasElapsed) { this.m_specialRightButtonTimer = new Timer(0.1f); } else { mQueuedCombo = PlayerCharacter.ActionType.SpecialAttack; } } } if (!this.m_uninterruptibleAbility) { this.m_queuedCombo = mQueuedCombo; this.m_queuedindex = mQueuedindex; } if (!base.IsDead && !base.IsHit && !this.m_failedCounter && !this.m_uninterruptibleAbility) { Action action = () => { this.m_queuedCombo = PlayerCharacter.ActionType.None; this.m_queuedindex = 0; }; if (this.m_queuedCombo == PlayerCharacter.ActionType.Counter) { Roost.Debug.Assert(this.m_playerAbilities.Counter != null); Roost.Debug.Assert(this.m_playerAbilities.FailedCounter != null); if (base.InAction) { this.Cancel(); } if (this.m_CounterTarget != null) { base.UseAbility(this.m_playerAbilities.Counter, this.m_CounterTarget); } else if (base.IsGrounded) { base.UseAbility(this.m_playerAbilities.FailedCounter, null); } action(); } if (this.m_queuedCombo == PlayerCharacter.ActionType.TeamAttack && this.m_playerAbilities.TeamAttack != null && this.m_TeamAttackTarget != null) { if (base.InAction) { this.Cancel(); } base.UseAbility(this.m_playerAbilities.TeamAttack, this.m_TeamAttackTarget); action(); } if (!base.InAction || this.m_canPerformCombo) { switch (this.m_queuedCombo) { case PlayerCharacter.ActionType.Dodge: { if (this.m_canDodge && this.m_canDodgeInAir && Singleton_MonoBehaviour <GameManager> .Instance.PlayerCamera.LockOnTarget == null) { base.NotifyCamera(); this.m_canDodgeInAir = false; base.UseAbility((!base.IsGrounded ? this.m_playerAbilities.DodgeAir : this.m_playerAbilities.DodgeLand), null); } goto case PlayerCharacter.ActionType.TeamAttack; } case PlayerCharacter.ActionType.Counter: case PlayerCharacter.ActionType.LightAttack: case PlayerCharacter.ActionType.HeavyAttack: case PlayerCharacter.ActionType.RangedAttack: { this.SelectAttack(this.m_queuedCombo); goto case PlayerCharacter.ActionType.TeamAttack; } case PlayerCharacter.ActionType.SpecialAttack: { if (this.m_playerAbilities.SpecialAttack != null) { if (base.Stats.CurrentSpecial >= this.m_playerAbilities.SpecialAttack.SpecialCost) { this.m_statsScript.AddSpecial(-this.m_playerAbilities.SpecialAttack.SpecialCost); base.UseAbility(this.m_playerAbilities.SpecialAttack, null); } else if (this.event_OnNotEnoughAura != null) { this.event_OnNotEnoughAura(); } } goto case PlayerCharacter.ActionType.TeamAttack; } case PlayerCharacter.ActionType.TeamAttack: { action(); break; } case PlayerCharacter.ActionType.Taunt: { base.UseAbility(this.m_playerAbilities.Taunt, null); goto case PlayerCharacter.ActionType.TeamAttack; } default: { goto case PlayerCharacter.ActionType.TeamAttack; } } } } this.m_isSprinting = Singleton_MonoBehaviour <ApplicationManager> .Instance.PlayerInput.Dodge.IsPressed; this.m_animation[this.m_baseAnimations.Run.name].speed = Mathf.Lerp(this.m_animation[this.m_baseAnimations.Run.name].speed, (!this.m_isSprinting ? 1f : this.m_sprintAnimationSpeed), 5f * Time.deltaTime); base.MovementSpeedModifier = Mathf.Lerp(base.MovementSpeedModifier, (!this.m_isSprinting ? 1f : this.m_sprintSpeedMultiplier), 1f * Time.deltaTime); } }
private void InitPickup() { thisPickup = PickupDatabase.instance.GetPickupByName("PowerGun"); }
IEnumerator ParseSteps() { playerInteraction.playerInteraction_UI.loadingText.text = "Parsing..."; currentStep = 0; paused = false; Level lvl = GameManager.Instance.GetDataManager().currentLevelData; if(lvl.execution.Count > 0) { int maxStep = 0; stepDictionary = new Dictionary<int, List<StepData>>(); Dictionary<int, List<int>> componentStepsDictionary = new Dictionary<int, List<int>>(); timeSteps = new List<TimeStepData>(); List<GridComponent> threads = new List<GridComponent>(); foreach (GridComponent g in lvl.components) { if (g.type == "thread") { threads.Add(g); } } yield return new WaitForSeconds(1f); System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); for (int i = 0; i < lvl.execution.Count; i++) { StepData step = lvl.execution[i]; if (step.timeStep > maxStep) { maxStep = step.timeStep; } if (step.eventType == "M") { if (!componentStepsDictionary.ContainsKey(step.componentID)) { componentStepsDictionary.Add(step.componentID, new List<int>()); componentStepsDictionary[step.componentID].Add(i); } else { componentStepsDictionary[step.componentID].Add(i); } } if (stepDictionary.ContainsKey(step.timeStep)) { if (step.eventType == "D") { stepDictionary[step.timeStep].Insert(0, step); } else { stepDictionary[step.timeStep].Add(step); } } else { stepDictionary[step.timeStep] = new List<StepData>(); stepDictionary[step.timeStep].Add(step); } if(stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } //create in between steps for thread movements for (int i = 0; i <= maxStep; i++) { if (stepDictionary.ContainsKey(i) == false) stepDictionary.Add(i, new List<StepData>()); if (stepDictionary[i] == null) stepDictionary[i] = new List<StepData>(); if (stepDictionary[i].Count == 0) { for (int j = 0; j < threads.Count; j++) { Vector2 prevPos = new Vector2(); if (i > 0) { for (int k = 0; k < stepDictionary[i - 1].Count; k++) { if (stepDictionary[i - 1][k].eventType == "M" && stepDictionary[i - 1][k].componentID == threads[j].id) { prevPos = stepDictionary[i - 1][k].componentPos; } } } Vector2 nextPos = prevPos; bool end = false; for (int k = i + 1; k < maxStep+1; k++) { if (stepDictionary.ContainsKey(k)) { for (int l = 0; l < stepDictionary[k].Count; l++) { if (stepDictionary[k][l].eventType == "M" && stepDictionary[k][l].componentID == threads[j].id) { if (stepDictionary[k][l].componentPos != prevPos) { if (Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) > 1 || Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) < -1) { if (k - Mathf.Abs(Vector2.Distance(prevPos, stepDictionary[k][l].componentPos)) == i - 1) { if (prevPos.x != stepDictionary[k][l].componentPos.x) { if (prevPos.x > stepDictionary[k][l].componentPos.x) { nextPos = new Vector2(nextPos.x - 1, nextPos.y); } else { nextPos = new Vector2(nextPos.x + 1, nextPos.y); } } else { if (prevPos.y > stepDictionary[k][l].componentPos.y) { nextPos = new Vector2(nextPos.x, nextPos.y - 1); } else { nextPos = new Vector2(nextPos.x, nextPos.y + 1); } } } } } end = true; break; } } if (end == true) { break; } } } StepData newStep = new StepData(); newStep.componentID = threads[j].id; newStep.componentPos = nextPos; newStep.eventType = "M"; newStep.timeStep = i; stepDictionary[i].Add(newStep); } } else { List<bool> hasTimeStepData = new List<bool>(); for (int j = 0; j < threads.Count; j++) { hasTimeStepData.Add(false); } for (int j = 0; j < stepDictionary[i].Count; j++) { if (stepDictionary[i][j].eventType == "M") { for (int k = 0; k < threads.Count; k++) { if (threads[k].id == stepDictionary[i][j].componentID) { hasTimeStepData[k] = true; } } } } for (int j = 0; j < hasTimeStepData.Count; j++) { if (hasTimeStepData[j] == false) { Vector2 prevPos = new Vector2(); for (int k = 0; k < stepDictionary[i - 1].Count; k++) { if (stepDictionary[i - 1][k].eventType == "M" && stepDictionary[i - 1][k].componentID == threads[j].id) { prevPos = stepDictionary[i - 1][k].componentPos; } } Vector2 nextPos = prevPos; bool end = false; for (int k = i + 1; k < maxStep+1; k++) { if (stepDictionary.ContainsKey(k)) { for (int l = 0; l < stepDictionary[k].Count; l++) { if (stepDictionary[k][l].eventType == "M" && stepDictionary[k][l].componentID == threads[j].id) { if (stepDictionary[k][l].componentPos != prevPos) { if (Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) > 1 || Vector2.Distance(prevPos, stepDictionary[k][l].componentPos) < -1) { if (k - Mathf.Abs(Vector2.Distance(prevPos, stepDictionary[k][l].componentPos)) == i - 1) { if (prevPos.x != stepDictionary[k][l].componentPos.x) { if (prevPos.x > stepDictionary[k][l].componentPos.x) { nextPos = new Vector2(nextPos.x - 1, nextPos.y); } else { nextPos = new Vector2(nextPos.x + 1, nextPos.y); } } else { if (prevPos.y > stepDictionary[k][l].componentPos.y) { nextPos = new Vector2(nextPos.x, nextPos.y - 1); } else { nextPos = new Vector2(nextPos.x, nextPos.y + 1); } } } } } end = true; break; } } if (end == true) { break; } } } StepData newStep = new StepData(); newStep.componentID = threads[j].id; newStep.componentPos = nextPos; newStep.eventType = "M"; newStep.timeStep = i; stepDictionary[i].Add(newStep); } } } if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } yield return new WaitForSeconds(1f); TimeStepData timeStep = new TimeStepData(); for (int i = 0; i < lvl.components.Count; i++) { switch (lvl.components[i].type) { case "thread": ThreadData thread = new ThreadData(); thread.id = lvl.components[i].id; thread.pos = Vector2.zero; switch (lvl.components[i].configuration.initial_direction) { case "North": thread.rotation = new Vector3(0, 0, 90); break; case "South": thread.rotation = new Vector3(0, 0, -90); break; case "East": thread.rotation = new Vector3(0, 0, 0); break; case "West": thread.rotation = new Vector3(0, 0, 180); break; } timeStep.threads.Add(thread); break; case "pickup": PickupData pickup = new PickupData(); pickup.id = lvl.components[i].id; pickup.available = lvl.components[i].configuration.value; timeStep.pickups.Add(pickup); break; case "delivery": DeliveryData delivery = new DeliveryData(); delivery.id = lvl.components[i].id; delivery.deliveries = 0; timeStep.deliveryPoints.Add(delivery); break; case "semaphore": SemaphoreData semaphore = new SemaphoreData(); semaphore.id = lvl.components[i].id; semaphore.open = lvl.components[i].configuration.value; timeStep.sempahores.Add(semaphore); break; case "conditional": ConditionalData conditional = new ConditionalData(); conditional.id = lvl.components[i].id; conditional.current = lvl.components[i].configuration.current; conditional.directions = lvl.components[i].configuration.directions; timeStep.conditionals.Add(conditional); break; } if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } yield return new WaitForSeconds(1f); for (int i = 0; i < stepDictionary.Count; i++) { if (i != 0) { timeStep = timeStep.Copy(timeSteps[i - 1]); timeStep.timeStep = i; timeStep.previousStep = timeSteps[i - 1]; timeSteps[i - 1].nextStep = timeStep; } for (int j = 0; j < stepDictionary[i].Count; j++) { switch (stepDictionary[i][j].eventType) { case "M": timeStep.GetThread(stepDictionary[i][j].componentID).pos = stepDictionary[i][j].componentPos; if (i != 0) { Vector2 difference = timeSteps[timeSteps.Count - 1].GetThread(stepDictionary[i][j].componentID).pos - timeStep.GetThread(stepDictionary[i][j].componentID).pos; if (difference.x > 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 180); } else if (difference.x < 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 0); } else if (difference.y > 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, 90); } else if (difference.y < 0) { timeStep.GetThread(stepDictionary[i][j].componentID).rotation = new Vector3(0, 0, -90); } } break; case "D": if (stepDictionary[i][j].componentStatus.delivered_to != 0) { timeStep.GetDeliveryPoint(stepDictionary[i][j].componentStatus.delivered_to).deliveries++; } break; case "E": if (timeStep.GetSemaphore(stepDictionary[i][j].componentID) != null) { timeStep.GetSemaphore(stepDictionary[i][j].componentID).open = stepDictionary[i][j].componentStatus.value; } else if (timeStep.GetPickup(stepDictionary[i][j].componentID) != null) { timeStep.GetPickup(stepDictionary[i][j].componentID).available = stepDictionary[i][j].componentStatus.available; } else if (timeStep.GetThread(stepDictionary[i][j].componentID) != null) { if (stepDictionary[i][j].componentStatus.payload != null) { timeStep.GetThread(stepDictionary[i][j].componentID).DisablePackages(); for (int k = 0; k < stepDictionary[i][j].componentStatus.payload.Length; k++) { for (int l = 0; l < i; l++) { if (timeSteps[l].GetThread(stepDictionary[i][j].componentID).ContainsPackage(stepDictionary[i][j].componentStatus.payload[k]) == false) { PackageData package = new PackageData(); package.active = false; package.id = stepDictionary[i][j].componentStatus.payload[k]; timeSteps[l].GetThread(stepDictionary[i][j].componentID).packages.Add(package); } } if (timeStep.GetThread(stepDictionary[i][j].componentID).ContainsPackage(stepDictionary[i][j].componentStatus.payload[k])) { timeStep.GetThread(stepDictionary[i][j].componentID).GetPackage(stepDictionary[i][j].componentStatus.payload[k]).active = true; } else { PackageData package = new PackageData(); package.active = true; package.id = stepDictionary[i][j].componentStatus.payload[k]; timeStep.GetThread(stepDictionary[i][j].componentID).packages.Add(package); } } } } else if (timeStep.GetConditional(stepDictionary[i][j].componentID) != null) { if (stepDictionary[i][j].componentStatus.current != -1) { timeStep.GetConditional(stepDictionary[i][j].componentID).current = stepDictionary[i][j].componentStatus.current; } } break; } } timeSteps.Add(timeStep); if (stopwatch.ElapsedMilliseconds > 1000 / 60) { stopwatch.Stop(); stopwatch.Reset(); yield return new WaitForEndOfFrame(); stopwatch.Start(); } } playerInteraction.playerInteraction_UI.playbackSlider.maxValue = maxStep; playerInteraction.playerInteraction_UI.loadingOverlay.ClosePanel(); playerInteraction.playerInteraction_UI.playbackControls.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.stopSimulationButton.interactable = true; playerInteraction.playerInteraction_UI.stopSimulationButton.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.pauseSimulationButton.interactable = true; playerInteraction.playerInteraction_UI.pauseSimulationButton.gameObject.SetActive(true); playerInteraction.playerInteraction_UI.playbackSlider.interactable = true; playerInteraction.playerInteraction_UI.playbackSlider.gameObject.SetActive(true); yield return PlaySimulation(maxStep); } else { yield return null; } }
public TimeStepData Copy(TimeStepData _timeStep) { TimeStepData timeStep = new TimeStepData(); for (int i = 0; i < _timeStep.threads.Count; i++) { ThreadData thread = new ThreadData(); thread.id = _timeStep.threads[i].id; thread.pos = new Vector2(_timeStep.threads[i].pos.x, _timeStep.threads[i].pos.y); thread.rotation = new Vector3(_timeStep.threads[i].rotation.x, _timeStep.threads[i].rotation.y, _timeStep.threads[i].rotation.z); thread.packages = new List <PackageData>(); for (int j = 0; j < _timeStep.threads[i].packages.Count; j++) { PackageData package = new PackageData(); package.id = _timeStep.threads[i].packages[j].id; package.active = _timeStep.threads[i].packages[j].active; thread.packages.Add(package); } timeStep.threads.Add(thread); } for (int i = 0; i < _timeStep.pickups.Count; i++) { PickupData pickup = new PickupData(); pickup.id = _timeStep.pickups[i].id; pickup.available = _timeStep.pickups[i].available; timeStep.pickups.Add(pickup); } for (int i = 0; i < _timeStep.deliveryPoints.Count; i++) { DeliveryData delivery = new DeliveryData(); delivery.id = _timeStep.deliveryPoints[i].id; delivery.deliveries = _timeStep.deliveryPoints[i].deliveries; timeStep.deliveryPoints.Add(delivery); } for (int i = 0; i < _timeStep.sempahores.Count; i++) { SemaphoreData semaphore = new SemaphoreData(); semaphore.id = _timeStep.sempahores[i].id; semaphore.open = _timeStep.sempahores[i].open; timeStep.sempahores.Add(semaphore); } for (int i = 0; i < _timeStep.conditionals.Count; i++) { ConditionalData conditional = new ConditionalData(); conditional.id = _timeStep.conditionals[i].id; conditional.current = _timeStep.conditionals[i].current; conditional.directions = new string[_timeStep.conditionals[i].directions.Length]; for (int j = 0; j < _timeStep.conditionals[i].directions.Length; j++) { conditional.directions[j] = _timeStep.conditionals[i].directions[j]; } timeStep.conditionals.Add(conditional); } for (int i = 0; i < _timeStep.signals.Count; i++) { SignalData signal = new SignalData(); signal.id = _timeStep.signals[i].id; signal.passed = _timeStep.signals[i].passed; timeStep.signals.Add(signal); } return(timeStep); }
public void UpdateSelecItemText(PickupData item) { nameText.text = item.name; descriptionText.text = item.description; }
public void UpdateCraftElement(PickupData pickupData) { textName.text = pickupData.name; sprite.sprite = pickupData.icon; }
private void InitPickup() { thisPickup = PickupDatabase.instance.GetPickupByName("Shield"); }
void FixedUpdate() { //if(Time.time % 2 == 0) // GameSettings.connectedServer.SendMessage("tessst"); if (GameSettings.connectedServer == null) { return; } string message = GameSettings.connectedServer.GetMessage(); if (message != null && message.Contains("start")) { GameSettings.connectedServer.RemoveMessage(); //start game //GameSettings.players = GameSettings.connectedPlayers.Count + 1; //GameSettings.units = int.Parse(startUnits.text); SceneManager.LoadScene("Game", LoadSceneMode.Single); } if (message != null && message.Contains("players: ")) { GameSettings.connectedServer.RemoveMessage(); GameSettings.players = int.Parse(message.Split('{')[1].Split('}')[0]); } if (message != null && message.Contains("units: ")) { GameSettings.connectedServer.RemoveMessage(); GameSettings.units = int.Parse(message.Split('{')[1].Split('}')[0]); } if (message != null && message.Contains("current: ")) { GameSettings.connectedServer.RemoveMessage(); GameSettings.currentPlayerNum = int.Parse(message.Split('{')[1].Split('}')[0]); } //check if they are sending data if (message != null && message.Contains("player: ")) { GameSettings.connectedServer.RemoveMessage(); //index is ignored since tcp preserves order of messages PlayerData player = new PlayerData(new Vector2(float.Parse(message.Split('{')[2].Split('}')[0]), float.Parse(message.Split('{')[3].Split('}')[0])), int.Parse(message.Split('{')[4].Split('}')[0])); GameSettings.serverPlayerData.Add(player); } if (message != null && message.Contains("pickup: ")) { GameSettings.connectedServer.RemoveMessage(); //index is ignored since tcp preserves order of messages PickupData pickup = new PickupData(new Vector2(float.Parse(message.Split('{')[2].Split('}')[0]), float.Parse(message.Split('{')[3].Split('}')[0])), int.Parse(message.Split('{')[4].Split('}')[0])); GameSettings.serverPickupData.Add(pickup); } }
public PickupData GetPickupRandom() { PickupData result = pickups[UnityEngine.Random.Range(0, pickups.Length)]; return(result); }
private void InitPickup() { thisPickup = PickupDatabase.instance.GetPickupByName("Repair"); }