//public Camera camera; void Awake() { model = GetComponent <GameModel>(); view = GetComponent <GameView>(); ball = GameObject.Find("Ball").GetComponent <BallView>(); //camera = GameObject.Find("Main Camera").GetComponent<Camera>(); /***********************SUBSCRICOES AOS EVENTOS*******************/ //movimentacoes: barras e bola MoveLeftBarEvent += view.OnMoveLeftbar; MoveRightBarEvent += view.OnMoveRightbar; MoveBallEvent += model.OnMoveBall; //MoveBallEvent += ball.OnMoveBall; GameModel.ChangeBallDirectionEvent += ball.OnMoveBall; //colisoes da bola com os limites e barras /*BallView.BoundColisionEvent += model.OnBoundCollision; * BallView.BarColisionEvent += model.OnBarCollision;*/ BallView.ColisionEvent += model.OnBallCollision; //pontuacao jogadores PlayerScoresEvent += model.OnPlayerScores; PlayerScoresEvent += ball.OnPlayerScore; GameModel.PlayerScoresEvent += view.OnPlayerScores; }
private void GetLinkedBalls(BallView ballView, ref List <BallView> linkedBalls) { var allNearbyBalls = ballView.GetCollideWith(); var matchBalls = allNearbyBalls.FindAll(n => n.ballConfig.id == ballView.ballConfig.id); if (matchBalls.Count > 0) { //Remove already listed balls for (int i = 0; i < linkedBalls.Count; i++) { if (matchBalls.Contains(linkedBalls[i])) { matchBalls.Remove(linkedBalls[i]); } } //Add new matched balls linkedBalls.AddRange(matchBalls); //Run recursive search of others balls for (int i = 0; i < matchBalls.Count; i++) { GetLinkedBalls(matchBalls[i], ref linkedBalls); } } }
public void AddBall(BallView ball) { var position = ball.Ball.localPosition; ball.Ball.localPosition = new Vector3(position.x, position.y, _rectDesck.position.z); ball.transform.SetParent(_rectDesck); }
public static void doDone(InstantBallMovingAction actionObject) { BallView entity = SceneViews.instance.getCurFBScene().ball; entity.setPosition(actionObject.targetPosition); entity.startSamplePosition = actionObject.targetPosition; }
public BallModel(int _Row, int _Column) { Row = _Row; Column = _Column; RowVelocity = ColumnVelocity = Power = PreviousRow = PreviousColumn = 0; View = GameObject.FindGameObjectWithTag("Ball").GetComponent <BallView>(); }
private async Task DestroyBall(BallView ballView) { //Check for resource if (ballView.resourceConfig != null) { switch (ballView.resourceConfig.id) { case 0: { wood++; } break; case 1: { stones++; } break; case 2: { water++; } break; } } await ballView.Explode(); ballView.onMouseDown -= OnBallClicked; ballViews.Remove(ballView); ballView.Dispose(); }
public BounceView() { ballView = new BallView(); waveView = new WaveView(); ballView.Hidden = true; AddSubview(ballView); AddSubview(waveView); waveView.didEndPull = () => { Helpers.CreateScheduledTimer(0.2, () => { ballView.Hidden = false; ballView.StartAnimation(); }); }; BallSize = 28f; BallMovementTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut); BallMoveUpDuration = 0.2; BallMoveUpDistance = 32f * 1.5f; BallViewHeight = 100f; WaveBounceDuration = 0.8; BallColor = UIColor.White; WaveColor = UIColor.White; }
public static void doProgress(BallMovingAction actionObject, float progress) { BallView entity = SceneViews.instance.getCurFBScene().ball; //获取本次移动位置 Vector3 thisEndPostion = MovingProcessorUtility.getMovePosition(entity.startSamplePosition, actionObject.targetPosition, progress); entity.setPosition(thisEndPostion); }
private void ReturnToPool(BallView ball) { _activeBalls.Remove(ball); _pool.Add(ball); ball.gameObject.SetActive(false); SetBallSettings(ball); ball.Init(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballTexture = Content.Load <Texture2D>("aqua-ball.png"); ballSimulation = new BallSimulation(); ballView = new BallView(graphics, ballSimulation, ballTexture); }
public BallPool(int poolSize, BallView ball) { _freeBallPool = new Queue <BallView>(poolSize); for (int i = 0; i < poolSize; i++) { _freeBallPool.Enqueue(Object.Instantiate(ball)); } }
public BallController(BallView view, GameContext context) { _view = view; if (_view != null) { _viewIsNull = false; } _context = context; }
public override void Init() { base.Init(); m_view = GetComponent <BallView>(); m_view.Init(this); this.StateTransion(new BallIdle()); }
public Ball(BallView ballView) { m_ballView = ballView; Collider = new ssg.SphereCollider(); Collider.Radius = Radius; Collider.Trans = this; Collider.Tag = (int)ObjectId.Ball; }
public void Init() { model = GetComponent <BallModel>(); view = GetComponent <BallView>(); view.MoveInput += OnInput; view.Died += OnDeath; view.Jump += OnJump; }
public void delAllBallView() { for (int i = 0; i < listBallView.Count; i++) { BallView ball = listBallView[i]; TrashMan.despawn(ball.gameObject); } listBallView.Clear(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here Texture2D ball = Content.Load <Texture2D>("ball4"); model = new BallSimulation(); view = new BallView(GraphicsDevice, ball); }
private void StartGame() { var obj = Instantiate(ballPrefab, initialPosition, Quaternion.identity); obj.GetComponent <BallModel>(); ball = obj.GetComponent <BallView>().Init(initialPosition); ball.Died += OnDied_Ball; obj.GetComponent <BallController>().Init(); dispatcher.Notify("ball_spawned", ball); }
private BallView CreateBall() { BallView ball = Instantiate(_ballPrefab, gameObject.transform); SetBallSettings(ball); ball.gameObject.SetActive(false); ball.ReturnToPool = ReturnToPool; ball.AddPoints = AddPoints; ball.Init(); return(ball); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballSimulation = new BallSimulation(); ballVIew = new BallView(graphics, ballSimulation, Content); // TODO: use this.Content to load your game content here //camera = new Camera(GraphicsDevice.Viewport); }
public BallView CreateBall(NetObject netObj) { GameObject obj = TrashMan.spawn("Ball"); BallView ball = obj.GetComponent <BallView>(); RectTransform rect = obj.GetComponent <RectTransform>(); ball.uid = netObj.uid; obj.transform.parent = GameObject.Find("Canvas").transform; rect.anchoredPosition = GraphicUtil.ToVector2(netObj.body.center); ball.setData(netObj); return(ball); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here ballSimulation = new BallSimulation(); ballTexture = Content.Load <Texture2D>("Ball.png"); Camera camera = new Camera(GraphicsDevice.Viewport); ballView = new BallView(ballSimulation, camera, GraphicsDevice, ballTexture); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here m_camera = new Camera(GraphicsDevice.Viewport); m_bv = new BallView(); m_bs = new BallSimulation(); m_gameCon = new GameController(Content); this.IsMouseVisible = true; base.Initialize(); }
private void SpawnBall() { if (_pool.Count == 0) { _pool.Add(CreateBall()); } BallView ball = _pool[0]; _pool.RemoveAt(0); _activeBalls.Add(ball); ball.gameObject.SetActive(true); }
public BallController(BallView ballView, int xPositinon, int yPosition, TypeBall typeBall, ResourcesCount typeResources) { _ballView = ballView; _xPositinon = xPositinon; _yPosition = yPosition; _typeBall = typeBall; _typeResources = typeResources; _moveAnimator = _ballView.MoveAnimator; _ballView.PointerObject.BallMoveSide += PointerObject_BallMoveSide; _ballView.MoveAnimator.EndAnimation += OnEndAnimation; _isChanged = true; }
public void shoot(int id) { for (int i = 0; i < listBallView.Count; i++) { BallView ball = listBallView[i]; if (ball.uid == id) { ball.performShoot(); return; } } }
public void Initialize() { _gameObjectsContainerInstance = Instantiate(GameObjectsContainerPrefab); _fieldViewInstance = Instantiate(FieldViewPrefab, _gameObjectsContainerInstance.gameObject.transform); _topRacketViewInstance = Instantiate(RacketViewPrefab, _fieldViewInstance.gameObject.transform); _topRacketViewInstance.gameObject.transform.position = new Vector3(0, 4.5f, 0); _bottomRacketViewInstance = Instantiate(RacketViewPrefab, _fieldViewInstance.gameObject.transform); _bottomRacketViewInstance.gameObject.transform.position = new Vector3(0, -4.5f, 0); _ballViewInstance = Instantiate(BallViewPrefab, _fieldViewInstance.gameObject.transform); }
public void createBallView(int id) { GameObject obj = TrashMan.spawn(ballPrefab.gameObject); BallView ball = obj.GetComponent <BallView>(); listBallView.Add(ball); ball.uid = id; obj.transform.SetParent(this.transform, false); obj.transform.localPosition = Vector3.zero; NetObject data = NetScene.getInstance().GetBall(ball.uid); ball.setData(data); }
public void delBallView(int id) { for (int i = 0; i < listBallView.Count; i++) { BallView ball = listBallView[i]; if (ball.uid == id) { listBallView.Remove(ball); TrashMan.despawn(ball.gameObject); return; } } }
public void Initialize() { _brickViewInstances.CollectionChanged += BrickViewInstancesOnCollectionChanged; _gameObjectsContainerInstance = Instantiate(GameObjectsContainerPrefab); _fieldViewInstance = InstantiateElement(FieldViewPrefab, _gameObjectsContainerInstance); _bricksContainerInstance = InstantiateElement(BricksContainerPrefab, _gameObjectsContainerInstance, new Vector3(0, 3.5f, 0)); _bricksContainerInstance.BrickPositioningCompleted += BricksContainerInstanceOnBrickPositioningCompleted; var brickTypes = Enum.GetValues(typeof(BrickType)).Cast <BrickType>().Reverse(); foreach (var brickType in brickTypes) { for (var j = 0; j < bricksCountPerType; j++) { var brickViewInstance = InstantiateElement <BrickView>(BrickViewPrefab, _bricksContainerInstance.transform); brickViewInstance.Initialize(brickType); brickViewInstance.WasDestroyed += BrickViewInstanceOnWasDestroyed; _brickViewInstances.Add(brickViewInstance); } } if (_randomLevelGeneration) { foreach (var brickViewInstance in _brickViewInstances) { var destroyBrick = _random.Next(0, 2); if (destroyBrick > 0) { _brickViewInstancesForDestruction.Add(brickViewInstance); } } } if (_advantageousPositioningOfTargetBrick) { var randomBrick = _brickViewInstances.Last(); randomBrick.Targeted = true; } else { var randomBrick = _brickViewInstances[_random.Next(_brickViewInstances.Count)]; randomBrick.Targeted = true; } _racketViewInstance = InstantiateElement(RacketViewPrefab, _fieldViewInstance.gameObject.transform, new Vector3(0, -4.5f, 0)); _ballViewInstance = InstantiateElement(BallViewPrefab, _fieldViewInstance.gameObject.transform, new Vector3(0, -1f, 0)); }
private void OnBallClicked(BallView ballView) { var linkedBalls = new List <BallView>(); GetLinkedBalls(ballView, ref linkedBalls); if (linkedBalls.Count >= 3) { linkedBalls.ForEach(n => DestroyBall(n)); } else { ballView.Decoy(); } }
public void Initialize() { CellViewInstances = new List <CellView>(); _directionalLightInstance = Instantiate(_directionalLightPrefab); _cameraInstance = Instantiate(_cameraPrefab); _fieldViewInstance = Instantiate(_fieldViewPrefab); BallViewInstance = Instantiate(_ballViewPrefab); BallViewInstance.transform.position = new Vector3( BallViewInstance.gameObject.transform.position.x, BallViewInstance.gameObject.transform.position.y + 1, BallViewInstance.gameObject.transform.position.z); }
public GameController(ContentManager cm, Camera cam, SpriteBatch sprite, MouseState mouse, GraphicsDevice graphics, BallSimulation ballSim) { content = cm; camera = cam; spriteBatch = sprite; this.graphics = graphics; this.ballSim = ballSim; explosionTexture = content.Load<Texture2D>("explosion"); splitterTexture = content.Load<Texture2D>("spark"); smokeTexture = content.Load<Texture2D>("smokePic"); ballTexture = content.Load<Texture2D>("ball"); pistolEffect = content.Load<SoundEffect>("fire"); splitterView = new SplitterView(spriteBatch,camera, splitterTexture); smokeView = new SmokeView(spriteBatch, camera, smokeTexture); ballView = new BallView(ballSim, camera, graphics, ballTexture); }