public void Lerp(PipeController fromPipe, PipeController toPipe)
 {
     this.fromPipe = fromPipe;
     this.toPipe = toPipe;
     t = 0f;
     transform.localPosition = transform.parent.localPosition;
     transform.parent = transform.parent.parent;
 }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     currentBg = this.transform.parent;
     //获取子游戏对象的组件
     //GetChild(int index); 返回一个GameObject类型的值 index为子物体的索引值(从零开始)
     pipe1 = currentBg.GetChild(1).transform.GetComponent <PipeController>();
     pipe2 = currentBg.GetChild(2).transform.GetComponent <PipeController>();
 }
Ejemplo n.º 3
0
  public void connectOutPipe(Room destination)
  {
      PipeController pc = output_pipe.GetComponent(typeof(PipeController)) as PipeController;

      pc.destination      = destination.getInLocation();
      pc.parent           = this;
      pc.destination_room = destination;
  }
Ejemplo n.º 4
0
 //Add pipe prefab to the pipes queue.
 private void AddPipe(int count)
 {
     for (int i = 0; i < count; i++)
     {
         PipeController pipeController = MonoBehaviour.Instantiate(pipePrefab);
         pipeController.gameObject.SetActive(false);
         pipes.Enqueue(pipeController);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Stores a set of measurements in the database.
        /// </summary>
        /// <param name="measurements">The set of measurements.</param>
        private void Persist(MeasurementSet measurements)
        {
            var houseController  = new HouseController(_dataService);
            var pipeController   = new PipeController(_dataService);
            var sourceController = new SourceController(_dataService);

            measurements.Houses.ForEach((House house) => houseController.Create(house));
            measurements.Pipes.ForEach((Pipe pipe) => pipeController.Create(pipe));
            measurements.Sources.ForEach((Source source) => sourceController.Create(source));
        }
Ejemplo n.º 6
0
    private void OnTriggerExit(Collider other)
    {
        PipeController pc = other.gameObject.GetComponent <PipeController>();

        if (pc != null)
        {
            pipeState.Remove(pc.id);
            insidePipes.Remove(pc.id);
        }
    }
Ejemplo n.º 7
0
    public void setActive(bool active, bool notifypartner)
    {
        isActive = active;
        PipeController OtherPipe = destination.GetComponent <PipeController>();

        if (notifypartner)
        {
            OtherPipe.setActive(isActive, false);
        }
        ani.SetBool("active", active);
    }
Ejemplo n.º 8
0
    void CreatePipe()
    {
        float      randomY       = Random.Range(-spawnPositionY, spawnPositionY);
        GameObject thePipeObject = Instantiate(PipePrefab, new Vector3(maxPipePos, randomY, transform.position.z), Quaternion.identity);

        thePipeObject.transform.SetParent(this.transform);
        PipeController thePipe = thePipeObject.GetComponent <PipeController>();

        thePipe.minPipePos = minPipePos;
        theLevel.allPipe.Add(thePipe);
    }
Ejemplo n.º 9
0
 public void PrepareTest()
 {
     if (GameManager._instance == null)
     {
         MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefab/GameManager"));
     }
     if (PipeManager._instance == null)
     {
         MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefab/PipeManager"));
     }
     pipe = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefab/Pipe")).GetComponent <PipeController>();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Set the pipe pair to face each other vertically with gap in the middle.
 /// </summary>
 /// <param name="maxRange">Total length of both pipes including the gap (in meters).</param>
 /// <param name="pipeGap">The length of the gap between both pipes(in meters).</param>
 /// <param name="gapOffset">how far the gap wull go up or down (in meters).</param>
 public void SetPipeHeight(float maxRange, float pipeGap, float gapOffset)
 {
     Transform[] transforms = gameObject.GetComponentsInChildren <Transform>();
     bottomPipe = transforms[1].gameObject.GetComponent <PipeController>();
     topPipe    = transforms[5].gameObject.GetComponent <PipeController>();
     trigger    = transforms[9].gameObject;
     bottomPipe.SetPipeHeight(((maxRange - pipeGap) + (gapOffset * 2)) / 4, Vector3.down * maxRange / 2);
     topPipe.SetPipeHeight(((maxRange - pipeGap) - (gapOffset * 2)) / 4, Vector3.down * maxRange / 2);
     topPipe.gameObject.transform.Rotate(180, 0, 0);
     trigger.transform.localScale = new Vector3(1, pipeGap, 1);
     trigger.transform.position  += Vector3.up * gapOffset;
 }
Ejemplo n.º 11
0
    private void OnTriggerEnter(Collider collider)
    {
        if (collider.CompareTag("Player"))
        {
            PipeController spawnNewPipe = PipePoolManager.Instance.Get();
            spawnNewPipe.transform.position = transform.position + new Vector3(0f, 0f, 500f);
            spawnNewPipe.transform.rotation = transform.rotation;
            spawnNewPipe.gameObject.SetActive(true);

            Debug.Log("Spawning new pipe");
        }
    }
Ejemplo n.º 12
0
    private void OnTriggerEnter(Collider other)
    {
        PipeController pc = other.gameObject.GetComponent <PipeController>();

        if (pc != null)
        {
            GrabableObj grabable = pc.gameObject.GetComponent <GrabableObj>();
            // Puede ser ungrab porque lo puedes lanzar hacia el grid, no meterlo cogido
            pipeState[pc.id]   = grabable.GetGrabber() != null ? GrabState.Grab : GrabState.Ungrab;
            insidePipes[pc.id] = pc;
        }
    }
Ejemplo n.º 13
0
    void OnDrawGizmos()
    {
        Gizmos.color = Color.yellow;
        Transform pipeTo = null;

        var pipeOut = PipeController.FindCouple(index);

        if (pipeOut != null)
        {
            Gizmos.DrawLine(transform.position, pipeOut.transform.position);
        }
    }
Ejemplo n.º 14
0
    public IController updateController(IControllerValue c)
    {
        pManager  = (PipeController)gameObject.GetComponent <PipeController>().updateController(((GameControllerValue)c).pControllerValues);
        bgManager = (BackgroundController)gameObject.GetComponent <BackgroundController>();

        this.main    = ((GameControllerValue)c).main;
        this.UIview  = ((GameControllerValue)c).view;
        this.weights = ((GameControllerValue)c).weights;

        this.runAi          = ((GameControllerValue)c).aiActive;
        this.scoreIncrement = ((GameControllerValue)c).scoreIncrement;
        return(this);
    }
Ejemplo n.º 15
0
    private void SwitchPipes()
    {
        if (pipe.type == lastSelectedTile.pipe.type)
        {
            return;
        }

        // Switch the pipes transform
        pipe.transform.parent = lastSelectedTile.transform;
        lastSelectedTile.pipe.transform.parent = transform;

        pipe = GetComponentInChildren <PipeController>();
        pipe.transform.localPosition = new Vector3(0, 0, 0);
        lastSelectedTile.pipe        = lastSelectedTile.GetComponentInChildren <PipeController>();
        lastSelectedTile.pipe.transform.localPosition = new Vector3(0, 0, 0);
        SFXManager.instance.PlaySFX(Clip.Swap);
    }
    private void CreateBoard(float xOffset, float yOffset)
    {
        tiles = new GameObject[boardSizeX, boardSizeY];

        float startPointX = transform.position.x;
        float startPointY = transform.position.y;

        for (int x = 0; x < boardSizeX; x++)
        {
            for (int y = 0; y < boardSizeY; y++)
            {
                GameObject newTile = Instantiate(tilePrefab, new Vector3(startPointX + (xOffset * x), startPointY + (yOffset * y), transform.position.z), tilePrefab.transform.rotation);
                tiles[x, y] = newTile;
                newTile.transform.parent = transform;

                List <GameObject> possiblePipes = new List <GameObject>();
                possiblePipes.AddRange(pipes);
                if (gameMode != Mode.Easy)
                {
                    possiblePipes.Add(bombPipePrefab);
                }

                GameObject newPipe = Instantiate(possiblePipes[Random.Range(0, possiblePipes.Count)], newTile.transform);
                newPipe.transform.parent = newPipe.transform;
                newTile.GetComponent <TileController>().pipe = newPipe.GetComponent <PipeController>();
            }
        }

        // Add in the entry and exit pipes
        Vector3 entryPipeLocation = tiles[0, Random.Range(0, boardSizeY - 1)].transform.position;

        entryPipeLocation.x -= entryPipePrefab.GetComponent <SpriteRenderer>().bounds.size.x;
        GameObject entryPipe = Instantiate(entryPipePrefab, entryPipeLocation, entryPipePrefab.transform.rotation);

        entryPipe.transform.parent = transform;

        Vector3 exitPipeLocation = tiles[boardSizeX - 1, Random.Range(0, boardSizeY - 1)].transform.position;

        exitPipeLocation.x += exitPipePrefab.GetComponent <SpriteRenderer>().bounds.size.x;
        GameObject exitPipe = Instantiate(exitPipePrefab, exitPipeLocation, exitPipePrefab.transform.rotation);

        exitPipe.transform.parent = transform;

        activePipe = entryPipe.GetComponent <PipeController>();
    }
 public void SearchForNextPipe()
 {
     for (int i = 0; i < outways.Count; i++)
     {
         if (outways[i] != entryway)
         {
             RaycastHit2D hit = Physics2D.Raycast(transform.position + new Vector3(outways[i].offset.x, outways[i].offset.y, transform.position.z), exitDirection[i], PuzzlePipeManager.instance.checkDistance, PuzzlePipeManager.instance.pipeLayer);
             Debug.Log("Direction: " + exitDirection[i]);
             //Debug.DrawLine(transform.position + new Vector3(outways[i].offset.x, outways[i].offset.y, transform.position.z), transform.position + new Vector3(outways[i].offset.x, outways[i].offset.y, transform.position.z) + exitDirection[i], Color.blue, 8.0f);
             if (hit.collider != null)
             {
                 Debug.Log("HitPipe");
                 PipeController otherPipe = hit.collider.GetComponent <PipeController>();
                 spriteRenderer.sprite = filledPipe;
                 if (otherPipe.type == PipeType.Exit)
                 {
                     UIManager.instance.GameOver();
                     UIManager.instance.GameOverTxt.text = "Nice you got the water to the end pipe, now what did this machine do again?";
                 }
                 else if (otherPipe.type == PipeType.Bomb)
                 {
                     UIManager.instance.GameOver();
                     UIManager.instance.GameOverTxt.text = "The Office of the Reaper wishes to inform you that death by bombs is a unique way of dying, try again";
                 }
                 else
                 {
                     PuzzlePipeManager.instance.activePipe = otherPipe;
                     otherPipe.spriteRenderer.color        = Color.blue;
                     otherPipe.entryway = (BoxCollider2D)hit.collider;
                     UIManager.instance.ResetTimer();
                     SFXManager.instance.PlaySFX(Clip.Clear);
                 }
             }
             else
             {
                 Debug.Log("DidntHitPipe");
                 UIManager.instance.GameOver();
                 UIManager.instance.GameOverTxt.text = "Welp there's water spilling all over the floor now, who's cleaning this up (not me that's for sure)";
             }
         }
     }
 }
Ejemplo n.º 18
0
    void OnDrawGizmos()
    {
        if (!_isPipeIn)
        {
            if (!PipeController.PipesOut.Contains(this))
            {
                PipeController.PipesOut.Add(this);
            }
            return;
        }

        Gizmos.color = Color.yellow;

        var pipeOut = PipeController.FindCouple(_index);

        if (pipeOut != null)
        {
            Gizmos.DrawLine(transform.position, pipeOut.transform.position);
        }
    }
Ejemplo n.º 19
0
 void findConnected()
 {
     if (IsConnectedToSource)
     {
         Collider[] nearbyPipes = Physics.OverlapSphere(gameObject.transform.position, 0.5f, _pipeLayer);
         foreach (Collider pipe in nearbyPipes)
         {
             if (pipe == gameObject.GetComponent <BoxCollider>())
             {
                 continue;
             }
             if (pipe.name.Contains("Pipe"))
             {
                 print("pipe found");
                 PipeController otherController = pipe.gameObject.GetComponentInChildren <PipeController>();
                 if (otherController != null)
                 {
                     print("connected");
                     otherController.IsConnectedToSource = true;
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 // Start is called before the first frame update
 private void Start()
 {
     instance            = this;
     currentSelectedBelt = TypeOfBelts.Top;
     GetBeltPos();
 }
Ejemplo n.º 21
0
 private void Awake()
 {
     pipeController = transform.root.GetComponentInChildren <PipeController>();
     onCollision   += pipeController.NotifyPipePassed;
 }
Ejemplo n.º 22
0
 //Instead of destroying the pipe we return it to the pool
 public void ReturnToPool(PipeController pipeController)
 {
     pipeController.gameObject.SetActive(false);
     pipes.Enqueue(pipeController);
 }