Пример #1
0
        public void SpawnHunters()
        {
            //Load Hunters
            var huntersObjects = _level.Map.ObjectGroup.Objects.Where(o => o.Name.StartsWith("hunter")).ToArray();

            for (int i = 0; i < huntersObjects.Length; i++)
            {
                var hunterData = huntersObjects[i];

                float sightSpeed = hunterData.GetFloatProperty("sight_speed", 200);

                var hunter = new HunterGameObject(hunterData.X, hunterData.Y, hunterData.Width, hunterData.Height,
                                                  sightSpeed);

                hunter.HunterBehaviorListeners =
                    hunter.HunterBehaviorListeners.Concat(new IHunterBehaviorListener[] { this }).ToArray();

                _hunters.Add(hunter);

                _level.AddChild(hunter);
            }

            for (int i = _hunters.Count() - 1; i > -1; i--)
            {
                if (_hunters[i].Destroyed)
                {
                    _hunters.RemoveAt(i);
                }
            }
        }
        public HunterCrossHairGameObject(HunterGameObject pHunter) : base("data/Hunter Crosshair00.png", 1, 1)
        {
            _hunter = pHunter;

            color = _startColor = 0x6acedd; //Light blue from stylesheet

            SetOrigin(width * 0.5f, height * 0.5f);

            _customColliderBounds = new Rectangle(-44 * 0.5f, -44 * 0.5f, 44, 44);
        }
Пример #3
0
        public void SpawnBullet(float x, float y, Vector2 direction, HunterGameObject shooter)
        {
            var bullet = GetBulletFromPool();

            bullet.SetXY(x, y);
            bullet.SetScaleXY(1, 1);

            var dirNorm = direction.Normalized;

            bullet.rotation = (Mathf.Atan2(dirNorm.y, dirNorm.x)).RadToDegree();

            bullet.Range = shooter.ScanEnemyRange * 1.2f;

            bullet.LifeTimeCounter = 0;

            bullet.SetActive(true);

            bullet.Shooter = shooter;
        }
Пример #4
0
 void IHunterBehaviorListener.OnShootAtEnemy(HunterGameObject hunter, Vector2 aimDistance, GameObject enemy)
 {
     _bulletManager.SpawnBullet(hunter.x, hunter.y, aimDistance, hunter);
 }