Пример #1
0
        protected override void LoadContent(ContentManager theContentManager, GraphicsDevice theGraphicsDevice)
        {
            mPShipSprite = new PShip();
            mProjectileSprite = new Projectile();

            //Initialize and add the background images to the Scrolling background. You can change the
            //scroll area by passing in a different Viewport. The images will then scale and scroll within
            //that given Viewport.
            mScrollingBackground = new VerticallyScrollingBackground(theGraphicsDevice.Viewport);
            mScrollingBackground.AddBackground("Background1");
            mScrollingBackground.AddBackground("Background2");
            mScrollingBackground.AddBackground("Background3");
            mScrollingBackground.AddBackground("Background4");
            mScrollingBackground.AddBackground("Background5");
            mScrollingBackground.AddBackground("Background6");
            mScrollingBackground.AddBackground("Background7");
            mScrollingBackground.AddBackground("Background8");
            mScrollingBackground.AddBackground("Background9");

            //Load the content for the Scrolling background
            mScrollingBackground.LoadContent(theContentManager);

            mProjectileSprite.LoadContent(theContentManager);
            mPShipSprite.LoadContent(theContentManager);
        }
Пример #2
0
        protected override void LoadContent(ContentManager theContentManager, GraphicsDevice theGraphicsDevice)
        {
            mPShipSprite      = new PShip();
            mProjectileSprite = new Projectile();

            //Initialize and add the background images to the Scrolling background. You can change the
            //scroll area by passing in a different Viewport. The images will then scale and scroll within
            //that given Viewport.
            mScrollingBackground = new VerticallyScrollingBackground(theGraphicsDevice.Viewport);
            mScrollingBackground.AddBackground("Background1");
            mScrollingBackground.AddBackground("Background2");
            mScrollingBackground.AddBackground("Background3");
            mScrollingBackground.AddBackground("Background4");
            mScrollingBackground.AddBackground("Background5");
            mScrollingBackground.AddBackground("Background6");
            mScrollingBackground.AddBackground("Background7");
            mScrollingBackground.AddBackground("Background8");
            mScrollingBackground.AddBackground("Background9");

            //Load the content for the Scrolling background
            mScrollingBackground.LoadContent(theContentManager);

            mProjectileSprite.LoadContent(theContentManager);
            mPShipSprite.LoadContent(theContentManager);
        }
    //private Vector2 swipeDirection;

    private void Start()
    {
        player         = GetComponent <PShip>();
        lineRenderer   = GetComponent <LineRenderer>();
        playerGhostObj = GameObject.Instantiate(playerGhostObj, playerGhostObj.transform.position, playerGhostObj.transform.rotation);
        playerGhostObj.SetActive(false);
    }
Пример #4
0
 //TODO: In an asteroid-asteroid collision, this function is being called from both asteroids, and should just be the one getting hit.
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.GetComponent <Asteroid>() is Asteroid)
     {
         Asteroid asteroidHit = collision.gameObject.GetComponent <Asteroid>();
         asteroidHit.impactVelocity = impactVelocity;
         color = asteroidHit.color;
         asteroidHit.OnHit();
     }
     else if (collision.gameObject.GetComponent <PShip>() is PShip) // TODO: These should take advantage of ShipBase polymorphism.
     {
         Debug.LogError("PLAYER COLLISION");
         PShip _player = collision.gameObject.GetComponent <PShip>();
         state = AsteroidState.Enemy;
         color = _player.renderer.material.color;
         rend.material.SetColor("_Color", color);
     }
     else if (collision.gameObject.GetComponent <EShip>() is EShip)
     {
         EShip _enemy = collision.gameObject.GetComponent <EShip>();
         state = AsteroidState.Enemy;
         color = _enemy.renderer.material.color;
         rend.material.SetColor("_Color", color);
     }
 }
Пример #5
0
    protected override void Start()
    {
        base.Start();
        player        = FindObjectOfType <PShip>();
        moveSpeed     = player.moveSpeed;
        moveLocations = new Vector2[] { new Vector2(0, -3), new Vector2(0, 3.1f), new Vector2(-6, 2.2f), new Vector2(-4.5f, -4), new Vector2(-1.8f, 0), new Vector2(1, -4) };
        asteroids     = GameObject.FindObjectsOfType <Asteroid>();

        random = new System.Random();
    }
    private void Awake()
    {
        /* Enforce Singleton: */
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }

        /* Additional intialization: */
        player    = FindObjectOfType <PShip>();
        enemy     = FindObjectOfType <EShip>();
        UIManager = GetComponent <UIManager>();
        turnOrder = new GameState[] { GameState.MoveTurn, GameState.BulletTurn };
        asteroids = GameObject.FindObjectsOfType <Asteroid>();
    }