Beispiel #1
0
 private void ResetReload(IShooter shooter, float dt)
 {
     if (shooter.Reload > 0)
     {
         shooter.Reload -= dt;
     }
 }
Beispiel #2
0
    public SetSequences(SetSequencesData data, PlayerControllerInput playerController, IShooter controller)
    {
        this.data             = data;
        this.playerController = playerController;
        this.controller       = controller;

        commands = new List <CommandSequence>();
        foreach (CommandSequenceData sequences in data.comboSections)
        {
            CommandSequence command = new CommandSequence(sequences, this.playerController, this.controller);
            command.onCompletedSequence += NextSection;
            command.onWrongInput        += RemoveSequence;
            commands.Add(command);
        }

        commands[0].onStartSequence += StartSection;

        this.playerController.OnInputPressed += CheckPressedInput;
        this.controller.OnDestroy            += UnsubscribeEvent;

        currentSection = commands[0];
        canExecute     = true;

        cooldownCorutine = CooldownCorutine();
    }
Beispiel #3
0
        void GameEvent.IPlayerShoot.OnShoot(IShooter player)
        {
            if (GunData == null)
            {
                return;
            }

            var bullet = UiObjectsPooler.Instance.Get <UiBullet>(GunData.Bullet);

            //define bullet direction
            var xDirection = UiPlayer.Sprite.flipX ? -1 : 1;

            //define starting position
            bullet.transform.position = BulletSpawn.position;

            //go
            var velocity   = GunData.Velocity;
            var precision  = GunData.Precision;
            var adjustment = GunData.Adjustment;
            var info       = new UiBullet.BulletTriggerInfo
            {
                Damage     = GunData.Damage,
                LifeSpan   = GunData.BulletLifeSpan,
                Adjustment = adjustment,
                Velocity   = velocity,
                Direction  = xDirection,
                Precision  = precision
            };

            bullet.Fire(info);
        }
Beispiel #4
0
    void ChangeActiveShooterTo(IShooter shooter)
    {
        _activeShooter = shooter;
        if (_activeShooter is ShotgunShooter)
        {
            _shooterDisplay.sprite = shotgunImage;
        }
        else if (_activeShooter is MachineGunShooter)
        {
            _shooterDisplay.sprite = machinegunImage;
        }
        else if (_activeShooter is SimpleShooter)
        {
            _shooterDisplay.sprite = gunImage;
        }

        if (gunLevel == 0)
        {
            _shooterBackground.color = Color.yellow;
        }
        else if (gunLevel == 1)
        {
            _shooterBackground.color = Color.cyan;
        }
        else if (gunLevel == 2)
        {
            _shooterBackground.color = Color.magenta;
        }
    }
Beispiel #5
0
 public GameManager(GameObject ui, ICourseInspector courseInspector, IShooter shooter, ICelestialBody startingPosition)
 {
     this.overviewUI             = ui;
     this.courseInspector        = courseInspector;
     this.shooter                = shooter;
     this.currentGolfingPosition = startingPosition;
     this.normal = Vector3.up;
 }
Beispiel #6
0
    public virtual void Start()
    {
        mWeapons = GetComponents <Weapon> ();

        mShooter = ServiceLocator.GetService <IShooter>();
        mShooter.LevelChangedEvent += HandleLevelChangedEvent;
        mShooter.GameOverEvent     += HandleGameOverEvent;
    }
Beispiel #7
0
 public void OnKill(IShooter i_MyKiller)
 {
     (Game as GameWithScreens).SpriteSoundEffects["MotherShipKill"].Play();
     m_IsDying = true;
     Velocity  = new Vector2(0);
     m_Animations.Restart();
     i_MyKiller.OnHit(this);
 }
Beispiel #8
0
    void Start()
    {
        m_seeker          = GetComponent <Seeker>();
        m_controlledEnemy = GetComponent <Rigidbody2D>();
        m_shooter         = GetComponent <IShooter>();

        InvokeRepeating("UpdatePath", 0f, .5f);
    }
Beispiel #9
0
    void Start()
    {
        mPlayAgain = (UIButton)GetItem("BtnPlayAgain");

        mShooter = ServiceLocator.GetService <IShooter>();
        mShooter.GameOverEvent  += HandleGameOverEvent;
        mShooter.StartGameEvent += HandleStartGameEvent;
    }
Beispiel #10
0
    public void init(Color color, IShooter shooter, Vector3 direction)
    {
        this.shooter   = shooter;
        this.direction = direction;

        lifeTimer            = life;
        spriteRenderer.color = color;
    }
Beispiel #11
0
    void Start()
    {
        mBtnResume = (UIButton)GetItem("BtnResume");
        mBtnQuit   = (UIButton)GetItem("BtnQuit");

        mShooter = ServiceLocator.GetService <IShooter>();
        mShooter.PauseGameEvent += HandlePauseGameEvent;
    }
Beispiel #12
0
 public Gun(Game i_Game, IShooter i_Shooter, int i_MaxNumOfBullets, Vector2 i_BulletsVelocity, Color i_BulletsColor) : base(i_Game)
 {
     m_BulletsVelocity = i_BulletsVelocity;
     m_MaxNumOfBullets = i_MaxNumOfBullets;
     m_Shooter         = i_Shooter;
     m_BulletsColor    = i_BulletsColor;
     m_AliveBullets    = new LinkedList <Bullet>();
     m_NonActiveBullet = new LinkedList <Bullet>();
 }
Beispiel #13
0
 public override void OnClick(Selectable item)
 {
     if (item.name.Equals(mBtnStart.name))
     {
         IShooter shooter = ServiceLocator.GetService <IShooter>();
         shooter.StartGame();
         SetVisiblity(false);
     }
 }
Beispiel #14
0
    public CommandSequence(CommandSequenceData data, PlayerControllerInput playerController, IShooter controller)
    {
        this.data             = data;
        this.playerController = playerController;
        this.controller       = controller;

        //this.playerController.OnInputPressed += CheckPressedInput;
        this.controller.OnDestroy += UnsubscribeEvent;
    }
Beispiel #15
0
        private void addScore(int i_Score, IShooter i_Shooter)
        {
            PlayerSpaceship shooter = i_Shooter as PlayerSpaceship;

            if (shooter != null)
            {
                shooter.AddScore(i_Score);
            }
        }
Beispiel #16
0
    public void AlignWithTarget(IShooter target, Action OnAlignComplete)
    {
        Vector3 alignTo = new Vector3(target.GetPosition().x, GetPosition().y, GetPosition().z);

        StartAligning(alignTo, () => {
            OnAlignComplete();
            playerState = State.Idle;
        });
    }
Beispiel #17
0
 /// <summary>
 /// Applies damage tho itself.
 /// </summary>
 /// <param name="instigator"></param>
 public void ApplyDamage(IShooter instigator)
 {
     currentLifeText.text = life.ToString();
     life -= instigator.getDamage();
     if (life <= 0)
     {
         CheckDestruction();
     }
 }
Beispiel #18
0
 // Start is called before the first frame update
 void Start()
 {
     base.Start();
     playerParentTransform = GameObject.FindGameObjectWithTag("Player").transform.parent;
     transform.parent      = playerParentTransform;
     status           = Statuses.GettingClose;
     timer            = 0;
     distanceToPlayer = Vector2.Distance(transform.position, playerParentTransform.position);
     _shooter         = new RadialShooter(24, playerParentTransform.gameObject);
 }
Beispiel #19
0
 public void Shoot(float _speed, Vector3 _dir, int _damageAmount, IShooter _shooter, Vector3 _shootPosition)
 {
     hitSound.Init();
     speed                   = _speed;
     direction               = _dir;
     damageAmount            = _damageAmount;
     shooter                 = _shooter;
     this.transform.position = _shootPosition;
     this.transform.right    = _dir.normalized;
     this.gameObject.SetActive(true);
 }
Beispiel #20
0
        public Gun(IShooter i_Shooter, int i_MaxBulletsInScreen)
        {
            r_BulletsFired       = new HashSet <Bullet>();
            r_Shooter            = i_Shooter;
            r_MaxBulletsInScreen = i_MaxBulletsInScreen;

            r_BulletsFactory = r_Shooter.Game.Services.GetService <BulletsFactory>();
            if (r_BulletsFactory == null)
            {
                r_BulletsFactory = new BulletsFactory(r_Shooter.Game);
            }
        }
Beispiel #21
0
    public override void Awake()
    {
        base.Awake();

        steerable = GetComponent <SteerableBehaviour>();

        shooter = steerable as IShooter;
        if (shooter == null)
        {
            throw new MissingComponentException("Esse GameObject não implementa IShooter");
        }
    }
Beispiel #22
0
        private bool hitEnemyBullet(ICollidable i_CollidingObject)
        {
            bool hitBullet = false;

            if (i_CollidingObject is Bullet)
            {
                IShooter collidingBulletShooter = (i_CollidingObject as Bullet).Shooter;
                hitBullet = (collidingBulletShooter is PlayerSpaceship && Shooter is Enemy) || (collidingBulletShooter is Enemy && Shooter is PlayerSpaceship);
            }

            return(hitBullet);
        }
Beispiel #23
0
 public virtual void Shoot(Vector3 shootPosition, Vector3 direction, IShooter _shooter)
 {
     shooter            = _shooter;
     transform.position = shootPosition;
     state      = State.Shooted;
     returnTime = Time.time + _duration;
     OnPreShoot?.Invoke();
     OnShoot?.Invoke();
     if (vfx != null)
     {
         vfx.Play();
     }
 }
Beispiel #24
0
        public void Process_WeaponStraightShootingAction(IShooter shooter, int weaponDamagePower, List <IEnemy> allEnemies, List <System.Windows.Controls.Image> allShootingArrowImages, System.Drawing.Point newPoint)
        {
            var selectedStrikeStrategy = _strikeStrategyInvoker.GetStrikeStrategy(Enums.StrikeStrategiesEnum.Shoot);
            var shootingStrategy       = (IStraightShootStrikeStrategy)selectedStrikeStrategy.StrikeStrategyType;

            foreach (var arrowImage in allShootingArrowImages)
            {
                if (arrowImage.Visibility == System.Windows.Visibility.Visible)
                {
                    shootingStrategy.ShootStraightStrike(arrowImage, newPoint);
                }
                WeaponStrikeTarget(shooter, weaponDamagePower, arrowImage, allEnemies);
            }
        }
Beispiel #25
0
    void Start()
    {
        mItemLife  = (UIText)GetItem("LblLivesValue");
        mItemScore = (UIText)GetItem("LblScoreValue");
        mHighscore = (UIText)GetItem("LblHighscoreValue");
        mBtnPause  = (UIButton)GetItem("BtnPause");

        mShooter = ServiceLocator.GetService <IShooter>();
        mShooter.GameOverEvent         += HandleGameOverEvent;
        mShooter.StartGameEvent        += HandleStartGameEvent;
        mShooter.PauseGameEvent        += HandlePauseGameEvent;
        mShooter.LivesUpdatedEvent     += HandleLivesUpdatedEvent;
        mShooter.HighscoreUpdatedEvent += HandleHighscoreUpdatedEvent;
        mShooter.PointUpdatedEvent     += HandlePointUpdatedEvent;
    }
Beispiel #26
0
 public void WeaponStrikeTarget(IShooter shooter, int weaponDamagingPoints, System.Windows.Controls.Image weaponImage, List <IEnemy> allActiveEnemies)
 {
     foreach (var target in allActiveEnemies)
     {
         if (target.GetHealthPoints() > 0)
         {
             var weaponHitEnemy = _imageManager.ImagesCollisionDetected_Adaptor(weaponImage, target.EnemyImage);
             if (weaponHitEnemy)
             {
                 target.ReduceHealth(weaponDamagingPoints);
                 //hero increases total strike points
                 shooter.IncreasePointForStrikingTarget(weaponDamagingPoints);
             }
         }
     }
 }
Beispiel #27
0
    // Start is called before the first frame update
    void Start()
    {
        if (mThruster == null)
        {
            mThruster = GetComponent <IThruster>();
        }

        if (mTurner == null)
        {
            mTurner = GetComponent <ITurner>();
        }

        if (mShooter == null)
        {
            mShooter = GetComponent <IShooter>();
        }
    }
Beispiel #28
0
    public override void Awake()
    {
        base.Awake();

        Transition Patrulha = new Transition();

        Patrulha.condition = new ConditionDistGT(transform, GameObject.FindWithTag("Player").transform, 2.0f);
        Patrulha.target    = GetComponent <StatePatrulhaWaypoints>();
        transitions.Add(Patrulha);

        steerable = GetComponent <SteerableBehaviour>();
        shooter   = steerable as IShooter;
        if (shooter == null)
        {
            throw new MissingComponentException("Este GameObject não implementa IShooter");
        }
    }
Beispiel #29
0
    public override void Awake()
    {
        base.Awake();


        Transition ToPatrolState = new Transition();

        ToPatrolState.condition = new ConditionDistGT(transform, GameObject.FindWithTag("Player").transform, 5.0f);
        ToPatrolState.target    = GetComponent <PatrolState>();
        // Adicionamos a transição em nossa lista de transições
        transitions.Add(ToPatrolState);

        steerable = GetComponent <SteerableBehaviour>(); // acho que caguei kkkkk
        shooter   = steerable as IShooter;
        if (shooter == null)
        {
            throw new MissingComponentException("Este GameObject não implementa IShooter");
        }
    }
Beispiel #30
0
 public void Update(Time dt)
 {
     foreach (FloatRect rect in _tileMap.Collidables)
     {
         foreach (Entity entity in _entities)
         {
             Box   a = new Box(entity);
             Box   b = new Box(rect);
             float x;
             float y;
             if (Box.AABB(a, b, out x, out y))
             {
                 Vector2f pos = entity.Position;
                 pos.X          += x;
                 pos.Y          += y;
                 entity.Position = pos;
                 //if(y != 0)
                 //    Console.WriteLine("x:{0},y:{1}",x,y);
                 //todo: fix this shit.
                 if (y < 0)
                 {
                     entity.Velocity = new Vector2f(entity.Velocity.X, 0);
                     entity.Jumping  = false;
                 }
                 if (y > 0 && entity.Jumping)
                 {
                     entity.Velocity = entity.Jumping
                         ? new Vector2f(entity.Velocity.X, 0)
                         : new Vector2f(entity.Velocity.X, entity.Velocity.Y);
                 }
             }
             IShooter shooter = entity as IShooter;
             if (shooter != null)
             {
                 foreach (var proj in shooter.Projectiles.ProjectileList.Where(proj => Box.AABBCheck(new Box(proj), b)))
                 {
                     shooter.Projectiles.Explode(proj);
                 }
             }
         }
     }
 }
Beispiel #31
0
 public MouseAimer(MouseButton button, IShooter shooter)
 {
     _shooter = Add(shooter);
     Add(new MouseButtonBinding(button, Shoot, _shooter.Release));
 }