Пример #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        ;
        if (collision.gameObject.layer == LayerMask.NameToLayer("PlayerBullets"))
        {
            PlayerShot PS = collision.gameObject.GetComponent <PlayerShot>();
            Debug.Log(PS.FiredFrom + " " + PassThrough);

            if (PS != null && PS.FiredFrom != PassThrough)
            {
                Debug.Log("Blocked");
                Destroy(collision.gameObject);

                hitAudio.PlayOneShot(deflectClip, hitVolume * Random.Range(0.5f, 1.5f));
            }
            else
            {
                BossHealth BH = transform.GetComponentInParent <BossHealth>();
                if (BH)
                {
                    BH.TakeDamage();
                }
            }
        }
    }
        public void GameOn()
        {
            this.WelcomeMessage();
            while (true)
            {
                Console.WriteLine(this.inputMessage);
                string input = Console.ReadLine();
                bool areInputCoordinates = Validation.InstanceOfValidation.AreInputCoordinates(input);
                bool isInputCommand = Validation.InstanceOfValidation.IsInputCommand(input);
                if (areInputCoordinates == true)
                {
                    this.Shots++;
                    PlayerShot playerShot = new PlayerShot();
                    PlayerShot.InstanceOfPlayerShot.ConvertInputToCoordinates(input, ref playerShot);
                    Grid.InstanceOfGrid.UpdateGrid(playerShot);
                }
                else if (isInputCommand == true)
                {
                    switch (input)
                    {
                        case "show":
                            this.instanceOfCommand.Show();
                            break;

                        case "exit":
                            this.instanceOfCommand.Exit();
                            break;

                        default:
                            break;
                    }
                }
            }
        }
Пример #3
0
        public void GameOn()
        {
            this.WelcomeMessage();
            while (true)
            {
                Console.WriteLine(this.inputMessage);
                string input = Console.ReadLine();
                bool   areInputCoordinates = Validation.InstanceOfValidation.AreInputCoordinates(input);
                bool   isInputCommand      = Validation.InstanceOfValidation.IsInputCommand(input);
                if (areInputCoordinates == true)
                {
                    this.Shots++;
                    PlayerShot playerShot = new PlayerShot();
                    PlayerShot.InstanceOfPlayerShot.ConvertInputToCoordinates(input, ref playerShot);
                    Grid.InstanceOfGrid.UpdateGrid(playerShot);
                }
                else if (isInputCommand == true)
                {
                    switch (input)
                    {
                    case "show":
                        this.instanceOfCommand.Show();
                        break;

                    case "exit":
                        this.instanceOfCommand.Exit();
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #4
0
    void Awake()
    {
        v            = 0.0f;
        h            = 0.0f;
        forwardSpeed = 0.0f;
        tr           = GetComponent <Transform>();
        rg           = GetComponent <Rigidbody>();

        anim = transform.Find("FighterInterceptor").GetComponent <Animator>();

        Booster_1      = transform.Find("FighterInterceptor").transform.Find("Booster_1").GetComponent <ParticleSystem>();
        Booster_2      = transform.Find("FighterInterceptor").transform.Find("Booster_2").GetComponent <ParticleSystem>();
        Speed_Particle = transform.Find("BoosterParticle").GetComponent <ParticleSystem>();

        Shot           = transform.Find("FighterInterceptor").transform.Find("Fire_Effect").GetComponent <ParticleSystem>();
        Controller_Tr  = transform.Find("[CameraRig]").transform.GetChild(0).transform.GetChild(1).GetComponent <Transform>();
        Controller_Tr2 = transform.Find("[CameraRig]").transform.GetChild(1).transform.GetChild(1).GetComponent <Transform>();

        check_tr_1 = check_ctrl_left.GetComponent <Transform>();
        check_tr_2 = check_ctrl_right.GetComponent <Transform>();

        playerShot   = GetComponent <PlayerShot>();
        playerHealth = GetComponent <PlayerHealth>();

        // xPort = Sym.Sym4D_X_Find();
        // wPort = Sym.Sym4D_W_Find();

        myAudio = GetComponent <AudioSource>();

        if (photonView.IsMine)
        {
            followCam        = Camera.main.GetComponent <FollowCam>();
            followCam.target = tr;
        }
    }
Пример #5
0
    private void Start()
    {
        curPlayerHealth = 25.0f;

        tr             = GetComponent <Transform>();
        PlayerMove     = GetComponent <PlayerMove>();
        needRescue     = transform.Find("FighterInterceptor").transform.Find("Fuselage").GetComponent <MeshRenderer>();
        smoke          = transform.Find("DestroySmoke").GetComponent <ParticleSystem>();
        repairParticle = transform.Find("RepairParticle").GetComponent <ParticleSystem>();
        fireEffect     = transform.Find("FighterInterceptor").transform.Find("Fire_Effect").GetComponent <ParticleSystem>();
        shotPos        = transform.Find("ShotPos").gameObject;

        gameoverPanel = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas").transform.Find("GameOver").gameObject;


        hp_1 = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").transform.Find("HP_Panel").transform.Find("HP_1").gameObject;
        hp_2 = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").transform.Find("HP_Panel").transform.Find("HP_2").gameObject;
        hp_3 = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").transform.Find("HP_Panel").transform.Find("HP_3").gameObject;
        hp_4 = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").transform.Find("HP_Panel").transform.Find("HP_4").gameObject;
        hp_5 = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").transform.Find("HP_Panel").transform.Find("HP_5").gameObject;

        damageImage = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas").transform.Find("Damaged").gameObject;
        hpBar       = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("Canvas_UI").gameObject;
        laser       = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("[CameraRig]").gameObject;

        myaudio     = GetComponent <AudioSource>();
        boss_Health = GameObject.Find("Boss_position").transform.Find("BOSS").GetComponent <Boss_Health>();
        clearCanv   = GameObject.Find("CameraRig").transform.Find("Camera").transform.Find("ClearCanvas").gameObject;
        playerShot  = GetComponent <PlayerShot>();
    }
Пример #6
0
        private void UpdatePlayerShots(GameTime gameTime)
        {
            // if we are allowed to fire, add a shot to the list
            if (_player != null && InputManager.ControlState.Fire && gameTime.TotalGameTime.TotalMilliseconds - _lastTime > 500)
            {
                // create a new shot over the ship
                PlayerShot ps = new PlayerShot();
                ps.Position = new Vector2((_player.Position.X + _player.Width / 2.0f) - ps.Width / 2.0f, _player.Position.Y - ps.Height);
                _playerShots.Add(ps);
                _lastTime = gameTime.TotalGameTime.TotalMilliseconds;
                AudioManager.PlayCue(AudioManager.Cue.PlayerShot);
            }

            // enumerate the player shots on the screen
            for (int i = 0; i < _playerShots.Count; i++)
            {
                PlayerShot playerShot = _playerShots[i];

                playerShot.Update(gameTime);

                // if it's off the top of the screen, remove it from the list
                if (playerShot.Position.Y + playerShot.Height < 0)
                {
                    _playerShots.RemoveAt(i);
                }
            }
        }
 void GetAndSetCompoents()
 {
     _collider = GetComponent <QuadtreeCollider>();
     _life     = GetComponent <Life>();
     _shot     = GetComponent <PlayerShot>();
     _move     = GetComponent <DragMove>();
 }
Пример #8
0
        private void AddPlayerShot()
        {
            // create a new shot over the ship
            PlayerShot ps = new PlayerShot();

            ps.Position = _player.Position + (_player.Size / 2) - (ps.Size / 2) - new Vector2(0, ps.Height);
            _playerShots.Add(ps);
        }
Пример #9
0
 /// <summary>
 /// 球の生成
 /// </summary>
 /// <param name="go">生成する球のプレハブ</param>
 /// <param name="shotMoveDir">球の移動方向</param>
 void CreateShot(PlayerShot go, Vector3 shotMoveDir)
 {
     playerShot  = Instantiate(go);
     freezeExist = true;
     playerShot.transform.position = shotCenterPos + transform.position + (shotMoveDir * shotPos);
     playerShot.moves = shotMoveDir;
     SEMaster.Play(shotSound);
 }
Пример #10
0
    //Main switcher
    public void TakeShot(string address)
    {
        ShowShotBoard();
        PlayerShot currentShot = new PlayerShot(address);

        currentPlayer.game.shots.Add(currentShot);
        DisplayShot(currentShot);
    }
Пример #11
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="pShot"></param>
    public void DestroyShot(PlayerShot pShot)
    {
        GameObject.Destroy(pShot.gameObject);

        if (mShots.Contains(pShot))
        {
            mShots.Remove(pShot);
        }
    }
Пример #12
0
 void Shoot()
 {
     if (Input.GetMouseButtonDown(0) && pt.getAmmo() > 0)
     {
         pt.takeAmmo();
         PlayerShot s = Instantiate(shot, transform.GetChild(0).position, Quaternion.identity).GetComponent <PlayerShot>();
         s.setSpeed(shotSpeed);
     }
 }
Пример #13
0
        public void AddShot()
        {
            PlayerShot shot = new PlayerShot(
                new DynamicShape(
                    player.GetCannonPoint(),
                    new Vec2F(0.008F, 0.027F)));

            playerShots.AddDynamicEntity(shot);
        }
Пример #14
0
    public static PlayerShot Add(string tag_name, float x, float y, float z)
    {
        // Enemyインスタンスの取得
        PlayerShot ps = parent.Add(x, y, z);

        ps.SetTagName(tag_name);

        return(ps);
    }
Пример #15
0
    public void Run()
    {
        const int      NUM_ENEMIES = 4;
        ConsoleKeyInfo userkey;

        Spaceship        ship = new Spaceship();
        MovingBackground back = new MovingBackground();
        Scoreboard       sb   = new Scoreboard();

        Enemy[] enemies = new Enemy[NUM_ENEMIES];
        enemies[0] = new EnemyLevel1();
        enemies[1] = new EnemyLevel2();
        enemies[2] = new EnemyLevel3();
        enemies[3] = new EnemyLevel4();
        Mothership ms    = new Mothership();
        PlayerShot shot1 = new PlayerShot(20, 10);
        EnemyShot  shot2 = new EnemyShot(15, 1);

        while (true)
        {
            // Update elements position and appearance
            back.Update();
            ms.Update();
            ship.Update();
            foreach (Enemy e in enemies)
            {
                e.Update();
            }
            shot1.Update();
            shot2.Update();

            // Screen update
            Console.Clear();
            back.Draw();
            sb.Draw();
            ms.Draw();
            ship.Draw();
            foreach (Enemy e in enemies)
            {
                e.Draw();
            }
            shot1.Draw();
            shot2.Draw();

            // Get user input
            userkey = Console.ReadKey(true);
            switch (userkey.Key)
            {
            case ConsoleKey.A: ship.MoveLeft(); break;

            case ConsoleKey.D: ship.MoveRight(); break;

            case ConsoleKey.Escape: return;
            }
        }
    }
Пример #16
0
 private void IncrementStatPlayerDestroyEnemy(PlayerShot playerShot, int value)
 {
     enemiesKilled++;
     enemyKillScore += value;
     //Debug.Log(playerShot.FiredFrom.ToString() + " scored a kill");
     overallScore += value;
     ShowOverallScore();
     StartEnemiesKilledSlider();
     CalculateRating();
 }
Пример #17
0
    void OnCollisionEnter2D(Collision2D collision2d)
    {
        PlayerShot playerShot = collision2d.rigidbody.GetComponent <PlayerShot>();

        if (playerShot)
        {
            playerShot.HandleCollisionWithEnemy(this);
            this.SustainDamage(playerShot.damage);
        }
    }
Пример #18
0
    private void DisplayShot(PlayerShot shot)
    {
        Transform tilePos;

        if ((tilePos = currentBoard.transform.Find(shot.coords)) != null)
        {
            Debug.Log("Shot -" + tilePos);
            Peg curPeg = Instantiate(pegObject, Vector3.zero, Quaternion.identity) as Peg;
            curPeg.transform.position = tilePos.position;
        }
    }
Пример #19
0
    // Update is called once per frame
    void Update()
    {
        timeUntilShot -= Time.fixedDeltaTime;
        if (timeUntilShot <= 0)
        {
            PlayerShot newshot = Instantiate(shotType, transform.position, transform.rotation);

            shotType.transform.parent = null;
            timeUntilShot             = shotInterval;
        }
    }
Пример #20
0
    public void shot()
    {
        PlayerShot shot = new PlayerShot(
            new DynamicShape(new Vec2F(Entity.Shape.Position.X +
                                       Entity.Shape.Extent.X / 2,
                                       Entity.Shape.Position.Y +
                                       Entity.Shape.Extent.Y - 0.01f),
                             new Vec2F(0.008f, 0.027f)),
            new Image(Path.Combine("Assets", "Images", "BulletRed2.png")));

        Game.PlayerShots.Add(shot);
    }
Пример #21
0
    /// <summary> Called when a shot hit something </summary>
    /// <param name="_shot"> Shot's script </param>
    public void ShotHit(PlayerShot _shot, GameObject _objHit)
    {
        shotPFXPool.RetrieveOrCreate(shotHitPFXPrefab).transform.position = _shot.transform.position;
        shotsPool.Recycle(_shot.gameObject);

        Enemy enemy = _objHit.GetComponentInParent <Enemy>();

        if (enemy != null)
        {
            enemy.OnShot();
        }
    }
Пример #22
0
    void shoot()
    {
        int xdir = dirs[0];
        int ydir = dirs[1];

        if (xdir == 0 && ydir == 0 && !abilities[2])
        {
            xdir = faceDir ? 1 : -1;
        }
        PlayerShot newBullet = Instantiate(bullet, new Vector3(this.transform.position.x + (xdir * xBulletOffset), this.transform.position.y + (ydir * yBulletOffset), this.transform.position.z), Quaternion.identity);

        newBullet.setDirs(xdir, ydir);
    }
Пример #23
0
    /// <summary>
    ///
    /// </summary>
    private void SpawnShot()
    {
        float         offsetX = mLookDir.LookLeft ? -0.5f : 0.5f;
        float         offsetY = (this.State == ePlayerState.Crouch) ? 0.75f : 1.6f;
        Vector3       offset  = new Vector3(offsetX, offsetY, 0);
        GameObject    newObj  = GameObject.Instantiate(this.PrefabShot, this.transform.position + offset, Quaternion.identity);
        LookDirection dir     = newObj.GetComponent <LookDirection>();

        dir.LookLeft = this.mLookDir.LookLeft;
        PlayerShot pShot = newObj.GetComponent <PlayerShot>();

        pShot.ShotType = this.CurrentWeapon;
        mShots.Add(pShot);
    }
Пример #24
0
 public void FirePlayerShot()
 {
     if (levelActive && playerShotPool != null && Time.time - lastFireTime >= fireRate)
     {
         lastFireTime = Time.time;
         Transform  pstrans = playerShotPool.Spawn();
         PlayerShot ps      = pstrans.GetComponent <PlayerShot>();
         ps.PlayerShotStart(this);
         pstrans.position     = PositionOnCircle(playerShip.selfTransform.position, playerInput.pathRingTransform.position, shipDistance - ps.spawnShipGap);
         ps.moving            = true;
         ps.movementSpeed     = playerShotSpeed;
         ps.movementDirection = ((Vector2)(playerInput.pathRingTransform.position - pstrans.position)).normalized;
     }
 }
    // Fires a shot if the cooldown from the previous shot has ended.
    public void Fire()
    {
        if (this.cooldownEndTime > Time.time)
        {
            // Cooldown ends in the future. Do nothing.
            return;
        }

        // Fire shot.
        PlayerShot shot = Instantiate <PlayerShot>(this.shotPrefab, this.transform.position, Quaternion.identity);

        shot.angle           = this.shotAngleDeg * Mathf.Deg2Rad;
        this.cooldownEndTime = Time.time + this.cooldown;
    }
Пример #26
0
        // true if player is on turn
        public bool ExecutePlayerShot(PlayerShot shot, string userID)
        {
            GamePlayer player = this.players.Where(player => player.User.ID == userID).FirstOrDefault();

            if (player == null)
            {
                return(false);
            }

            if (!player.PlayerTurn)
            {
                return(false);
            }

            return(this.Shot(shot, player));
        }
Пример #27
0
        internal bool Use(Player player, Transform transform, ProjectileShotDirection direction, out RecordableAction resultingAction)
        {
            if (Uses > 0)
            {
                PlayerShot shot = new PlayerShot(PowerupType, player, transform.Pos.Xy, direction);
                shot.Do();

                resultingAction = shot;

                Uses--;
                return(true);
            }

            resultingAction = null;
            return(false);
        }
Пример #28
0
    private void OnEnable()
    {
        _player        = GetComponent <PlayerProperty>();
        _playerShotter = GetComponent <PlayerShot>();
        _rig2D         = GetComponent <Rigidbody2D>();

        _trigger = new GameObject("Aim Detecter").AddComponent <CircleCollider2D>();
        _trigger.transform.parent   = transform;
        _trigger.transform.position = transform.position;
        _trigger.radius             = _player.DetectRadius;
        _trigger.gameObject.layer   = LayerMask.NameToLayer("Background");
        _trigger.isTrigger          = true;
        _detecter = _trigger.gameObject.AddComponent <Detecter>();

        _playerShotter.enabled = false;
    }
Пример #29
0
        private void UpdatePlayerShots(GameTime gameTime)
        {
            // enumerate the player shots on the screen
            for (int i = 0; i < _playerShots.Count; i++)
            {
                PlayerShot playerShot = _playerShots[i];

                playerShot.Update(gameTime);

                // if it's off the top of the screen, remove it from the list
                if (playerShot.Position.Y + playerShot.Height < 0)
                {
                    _playerShots.RemoveAt(i);
                }
            }
        }
Пример #30
0
    void Shoot()
    {
        // GameObject bulletPrefab = AssetDatabase.LoadAssetAtPath("Assets/Models/Megaman/Bullet.prefab", typeof(GameObject)) as GameObject;
        PlayerShot bullet = bulletPrefab.GetComponent <PlayerShot>();

        bullet.chargeLevel = chargeLevel;
        bullet.direction   = Mathf.Sign(spriteBody.localScale.x);
        gunLocation.x      = Mathf.Sign(spriteBody.localScale.x) * Mathf.Abs(gunLocation.x);
        if (animator.GetBool("isWallSliding"))
        {
            gunLocation.x    *= -1;
            bullet.direction *= -1;
        }
        bulletPrefab.transform.localScale = new Vector3(Mathf.Sign(gunLocation.x), 1, 1);

        Instantiate(bulletPrefab, gunLocation + transform.position, Quaternion.identity);
    }
Пример #31
0
        private void HandleCollisions(GameTime gameTime)
        {
            // see if a player shot hit an enemy
            for (int i = 0; i < _playerShots.Count; i++)
            {
                PlayerShot playerShot = _playerShots[i];
                // check the shot and see if it it collided with an enemy
                if (playerShot != null && _enemyGroup.HandlePlayerShotCollision(_playerShots[i]))
                {
                    // remove the shot, add the score
                    _playerShots.RemoveAt(i);
                    _score += 100;
                    _explosion.Play();
                }
            }

            // see if an enemy shot hit the player
            if (_player != null && _enemyGroup.HandleEnemyShotCollision(_player))
            {
                // blow up the player
                _playerExplosion = new Explosion();
                Vector2 center = _player.Position + (_player.Size / 2.0f);
                _playerExplosion.Position = center - (_playerExplosion.Size / 2.0f);
                _player = null;
                _explosion.Play();
            }

            // if the player explosion animation is running, update it
            if (_playerExplosion != null)
            {
                // if this is the last frame
                if (_playerExplosion.Update(gameTime))
                {
                    // remove it
                    _playerExplosion = null;

                    // reset the board
                    _enemyGroup.Reset();
                    _playerShots.Clear();

                    _player          = new Player();
                    _player.Position = PlayerStartPosition;
                }
            }
        }