void Start() { //set shootdown vector 2 ShootDown = new Vector2(0,-1); //spawn position of the food projectiles YPositionSpawn = transform.position + new Vector3(0,-1,0); //reference the boolean in food collision FCol = GameObject.FindGameObjectWithTag("Player").GetComponent<FoodCollision>(); }
public GameScene(GameMain game) : base(game) { _game = game; var sceneSize = new System.Drawing.Size(4096, 4096); _gameRect = new Rectangle(-sceneSize.Width / 2, -sceneSize.Height / 2, sceneSize.Width, sceneSize.Height); _bgContainer = game.newSprite <Sprite>(); _container = game.newSprite <Sprite>(); addChild(_bgContainer); addChild(_container); _foodContainer = game.newSprite <Sprite>(); _foodEatContainer = game.newSprite <Sprite>(); _playerContainer = game.newSprite <Sprite>(); _container.addChild(_foodContainer); _container.addChild(_foodEatContainer); _container.addChild(_playerContainer); init(); _initBg(); _initCollisionGroups(); _snakeCollisionUpdate = new SnakeCollisionUpdate(this); _foodList = new _FoodList(this); _foodCollision = new FoodCollision(this); this.game.gameUpdateEvent += Game_gameUpdateEvent; }
/// <summary> /// On Food collision event method. /// </summary> /// <param name="gameObject">Eaten food.</param> protected virtual void OnFoodCollision(GameObject gameObject) => FoodCollision?.Invoke(gameObject);
private void Start() { _foodCol = gameObject.GetComponent <FoodCollision>(); _prevCols = _foodCol.TimesCollided; }