// ---------------------------------------------------------------- // Doers // ---------------------------------------------------------------- public void UpdateBeamView() { int numBeamSegments; // Oh, if my Beam has been destroyed, say it's got no segments; just stop rendering it completely. (There will be a small visual inconsistency, but it's almost impossible to notice.) if (!MyBeam.IsInPlay) { numBeamSegments = 0; } else { numBeamSegments = MyBeam.NumSegments; } // Make more segments if we need them! int numNewSegmentViews = numBeamSegments - segmentViews.Count; for (int i = 0; i < numNewSegmentViews; i++) { segmentViews.Add(GetNewSegmentView()); } // Activate/deactivate the right ones! for (int i = 0; i < numBeamSegments; i++) { BoardOccupant sourceOccupant = MyBeam.GetSegment(i).SourceOccupant; BoardObjectView sourceView = MyBoardView.TEMP_GetObjectView(sourceOccupant); segmentViews[i].Activate(sourceView); } for (int i = numBeamSegments; i < segmentViews.Count; i++) { segmentViews[i].Deactivate(); } }
public void Activate(BoardObjectView _view) { sourceObjView = _view; //Activate(_view.Pos, _view.Rotation); //} //private void Activate(Vector2 _pos, float _rot) { this.gameObject.SetActive(true); //sourcePos = _pos; //sourceRot = _rot; UpdateSegmentView(); }
private BoardObjectView AddObjectView(BoardObject sourceObject) { GameObject prefab = resourcesHandler.GetBoardObjectView(sourceObject); if (prefab == null) { return(null); } // Safety check. BoardObjectView newView = Instantiate(prefab).GetComponent <BoardObjectView>(); newView.Initialize(this, sourceObject); allObjectViews.Add(newView); return(newView); }
//public BeamRendererColliderLine[] Debug_colliderLines { get { return colliderLines; } } // ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public BeamRendererCollider(BoardView _myBoardView, BoardObjectView _myObjectView) { beamRendererColliderArena = _myBoardView.BeamRendererColliderArena; myObjectView = _myObjectView; // Shrink everyone down uniformly if they're movable. float unitSize = _myBoardView.UnitSize; diameter = unitSize * 0.98f; if (myObject is BoardOccupant && (myObject as BoardOccupant).IsMovable) { diameter = unitSize * 0.75f; } // Set my lines hardcodedly! //if (myObject is Mirror) { InitializeLinesForMirror (); } if (myObject is BeamGoal) { InitializeLinesForBeamGoalOrSource(0.5f); } else if (myObject is BeamSource) { InitializeLinesForBeamGoalOrSource(0.1f); } //else if (myObject is Bucket) { InitializeLinesForBucket (); } //else if (myObject is Portal) { InitializeLinesForPortal (); } //else if (myObject is Wall) { InitializeLinesForWall (); } else if (myObject is Player) { InitializeLinesForPlayer(); } else { InitializeLinesForDefaultSquare(); } // Update my actual lines right off the bat! UpdateLines(); }
public BeamRendererColliderLine(BoardObjectView myObjectView, Line line, BeamRendererCollision.Types collisionType) { this._myObjectView = myObjectView; this._line = line; this._collisionType = collisionType; }
public BeamRendererColliderLine(BoardObjectView myObjectView, BeamRendererCollision.Types collisionType) { this._myObjectView = myObjectView; this._line = new Line(); // default to an empty line for now. this._collisionType = collisionType; }
public BeamRendererColliderLine(Line line) { this._myObjectView = null; this._line = line; this._collisionType = BeamRendererCollision.Types.End; }
public void Deactivate() { this.gameObject.SetActive(false); sourceObjView = null; }