private void UpdateLevelStartVariables() { GrabPlayerSpawnPositions(); timedTorchesGO = GameObject.FindWithTag("TimedTorches"); doorsGO = GameObject.FindWithTag("Doors"); torches = new TorchSwitch[timedTorchesGO.transform.childCount]; for (int i = 0; i < timedTorchesGO.transform.childCount; i++) { torches[i] = timedTorchesGO.transform.GetChild(i).GetComponent <TorchSwitch>(); } torch = torches[0]; doors = new DoorSwitch[doorsGO.transform.childCount]; for (int i = 0; i < doorsGO.transform.childCount; i++) { doors[i] = doorsGO.transform.GetChild(i).GetComponent <DoorSwitch>(); } door = doors[1]; }
// Use this for initialization void Start() { doorswitch = FindObjectOfType <DoorSwitch>(); gameObject.GetComponent <SpriteRenderer>().sprite = doorClosed.GetComponent <SpriteRenderer>().sprite; }
void Awake() { if (switch1 != null) { switch1_script = switch1.GetComponent <DoorSwitch> (); } if (switch2 != null) { switch2_script = switch2.GetComponent <DoorSwitch> (); } opening = false; closing = false; if (moveY < 0) { negative = true; } else { negative = false; } if (!negative) { dest = transform.position + new Vector3(0, moveY, 0); } else { openRate = openRate * -1; closeRate = closeRate * -1; dest = transform.position + new Vector3(0, -moveY, 0); } }
private void InitFromSaveGame(SaveManager.SaveGame SaveGame) { LoadedFromSaveGame = true; Skill = SaveGame.Skill; GetPlayer().AddScore(SaveGame.PlayerScore); GetPlayer().gameObject.transform.position = SaveGame.Player.Position.ToVector3(); GetPlayer().RestoreRotation(SaveGame.Player.Rotation.ToQuaternion()); GetPlayer().SetHealth(SaveGame.PlayerHealth); // //GetPlayer().Flip(); //SavedPlayerTransform = SaveGame.Player; StartingFromSaveGame = true; if (Coins == null) { Coins = new List <Coin>(); } ClearCoinsArray(); for (int i = 0; i < SaveGame.ItemPosition.Length; i++) { GameObject CurrentCoin = null; Debug.Log("Got type: " + SaveGame.ItemPosition[i].Type); Type CoinType = Type.GetType(SaveGame.ItemPosition[i].Type); Vector3 CoinPosition = SaveGame.ItemPosition[i].Position.ToVector3(); if (CoinType == typeof(GoldCoin)) { CurrentCoin = Instantiate(Resources.Load("Prefabs/GoldCoin"), CoinPosition, Quaternion.identity) as GameObject; } else if (CoinType == typeof(SilverCoin)) { CurrentCoin = Instantiate(Resources.Load("Prefabs/SilverCoin"), CoinPosition, Quaternion.identity) as GameObject; } else if (CoinType == typeof(CopperCoin)) { CurrentCoin = Instantiate(Resources.Load("Prefabs/CopperCoin"), CoinPosition, Quaternion.identity) as GameObject; } else { Debug.Log("Unknown type: " + CoinType.ToString()); continue; } CurrentCoin.name = CurrentCoin.name + i; Coin TempCoin = CurrentCoin.GetComponent <Coin>(); Coins.Add(TempCoin); } if (SaveGame.DoorSwitch != null && SaveGame.DoorSwitch.UnLocked) { GameObject SwitchObject = GameObject.Find(SaveGame.DoorSwitch.Name); if (SwitchObject != null) { DoorSwitch Switch = SwitchObject.GetComponent <DoorSwitch>(); Switch.UnlockDoor(true); } } }
public void RegisterMiniGameListener(DoorSwitch Switch) { if (InMiniGame) { return; } MiniGameSwitch = Switch; InMiniGame = true; }
void Awake() { platformSwitch_script1 = platformSwitch1.GetComponent <DoorSwitch>(); platformSwitch_script2 = platformSwitch2.GetComponent <DoorSwitch>(); initPos = gameObject.transform.position; left = new Vector2(); right = new Vector2(); dir = new Vector2(); playerLayer = 1 << LayerMask.NameToLayer("Player"); }
// Use this for initialization void Start() { _count = 0; _anim = Door.GetComponent <Animator>(); GameObject doorSwitch = GameObject.Find("switch"); _doorSwitchScript = doorSwitch.GetComponent <DoorSwitch>(); _gameTimmerScript = TimmerGameObject.GetComponent <GameTimer>(); }
public void ServerPerformInteraction(HandApply interaction) { if (interaction.IsAltClick == false) { return; } if (interaction.TargetObject.TryGetComponent <DoorSwitch>(out var @switch)) { Chat.AddExamineMsg(interaction.Performer.gameObject, "You assign the switch to the receiver."); doorSwitch = @switch; } }
private void ToggleDoorController(DoorSwitch doorSwitch, DoorController doorController) { if (doorSwitch.doorControllers.Contains(doorController)) { var list = doorSwitch.doorControllers.ToList(); list.Remove(doorController); doorSwitch.doorControllers = list.ToArray(); } else { var list = doorSwitch.doorControllers.ToList(); list.Add(doorController); doorSwitch.doorControllers = list.ToArray(); } }
private void UpdateLevelStartVariables() { GrabPlayerSpawnPositions(); torchesGO = GameObject.FindWithTag("Torches"); doorsGO = GameObject.FindWithTag("Doors"); messagesGO = GameObject.FindWithTag("Messages"); torchesColor = new TorchColor[torchesGO.transform.childCount]; torches = new TorchSwitch[torchesGO.transform.childCount]; for (int i = 0; i < torchesGO.transform.childCount; i++) { torchesColor[i] = torchesGO.transform.GetChild(i).GetComponent <TorchColor>(); torches[i] = torchesGO.transform.GetChild(i).GetComponent <TorchSwitch>(); } torchSwitch16 = torches[2]; torchSwitch17 = torches[3]; torchColor16 = torchesColor[2]; torchColor17 = torchesColor[3]; doors = new DoorSwitch[doorsGO.transform.childCount]; for (int i = 0; i < doorsGO.transform.childCount; i++) { doors[i] = doorsGO.transform.GetChild(i).GetComponent <DoorSwitch>(); } door04 = doors[1]; door06 = doors[3]; messages = new RevealMessage[messagesGO.transform.childCount]; for (int i = 0; i < messagesGO.transform.childCount; i++) { messages[i] = messagesGO.transform.GetChild(i).GetComponent <RevealMessage>(); } message04a = messages[4]; message04b = messages[5]; message05a = messages[6]; message05b = messages[7]; message06a = messages[8]; message06b = messages[9]; }
private void DoorLogic(DoorSwitch inDoor, bool doorState) { if (inDoor.isLocked()) { if (doorState == true) { inDoor.Unlock(); } } else { if (doorState == false) { inDoor.Lock(); } } }
public static SaveGame BuildSaveGame() { SaveGame Result; int Index; Result.PlayerScore = GameHandler.Instance.GetPlayer().GetScore(); Result.PlayerHealth = GameHandler.Instance.GetPlayer().GetHealth(); Result.Player = new SerializableEntity(GameHandler.Instance.GetPlayer().transform.position, GameHandler.Instance.GetPlayer().transform.rotation); //Result.PlayerPosition = new SerializableVector3(GameHandler.Instance.GetPlayer().transform.position); Result.Enemies = new SerializableEntity[GameHandler.Instance.Enemies.Count]; //Result.EnemyPosition = new SerializableVector3[GameHandler.Instance.Enemies.Count]; Result.Skill = GameHandler.Instance.Skill; Index = 0; foreach (EnemyAI Enemy in GameHandler.Instance.Enemies) { if (Enemy.HasLockedDoor()) { continue; } Result.Enemies[Index++] = new SerializableEntity(Enemy.transform.position, Enemy.transform.rotation); } Debug.Log("Saving " + GameHandler.Instance.Coins.Count); Result.ItemPosition = new SerializableCoin[GameHandler.Instance.Coins.Count]; Index = 0; foreach (Coin CoinPosition in GameHandler.Instance.Coins) { Result.ItemPosition[Index++] = new SerializableCoin(CoinPosition); } GameObject SwitchObject = GameObject.FindGameObjectWithTag("DoorSwitch"); if (SwitchObject != null) { DoorSwitch Switch = SwitchObject.GetComponent <DoorSwitch>(); Result.DoorSwitch = new SerializableDoorSwitch(Switch); } else { Result.DoorSwitch = null; } Result.SceneName = SceneManager.GetActiveScene().name; Debug.Log("Saving current scene: " + Result.SceneName); return(Result); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Trap") { LightCheck(MaxLightCount, false); } if (collision.gameObject.tag == "Door") { if ((int)collision.contacts[0].point.y == (int)GroundCheck.transform.transform.position.y) { DoorSwitch Door = collision.gameObject.GetComponent <DoorSwitch>(); if (Door.Off == false) { Door.DoorOn(); } } } if (collision.gameObject.tag == "Ground") { if (!Land && IsGround && !WallSliding && transform.parent == null) { Audio.Play(1); } } if (collision.gameObject.tag == "Rock") { if (!Rock && IsGround && !WallSliding) { Audio.Play(5); } } if (collision.gameObject.tag == "Wood") { if (!Land && IsGround && !WallSliding) { Audio.Play(3); } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (!isSelecting) { if (GUILayout.Button("Begin Selecting DoorControllers")) { isSelecting = true; doorSwitch = (DoorSwitch)target; } } else { if (GUILayout.Button("Stop Selecting DoorControllers")) { isSelecting = false; doorSwitch = null; } } }
void OnTriggerEnter2D(Collider2D other) { switch (other.tag) { case "Pickup": other.gameObject.SetActive(false); batteriesCollected++; UpdateCollectedText(); health += 0.25f; beep.Play(); break; case "GravityPad": inGravityPadTrigger = true; YButton.enabled = true; break; case "DoorSwitch": inDoorSwitchTrigger = true; doorSwitch = other.GetComponent <DoorSwitch>(); YButton.enabled = true; break; case "Terminal": leftTerminal = false; Camera.main.transform.localPosition = Vector3.Lerp(Camera.main.transform.localPosition, new Vector3(10.15f, 30, 7.71f), Time.deltaTime); Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, 33, Time.deltaTime); break; case "Generator": inGenerator = true; YButton.enabled = true; break; case "bloop": pullBackCamera = true; break; } }
public void Init(DoorSwitch Parent) { this.Parent = Parent; InitGrid(); InitTimer(); }
public SerializableDoorSwitch(DoorSwitch Switch) { Name = Switch.gameObject.name; UnLocked = Switch.Unlocked; }
private void Start() { doorSwitch = GetComponent <DoorSwitch>(); }
void Awake() { switch1_script = switch1.GetComponent <DoorSwitch> (); }
public void Register(DoorSwitch sw) { switches.Add(sw); }
void FixedUpdate() { Collider2D DoorSwitch = null; float FinalSpeed; //CheckEscapeKey(); if (IsPaused || IsDead) { return; } IsOnGround = Physics2D.OverlapCircle(GroundPosition.position, GroundRadius, GroundMask); //Debug.Log("IsOnGround: " + IsOnGround); //In general set health to -99999 and check for this! //If not on ground and we have registered our fall time... if (!IsOnGround && FallTime > 0) { float Delta = Time.time - FallTime; if (Delta > 3f) { Damage(100); } } else { //Debug.Log("Stopped fall time"); FallTime = 0f; } if (HealthBar != null && HealthBar.value <= 0) { //FreezePlayer(true,true); GameHandler.Instance.OnGameOver(); return; } //Anim.SetFloat("VerticalSpeed",RBody.velocity.y); // Reset Jump animation parameters if we are on ground. if (IsOnGround && (Anim.GetBool("Jump") || Anim.GetBool("Land"))) { Anim.SetBool("Jump", false); Anim.SetBool("Land", false); LandSound.Play(); } // Jump and also sets the correct animation. if (IsOnGround && UpPressed) { Debug.Log("Jumping!"); RBody.velocity = Vector2.up * JumpVelocity; Anim.SetBool("Jump", true); JumpSound.Play(); } FinalSpeed = SpeedBooster ? MaxSpeed + 5f : MaxSpeed; RBody.velocity = new Vector2(XInputOffset * FinalSpeed, RBody.velocity.y); Anim.SetFloat("PlayerSpeed", Mathf.Abs(XInputOffset)); if (XInputOffset > 0 && !FacingRight) { Flip(); } else if (XInputOffset < 0 && FacingRight) { Flip(); } // End of jump/ Free fall. if (!IsOnGround && RBody.velocity.y < 0) { RBody.velocity += Vector2.up * Physics2D.gravity * 1.5f * Time.deltaTime; Anim.SetBool("Land", true); //Make sure we don't overwrite the previous frame value. if (FallTime == 0f) { FallTime = Time.time; } } else if (RBody.velocity.y > 0) { RBody.velocity += Vector2.up * Physics2D.gravity * 1f * Time.deltaTime; } //Shoot if (ActionPressed && (DoorSwitch = GetNearestSwitch()) != null) { //Push it. //Handle it Debug.Log("Pressing the switch!"); DoorSwitch Switch = DoorSwitch.GetComponent <DoorSwitch>(); if (Switch == null) { Debug.Log("Warning Gameobject marked as DoorSwitch has not a doorswitch script attached!"); return; } Switch.OnPush(); ActionPressed = false; } else { float Delta = Time.time - LastRocketFireTime; //Rate limit. if (Anim.GetBool("Shoot")) { Anim.SetBool("Shoot", false); } if (Delta < 2 && LastRocketFireTime > 0f) { ActionPressed = false; return; } if (ActionPressed) { FireRocket(); Anim.SetBool("Shoot", true); LastRocketFireTime = Time.time; } HandleAnimationLayers(); } }