bool InputActivator() { if (LastSeenTile.ActivatorOnTile == null) { return(false); } PreassurePlate pp = LastSeenTile.ActivatorOnTile as PreassurePlate; if (pp != null) { return(false); } LaserReceiver lr = LastSeenTile.ActivatorOnTile as LaserReceiver; if (lr != null) { return(false); } LaserGenerator lg = LastSeenTile.ActivatorOnTile as LaserGenerator; if (lg != null) { return(false); } LastSeenTile.ActivatorOnTile.OnActivate(); return(true); }
public void CheckPreassurePlateOnTIle() { Debug.Log("Checking Preassure Plate"); PreassurePlate pp = LastSeenTile.ActivatorOnTile as PreassurePlate; if (pp != null) { pp.OnActivate(); } }
void SwitchTiles(List <Tile> tiles) { foreach (Tile t in tiles) { PreassurePlate pp = t.ActivatorOnTile as PreassurePlate; if (pp != null) { pp.ChangeState(); } if (t.LaserOnTile != null) { t.LaserOnTile.ChangeState(); } if (t.ObjectOnTile != null) { Generator g = t.ObjectOnTile as Generator; if (g != null) { continue; } //Debug.Log("Vyska generatoru: " + (int)transform.position.y); if (Mathf.Abs((int)transform.position.y - (int)t.ObjectOnTile.transform.position.y) <= AreaOfEffect) { t.ObjectOnTile.ChangeState(); } Box b = t.ObjectOnTile as Box; while (b != null && b.ItemOnTop != null) { if (Mathf.Abs((int)transform.position.y - (int)b.ItemOnTop.transform.position.y) <= AreaOfEffect) { b.ItemOnTop.ChangeState(); } b = b.ItemOnTop as Box; } } } }
void InputPush() { Debug.Log("<<<PUSH>>>"); if (LastSeenTile.ObjectOnTile == null) { return; } MovableObject i = LastSeenTile.ObjectOnTile as MovableObject; if (i == null) { return; } if (!i.isPushable) { return; } if (LastSeenTile.LaserOnTile != null) { Debug.Log("We cant push from tile where is laser"); return; } //Debug.Log("We are going to push..."); Tile[] t = Level.GetTile(transform.position); Vector2Int vector = LastSeenTile.Position - t[0].Position; Tile[] dest = Level.GetTile(LastSeenTile.Position + vector); if (dest == null) { Debug.LogWarning("NO VALID TILE"); return; } List <Generator> gens = Level.Instance.GetGeneratorsAffectingTile(dest[0]); Vector3 d = new Vector3(dest[0].Position.x, dest[0].Height, dest[0].Position.y); Tile actualTile = null; Debug.Log("Pushing from " + LastSeenTile.Timeline); //divame se na dest v pritomnosti bez vlivu generatoru if (gens.Count == 0) { if (LastSeenTile.Timeline.Equals(TimelineObject.Present)) { actualTile = TimeLinePushCheck(i, dest[0], true); } else { actualTile = TimeLinePushCheck(i, dest[1], false); } } else { //Debug.Log("Some Generators effects the new tile"); foreach (Generator g in gens) { if (g.IsOn) { Debug.Log("Some Generator is on"); if (LastSeenTile.Timeline.Equals(TimelineObject.Present)) { actualTile = TimeLinePushCheck(i, dest[0], !dest[0].Timeline.Equals(LastSeenTile.Timeline)); } else { actualTile = TimeLinePushCheck(i, dest[1], dest[1].Timeline.Equals(LastSeenTile.Timeline)); } //actualTile = TimeLinePushCheck(i, dest[1], dest[1].Timeline.Equals(LastSeenTile.Timeline)); break; } //zadny generator ovlivnujici tile neni zaply else { actualTile = TimeLinePushCheck(i, dest[0], dest[0].Timeline.Equals(LastSeenTile.Timeline)); } } } Debug.Log("Finsihing..."); if (actualTile == null) { return; } PreassurePlate pp = actualTile.ActivatorOnTile as PreassurePlate; if (pp != null) { pp.OnActivate(); } PreassurePlate pp2 = LastSeenTile.ActivatorOnTile as PreassurePlate; if (pp2 != null) { pp2.OnActivate(); } i.StartCoroutine(i.PushMovement(d)); LastSeenTile.ChangeOccupation(); StartCoroutine(PushMovement()); Debug.Log("ACTUAL TILE: " + actualTile.Timeline + " " + actualTile.Position); if (actualTile.LaserOnTile != null) { actualTile.LaserOnTile.DestroyNextLasers(); } }