void OnPipeUpdated(GamePipe pipe) { if (pipe.State == GamePipeState.CORRECT) { CreatePipeShadow(pipe); } }
private void InitView(GamePipe pipe, GamePlumbingController plumbingController, GamePlumbingDragView plumbingDragView) { pipe.RegisterOnPipeUpdated(OnPipeUpdated); gamePlumbingDragView = plumbingDragView; gamePlumbingController = plumbingController; OnPipeUpdated(pipe); }
private void OnPipeStateChanged(GamePipe pipe) { if (pipe.State == GamePipeState.FINISHED || pipe.State == GamePipeState.WRONG) { Destroy(gameObject); } }
private void FromMoving(GameShape shape, GameShapeState shapeState) { GamePipe pipe = GetShapePipePair(shape).AttachedPipe; switch (shapeState) { case GameShapeState.CORRECT_MOVING: if (pipe != null) { pipe.RemoveShape(shape); } shape.SetState(GameShapeState.CORRECT_MOVING); break; case GameShapeState.FINISHED: if (pipe != null) { pipe.RemoveShape(shape); } shape.SetState(GameShapeState.FINISHED); shape.OnShapeFinished(false); break; default: break; } }
public void RemovePipe() { if (AttachedPipe != null) { AttachedPipe.SetState(GamePipeState.FINISHED); AttachedPipe = null; } }
public static GamePipeView CreatePipe(GameObject pipePrefab, GamePipe pipeDef, GameObject parent, GamePlumbingController plumbingController, GamePlumbingDragView plumbingDragView) { Vector3 position = pipeDef.StartPoint; GameObject newPipeObject = Instantiate(pipePrefab, position, Quaternion.identity); newPipeObject.transform.SetParent(parent.transform); GamePipeView component = newPipeObject.AddComponent <GamePipeView>(); component.InitView(pipeDef, plumbingController, plumbingDragView); return(component); }
public static GamePipeShadowView CreateShadow(GameObject shadowPrefab, GamePipe pipeDef, GameObject parent) { Vector3 position = pipeDef.StartPoint; GameObject newPipeObject = Instantiate(shadowPrefab, position, Quaternion.identity); newPipeObject.transform.SetParent(parent.transform); GamePipeShadowView component = newPipeObject.AddComponent <GamePipeShadowView>(); component.InitView(pipeDef); return(component); }
private GamePipe AddPipe(GameSpawner spawner, GamePipeEnd end) { GamePipe newPipe = new GamePipe(spawner, end); pipes.Add(newPipe); spawner.AttachPipe(newPipe); if (onPipeAdded != null) { onPipeAdded(newPipe); } return(newPipe); }
private float MoveShape(ShapePipePair pair, float dt) { GameShape shape = pair.Shape; GamePipe pipe = pair.AttachedPipe; float distanceTravelled = dt * shape.Speed; float percentualTravelled = shape.PercentualTraveled + distanceTravelled; Vector3 newPosition = pipe.GetPositionFromPercentual(percentualTravelled); shape.UpdatePosition(percentualTravelled, newPosition); return(percentualTravelled); }
void AddPipe(GamePipe pipe) { GamePipeView pipeView = GamePipeView.CreatePipe(pipePrefab, pipe, pipeParent, gamePlumbingController, gamePlumbingDragView); pipeViewList.Add(pipeView); pipeView.RegisterOnPipeViewUpdated(OnPipeViewUpdated); if (onPipeViewAdded != null) { onPipeViewAdded(pipeView); } }
private ArrayList GetShapePipePair(GamePipe pipe) { ArrayList pairs = new ArrayList(); foreach (ShapePipePair pair in Pairs) { if (pair.AttachedPipe == pipe) { pairs.Add(pair); } } return(pairs); }
public void OnShapeFinishedSpawning(GameShape shape) { GamePipe pipe = shape.Spawner.AttachedPipe; if (pipe != null) { AttachPipe(shape, pipe); } UpdateState(shape, GameShapeState.MOVING); if (pipe != null) { OnPipeUpdated(pipe); } }
public void OnPipeUpdated(GamePipe pipe) { ArrayList pairs = GetShapePipePair(pipe); if (pairs.Count > 0) { foreach (ShapePipePair pair in pairs) { GameShapeType pipeEnd = pair.AttachedPipe.CurrentEndType; GameShapeType shapeType = pair.Shape.Type; if (pipeEnd == shapeType) { UpdateState(pair.Shape, GameShapeState.CORRECT_MOVING); } } } }
public int GetNumberOfValidShapesOnPipe(GamePipe pipe) { if (pipe == null) { return(0); } int valids = 0; foreach (ShapePipePair pair in Pairs) { if (pair.AttachedPipe == pipe) { if (pair.Shape.State == GameShapeState.SPAWNING || pair.Shape.State == GameShapeState.MOVING) { valids++; } } } return(valids); }
public int GetNumberOfShapesOnPipe(GamePipe pipe) { if (pipe == null) { return(0); } int number = 0; foreach (ShapePipePair pair in Pairs) { if (pair.AttachedPipe == pipe) { if (pair.Shape.State != GameShapeState.FINISHED || pair.Shape.State != GameShapeState.TO_DESTROY) { number++; } } } return(number); }
private void OnPipeUpdated(GamePipe pipe) { updatedPipe = pipe; origin = pipe.StartPoint; last = pipe.CurrentEnd; UpdatePipe(origin, last); if (pipe.State == GamePipeState.FINISHED || pipe.State == GamePipeState.CORRECT) { if (isDragging) { gamePlumbingDragView.CancelPipeDragView(lastDragId); } destroyed = true; Destroy(gameObject); } if (OnPipeViewUpdated != null) { OnPipeViewUpdated(this); } }
private void FromSpawning(GameShape shape, GameShapeState shapeState) { switch (shapeState) { case GameShapeState.MOVING: GamePipe pipe = GetShapePipePair(shape).AttachedPipe; if (pipe == null) { shape.SetState(GameShapeState.EXPLODING); shape.OnShapeFinished(false); } else { shape.SetState(GameShapeState.MOVING); } break; default: break; } }
public int GetNumberOfValidShapesOnPipe(GameShape shape) { GamePipe pipe = GetShapePipePair(shape).AttachedPipe; return(GetNumberOfValidShapesOnPipe(pipe)); }
public void AttachPipeToSpawner(GamePipe pipe, GameSpawner spawner) { spawner.AttachPipe(pipe); }
public void InitView(GamePipe pipe) { _pipe = pipe; pipe.RegisterOnPipeUpdated(OnPipeStateChanged); UpdatePipe(pipe.StartPoint, pipe.CurrentEnd); }
public int GetNumberOfShapesOnPipe(GameShape shape) { GamePipe pipe = GetPipeOfShape(shape); return(GetNumberOfShapesOnPipe(pipe)); }
public void UpdatePipeEnd(GamePipe pipe, GamePipeEnd pipeEnd) { pipe.UpdateGamePipeEnd(pipeEnd, pipeEnd.Type); shapeController.OnPipeUpdated(pipe); }
void CreatePipeShadow(GamePipe pipe) { GamePipeShadowView.CreateShadow(pipeShadowPrefab, pipe, pipeShadowParent); }
public void AttachPipe(GamePipe pipe) { AttachedPipe = pipe; }
private void _OnGamePipeLog(string gamePipe) => GamePipe?.Invoke(this, new GameWorkerPipeLogEventArgs(gamePipe));
public void AttachPipe(GameShape shape, GamePipe pipe) { ShapePipePair pair = GetShapePipePair(shape); pair.AttachedPipe = pipe; }
private void Awake() { pipe = GetComponent <GamePipe>(); grid = GameObject.Find("Grid"); gs = grid.GetComponent <GridScript>(); }