Esempio n. 1
0
    IEnumerator CheckFar()
    {
        for (;;)
        {
            yield return(new WaitForSeconds(Random.Range(5, 10)));

            if (Vector3.Distance(ship.position, transform.position) > 10000)
            {
                Destroy(gameObject);
                yield break;
            }
            else if (Vector3.Distance(ship.position, transform.position) < 10)
            {
                switch (type)
                {
                case AsteroidType.ice:
                    SpaceShip ss = ship.GetComponent <SpaceShip>();
                    ss.ChangeWater(Random.Range(5f, 50f));
                    ss.ChangeFuel(-2f);
                    ss.ChangeEnergy(-2f);
                    FindObjectOfType <StatusText>().SetText("мы добыли лед из астероида");
                    break;

                case AsteroidType.rock:
                    ss = ship.GetComponent <SpaceShip>();
                    ss.ChangeFuel(Random.Range(5f, 50f));
                    ss.ChangeEnergy(-2f);
                    FindObjectOfType <StatusText>().SetText("мы добыли топливо из астероида");
                    break;
                }
            }
        }
    }
Esempio n. 2
0
        public void TestMethod1(SpaceShipParameters parameter)
        {
            SpaceShip spaceShip = new SpaceShip();

            parameter.Text = "start";
            Assert.True(spaceShip.Start(parameter));
        }
Esempio n. 3
0
        public ComponentManager(ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicsDeviceManager)
        {
            _contentManager     = contentManager;
            _resourceRepository = new ResourceRepository(new BasicResourceRepositoryConfiguration(), _contentManager);

            Font = _resourceRepository.GetFont();
            _spaceShipTexture = _resourceRepository.GetTextureByType(typeof(SpaceShip));

            var graphicsDevice = graphicsDeviceManager.GraphicsDevice;

            Configuration = new BasicGameConfiguration(
                _spaceShipTexture.Height,
                Font
                );

            graphicsDeviceManager.PreferredBackBufferWidth  = Configuration.ScreenSize.Width;
            graphicsDeviceManager.PreferredBackBufferHeight = Configuration.ScreenSize.Height;
            graphicsDeviceManager.ApplyChanges();

            SpaceShip      = new SpaceShip(Configuration, new Size(_spaceShipTexture.Width, _spaceShipTexture.Height));
            _ballTexture   = _resourceRepository.GetTextureByType(typeof(BasicBall));
            BallRepository = new BallRepository(Configuration, new Size(_ballTexture.Width, _ballTexture.Height));

            Balls = new List <IBall>();

            _drawer = new ComponentDrawer(graphicsDevice, Font);

            Prizes = new List <IPrize>();
            Shoots = new List <IShoot>();

            MediaPlayer.Volume = .03f;
        }
Esempio n. 4
0
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship = GetComponent<SpaceShip> ();

        // ローカル座標のY軸のマイナス方向に移動する
        Move (transform.up * -1);

        // canShotがfalseの場合、ここでコルーチンを終了させる
        if (spaceship.canShot == false) {
            yield break;
        }

        while (true) {

            // 子要素を全て取得する
            for (int i = 0; i < transform.childCount; i++) {

                Transform shotPosition = transform.GetChild(i);

                // ShotPositionの位置/角度で弾を撃つ
                spaceship.Shot (shotPosition);
            }

            // shotDelay秒待つ
            yield return new WaitForSeconds (spaceship.shotDelay);
        }
    }
Esempio n. 5
0
        public void Update(Actor caller)
        {
            SpaceShip  ship   = caller as SpaceShip;
            GameObject target = caller.Target;

            if (target != null)
            {
                Vector2 thrust;
                Vector2 callerPos = caller.AbsolutePosition;
                Vector2 targetPos = target.AbsolutePosition;
                Vector2.Subtract(ref callerPos, ref targetPos, out thrust);

                ship.ApplyThrust(-thrust);
                //if (target.AbsolutePosition.X > caller.AbsolutePosition.X)
                //{

                //}
                //else
                //{
                //    caller.MoveLeft();
                //}

                //if (target.AbsolutePosition.Y < caller.AbsolutePosition.Y)
                //{
                //    caller.MoveUp();
                //}
                //else
                //{
                //    caller.MoveDown();
                //}
            }
        }
Esempio n. 6
0
        private void SetUpGameWorld()
        {
            //AtmosphericScatteringGround

            float radius = 6000;

            earth = new Planet("earth", new Vector3(0, 0, 0),
                               NoiseGenerator.FastPlanet(radius),
                               EffectLoader.LoadSM5Effect("flatshaded").Clone(),
                               radius, Color.DarkSeaGreen.ChangeTone(-100), Color.SaddleBrown, Color.SaddleBrown.ChangeTone(-10), 0);
            //earth.AddAtmosphere();
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(earth);


            mouseCamera.SetPositionAndLook(new Vector3(0, radius + 200, 0), (float)Math.PI, (float)-Math.PI / 5);


            duneBuggyOne = new DuneBuggy(PlayerIndex.One, Color.Red, new Vector3(0, radius + 100, 0));
            spaceShipOne = new SpaceShip(PlayerIndex.One, Color.Red, new Vector3(0, radius + 200, 0));


            field = new GravitationalField(new InfiniteForceFieldShape(), Vector3.Zero.ToBepuVector(), 100000 * radius, 100);
            SystemCore.PhysicsSimulation.Add(field);

            spaceShipOne.Activate();

            duneBuggyCamera = new DuneBuggyPlanetCamera(duneBuggyOne);
            spaceShipCamera = new SpaceShipCamera(spaceShipOne);
        }
Esempio n. 7
0
 public GamePlayScreen(Game game, GameStateManager manager)
     : base(game, manager)
 {
     myBoard      = new Board();
     MyShip       = new SpaceShip();
     this.manager = manager;
 }
Esempio n. 8
0
        public override string DrawSpaceship(SpaceShip spaceShip)
        {
            FileLogger.Log("Retro Template method pattern: drawing spaceship");

            var builder = new StringBuilder();

            var everySecond = false;

            for (var position = 0; position < Contracts.GameSizeWidth; position++)
            {
                var contains = spaceShip.Position.From.X < position && position <= spaceShip.Position.To.X;
                if (contains)
                {
                    if (everySecond)
                    {
                        builder.Append("\u25CA");
                    }

                    builder.Append("\u25CA");
                    everySecond = !everySecond;
                }
                else
                {
                    builder.Append(" ");
                }
                //builder.Append(contains ? "_" : " ");
            }
            return(builder.ToString());
        }
Esempio n. 9
0
 public GeneralGameState(ContentManager Content, Monsters monsters, SpaceShip spaceship, int windowWidth, int windowHeight)
 {
     this.content      = Content;
     this.windowWidth  = windowWidth;
     this.windowHeight = windowHeight;
     collisionEvents   = new OnCollsionEvents(spaceship, monsters);
 }
Esempio n. 10
0
        /// <summary>
        /// Конструктор визуальной части космического корабля
        /// </summary>
        /// <param name="ship"></param>
        public ShipControl(SpaceShip ship)
        {
            InitializeComponent();
            DataContext = this;

            Ship = ship;

            switch (Ship.ShipType)
            {
            case ShipType.Interceptor:
                ShipImage.Source = new BitmapImage(new Uri("/Images/interceptor.png", UriKind.Relative));
                break;

            case ShipType.LightCruiser:
                ShipImage.Source = new BitmapImage(new Uri("/Images/lightcruiser.png", UriKind.Relative));
                break;

            case ShipType.HeavyCruiser:
                ShipImage.Source = new BitmapImage(new Uri("/Images/heavycruiser.png", UriKind.Relative));
                break;

            case ShipType.DeathStar:
                ShipImage.Source = new BitmapImage(new Uri("/Images/deathstar.png", UriKind.Relative));
                break;

            default:
                break;
            }
        }
 public void Start()
 {
     spc = FindObjectOfType <SpaceSuitControls>();
     ss  = FindObjectOfType <SpaceShip>();
     if (putin == CameraDictatorShip.orbit)
     {
         MoveCamToOrbit();
     }
     else if (putin == CameraDictatorShip.ship)
     {
         MoveCamToShip();
     }
     else if (putin == CameraDictatorShip.player)
     {
         MoveCamToPlayer();
     }
     else if (putin == CameraDictatorShip.goblin)
     {
         MoveCamToGoblin();
     }
     else
     {
         MoveCamToCinematic();
     }
 }
Esempio n. 12
0
        public void DetermineShipDamage()
        {
            SpaceShip = new SpaceShip("Test", 1, 15, 1, 1, 1, new Random());
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.Undamaged));
            SpaceShip.RecieveDamage(2);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.LightlyDamaged));

            SpaceShip.RecieveDamage(1);

            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.ModeratelyDamaged));


            SpaceShip.RecieveDamage(3);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.HeavilyDamaged));

            SpaceShip.RecieveDamage(2);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.HeavilyDamaged));


            SpaceShip.RecieveDamage(2);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.HeavilyDamaged));


            SpaceShip.RecieveDamage(2);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.VeryHeavilyDamaged));

            SpaceShip.RecieveDamage(2000);
            Assert.That(SpaceShip.DamageStatus(), Is.EqualTo(ShipDamageEnum.VeryHeavilyDamaged));
        }
Esempio n. 13
0
        private string buildMessage()
        {
            string    playersInformationScore = string.Empty;
            int       scoreOfWinningPlayer    = 0;
            SpaceShip winningSpaceShip        = null;

            foreach (SpaceShip spaceShip in r_SpaceShips)
            {
                if (scoreOfWinningPlayer <= spaceShip.CurrentPlayerInformation.CurrentScore)
                {
                    winningSpaceShip     = spaceShip;
                    scoreOfWinningPlayer = spaceShip.CurrentPlayerInformation.CurrentScore;
                }

                playersInformationScore += string.Format("Player {0}, Your Score is: {1}{2}", spaceShip.CurrentPlayerInformation.PlayerIndex + 1,
                                                         spaceShip.CurrentPlayerInformation.CurrentScore, Environment.NewLine);
            }

            string winningMessage = string.Format("Player {0} you won!{1}{1}", winningSpaceShip.CurrentPlayerInformation.PlayerIndex + 1,
                                                  Environment.NewLine);

            winningMessage += playersInformationScore;

            return(winningMessage);
        }
Esempio n. 14
0
    // コルーチンでメソッドStartを呼びだす
    IEnumerator Start()
    {
        // GetComponentでSpaceShipクラスのインスタンスを取得しローカル変数SpaceShipで保持
        SpaceShip = GetComponent <SpaceShip>();

        // Moveメソッドを呼びだしy方向に移動する
        Move(transform.up * -1);

        // CanShotにチェックが入っていなければそれを中断する
        if (SpaceShip.CanShot == false)
        {
            yield break;
        }

        // 以下を繰り返す
        while (true)
        {
            // int型の変数iを宣言し0を代入、子要素ShotPositionを全て取得するまで繰り返す
            for (int i = 0; i < transform.childCount; i++)
            {
                // GetChildメソッドでi番目かつTransformクラスの子要素ShotPositionを取得
                Transform ShotPosition = transform.GetChild(i);

                // Shotメソッドを呼び出し、ShotPositionの位置と角度で弾を撃つ
                SpaceShip.Shot(ShotPosition);
            }

            // ShotDelay杪待つ
            yield return(new WaitForSeconds(SpaceShip.ShotDelay));
        }
    }
Esempio n. 15
0
        public void Initialize()
        {
            CargoDAO cargoDao = new CargoDAO();

            cargo1      = CreateCargo();
            cargo2      = CreateCargo();
            cargo2.Type = "newtype";
            cargoDao.InsertCargo(cargo1);
            cargoDao.InsertCargo(cargo2);

            BaseDAO bas = new BaseDAO();

            newBase        = new Base();
            newBase.Planet = "Země";
            bas.InsertBase(newBase);

            PlayerDAO playerDao = new PlayerDAO();

            player = CreatePlayer();
            playerDao.InsertPlayer(player);

            SpaceShipDAO shipDao = new SpaceShipDAO();

            ship = CreateSpaceShip();
            shipDao.InsertSpaceShip(ship);
        }
Esempio n. 16
0
        public static void Load()
        {
            for (int i = 0; i < 10; i++)
            {
                __GameObjects.Add(new Star(
                                      new Point(600, i / 2 * 20),
                                      new Point(-i, 0), 30));
            }


            const int asteroid_count     = 10;
            const int asteroid_size      = 25;
            const int asteroid_max_speed = 20;

            const int health_count = 5;
            const int health_size  = 25;
            const int health_speed = 20;

            for (int i = 0; i < asteroid_count; i++)
            {
                __Asteroids.Add(new Asteroids(new Point(rnd.Next(150, Width),
                                                        rnd.Next(150, Height)),
                                              new Point(-rnd.Next(0, asteroid_max_speed), 0), asteroid_size));
            }

            for (int i = 0; i < health_count; i++)
            {
                __Healths.Add(new Health(new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                         new Point(-rnd.Next(0, health_speed), 0), health_size));
            }

            __Bullet               = new Bullet(200);
            __SpaceShip            = new SpaceShip(new Point(10, 200), new Point(50, 50), new Size(50, 30), null);
            __SpaceShip.Destroyed += OnShipDestroyed;
        }
Esempio n. 17
0
 public MovingEnemy(byte startingPositionX, byte startingPositionY, ConsoleColor color, SpaceShip shipToTrace)
     : base(startingPositionX, startingPositionY, color)
 {
     this.HealthPoints = 10;
     this.Sprite       = '*';
     this.shipToTrace  = shipToTrace;
 }
    private void Update()
    {
        float before = ScoreBar.GetComponent <Image>().fillAmount;

        ScoreBar.GetComponent <Image>().fillAmount += (score * 1f / threeStar - ScoreBar.GetComponent <Image>().fillAmount) * 0.2f;
        SpaceShip.GetComponent <RectTransform>().anchoredPosition = new Vector2(ScoreBar.GetComponent <RectTransform>().rect.width *ScoreBar.GetComponent <Image>().fillAmount, 0);
        if (oneStar * 1f / threeStar < ScoreBar.GetComponent <Image>().fillAmount&& oneStar * 1f / threeStar > before)
        {
            Debug.Log("1 sao");
            Destroy(Instantiate(StarExplo, new Vector3(OneStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f);
            GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao();
        }
        if (twoStar * 1f / threeStar < ScoreBar.GetComponent <Image>().fillAmount&& twoStar * 1f / threeStar > before)
        {
            Debug.Log("2 sao");
            Destroy(Instantiate(StarExplo, new Vector3(TwoStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f);
            GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao();
        }
        if (before < 1 && ScoreBar.GetComponent <Image>().fillAmount == 1)
        {
            Debug.Log("3 sao");
            Destroy(Instantiate(StarExplo, new Vector3(ThreeStarPos.transform.position.x, OneStarPos.transform.position.y + 1f, 0f), Quaternion.identity), 1.5f);
            GameObject.FindGameObjectWithTag("UI").GetComponentInChildren <starSlider>().tangsao();
        }
    }
Esempio n. 19
0
 public virtual void Remove(SpaceShip ship)
 {
     foreach (KeyValuePair <string, int> item in statBonuses)
     {
         ship.changeStat(item.Key, -item.Value);
     }
 }
Esempio n. 20
0
    public void ChangeObject(int type)
    {
        SpaceShip ss = GameObject.FindObjectOfType <SpaceShip>();

        foreach (ManualLight m in ss.manualObjects)
        {
            if (m == ss.manualObjects[type])
            {
                if (m.active == true)
                {
                    m.Activate();
                }
                m.active = true;
            }
            else
            {
                m.active = false;
            }
        }

        foreach (Image i in icons)
        {
            Color c = i.color;
            c.a     = 0.5f;
            i.color = c;
        }

        Color cr = icons[type].color;

        cr.a = 1f;
        icons[type].color = cr;
    }
Esempio n. 21
0
 public bool UpdateSpaceShipById(SpaceShip spaceShip)
 {
     using (var contextDB = CreateContext())
         try
         {
             var spaceShipTab = contextDB.SpaceShips.FirstOrDefault(x => x.SpaceShipId.Equals(spaceShip.SpaceShipId));
             spaceShipTab.DamagePercent     = spaceShip.DamagePercent;
             spaceShipTab.UserCode          = spaceShip.UserCode;
             spaceShipTab.TimeOfArrival     = spaceShip.TimeOfArrival;
             spaceShipTab.IsFlying          = spaceShip.IsFlying;
             spaceShipTab.SpaceShipName     = spaceShip.SpaceShipName;
             spaceShipTab.SpaceShipModel    = spaceShip.SpaceShipModel;
             spaceShipTab.DockedAtBaseId    = spaceShip.DockedAtBaseId;
             spaceShipTab.CurrentStarSystem = spaceShip.CurrentStarSystem;
             spaceShipTab.FuelTank          = spaceShip.FuelTank;
             spaceShipTab.CurrentFuelTank   = spaceShip.CurrentFuelTank;
             spaceShipTab.PlayerId          = spaceShip.PlayerId;
             // save context to database
             contextDB.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
 }
Esempio n. 22
0
 public void init()
 {
     dbp    = new DatabasePopulate();
     eco    = new Economy();
     trad   = new Trading();
     myShip = new  SpaceShip();
 }
Esempio n. 23
0
    override public void WhenActivate()
    {
        SpaceShip ss = FindObjectOfType <SpaceShip>();

        PlanetGen[] pg = FindObjectsOfType <PlanetGen>();
        if (pg.Length == 0)
        {
            return;
        }

        PlanetGen nearp    = pg[0];
        float     neardist = 99999f;

        foreach (PlanetGen p in pg)
        {
            if (p.founded)
            {
                continue;
            }
            float d = Vector3.Distance(ss.transform.position, p.transform.position);
            if (d < neardist)
            {
                neardist = d;
                nearp    = p;
            }
        }

        if (nearp == null)
        {
            return;
        }

        nearp.Founded();
    }
Esempio n. 24
0
    public static List <SpaceShip> FindMyTargets(SpaceShip attacker)
    {
        List <SpaceShip> result = Ships.FindAll(ship =>
                                                (ship.shipSize == attacker.bestTarget.Item1 && ship.shipArmor == attacker.bestTarget.Item2));

        return(result);
    }
Esempio n. 25
0
 public void _on_Launch_button_down()
 {
     SpaceShip.close_interface();
     PlayerState.state = PlayerState.State.Finish;
     Save.DeleteSave(Game.saveName);
     GetTree().ChangeScene("res://Assets/Objects/UI/Menus/EndMenu.tscn");
 }
Esempio n. 26
0
    private static void GenericSpawner(int count, Entity prefab)
    {
        for (int i = 0; i < count; i++)
        {
            var         entity   = MainLoader.entityManager.Instantiate(prefab);
            var         position = new float3(TerrainSystem.terrainWidth / 2, 50, TerrainSystem.terrainWidth / 2);
            Translation pos      = new Translation {
                Value = position
            };
            MainLoader.entityManager.SetComponentData(entity, pos);
            MainLoader.entityManager.SetComponentData(entity, new Rotation {
                Value = Quaternion.Euler(0, 0, 0)
            });

            SpaceShip s = MainLoader.entityManager.GetComponentData <SpaceShip>(entity);
            s.dest = position;
            MainLoader.entityManager.SetComponentData <SpaceShip>(entity, s);

            Weapon w = MainLoader.entityManager.GetComponentData <Weapon>(entity);
            w.enabled = true;
            MainLoader.entityManager.SetComponentData <Weapon>(entity, w);

            //MainLoader.entityManager.AddBuffer<ProjectileBuffer>(entity);
        }
    }
Esempio n. 27
0
        public Level(string level)
        {
            LevelName = level;
            ResourceLoader.LoadBitmaps(this);
            Ship = new SpaceShip(17, 30, 0, new Vector2(3, 8), new Vector2(120, 100), shipImage);
            Enemies = new List<GameObject>();
            Platforms = new List<GameObject>();
            DestroyableBricks = new List<GameObject>();
            WarpPipes = new List<GameObject>();
            Coins = new List<GameObject>();
            gifs = new Bitmap[5];

            // GetEnemies
            ResourceLoader.GetGameObjects(this, LevelName, "Enemies");
            // GetPlatforms/Pipes
            ResourceLoader.GetGameObjects(this, LevelName, "Platforms");
            ResourceLoader.GetGameObjects(this, LevelName, "DestroyableBricks");
            // GetWarpPipes
            ResourceLoader.GetGameObjects(this, LevelName, "WarpPipes");
            // GetCoins
            ResourceLoader.GetGameObjects(this, LevelName, "Coins");
            CountBulletBills();
            gifs[0] = npcImage;
            gifs[1] = koopaImage;
            gifs[2] = coinImage;
            gifs[3] = questionBlock;
            gifs[4] = (Bitmap)Image.FromFile(Environment.CurrentDirectory + @"\Resources\bigMario.gif");
        }
Esempio n. 28
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        SpaceShip player = col.GetComponent <SpaceShip>();

        Debug.Log("Player: " + col.tag + "Bullet: " + tag);

        if (((tag == "bullet2") && (col.tag == "Player1")) || ((tag == "bullet1") && (col.tag == "Player2")))
        {
            Debug.Log("aga");
            // PlayExplosion();
            SetHealth(col);
        }

        if (((tag == "bullet1") && (col.tag != "Player1")) || ((tag == "bullet2") && (col.tag != "Player2")))
        {
            if ((col.tag == "bullet1") && (tag == "bullet2") || (col.tag == "bullet2") && (tag == "bullet1"))
            {
            }
            else
            {
                PlayExplosion();
                PhotonNetwork.Destroy(gameObject);
            }
        }
    }
Esempio n. 29
0
 void Awake()
 {
     m_game      = GameObject.Find("spaceship").GetComponent <Game> ();
     m_spaceShip = m_game.GetMySpaceShip();
     m_stage1    = GameObject.Find("lunarSurface1");
     m_stage2    = GameObject.Find("lunarSurface2");
 }
Esempio n. 30
0
        /// <summary>
        /// Creates an array of spaceships
        /// </summary>
        /// <param name="expectedNumberOfShips"></param>
        /// <returns></returns>
        private SpaceShip[] CreateSpaceShips(int expectedNumberOfShips)
        {
            SpaceShip[] spaceShips        = new SpaceShip[expectedNumberOfShips];
            int         shipsCreatedIndex = 0;
            int         index             = ShipInformationStartPostion;

            // while not created all ships
            while (shipsCreatedIndex != expectedNumberOfShips)
            {
                SpaceShip spaceShip = CreateSpaceShip(index);

                if (spaceShip == null)
                {
                    return(null); // exit as soon as there is an invalid ship
                }
                spaceShips[shipsCreatedIndex] = spaceShip;
                shipsCreatedIndex++;
                index += NumberOfPropertiesPerShip;
            }

            if (ArrayUtils.HasValidElementsInArrayRange(fleetFileContents, index,
                                                        fleetFileContents.Length))
            {
                // more content in the file than expected, reject
                ConsoleUtil.WriteMoreShipsThanExpected(fleetFileName);
                return(null);
            }
            return(spaceShips);
        }
Esempio n. 31
0
        public void Update(SpaceShip _spaceShip, Monsters _monsters)
        {
            List <Arrow> gameArrows = player.Gun.ArrowList;

            if (MonsterCount > 0)
            {
                foreach (var monster in monsters.MonstersList)
                {
                    if (monster.ReachedTheButtom)
                    {
                        MonsterHitTheFloor = true;
                    }

                    if (monster.CollsionWith(player))
                    {
                        MonsterHitTheSpaceship = true;
                    }

                    foreach (var currentArrow in gameArrows)
                    {
                        if (currentArrow.CollsionWith(monster))
                        {
                            currentArrow.MonsterHit = true;
                            currentArrow.Exploade(new Rectangle(monster.Location.X, monster.Location.Y, monster.AreaRect.Width, monster.AreaRect.Height));

                            monster.GotHit = true;
                        }
                    }
                }
            }
            player   = _spaceShip;
            monsters = _monsters;
        }
Esempio n. 32
0
    // フォントの色変え.
    void ChangeColor()
    {
        if (m_spaceship == null)
        {
            if (m_game == null)
            {
                return;
            }
            m_spaceship = m_game.GetMySpaceShip();
            return;
        }

        // テキストの種類の現状によって色を決める.
        switch (m_textType)
        {
        case eTextType.eTextAngle:
            ChangeColorTextAngle();
            break;

        case eTextType.eTextLandingVelocity:
            ChangeColorTextLandingVelocity();
            break;

        case eTextType.eTextCheckLanding:
            ChangeColorTextCheckLanding();
            break;

        case eTextType.eTextHorizontalSpeed:
            ChangeColorTextHorizontalSpeed();
            break;

        case eTextType.eTextMyScore:
            m_fontColor = eFontColor.eRed;
            break;

        default:
            m_fontColor = eFontColor.eWhite;
            break;
        }

        // フォントの色を変える.
        switch (m_fontColor)
        {
        case eFontColor.eGreen:
            m_text.color = Color.green;
            break;

        case eFontColor.eYellow:
            m_text.color = Color.yellow;
            break;

        case eFontColor.eRed:
            m_text.color = Color.red;
            break;

        case eFontColor.eWhite:
            m_text.color = Color.white;
            break;
        }
    }
    public SpaceShipController(SpaceGrid grid, SpaceShip ship)
    {
        this.grid = grid;
        this.ship = ship;

        Console.WriteLine(ShipPosition());
    }
 public Player(GameScreen i_GameScreen, SpaceShipConfiguration i_SpaceShipConfiguration, int i_PlayerId, IPlayerState i_PlayerState)
 {
     r_SpaceShip = new SpaceShip(i_GameScreen, i_SpaceShipConfiguration, i_PlayerId);
     ScoresBoard = new ScoresBoard(i_GameScreen, i_PlayerId, i_SpaceShipConfiguration.TextColor);
     r_SoulsBoard = new SoulsBoard(i_GameScreen, i_PlayerState, i_SpaceShipConfiguration.AssetName, i_PlayerId);
     r_SpaceShip.SpaceShipHit += spaceShipOnHit;
     r_SpaceShip.Died += spaceShipOnDie;
     r_SpaceShip.BulletCollided += bulletCollision;
 }
 /// <summary>
 /// Saves the space ship.
 /// </summary>
 /// <param name="spaceShip">The space ship.</param>
 public void SaveSpaceShip(SpaceShip spaceShip)
 {
     try
     {
         DataContext.SpaceShips.InsertOnSubmit(spaceShip);
         DataContext.SubmitChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 36
0
 public void NotifySpaceShipDied(SpaceShip ship)
 {
     enemiesLeft--;
     if (enemiesLeft < 0)
         Debug.LogError("enemies left is negative!");
     if (enemiesLeft == 0)
     {
         if (!mustFinishWaveBeforeNext)
             parentStage.NotifyWaveCompleted(this);
         else
             StartCoroutine(FinishCurrWave());
         return;
     }
 }
Esempio n. 37
0
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship = GetComponent<SpaceShip> ();

        // Backgroundコンポーネントを取得。3つのうちどれか1つを取得する
        background = FindObjectOfType<Background> ();

        while (true) {

            // 弾をプレイヤーと同じ位置/角度で作成
            spaceship.Shot (transform);

            var audio = GetComponent<AudioSource>();
            audio.Play();

            // shotDelay秒待つ
            yield return new WaitForSeconds (spaceship.shotDelay);
        }
    }
Esempio n. 38
0
    void Start()
    {
        spaceShip = new SpaceShip();
        savedSpaceShip = new SpaceShip ();
        shipNamesAsArray = PlayerPrefsX.GetStringArray ("shipNamesAsArray");
        buttonList = new List<GameObject> ();
        for (int i = 0; i < shipNamesAsArray.Length; i++)
        {
            shipNamesAsList.Add(shipNamesAsArray[i]);
            GameObject newButton = Instantiate(button) as GameObject;
            newButton.transform.SetParent(savedShipPanel.transform);
            newButton.transform.GetChild(0).GetComponent<Text>().text = shipNamesAsList[i];
            buttonList.Add(newButton);
        }

        //PlayerPrefs.DeleteAll ();
    }
		public void AutoDetectAliasing()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Organization ifa = new Organization("IFA");
			Organization jboss = new Organization("JBoss");
			Person gavin = new Person("Gavin");
			Employment emp = new Employment(gavin, jboss, "AU");
			s.Save(jboss);
			s.Save(ifa);
			s.Save(gavin);
			s.Save(emp);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			IList list = s.CreateSQLQuery(EmploymentSQL)
				.AddEntity(typeof(Employment).FullName)
				.List();
			Assert.AreEqual(1, list.Count);

			Employment emp2 = (Employment) list[0];
			Assert.AreEqual(emp2.EmploymentId, emp.EmploymentId);
			Assert.AreEqual(emp2.StartDate.Date, emp.StartDate.Date);
			Assert.AreEqual(emp2.EndDate, emp.EndDate);

			s.Clear();

			list = s.CreateSQLQuery(EmploymentSQL)
				.AddEntity(typeof(Employment).FullName)
				.SetResultTransformer(CriteriaSpecification.AliasToEntityMap)
				.List();
			Assert.AreEqual(1, list.Count);
			IDictionary m = (IDictionary) list[0];
			Assert.IsTrue(m.Contains("Employment"));
			Assert.AreEqual(1, m.Count);

			list = s.CreateSQLQuery(EmploymentSQL).List();
			Assert.AreEqual(1, list.Count);
			object[] o = (object[]) list[0];
			Assert.AreEqual(8, o.Length);

			list = s.CreateSQLQuery(EmploymentSQL).SetResultTransformer(CriteriaSpecification.AliasToEntityMap).List();
			Assert.AreEqual(1, list.Count);
			m = (IDictionary) list[0];
			Assert.IsTrue(m.Contains("EMPID") || m.Contains("empid"));
			Assert.IsTrue(m.Contains("AVALUE") || m.Contains("avalue"));
			Assert.IsTrue(m.Contains("ENDDATE") || m.Contains("enddate"));
			Assert.AreEqual(8, m.Count);

			// TODO H3: H3.2 can guess the return column type so they can use just addScalar("employerid"),
			// but NHibernate currently can't do it.
			list =
				s.CreateSQLQuery(EmploymentSQLMixedScalarEntity).AddScalar("employerid", NHibernateUtil.Int64).AddEntity(
					typeof(Employment)).List();
			Assert.AreEqual(1, list.Count);
			o = (object[]) list[0];
			Assert.AreEqual(2, o.Length);
			AssertClassAssignability(o[0].GetType(), typeof(long));
			AssertClassAssignability(o[1].GetType(), typeof(Employment));


			IQuery queryWithCollection = s.GetNamedQuery("organizationEmploymentsExplicitAliases");
			queryWithCollection.SetInt64("id", jboss.Id);
			list = queryWithCollection.List();
			Assert.AreEqual(list.Count, 1);

			s.Clear();

			list = s.CreateSQLQuery(OrganizationJoinEmploymentSQL)
				.AddEntity("org", typeof(Organization))
				.AddJoin("emp", "org.employments")
				.List();
			Assert.AreEqual(2, list.Count);

			s.Clear();

			list = s.CreateSQLQuery(OrganizationFetchJoinEmploymentSQL)
				.AddEntity("org", typeof(Organization))
				.AddJoin("emp", "org.employments")
				.List();
			Assert.AreEqual(2, list.Count);

			s.Clear();

			// TODO : why twice?
			s.GetNamedQuery("organizationreturnproperty").List();
			list = s.GetNamedQuery("organizationreturnproperty").List();
			Assert.AreEqual(2, list.Count);

			s.Clear();

			list = s.GetNamedQuery("organizationautodetect").List();
			Assert.AreEqual(2, list.Count);

			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			s.Delete(emp2);

			s.Delete(jboss);
			s.Delete(gavin);
			s.Delete(ifa);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			Dimension dim = new Dimension(3, int.MaxValue);
			s.Save(dim);
			//		s.Flush();
			s.CreateSQLQuery("select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension").List();
			s.Delete(dim);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			SpaceShip enterprise = new SpaceShip();
			enterprise.Model = "USS";
			enterprise.Name = "Entreprise";
			enterprise.Speed = 50d;
			Dimension d = new Dimension(45, 10);
			enterprise.Dimensions = d;
			s.Save(enterprise);
			//		s.Flush();
			object[] result = (object[]) s.GetNamedQuery("spaceship").UniqueResult();
			enterprise = (SpaceShip) result[0];
			Assert.IsTrue(50d == enterprise.Speed);
			Assert.IsTrue(450d == ExtractDoubleValue(result[1]));
			Assert.IsTrue(4500d == ExtractDoubleValue(result[2]));
			s.Delete(enterprise);
			t.Commit();
			s.Close();
		}
Esempio n. 40
0
        public void MoveTowards(SpaceShip ship)
        {
            // Get Offsets
            double XOffset = ship.Position.X - this.Position.X;
            double YOffset = ship.Position.Y - this.Position.Y;
            // Left
            if (XOffset < 0)
            {
                Velocity.X -= 0.1;
            }
            // Right
            else
            {
                Velocity.X += 0.1;
                // Invert XOffset to be consistent with YOffset
                XOffset = XOffset * -1;
            }
            // Jump
            if (YOffset < 0
                && this.IsGrounded == true
                && YOffset < XOffset) /* Only jumps if YOffset is greater */
            {
                Velocity.Y -= 7.5;
            }

            Move();
        }
Esempio n. 41
0
        private UIElement CreateShipSelectionItem(SpaceShip spaceShip)
        {
            var shipPanel = UILibrary.InstantiateElement<Panel>("ShipButton");
            var shipButton = shipPanel.FindVisualChildOfType<ButtonBase>("shipButton");
            var shipImage = shipButton.FindVisualChildOfType<ImageElement>("shipImage");

            // Update spaceship
            spaceShip.PowerImageElement = shipButton.FindVisualChildOfType<ImageElement>("powerImage");
            spaceShip.ControlImageElement = shipButton.FindVisualChildOfType<ImageElement>("controlImage");
            spaceShip.SpeedImageElement = shipButton.FindVisualChildOfType<ImageElement>("speedImage");

            var shipIndex = MainSceneImages.FindImageIndex(spaceShip.Name);
            ((SpriteFromSheet) shipImage.Source).CurrentFrame = shipIndex;

            shipButton.Click += delegate
            {
                activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name);
                ((SpriteFromSheet)currentShipImage.Source).CurrentFrame = shipIndex;

                PowerStatus = spaceShip.Power;
                ControlStatus = spaceShip.Control;
                SpeedStatus = spaceShip.Speed;

                CloseShipSelectPopup();
            };
            shipButton.IsEnabled = !spaceShip.IsLocked;

            if (spaceShip.IsLocked)
            {
                var lockIconElement = shipPanel.FindVisualChildOfType<ImageElement>("lockIcon");
                lockIconElement.Visibility = Visibility.Visible;
            }

            return shipPanel;
        }
Esempio n. 42
0
        private UniformGrid CreateShipButtonElement(SpaceShip spaceShip)
        {
            // Put the stat text block in a vertical uniform grid
            var statusTextGrid = new UniformGrid { Rows = 3, Margin = new Thickness(5f, -6f, 0, 0)};
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Power", 0));
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Control", 1));
            statusTextGrid.Children.Add(CreateShipStatusTextBlock("Speed", 2));

            // Put the stat stars in a vertical uniform grid
            spaceShip.PowerImageElement = CreateShipStatusStar(0);
            spaceShip.ControlImageElement = CreateShipStatusStar(1);
            spaceShip.SpeedImageElement = CreateShipStatusStar(2);

            var starGrid = new UniformGrid { Rows = 3 };
            starGrid.Children.Add(spaceShip.PowerImageElement);
            starGrid.Children.Add(spaceShip.ControlImageElement);
            starGrid.Children.Add(spaceShip.SpeedImageElement);
            starGrid.SetGridColumn(2);

            // Ship image
            var shipSprite = mainScreneImages[spaceShip.Name];
            var shipImageElement = new ImageElement { Source = shipSprite };
            shipImageElement.SetGridColumn(4);

            // Create the horizontal grid with two blank stretchable columns and add the text blocks, the starts and the ship image
            var shipContent = new Grid();
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star));
            shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            shipContent.RowDefinitions.Add(new StripDefinition());
            shipContent.LayerDefinitions.Add(new StripDefinition());

            shipContent.Children.Add(statusTextGrid);
            shipContent.Children.Add(starGrid);
            shipContent.Children.Add(shipImageElement);

            //
            var shipSelectFrameSprite = mainScreneImages["weapon_select_frame"];

            var shipButton = new Button
            {
                Name = spaceShip.Name,
                Content = shipContent,
                PressedImage = shipSelectFrameSprite,
                NotPressedImage = shipSelectFrameSprite,
                MouseOverImage = shipSelectFrameSprite,
                Padding = new Thickness(60, 20, 20, 20)
            };

            shipButton.Click += delegate
            {
                currentShipImage.Source = shipSprite;

                activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name);

                PowerStatus = spaceShip.Power;
                ControlStatus = spaceShip.Control;
                SpeedStatus = spaceShip.Speed;

                CloseShipSelectPopup();
            };

            shipButton.IsEnabled = !spaceShip.IsLocked;
            shipButton.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f));

            var buttonGrid = new UniformGrid { MaximumHeight = 100 };
            buttonGrid.Children.Add(shipButton);

            if (spaceShip.IsLocked)
            {
                var lockIconImage = mainScreneImages["lock_icon"];
                var lockIconElement = new ImageElement { Source = lockIconImage, StretchType = StretchType.Fill, };
                lockIconElement.SetPanelZIndex(1);
                buttonGrid.Children.Add(lockIconElement);
            }

            return buttonGrid;
        }
    static void Main()
    {
        var grid = new SpaceGrid();

        // Input stars
        for (int star = 0; star < 3; star++)
        {
            string[] starData = Console.ReadLine().Split(' ');

            grid.Stars.Add(new Star(starData[0],
               decimal.Parse(starData[1]),
               decimal.Parse(starData[2])));
        }

        // Input spaceship
        decimal[] spaceShipData = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
        var spaceShip = new SpaceShip(spaceShipData[0], spaceShipData[1]);

        // Input moves
        int moves = int.Parse(Console.ReadLine());

        var shipController = new SpaceShipController(grid, spaceShip);

        // Move ship
        for (int move = 0; move < moves; move++)
        {
            shipController.MoveShip();
        }
    }