Beispiel #1
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (live)
        {
            if (collider.CompareTag("PlayerBase"))
            {
                PlayerBase playerBase = collider.gameObject.GetComponent <PlayerBase>();
                playerBase.Die();
            }
            else if (collider.CompareTag("PlayerMissile"))
            {
                PlayerMissile p_missile = collider.gameObject.GetComponent <PlayerMissile>();
                // The player missile's collision function will handle its own death
            }
            else if (collider.CompareTag("Boundary"))
            {
                Destroy(gameObject);
            }
            else if (collider.CompareTag("BaseShield"))
            {
                Destroy(collider.gameObject);
            }
            live = false;
            gameObject.GetComponent <Renderer>().material.color = new Color(0, 0, 0.2f);
        }
    }
Beispiel #2
0
        public static void Main()
        {
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);

            var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(8);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall  = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X  = LeftJoystick.X / 128;
                leftBall.Y  = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("X=" + LeftJoystick.X.ToString() + " (" + LeftJoystick.XDirection.ToString() + ")" + ", Y=" + LeftJoystick.Y.ToString() + " (" + LeftJoystick.YDirection.ToString() + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }
Beispiel #3
0
    public PlayerMissile Create(Transform pool, EnemySwarm enemySwarm)
    {
        PlayerMissile missile = Create <PlayerMissile>(pool);

        missile._enemySwarm = enemySwarm;
        return(missile);
    }
Beispiel #4
0
 public Paddle(Side side, GameOfPong game)
 {
     _side   = side;
     _game   = game;
     _world  = game.World;
     _ball   = _world["ball"];
     _pixels = new PlayerMissile[Size];
     for (var i = 0; i < Size; i++)
     {
         _pixels[i] = new PlayerMissile(
             "paddle" +
             (_side == Side.Right ? 'R' : 'L') +
             i,
             _side == Side.Right ? 7 : 0,
             i,
             _world);
     }
     _world.Coinc +=
         (s, a) => {
         if (_ball.X == 0 && _side == Side.Left)
         {
             _game.BallGoingRight = true;
         }
         if (_ball.X == 7 && _side == Side.Right)
         {
             _game.BallGoingRight = false;
         }
     };
 }
            public override IPoolable GetNew()
            {
                PlayerMissile bullet = new PlayerMissile(_poolName, _activationD, _turningD, _angle, _spdActivate, _spdTurn, _isX, _pattern, EntityType.BULLET_PLR, _sprt, _order, _anim, 1.0f, Vector2.zero);

                bullet.Create(this);
                return(bullet);
            }
Beispiel #6
0
        public Meteor(GameOfMeteors game, int index, int x, int y)
        {
            _rnd = new Random();
            var speed = GetRandomSpeed();
            var j     = 0;
            var skip  = _rnd.Next(4);

            for (var i = 0; i < 4; i++)
            {
                if (i == skip)
                {
                    continue;
                }
                _rockXOffsets[j] = _rockOffsets[i * 2];
                _rockYOffsets[j] = _rockOffsets[i * 2 + 1];
                _rocks[j]        = new PlayerMissile {
                    Name            = "Meteor" + index + ":" + j,
                    X               = x + _rockXOffsets[j],
                    Y               = y + _rockYOffsets[j],
                    HorizontalSpeed = speed.X,
                    VerticalSpeed   = speed.Y,
                    Owner           = game.World
                };
                j++;
            }
        }
    private void Awake()
    {
        _PlayerableCharacter = GetComponent <PlayerableCharacter>();

        // 미사일 오브젝트 프리팹 로드
        _PlayerMissilePrefab = ResourceManager.Instance.LoadResource <GameObject>(
            "PlayerMissilePrefab",
            "Prefabs/Projectile/PlayerMissile").GetComponent <PlayerMissile>();
    }
Beispiel #8
0
 public GameOfPong(ConsoleHardwareConfig config) : base(config)
 {
     World          = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize);
     Ball           = new PlayerMissile("ball", 0, 0, World);
     LeftPaddle     = new Paddle(Side.Left, this);
     RightPaddle    = new Paddle(Side.Right, this);
     BallGoingRight = true;
     ResetBall();
 }
Beispiel #9
0
    public void Shoot(Vector3 pos)
    {
        PlayerMissile pm = Instantiate(playerMissilePrefab, missileShootPos.position, Quaternion.identity).GetComponent <PlayerMissile>();

        pm.Shoot(pos);
        SetArmed(false);
        Delayed.Action(gameObject, () => {
            SetArmed(true);
        }, reloadTime);
    }
Beispiel #10
0
 private Meteor GetOwner(PlayerMissile rock)
 {
     foreach (var meteor in Meteors)
     {
         if (meteor.Has(rock))
         {
             return(meteor);
         }
     }
     return(null);
 }
Beispiel #11
0
 public bool Has(PlayerMissile someRock)
 {
     foreach (var rock in _rocks)
     {
         if (rock == someRock && rock.IsVisible)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #12
0
    private void Awake()
    {
        _PlayerableCharacter = GetComponent <PlayerableCharacter>();

        // 미사일 오브젝트 프리팹 로드
        _PlayerMissilePrefab = ResourceManager.Instance.LoadResource <GameObject>(
            "PlayerMissile",
            "Prefabs/Missile/PlayerMissile").GetComponent <PlayerMissile>();

        // 미사일 발사 시 재생될 소리 로드
        _MissileFireAudioClip = ResourceManager.Instance.LoadResource <AudioClip>(
            "Player_Missile_Fire",
            "Sound/Player_Missile_Fire");
    }
Beispiel #13
0
 public Meteor(GameOfMeteors game, int index)
 {
     Owner = game;
     Index = index;
     for (var i = 0; i < 3; i++)
     {
         _rocks[i] = new PlayerMissile {
             Name      = "Meteor" + index + ":" + i,
             IsVisible = false,
             Owner     = game.World,
             IsEnemy   = true
         };
     }
 }
 protected override void SpawnMissiles()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Vector3       touchTargetBaseOnScreen = m_targetCamera.ScreenToWorldPoint(Input.mousePosition);
         Vector3       targetPos = new Vector3(touchTargetBaseOnScreen.x, touchTargetBaseOnScreen.y, 0f);
         GameObject    missile   = m_pooler.GetClone();
         Transform     startingMissilePosition = m_shooter.transform.GetChild(1);
         PlayerMissile pMissile = missile.GetComponent <PlayerMissile>();
         missile.transform.position = startingMissilePosition.position;
         pMissile.ReadyMissile(this, targetPos);
         missile.SetActive(true);
         m_releaseInterval = m_releaseHolder;
     }
 }
Beispiel #15
0
        protected override void OnGameStart()
        {
            base.OnGameStart();

            _ship = new PlayerMissile()
            {
                Name          = "ship",
                IsEnemy       = false,
                X             = 3,
                IsVisible     = true,
                VerticalSpeed = 0,
            };

            ScrollMessage(" 6T4Racer!");
        }
Beispiel #16
0
 public void LaunchMissile(double time)
 {
     foreach (ShootPlayerNode n in listNode)
     {
         n.ShootComponent.TimeSinceLastShoot += time;
         //Console.WriteLine("Time since last shoot: "+ n.ShootComponent.TimeSinceLastShoot);
         //Console.WriteLine("Fire rate: " + n.ShootComponent.FireRate);
         if (!Engine.instance.EntitiesList.OfType <PlayerMissile>().Any())
         {
             n.ShootComponent.TimeSinceLastShoot = 0;
             Vecteur2D     posMissile = n.PlayerPosition.Position + new Vecteur2D(15, -15);
             PlayerMissile missile    = new PlayerMissile(posMissile);
             Engine.instance.AddEntity(missile);
         }
     }
 }
Beispiel #17
0
 bool WorldCoinc(object sender, PlayerMissile missile1, PlayerMissile missile2)
 {
     if (missile1 == Pruneau || missile2 == Pruneau)
     {
         // Explode rock or meteor
         var rock   = missile1 == Pruneau ? missile2 : missile1;
         var meteor = GetOwner(rock);
         // Does this rock belong to a meteor?
         if (meteor != null)
         {
             if (meteor.IsExploded)
             {
                 rock.IsVisible = false;
                 RemainingRocks--;
                 if (RemainingRocks == 0)
                 {
                     Hardware.Matrix.Display(SmallChars.ToBitmap(-1, NumberOfMeteors));
                     Thread.Sleep(1000);
                     NumberOfMeteors++;
                     if (NumberOfMeteors >= WinningNumberOfMeteors)
                     {
                         Stop();
                     }
                     else
                     {
                         SpawnMeteors();
                         Pruneau.IsVisible = false;
                         return(true);
                     }
                 }
             }
             else
             {
                 meteor.Explode();
                 MakeExplosionSound();
             }
             Pruneau.IsVisible = false;
             return(false);
         }
     }
     else if (missile1 == Ship || missile2 == Ship)
     {
         MakeExplosionSound();
         Stop();
     }
     return(false);
 }
Beispiel #18
0
        public static void Main()
        {
            using (var matrix = new Max72197221(chipSelect: Pins.GPIO_PIN_D8, speedKHz: 10000)) {
                matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
                matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
                matrix.SetDigitScanLimit(7);
                matrix.SetIntensity(8);

                var comp = new Composition(new byte[]  {
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x03, 0xC0,
                    0x07, 0xE0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x0F, 0xF0,
                    0x07, 0xE0,
                    0x03, 0xC0,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                    0x00, 0x00,
                }, 16, 16);

                var player  = new PlayerMissile("player", 0, 0);
                var missile = new PlayerMissile("missile", 0, 0);
                comp.AddMissile(player);
                comp.AddMissile(missile);

                while (true)
                {
                    for (var angle = 0; angle < 360; angle++)
                    {
                        player.X  = 8 + Math.Sin(angle * 2) / 160;
                        player.Y  = 8 + Math.Cos(angle * 2) / 160;
                        missile.X = 8 + Math.Sin(angle) / 160;
                        missile.Y = 8 + Math.Cos(angle) / 160;
                        var frame = comp.GetFrame(Math.Sin(angle * 20) / 250 + 4, Math.Cos(angle * 20) / 250 + 4);
                        matrix.Display(frame);
                        Thread.Sleep(25);
                    }
                }
            }
        }
Beispiel #19
0
        public Paddle(Side side, GameOfPaddles game)
        {
            _side = side;
            var world = game.World;

            _pixels = new PlayerMissile[Size];
            for (var i = 0; i < Size; i++)
            {
                _pixels[i] = new PlayerMissile(
                    "paddle" +
                    (_side == Side.Right ? 'R' : 'L') +
                    i,
                    _side == Side.Right ? 7 : 0,
                    i,
                    world);
            }
        }
        public GameOfPaddles(ConsoleHardwareConfig config) : base(config)
        {
            Hardware.LeftButton.Input.DisableInterrupt();
            Hardware.RightButton.Input.DisableInterrupt();
            Hardware.LeftButton.Input.OnInterrupt  += OnLeftButtonClick;
            Hardware.RightButton.Input.OnInterrupt += OnRightButtonClick;
            Hardware.LeftButton.Input.EnableInterrupt();
            Hardware.RightButton.Input.EnableInterrupt();

            DisplaySplashScreen();

            World       = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize);
            Ball        = new PlayerMissile("ball", 0, 0, World);
            LeftPaddle  = new Paddle(Side.Left, this);
            RightPaddle = new Paddle(Side.Right, this);

            ResetBall(true);
        }
Beispiel #21
0
        public GameOfPaddles(ConsoleHardwareConfig config) : base(config)
        {
            World = new Composition(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, ScreenSize, ScreenSize);
            Ball  = new PlayerMissile {
                Name    = "ball",
                Owner   = World,
                IsEnemy = true
            };
            LeftPaddle  = new Paddle(Side.Left, this);
            RightPaddle = new Paddle(Side.Right, this);

            World.Coinc +=
                (s, a, b) => {
                Ball.HorizontalSpeed = -Ball.HorizontalSpeed;
                return(false);
            };

            ResetBall(true);
        }
 public static void ApplyToreGeometry(PlayerMissile missile)
 {
     if (missile.ExactX < 0)
     {
         missile.ExactX += WorldSize;
     }
     if (missile.ExactY < 0)
     {
         missile.ExactY += WorldSize;
     }
     if (missile.ExactX >= WorldSize)
     {
         missile.ExactX -= WorldSize;
     }
     if (missile.ExactY >= WorldSize)
     {
         missile.ExactY -= WorldSize;
     }
 }
Beispiel #23
0
        public static void Main()
        {
#if NETDUINO || NETDUINO_PLUS
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_A0, Pins.GPIO_PIN_A1);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_A2, Pins.GPIO_PIN_A3);
            var matrix        = new Max72197221(chipSelect: Pins.GPIO_PIN_D8);
#endif
#if NETDUINO_MINI
            var LeftJoystick  = new AnalogJoystick(Pins.GPIO_PIN_5, Pins.GPIO_PIN_6, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var RightJoystick = new AnalogJoystick(Pins.GPIO_PIN_7, Pins.GPIO_PIN_8, minYRange: 1023, maxYRange: 0, centerDeadZoneRadius: 30);
            var matrix        = new Max72197221(chipSelect: Pins.GPIO_PIN_17);
#endif

            matrix.Shutdown(Max72197221.ShutdownRegister.NormalOperation);
            matrix.SetDecodeMode(Max72197221.DecodeModeRegister.NoDecodeMode);
            matrix.SetDigitScanLimit(7);
            matrix.SetIntensity(4);

            var comp = new Composition(new byte[8], 8, 8);

            var leftBall  = new PlayerMissile("leftBall", 0, 0);
            var rightBall = new PlayerMissile("rightBall", 0, 0);

            comp.AddMissile(leftBall);
            comp.AddMissile(rightBall);

            while (true)
            {
                leftBall.X  = LeftJoystick.X / 128;
                leftBall.Y  = LeftJoystick.Y / 128;
                rightBall.X = RightJoystick.X / 128;
                rightBall.Y = RightJoystick.Y / 128;

                Debug.Print("LEFT: (X=" + LeftJoystick.X + " (" + LeftJoystick.XDirection + ")" + ", Y=" + LeftJoystick.Y + " (" + LeftJoystick.YDirection + "), RIGHT: (X=" + RightJoystick.X + " (" + RightJoystick.XDirection + ")" + ", Y=" + RightJoystick.Y + " (" + RightJoystick.YDirection + ")");

                matrix.Display(comp.GetFrame(0, 0));

                Thread.Sleep(80);
            }
        }
Beispiel #24
0
 public GameOfMeteors(ConsoleHardwareConfig config) : base(config) {
     World = new Composition(new byte[WorldSize * WorldSize / 8], WorldSize, WorldSize);
     World.Coinc += WorldCoinc;
     Ship = new PlayerMissile {
         Name = "Ship",
         Owner = World,
         X = WorldSize/2,
         Y = WorldSize/2
     };
     Pruneau = new PlayerMissile {
         Name = "Pruneau",
         Owner = World,
         IsVisible = false
     };
     Meteors = new Meteor[WinningNumberOfMeteors];
     for (var i = 0; i < Meteors.Length; i++) {
         Meteors[i] = new Meteor(this, i);
     }
     NumberOfMeteors = StartingNumberOfMeteors;
     SpawnMeteors();
     DisplayDelay = 0;
 }
 public GameOfMeteors(ConsoleHardwareConfig config)
     : base(config)
 {
     World        = new Composition(new byte[WorldSize * WorldSize / 8], WorldSize, WorldSize);
     World.Coinc += WorldCoinc;
     Ship         = new PlayerMissile("ship", WorldSize / 2, WorldSize / 2, World);
     Ship.X       = WorldSize / 2;
     Ship.Y       = WorldSize / 2;
     Pruneau      = new PlayerMissile {
         Name      = "Pruneau",
         Owner     = World,
         IsVisible = false
     };
     Meteors = new Meteor[NumberOfMeteors];
     for (var i = 0; i < NumberOfMeteors; i++)
     {
         Meteors[i] = new Meteor(this, i,
                                 new[] { 0, WorldSize - 2, 0, WorldSize - 2 }[i],
                                 new[] { 0, 0, WorldSize - 2, WorldSize - 2 }[i]);
     }
     DisplayDelay = 0;
 }
    void Fire()
    {
        if (IsFireable() && GameInput.GetMissle(pCode))
        {
            if (missileFireSFX != null && sfx != null && lockedEnemies.Count > 0)
            {
                sfx.PlayOneShot(missileFireSFX);
            }

            foreach (GameObject target in lockedEnemies)
            {
                GameObject         missile = Instantiate(missilePrefab, this.transform);
                PlayerMissile      pm      = missile.transform.GetComponent <PlayerMissile>();
                ProjectileWhoShoot who     = missile.transform.GetComponent <ProjectileWhoShoot>();

                pm.SetTarget(target);
                who.who = transform.gameObject;
                missile.transform.SetParent(null);
            }

            lockedEnemies.Clear();
        }
    }
Beispiel #27
0
 // Start is called before the first frame update
 void Start()
 {
     missileCommnandScript = MissileCommand.GetComponent <MissileCommand>();
     playerMissileScript   = playerMissile.GetComponent <PlayerMissile>();
     NewLevel();
 }
    Animator animator;     // Stores the animator component

    // Set the instance to this missile
    void Awake()
    {
        Instance = this;
    }
Beispiel #29
0
 private Meteor GetOwner(PlayerMissile rock) {
     foreach (var meteor in Meteors) {
         if (meteor.Has(rock)) return meteor;
     }
     return null;
 }
Beispiel #30
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        if (timer >= fireRate && fired)
        {
            fired = false;
        }
        if (!fired)
        {
            timer = 0;
        }
        bool touchMoveLeft  = false;
        bool touchMoveRight = false;
        bool touchFire      = false;

        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
            {
                Vector2 touchPos = touch.position;
                Camera  cam      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
                Vector2 camDims  = new Vector2(cam.pixelWidth, cam.pixelHeight);
                if (touchPos.x < (camDims.x * 0.2f))
                {
                    touchMoveLeft = true;
                }
                else if (touchPos.x > (camDims.x * 0.8f))
                {
                    touchMoveRight = true;
                }
                else if (touchPos.y < (camDims.y * 0.5f))
                {
                    touchFire = true;
                }
            }
        }
        if (((Input.GetButton("Fire1") && rapidFire) || Input.GetButtonDown("Fire1") || touchFire) && !fired)
        {
            AudioSource.PlayClipAtPoint(pewpew, gameObject.transform.position);
            fired = true;
            Vector3 spawnPos = gameObject.transform.position;
            spawnPos.z += 0.75f;
            if (beam)
            {
                spawnPos.z += 5.0f;
                GameObject    obj = Instantiate(beamObj, spawnPos, Quaternion.identity) as GameObject;
                PlayerMissile m   = obj.GetComponent <PlayerMissile>();
                m.playerBase = gameObject;
                m.isBeam     = true;
            }
            else
            {
                GameObject    obj = Instantiate(missile, spawnPos, Quaternion.identity) as GameObject;
                PlayerMissile m   = obj.GetComponent <PlayerMissile>();
                m.playerBase = gameObject;
                m.isBeam     = false;
            }
        }

        if ((Input.GetAxisRaw("Horizontal") > 0 || touchMoveRight) && gameObject.transform.position.x < controller.GetComponent <GameController>().rightLimit)
        {
            gameObject.transform.Translate(moveSpeed, 0, 0);
        }
        else if ((Input.GetAxisRaw("Horizontal") < 0 || touchMoveLeft) && gameObject.transform.position.x > controller.GetComponent <GameController>().leftLimit)
        {
            gameObject.transform.Translate(-moveSpeed, 0, 0);
        }
        Vector3 gunVec = gameObject.transform.position;

        gunVec.z += 0.5f;
        myGun.transform.position = gunVec;
    }