public void OnBeginDrag(PointerEventData eventData) { GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); // GameObject GameController = GameObject.Find ("GameController"); // GameController gameController = GameController.GetComponent<GameController> (); GameController.control.TurnTruePlayerButtons(); buttonScripts.CheckDropZone(); placeholder = new GameObject(); placeholder.transform.SetParent(this.transform.parent); LayoutElement le = placeholder.AddComponent <LayoutElement>(); le.preferredWidth = this.GetComponent <LayoutElement>().preferredWidth; le.preferredHeight = this.GetComponent <LayoutElement>().preferredHeight; le.flexibleWidth = 0; le.flexibleHeight = 0; placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex()); parentToReturnTo = this.transform.parent; // Debug.Log(parentToReturnTo); placeholderParent = parentToReturnTo; this.transform.SetParent(this.transform.parent.parent); GetComponent <CanvasGroup>().blocksRaycasts = false; }
void Start() { // map = TileMap.map; UpdateWorldPosition(); UpdatePrimaryMaterial(); ButtonScripts = GameObject.Find("ButtonsCanvas"); buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); }
public void SetTopText(String Text) { pOutputText = Text; TAtlasInfo CustomAtlas = new TAtlasInfo(); CustomAtlas.Atlas = ButtonScripts.CreateDynamicTextCheckbox(Text, BoxWidth); CustomAtlas.DivDimensions = new Point(2, 2); LocalAtlas = CustomAtlas; }
public DropMenu(String Name, Vector2 Location, float Depth, int Width, String DefaultText, String[] DropList, Boolean InitialToggle) : base(Name, Location, null, Depth, InitialToggle) { BoxWidth = Width; TAtlasInfo CustomAtlas = new TAtlasInfo(); CustomAtlas.Atlas = ButtonScripts.CreateDynamicTextCheckbox(DefaultText, BoxWidth); CustomAtlas.DivDimensions = new Point(2, 2); LocalAtlas = CustomAtlas; PopulateDropList(DropList); }
void PriceScreen() { // laittaa price screenin näkyviin GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); buttonScripts.priceScreen.SetActive(true); Debug.Log("price screen up?"); //Price screenin napit ohjaa kylään }
/* void Awake () { * if (map == null) { * DontDestroyOnLoad (gameObject); * map = this; * } * else if (map != this) { * Destroy(gameObject); * } * * } */ void Start() { GameObject GameControl = GameObject.Find("GameController"); buttonScripts = GameControl.GetComponent <ButtonScripts> (); buttonScripts.map = this; // buttonScripts = ButtonScripts.buttonScript; GameObject Scripts = GameObject.Find("_Scripts"); SummonStartEnemies summonStartEnemies = Scripts.GetComponent <SummonStartEnemies> (); SummonStartPlayers summonStartPlayers = Scripts.GetComponent <SummonStartPlayers> (); GameObject[] PlayersAlive = GameObject.FindGameObjectsWithTag("Player"); // GameObject.Find ("Players").SetActive(true); GenerateMapData(); // settings.TileObjects (); GeneratePathfindingGraph(); GenerateMapVisual(); // CreateEnemies(); foreach (GameObject Player in PlayersAlive) { PlayableCharacter player = Player.GetComponent <PlayableCharacter> (); // player.map = GameObject.Find ("Map").GetComponent<TileMap>(); // player.map = map; selecterPlayer = player.name; CheckVisibleTiles(); } selecterPlayer = "Player1"; buttonScripts.ShowVisibleTiles(); summonStartPlayers.CreatePlayers(); SelectedDeck(); // GameController.control.BuildInitialPlayerDeck(); // gameController.AddEnemyToMap(); summonStartEnemies.StartEnemies(); summonStartEnemies.CreateEnemies(); // CheckVisibleTiles(); GameObject[] EnemysAlive = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject enemy in EnemysAlive) { enemy.GetComponent <BaseEnemy> ().StartWalkable(); } GameObject[] Players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in Players) { player.GetComponent <PlayableCharacter> ().StartWalkable(); } // buttonScripts.AttackButtonDisable(); }
public void MoveNextTile() { // PlayerClass.RemainingMovement = PlayerClass.MoveSpeed; GameObject Map = GameObject.Find("Map"); TileMap map = Map.GetComponent <TileMap> (); GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); if (buttonScripts.moveSelected) { while (PlayerClass.RemainingMovement > 0) { // currentTile = ("Hex_" + PlayerClass.TileX + "_" + PlayerClass.TileY); // GameObject.Find (currentTile).GetComponent<ClickableTile> ().IsNotWalkable(); // int tileXHolder = PlayerClass.TileX; // int tileYHolder = PlayerClass.TileY; if (currentPath == null) { return; } PlayerClass.RemainingMovement -= map.CostToEnterTile(currentPath[0].x, currentPath[0].y, currentPath[1].x, currentPath[1].y); PlayerClass.TileX = currentPath[1].x; PlayerClass.TileY = currentPath[1].y; TransformPosition(); currentPath.RemoveAt(0); if (currentPath.Count == 1) { currentPath = null; } buttonScripts.moveSelected = false; // currentTile = ("Hex_" + tileXHolder + "_" + tileYHolder); // ClickableTile clickableTile = GameObject.Find (currentTile).GetComponent<ClickableTile> (); // clickableTile.IsWalkable(); // currentTile = ("Hex_" + PlayerClass.TileX + "_" + PlayerClass.TileY); // clickableTile = GameObject.Find (currentTile).GetComponent<ClickableTile> (); // clickableTile.IsNotWalkable(); } // map.CalculateAttackableTiles(); } return; }
public void TrapActivate() { GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); GameObject CardDropArea = GameObject.Find("CardDropArea"); DropZone dropZone = CardDropArea.GetComponent <DropZone>(); GameObject Enemy = GameObject.Find(map.selectedEnemy); BaseEnemy enemy = Enemy.GetComponent <BaseEnemy>(); HealthBar enemyHpBar = enemy.GetComponent <HealthBar> (); GameObject Tile = GameObject.Find("Hex_" + enemy.TileX + "_" + enemy.TileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); buttonScripts.CheckDropZone(); enemyHpBar.CurHealth -= (tile.trapDamage / enemy.HpPointsMax) * 100; enemyHpBar.SetHealthBarEnemy(); // map.CheckVisibleTiles(); enemyHpBar.parentName = map.selectedEnemy; enemyHpBar.KillUnit(); dropZone.effect = tile.trapEffect; dropZone.RunEffect(); }
void PopulateDropList(String[] TextList) { DepopulateDropList(); float CumulativeY = pDrawCoords.Y + (LocalAtlas.Atlas.Bounds.Height / 2) + 10; foreach (String Label in TextList) { TAtlasInfo ButtonAtlas = new TAtlasInfo(); ButtonAtlas.Atlas = ButtonScripts.CreateDynamicCustomButton(Label, BoxWidth); ButtonAtlas.DivDimensions = new Point(2, 1); Button B = new Button(Name + "_DROPOPTION_" + Label, new Vector2(pDrawCoords.X, CumulativeY), ButtonAtlas, LayerDepth - 0.001f); B.SubscribeToEvent(EventNames.ButtonPressFunction, typeof(Button).GetMethod("SetTopText"), new object[] { Label }); B.CenterOrigin = false; B.Enabled = DroppedDown; MyDropEntities.Add(B); Stickers.Add(B); Shell.UpdateQueue.Add(B); CumulativeY += (LocalAtlas.Atlas.Bounds.Height / 2) + 10; DropBackingTexture = VNFUtils.GetNovelTextureOfColour(Shell.DefaultShell, new Color(50, 50, 50, 255), new Point(BoxWidth + 10, (int)(CumulativeY - (pDrawCoords.Y + (LocalAtlas.Atlas.Bounds.Height / 2) + 10)))); } }
static void LoadScriptStemSave(Hashtable AttrIndex) { String ScriptName = (String)AttrIndex["#SCRIPTNAME"]; int SIndex = Convert.ToInt32((String)AttrIndex["#SCRIPTSHIFTINDEX"]); String[] Conditionals = ((String)AttrIndex["#CONDITIONALS"]).Split(','); Shell.UpdateQueue = new ArrayList(); Shell.RenderQueue = new ArrayList(); foreach (String C in Conditionals) { switch (C) { case "DEFAULTUI": ButtonScripts.InitDefaultUI(); break; } } ScriptProcessor.ScriptSniffer LoadSniffer = new ScriptProcessor.ScriptSniffer(ScriptName.ToUpper() + "_SNIFFER", ScriptProcessor.RetrieveScriptByName(ScriptName), ScriptName, true); LoadSniffer.SetLoadBreaker(SIndex); Shell.UpdateQueue.Add(LoadSniffer); }
public static void HandleConsoleInput(String Input) { pLastManualConsoleInput = Input; SortedDictionary <int, Color> Cols = new SortedDictionary <int, Color>(); Cols.Add(0, Color.LightGreen); WriteLine(Input, Cols); String[] Commands = Input.Split(' '); try { switch (Commands[0].ToUpper()) { //Run ScriptProcessor commands as a forced script shift (by default, shift conditions are unchanged). case "INSERT": ScriptProcessor.ScriptSniffer FoundSniffer = ScriptProcessor.SnifferSearch(); if (FoundSniffer != null) { FoundSniffer.ForceInsertScriptElement((Input.Remove(0, Input.IndexOf(' ') + 1)).Split(' '), false); } else { WriteLine("Cannot insert new script shift as a script is not running."); } break; //Activate a single script element. case "ACTIVATE": ScriptProcessor.ActivateScriptElement(Input.Remove(0, Input.IndexOf(' ') + 1)); break; //Freshly load a new script. case "LOAD": WriteLine("Attempting to load script " + Commands[1].ToUpper() + "."); ButtonScripts.StartScript(Commands[1].ToUpper()); break; //Executes a function statement per the EntityFactory's inbuilt function parser. case "DO": RunQueue.Add(EntityFactory.AssembleVoidDelegate("do=" + Input.Remove(0, Input.IndexOf(' ') + 1))); break; //Executes a method specifier (instance return) per the EntityFactory's inbuilt function parser. case "RUN": RunQueue.Add(EntityFactory.AssembleVoidDelegate(Input.Remove(0, Input.IndexOf(' ') + 1))); break; //Fork to a new script from your current state. Equivalent to "do B|[Script name]". case "FORK": ScriptProcessor.ActivateScriptElement("B|" + Commands[1].ToUpper()); break; //Close the program. case "QUIT": WriteLine("Closing the VNF client..."); ExitOut = true; break; default: WriteLine("Unrecognized command."); break; } } catch (Exception e) { WriteLine(e.GetType().Name + ": " + e.Message); } }
public static void DeserializeState(RecallableState S, Boolean ReinstantiatePast) { if (ReinstantiatePast) { ScriptProcessor.PastStates.Clear(); ScriptProcessor.PastStates.Push(S); } ArrayList ReconstructEnts = new ArrayList(); IFormatter SerFormatter = new BinaryFormatter(); SurrogateSelector SS = new SurrogateSelector(); Surrogates.Vector2SS V2SS = new Surrogates.Vector2SS(); Surrogates.PointSS PSS = new Surrogates.PointSS(); Surrogates.RectangleSS RSS = new Surrogates.RectangleSS(); Surrogates.Texture2DSS T2DSS = new Surrogates.Texture2DSS(); Surrogates.ColorSS CSS = new Surrogates.ColorSS(); Surrogates.SpriteFontSS SFSS = new Surrogates.SpriteFontSS(); SS.AddSurrogate(typeof(Vector2), new StreamingContext(StreamingContextStates.All), V2SS); SS.AddSurrogate(typeof(Point), new StreamingContext(StreamingContextStates.All), PSS); SS.AddSurrogate(typeof(Rectangle), new StreamingContext(StreamingContextStates.All), RSS); SS.AddSurrogate(typeof(Texture2D), new StreamingContext(StreamingContextStates.All), T2DSS); SS.AddSurrogate(typeof(Color), new StreamingContext(StreamingContextStates.All), CSS); SS.AddSurrogate(typeof(SpriteFont), new StreamingContext(StreamingContextStates.All), SFSS); SerFormatter.SurrogateSelector = SS; foreach (byte[] Br in S.SerializedEnts) { MemoryStream DecodeStream = new MemoryStream(Br); WorldEntity WE = (WorldEntity)SerFormatter.Deserialize(DecodeStream); DecodeStream.Close(); ReconstructEnts.Add(WE); } ArrayList NewUEnts = new ArrayList(); ArrayList NewREnts = new ArrayList(); foreach (VoidDel V in MouseLeftClick.GetInvocationList()) { MouseLeftClick -= V; } RunQueue = new ArrayList(); foreach (WorldEntity W in NonSerializables) { W.AddEventTriggers(); } ArrayList TempList = new ArrayList(); foreach (WorldEntity W in DeleteQueue) { if (NonSerializables.Contains(W)) { TempList.Add(W); } } DeleteQueue = TempList; foreach (WorldEntity W in ReconstructEnts) { if (S.UpdateIDs.Contains(W.EntityID)) { NewUEnts.Add(W); } if (S.RenderIDs.Contains(W.EntityID)) { NewREnts.Add(W); } W.ReissueID(); W.OnDeserializeDo(); } ScriptProcessor.LabelEntity = S.LabelEntity; if (ScriptProcessor.SongCom != S.SongCom && S.SongCom != null && S.SongCom.Split('|').Length > 1) { ScriptProcessor.ActivateScriptElement(S.SongCom); } if (S.Flags != null) { Flags = (Hashtable)S.Flags.Clone(); } foreach (WorldEntity W in UpdateQueue) { if (NonSerializables.Contains(W)) { NewUEnts.Add(W); } } foreach (WorldEntity W in RenderQueue) { if (NonSerializables.Contains(W)) { NewREnts.Add(W); } } UpdateQueue = new ArrayList(NewUEnts); RenderQueue = new ArrayList(NewREnts); foreach (WorldEntity W in ReconstructEnts) { W.ResubscribeEvents(); } ButtonScripts.UnHideUI(); }
protected void MainUpdate(GameTime gameTime, KeyboardState KCurrent) { if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) { if (ScriptProcessor.ActiveGame()) { if (!ButtonScripts.Paused) { ButtonScripts.Pause(); } else { ButtonScripts.Unpause(); } } else { ButtonScripts.Quit(); } } if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemTilde) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemTilde)) { if (!ConsoleOpen) { ButtonScripts.OpenAndConstructConsole(); ConsoleOpen = true; } else { ButtonScripts.CloseConsole(); ConsoleOpen = false; } } if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.H) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.H) && ScriptProcessor.ActiveGame()) { ButtonScripts.RefreshUIHideState(); } if (AutoCamera != null && LooseCamera) { if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.R) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.R)) { AutoCamera.CenterDefault(); AutoCamera.ResetZoom(); } AutoCamera.MouseDragEnabled = KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F); if (!UpdateQueue.Contains(AutoCamera)) { UpdateQueue.Add(AutoCamera); } } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed || ExitOut) { Exit(); } if (((KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && !ConsoleOpen) || DoNextShifter) && AllowEnter) { DoNextShifter = false; Boolean Found = false; foreach (WorldEntity E in UpdateQueue) { if (E is TextEntity && E.Name == "TEXT_MAIN") { if (((TextEntity)E).WrittenAll()) { GlobalWorldState = "CONTINUE"; } ((TextEntity)E).SkipWrite(); Found = true; break; } } if (!Found) { GlobalWorldState = "CONTINUE"; } } if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11)) { ToggleFullscreen(); } if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up)) { UpKeyPress?.Invoke(); } if (KCurrent.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down) && !LastKeyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down)) { DownKeyPress?.Invoke(); } LastKeyState = KCurrent; foreach (WorldEntity E in UpdateQueue) { E.Update(); } foreach (WorldEntity E in DeleteQueue) { if (UpdateQueue.Contains(E)) { UpdateQueue.Remove(E); } if (RenderQueue.Contains(E)) { RenderQueue.Remove(E); } if (NonSerializables.Contains(E)) { NonSerializables.Remove(E); } E.ManualDispose(); } DeleteQueue = new ArrayList(); foreach (VoidDel V in RunQueue) { V(); } RunQueue = new ArrayList(); if (FadeoutAmount != -100) { if (MediaPlayer.Volume > 0) { MediaPlayer.Volume -= FadeoutAmount; } else { MediaPlayer.Volume = GlobalVolume; if (QueuedSong != null) { MediaPlayer.Play(QueuedSong); } else { MediaPlayer.Stop(); } QueuedSong = null; FadeoutAmount = -100; } } ArrayList RemSounds = new ArrayList(); if (!(CaptureVolume is null) && CaptureVolume.Enabled) { if (CaptureVolume.Output() != LastCapturedVol) { GlobalVolume = CaptureVolume.Output(); } LastCapturedVol = CaptureVolume.Output(); } foreach (SoundEffectInstance S in ActiveSounds) { if (S.State == SoundState.Stopped) { RemSounds.Add(S); } } foreach (SoundEffectInstance RS in RemSounds) { ActiveSounds.Remove(RS); } if (!(CaptureTextrate is null) && CaptureTextrate.Enabled) { if (CaptureTextrate.Output() != LastCapturedText) { TextEntity.TickWriteInterval = TextEntity.GetTicksFromSliderValue(CaptureTextrate.Output()); if (!(CaptureRateDisplay is null)) { CaptureRateDisplay.Text = TextEntity.TickWriteInterval + (TextEntity.TickWriteInterval != 1 ? " milliseconds" : " millisecond"); CaptureRateDisplay.ReWrite(); } } LastCapturedText = CaptureTextrate.Output(); } MouseState Current = Mouse.GetState(); if (Current.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && LastMouseState.LeftButton != Microsoft.Xna.Framework.Input.ButtonState.Pressed && MouseLeftClick != null) { MouseLeftClick(); } LastMouseState = Current; if (GlobalVoid != null) { GlobalVoid(); GlobalVoid = null; } }
public void UpdateButtons(List <GameObject> items) { int index = 1; Transform element = transform.Find("Slot0"); Select(element.gameObject); PowerupMain main; GarageItemButton gIB = element.gameObject.AddComponent <GarageItemButton>(); ButtonScripts scripts = element.gameObject.GetComponent <ButtonScripts>(); GarageSlider slider = GameObject.Find("GarageUI").transform.Find("StatSliders").GetComponent <GarageSlider>(); gIB.slider = slider; gIB.Unequipper(gameObject.name); element.GetComponent <Button>().onClick.AddListener(scripts.UnequipItem); foreach (GameObject item in items) { main = item.GetComponent <PowerupMain>(); element = gameObject.transform.Find("Slot" + index); element.Find("Text").GetComponent <Text>().text = item.gameObject.name; element.Find("Image").GetComponent <Image>().sprite = item.GetComponent <SpriteRenderer>().sprite; if (main.IsOwned()) { element.Find("Image").GetComponent <Image>().color = Color.white; element.Find("Text").GetComponent <Text>().color = Color.white; } else { element.Find("Image").GetComponent <Image>().color = Color.black; element.Find("Text").GetComponent <Text>().color = Color.black; } if (!main.IsChecked()) { main.Check(); StatPack stats = item.GetComponent <PowerupStats>().GetPack(); if (stats != null) { SendStats(stats, item.GetComponent <PowerupAttachable>()); } } if (main.IsEquipped()) { Select(element.gameObject); } scripts = element.gameObject.GetComponent <ButtonScripts>(); gIB = element.gameObject.AddComponent <GarageItemButton>(); scripts.SetItem(item); element.GetComponent <Button>().onClick.AddListener(scripts.EquipItem); slider = GameObject.Find("GarageUI").transform.Find("StatSliders").GetComponent <GarageSlider>(); gIB.slider = slider; gIB.item = item; element.GetComponent <Button>().onClick.AddListener(slider.SetSlidersOnNewEquip); index++; } for (; index < 5; index++) { element = gameObject.transform.Find("Slot" + index); element.gameObject.SetActive(false); } }
// IMPORTANT: This should never be fixed update. Input always needs to be in normal update, or you constantly drop inputs. // TLDR: Use Update() for input and FixedUpdate() for motors/movement void Update() { if (comboBS == null && GameObject.Find("HUD") && GameObject.Find("HUD").GetComponent <ButtonScripts>()) { //Debug.Log("found"); comboBS = GameObject.Find("HUD").GetComponent <ButtonScripts>(); //.comboUpdate(comboTimer, comboTimeSet, comboMultiplier); } //Debug.Log("cm " + comboMultiplier); //combo stuff if (comboBS) { comboBS.comboUpdate(comboTimer, comboTimeSet, comboMultiplier); } if (curState != PlayerState.Rider) { foreach (GameObject go in GameObject.FindGameObjectsWithTag("VisibleWhenPlaying")) { go.SetActive(false); } } //update vehicle or rider respectively, depending on state. switch (curState) { //process input for vehicle case PlayerState.Vehicle: //---------------------------------------------------------speed //Speedometer.ShowSpeed(curVehicle.transform.GetComponent<Rigidbody>().velocity.magnitude, 0, 100); //speed > boost threshold if (curVehicle.transform.GetComponent <Rigidbody>().velocity.magnitude > curVehicle.returnActualMaxSpeed() * selectedCharacter_Prefab.GetComponent <BasicRider>().boostThreshold) { if (!prevBoostEffect) { prevBoostEffect = true; curBoostEffect = Instantiate(boostEffectPrefab, curVehicle.transform.position, curVehicle.transform.rotation); //mainCamera.ChangeDistance(15, 2f); } curBoostEffect.transform.position = curVehicle.transform.position; curBoostEffect.transform.rotation = curVehicle.transform.rotation; } else { if (curBoostEffect != null) { prevBoostEffect = false; //mainCamera.ChangeDistance(10f, 2f); Destroy(curBoostEffect); } } //---------------------------------------------------------sound if (curVehicle.GetComponent <AudioSource>().isPlaying == false) { SoundScript.PlaySound(curVehicle.GetComponent <AudioSource>(), "Engine"); } //-------------------------------------------------------input: //input horizontal movement curVehicle.inputHorz(InputManager.GetAxis("Horizontal")); float v_input = InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical"); //Debug.Log("1 " + ((v_input / Mathf.Abs(v_input)) * 0.5f) + " 2 " + (v_input * 0.5f) + " 3 " + (((v_input / Mathf.Abs(v_input)) * 0.5f) + (v_input * 0.5f))); //(v_input == 0) ? 0.5f : v_input //input accelleration curVehicle.inputAccel(InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical")); //input vertical movement curVehicle.inputVert(InputManager.GetAxis("Vertical")); //input jump if (InputManager.GetButtonDown("Jump") || curVehicle.GetComponent <BasicVehicle>().broken || curVehicle.transform.position.y < floorPerson - 25) { if (curVehicle.GetComponent <BasicVehicle>().broken) { prevBroken = true; if (comboBS) { comboBS.comboEnd(comboMultiplier); } comboMultiplier = 0; comboTimer = 0; } else { prevBroken = false; } ExitVehicle(); break; } break; //process input for air movement case PlayerState.Rider: if (curRider.cashoutcombo) { CashOutCombo(); } //If player has died, whether by ragdolling or being lower than an arbitrary threshold provided by the variable deadFloor. if (curRider.checkRagdoll() != null || curRider.transform.position.y < floorPerson) { if (Time.timeScale == 1) { SoundScript.PlaySound(playerSource, "Death"); if (comboBS) { comboBS.GameOver(); } curState = PlayerState.Dead; if (curRider.checkRagdoll() == null) { curRider.spawnRagdoll(); } curRagdoll = curRider.checkRagdoll().transform.GetComponent <RagdollStorage>().rb; mainCamera.ChangeFocus(curRagdoll.transform, -1); //mainCamera.ChangeDistance(6f, 2f); curRider.destroyThis(); } //drop combo before cashing in for death comboMultiplier = 0; comboTimer = 0; if (comboBS) { comboBS.comboEnd(comboMultiplier); } break; } else { //only countdown combo in air if (comboTimer > 0) { comboTimer -= Time.deltaTime; if (comboTimer <= 0) { if (comboBS) { comboBS.comboEnd(comboMultiplier); } comboTimer = 0; comboMultiplier = 0; } } //ENTER VEHICLE if (prevVehicleIntangibility > 0) { prevVehicleIntangibility -= Time.deltaTime; if (curRider.curAbilityAmmo == 0 || curRider.rb.velocity.y <= -50) { prevVehicleIntangibility = 0; } if (prevVehicleIntangibility < 0) { prevVehicleIntangibility = 0; } } //maybe ut this back curRider.vehicleToEnter().gameObject != prevVehicle || if (curRider.vehicleToEnter() != null && curState != PlayerState.Dead && (prevVehicleIntangibility <= 0 || curRider.vehicleToEnter().gameObject != prevVehicle)) { EnterVehicle(curRider.vehicleToEnter()); //if(curRider.veh) //curState != PlayerState.Dead && (newVehicle.gameObject != prevVehicle || (newVehicle.easyCheckWheelsOnGround() && newVehicle.getGravity() == Vector3.down) || prevVehicleIntangibility <= 0) break; } else { curRider.rejectVehicleToEnter(); } //ambience if (curRider) { ambientSource.volume = 0; //forever.S curRider.GetComponent<Rigidbody>().velocity.magnitude / 100; } //win if (!win && curRider.goalCollider.collidersCount() > 0) { win = true; if (comboBS && comboMultiplier != 0) { comboBS.comboEnd(comboMultiplier); } comboMultiplier = 0; comboTimer = 0; GameObject.FindGameObjectWithTag("HUD").GetComponent <timerScript>().setWin(); curRider.goalCollider.returnColliders()[0].transform.root.Find("shatter1").gameObject.SetActive(true); curRider.goalCollider.returnColliders()[0].gameObject.SetActive(false); curState = PlayerState.Win; mainCamera.ChangeFocus(curRider.transform, 1); mainCamera.SetCameraPosition(curRider.transform.position + curRider.transform.forward * 1.3f + curRider.transform.up * 1.1f); //curRider.off = true; Rigidbody killrb = curRider.rb; Destroy(curRider); killrb.isKinematic = true; killrb.velocity = Vector3.zero; SoundScript.PlaySound(playerSource, "Win"); if (comboBS) { comboMultiplier = 0; comboBS.comboEnd(comboMultiplier); comboBS.Win(GameObject.FindGameObjectWithTag("HUD").GetComponent <timerScript>().timeRemaining > 0); } } //input horizontal movement curRider.inputHorz(InputManager.GetAxis("Horizontal")); //float v_input = InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical"); //input vertical movement curRider.inputVert(InputManager.GetAxis("Vertical") == 0 ? InputManager.GetAxis("Accelerate") : InputManager.GetAxis("Vertical")); //input fastfall if (InputManager.GetButtonDown("FastFall")) { curRider.inputFastFall(1); SoundScript.PlaySound(playerSource, "Ability"); } //input abilty if (InputManager.GetButtonDown("Jump")) { curRider.inputAbility(1); } else if (InputManager.GetButton("Jump")) { curRider.inputAbility(2); } else if (InputManager.GetButtonUp("Jump")) { curRider.inputAbility(3); } else { curRider.inputAbility(0); } //input breakin if (InputManager.GetButtonDown("BreakIn")) { curRider.inputBreakIn(1); } else if (InputManager.GetButton("BreakIn")) { curRider.inputBreakIn(2); } else if (InputManager.GetButtonUp("BreakIn")) { curRider.inputBreakIn(3); } else { curRider.inputBreakIn(0); } } break; case PlayerState.Dead: updateReset(); break; default: //Debug.Log("ERROR - NO RIDER OR VEHICLE"); break; } }
void Start() { ButtonScripts = GameObject.Find("ButtonsCanvas"); buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); }