// Use this for initialization
	IEnumerator Start () {
		spaceship = GetComponent<Spaceship> ();
		spaceship.Move (transform.up * -1);

		if (spaceship.canShot == false) {
			yield break;
		}

		while(true){
			for(int i=0;i<transform.childCount;i++){


				
				Transform shotPosition=transform.GetChild(i);

				spaceship.Shot(shotPosition);

			}

			yield return new WaitForSeconds(spaceship.shotDelay);

		}

			
	}
Example #2
0
 void Start()
 {
     mEmitter = GetComponent<ParticleEmitter>();
     mControl = Tools.FindInParents<Spaceship>(transform);
     mEmission = new Vector2(mEmitter.minEmission, mEmitter.maxEmission);
     mDir = transform.rotation * Vector3.back;
 }
Example #3
0
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();
        common = GetComponent<EnemyCommon>();
        common.Init();

        Transform s1 = common.CreateShotPosition();

        //SE関係
        audioSource = gameObject.GetComponent<AudioSource>();
        audioSource.clip = shootSE;
        //

        yield return new WaitForEndOfFrame();
        while (true)
        {
            audioSource.PlayOneShot(shootSE);
            common.Shot(s1, 0+30, power, speed, BulletManager.BulletType.BlossomBullet);
            common.Shot(s1, 60 + 30, power, speed, BulletManager.BulletType.BlossomBullet);
            common.Shot(s1, 120 + 30, power, speed, BulletManager.BulletType.BlossomBullet);
            common.Shot(s1, 180 + 30, power, speed, BulletManager.BulletType.BlossomBullet);
            common.Shot(s1, 240 + 30, power, speed, BulletManager.BulletType.BlossomBullet);
            common.Shot(s1, 300 + 30, power, speed, BulletManager.BulletType.BlossomBullet);

            yield return new WaitForSeconds(spaceship.shotDelay);
        }
    }
Example #4
0
        public void AddWorldObjectTest()
        {
            Planet planet1 = new Planet();
            WorldObject[] worldObjects = {planet1};

            World target = new World(worldObjects);
            WorldObject spaceship1 = new Spaceship();
            WorldObject spaceship2 = new Spaceship();
            WorldObject projectile = new Projectile();
            WorldObject explosion = new Explosion();
            WorldObject planet2 = new Planet();

            target.AddWorldObject(spaceship1);
            target.AddWorldObject(spaceship2);
            target.AddWorldObject(projectile);
            target.AddWorldObject(explosion);
            target.AddWorldObject(planet2);

            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(planet1));
            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(spaceship1));
            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(spaceship2));
            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(projectile));
            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(explosion));
            Assert.IsTrue((new List<WorldObject>(target.WorldObjects)).Contains(planet2));
        }
Example #5
0
 static void ObjectInitalizer()
 {
     Spaceship spaceship = new Spaceship()
     {
         Health = 30
     };
 }
Example #6
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();
        common = GetComponent<EnemyCommon>();
        enemy = GetComponent<Enemy>();
        common.Init();

        //
        audioSource = gameObject.GetComponent<AudioSource>();
        //

        st = common.CreateShotPosition();
        pt = FindObjectOfType<Party>().transform;

        yield return new WaitForEndOfFrame();

        yield return StartCoroutine("Stop");

        audioSource.PlayOneShot(skillSE);
        FindObjectOfType<MessageWindow>().showMessage("「星霜の記憶」");
        stones = new GameObject[5];
        stones[0] = (GameObject)Instantiate(stoneAlex,transform.position,Quaternion.identity);
        stones[1] = (GameObject)Instantiate(stoneGuylus,transform.position,Quaternion.identity);
        stones[2] = (GameObject)Instantiate(stoneNely,transform.position,Quaternion.identity);
        stones[3] = (GameObject)Instantiate(stoneRinmaru,transform.position,Quaternion.identity);
        stones[4] = (GameObject)Instantiate(stoneMedhu,transform.position,Quaternion.identity);

        StartCoroutine("RotateStones");

        StartCoroutine("Attack");
        StartCoroutine("StonesSummon");
    }
Example #7
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();
        common = GetComponent<EnemyCommon>();
        enemy = GetComponent<Enemy>();
        common.Init();

        //SE関係
        audioSource = gameObject.GetComponent<AudioSource>();
        audioSource.clip = shootSE;
        //

        s2 = common.CreateShotPosition();
        pt = FindObjectOfType<Party>().transform;

        //FindObjectOfType<MessageWindow>().showMessage("メテオ");

        yield return new WaitForEndOfFrame();

        //StartCoroutine("Stop");

        StartCoroutine("Attack1");

        yield break;
    }
Example #8
0
 public Formationmember(Spaceship ship, float range, bool left, Transform leader)
     : base(ship, range)
 {
     actual = Manouver.FormationMember;
     leaderBacker = leader;
     this.left = left;
 }
Example #9
0
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();
        common = GetComponent<EnemyCommon>();
        enemy = GetComponent<Enemy>();
        common.Init();

        //SE関係
        audioSource = gameObject.GetComponent<AudioSource>();
        //

        s1 = common.CreateShotPosition();

        Party p = FindObjectOfType<Party>();
        if(p){
            pt = FindObjectOfType<Party>().transform;
        }

        yield return new WaitForEndOfFrame();

        StartCoroutine("Stop");
        StartCoroutine("Attack1");

        yield break;
    }
Example #10
0
    // Use this for initialization
    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);
        }
    }
	public override void OnPickup (Spaceship spaceship) {
		base.OnPickup (spaceship);
		laserBeamEffect.transform.localScale = Vector3.one;
		laserBeamEffect.sourceTransform = spaceship.spaceshipModelPitchYaw.transform;
		laserBeamEffectScript.laserMaxDistance = laserLength;
		currentEnergy = maxEnergy;
		active = true;
	}
Example #12
0
 void Start()
 {
     mLight = GetComponent<Light>();
     mOriginal = mLight.intensity;
     mTarget = mOriginal;
     mControl = Tools.FindInParents<Spaceship>(transform);
     mDir = transform.rotation * Vector3.back;
 }
Example #13
0
    /// <summary>
    /// Locate the spaceship and the power generator components.
    /// </summary>
    void Start()
    {
        mRen = GetComponent<Renderer>();
        mMat = mRen.material;

        Transform t = transform;
        mShip = Tools.FindInParents<Spaceship>(t);
        if (generator == null) generator = Tools.FindInParents<PowerGenerator>(t);
    }
Example #14
0
File: Enemy.cs Project: saihe/Unity
 //Speedを変更
 public float setSpeed(int level)
 {
     spaceship = GetComponent<Spaceship>();
     print("Current Speed: " + spaceship.speed);
     float speedUp = 1.0f + (level * 0.4f);
     print("Speed UP: *" + speedUp);
     spaceship.speed = spaceship.speed * speedUp;
     return spaceship.speed;
 }
Example #15
0
    public Formation(Spaceship ship, float range)
    {
        this.ship = ship;
        rig = ship.GetComponent<Rigidbody>();
        this.range = range;
        actual = Manouver.Rotate;

        nextAction = Random.Range(range / 2, 3 * range / 4);
    }
Example #16
0
	public override void Initialize()
	{
		Transform parent = transform.parent;
		while(parent.parent != null)
		{
			parent = parent.parent;
		}
		ship = parent.GetComponentInChildren<Spaceship>();
	}
Example #17
0
File: Enemy.cs Project: saihe/Unity
 //shoDelayを変更
 public float setDelay(int level)
 {
     spaceship = GetComponent<Spaceship>();
     print("Current Speed: " + spaceship.speed);
     float speedUp = level * 0.9f;
     print("Speed UP: *" + speedUp);
     spaceship.shotDelay = spaceship.shotDelay * speedUp;
     return spaceship.shotDelay;
 }
Example #18
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship>();

        while(true) {
            spaceship.Shot(transform);
            spaceship.GetComponent<AudioSource>().Play();
            yield return new WaitForSeconds(spaceship.shotDelay);
        }
    }
Example #19
0
    public void Init()
    {
        GameObject oo = new GameObject();
        oo.name = "shotPositions";
        oo.transform.parent = transform;
        oo.transform.localPosition = new Vector3(0,0,0);
        shotPositions = oo.transform;

        spaceship = GetComponent<Spaceship>();
    }
Example #20
0
 void Start()
 {
     if (NetworkManager.IsMine(this))
     {
         mSc = GetComponent<Spaceship>();
     }
     else
     {
         Destroy(this);
     }
 }
Example #21
0
	// Use this for initialization
	void Start () {
		if (!LevelManager.GetLoadedLevel().name.Equals("Tutorial")) {
			label.gameObject.SetActive(false);
			overlay.enabled = false;
			this.gameObject.SetActive(false);
		}
		currentState = states[0];
		overlay.gameObject.SetActive(true);
		label.text = "Press R2 to boost!";
		spaceship = GameplayManager.spaceship;
	}
Example #22
0
 /// <summary>
 /// Only the missile's owner should be controlling it.
 /// </summary>
 void Start()
 {
     if (NetworkManager.IsMine(this))
     {
         mTrans = transform;
         mControl = Tools.FindInParents<Spaceship>(mTrans);
     }
     else
     {
         Destroy(this);
     }
 }
Example #23
0
 // pravi prowerka na vseki edin "wragheski" korab dali ne e udaril tozi na igracha
 private static bool CheckEveryEnemyShipBumpPlayer(List<Spaceship> enemyShips, Spaceship playerShip)
 {
     bool isEnShipBumpPlayes = false;
     foreach (var enemyShip in enemyShips)
     {
         isEnShipBumpPlayes = isEnemyShipBumpPlayer(playerShip, enemyShip);
         if (isEnShipBumpPlayes)
         {
             return isEnShipBumpPlayes;
         }
     }
     return isEnShipBumpPlayes;
 }
Example #24
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();
        common = GetComponent<EnemyCommon>();
        enemy = GetComponent<Enemy>();
        common.Init();

        st = common.CreateShotPosition();
        pt = FindObjectOfType<Party>().transform;

        yield return new WaitForSeconds(2.0f);

        StartCoroutine("Attack");
    }
Example #25
0
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship = GetComponent<Spaceship> ();

        while (true) {

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

            // shotDelay秒待つ
            yield return new WaitForSeconds (spaceship.shotDelay);
        }
    }
Example #26
0
    IEnumerator Start()
    {
        spaceship = GetComponent<Spaceship> ();

        while (true) {
            // 弾をプレイヤーと同じ位置/角度で作成
            //Instantiate (bullet, transform.position, transform.rotation);
            spaceship.Shot(transform);
            GetComponent<AudioSource>().Play();

            // 0.05秒待つ
            yield return new WaitForSeconds (spaceship.shotDelay);
        }
    }
        public void DoesNotOverwriteExistingObject()
        {
            var mapper = new XmlMapper<Spaceship>
                             {
                                 {"agencyName", o => o.Owner.Name},
                             };

            var xml = XElement.Parse(@"<spaceship agencyName=""NASA""/>");

            var original = new Spaceship {Owner = new Agency {Country = Country.USA}};
            var actual = mapper.ToObject(xml, original);

            Assert.Equal("NASA", actual.Owner.Name);
            Assert.Equal(Country.USA, actual.Owner.Country);
        }
Example #28
0
	// Use this for initialization
	void Start () {
		spaceship = GameplayManager.spaceship;
		currentLevel = LevelManager.GetLoadedLevel();

		isTutorialLevel = currentLevel.name.Equals("Tutorial");
		tutorialGui.SetActive(isTutorialLevel);

		RegisterEventHandlers();
//		ImmediatelyReloadCurrentPanelButtons();
		menuGui.SetActive(false);
		
		keyboardControlsSprite = Resources.Load<Sprite>(keyboardControlsSpriteFilename);
		controllerControlsSprite = Resources.Load<Sprite>(controllerControlsSpriteFilename);
//		HideAllMenus();
	}
Example #29
0
	public static void SpawnSpaceship(Spaceship spaceship) {
		
		if (spawnPoints.Length > 0) {
			if (!instance.firstTimeSpawning) {
				instance.StartCoroutine(HandleSpawnWait(spaceship));
			}
			else {
				instance.firstTimeSpawning = false;
				spaceship.transform.position = spawnPoints[lastCheckpointID].transform.position;
			}
			lastCheckpointID = (++lastCheckpointID)%spawnPoints.Length;
		}
		else {
			Debug.LogError("SpawnManager: No SpawnPoints; Spawning '" + spaceship + "' at world origin!");
		}
	}
Example #30
0
    void Awake()
    {
        if (enabled && NetworkManager.IsMine(this))
        {
            trans	= transform;
            unit	= GetComponent<GameUnit>();
            ship	= GetComponent<Spaceship>();
            shield	= GetComponentInChildren<DamageShield>();

            ship.name = "Player";
        }
        else
        {
            Destroy(this);
        }
    }
Example #31
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent <Spaceship> ();

        Move(transform.up * -1);

        if (spaceship.canShot == false)
        {
            yield break;
        }

        while (true)
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                Transform shotPosition = transform.GetChild(i);
                spaceship.Shot(shotPosition);
            }

            yield return(new WaitForSeconds(spaceship.shotDelay));
        }
    }
Example #32
0
 // Use this for initialization
 void Start()
 {
     RB        = GetComponent <Rigidbody>();
     spaceship = GetComponent <Spaceship>();
     if (RB == null)
     {
         RB        = transform.parent.GetComponent <Rigidbody>();
         spaceship = transform.parent.GetComponent <Spaceship>();
     }
     if (!gameObject.CompareTag("Player"))
     {
         Steering = GetComponent <SteeringBehaviours>();
         if (Steering == null)
         {
             Debug.LogError("[Vechicle]:: No instance of SteeringBehaviours on " + gameObject.name);
         }
         else
         {
             Steering.Vehicle = this;
         }
     }
 }
Example #33
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))                                        //Αν πατηθεί το αριστερό κουμπί του ποντικιοί επιστρέφει true
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition); //κρατάμε την θέση του ποντικιού
            RaycastHit hit;                                                     //Αποθηκεύει πληροφορίες από οτι χτυπάμε

            if (Physics.Raycast(ray, out hit, 100.0f))                          //επιστρέφει true αν χτυπήσουμε κάτι
            {
                Transform objectHit = hit.transform;
                if (hit.transform.GetComponent <Alien>() != null)       //Αν αυτό το αντικείμενο είναι αντικείμενο της κλάσης Alien τότε επιστρέφει true
                {
                    Alien alien = hit.transform.GetComponent <Alien>(); //Κρατάμε το αντικείμενο Alien σε μια μεταβλητή
                    if (alien.isVisible)                                //Αν αυτό το αντικείμενο είναι ορατό επιστρέφει true
                    {
                        alien.OnHit();                                  //Καλούμε την μέθοδο OnHit() της κλάσης Alien

                        AlienSource.Play();                             //Ο ήχος που έχουμε θέσει παίζει
                        Vector3 hitVector = new Vector3(alien.transform.position.x - 1f,
                                                        alien.transform.position.y,
                                                        alien.transform.position.z); //Κρατάμε σε μια μεταβλητή την θέση του αντικειμένου που χτυπήσαμε
                        hammer.Hit(hitVector);                                       //Την δίνουμε στο σφυρί
                        score++;                                                     //Αυξάνουμε το σκορ
                    }
                }
                else if (hit.transform.GetComponent <Spaceship>() != null)
                {
                    Spaceship spaceship = hit.transform.GetComponent <Spaceship>();
                    SpaceshipSource.Play();
                    spaceship.OnHit();
                    Vector3 hitVector = new Vector3(spaceship.transform.position.x - 1f,
                                                    spaceship.transform.position.y,
                                                    spaceship.transform.position.z); //Κρατάμε σε μια μεταβλητή την θέση του αντικειμένου που χτυπήσαμε
                    hammer.Hit(hitVector);                                           //Την δίνουμε στο σφυρί
                    score = score + 5;
                }
            }
        }
    }
Example #34
0
        private Spaceship FindNearestSpaceship(IList <Spaceship> list, System.Func <Spaceship, bool> predicate = null)
        {
            Spaceship nearest     = null;
            var       minDistance = float.MaxValue;

            foreach (var obj in list)
            {
                if (!obj.IsAlive)
                {
                    continue;
                }
                var distance = spaceship.ClosestRelativePosition(obj).magnitude;
                if ((nearest == null ||
                     distance < minDistance) &&
                    (predicate == null || predicate(obj)))
                {
                    nearest     = obj;
                    minDistance = distance;
                }
            }
            return(nearest);
        }
Example #35
0
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship    = GetComponent <Spaceship> ();
        prevMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        currentMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        while (true)
        {
            // 弾をプレイヤーと同じ位置/角度で作成
            if (Input.GetMouseButton(0))
            {
                spaceship.Shot(transform);
            }

            // ショット音を鳴らす
            GetComponent <AudioSource>().Play();

            // shotDelay秒待つ
            yield return(new WaitForSeconds(spaceship.shotDelay));
        }
    }
Example #36
0
        public static void Load()
        {
            List <VisualObject> game_objects = new List <VisualObject>();

            //for (var i = 0; i < 30; i++)
            //{
            //    game_objects.Add(new VisualObject(
            //        new Point(600, i * 20),
            //        new Point(15 - i, 20 - i),
            //        new Size(20, 20)));
            //}

            for (var i = 0; i < 10; i++)
            {
                game_objects.Add(new Star(
                                     new Point(600, (int)(i / 2.0 * 20)),
                                     new Point(-i, 0),
                                     10));
            }

            var       rnd                = new Random();
            const int asteroid_count     = 10;
            const int asteroid_size      = 25;
            const int asteroid_max_speed = 20;

            for (var i = 0; i < asteroid_count; i++)
            {
                game_objects.Add(new Asteroid(
                                     new Point(rnd.Next(0, Width), rnd.Next(0, Height)),
                                     new Point(-rnd.Next(0, asteroid_max_speed), 0),
                                     asteroid_size));
            }

            //__Bullet = new Bullet(200);
            __GameObjects = game_objects.ToArray();

            __Spaceship            = new Spaceship(new Point(10, 400), new Point(5, 5), new Size(10, 10));
            __Spaceship.Destroyed += OnShipDestroyed;
        }
Example #37
0
 // Update is called once per frame
 void Update()
 {
     if (gun == null || pickups == null)
     {
         Spaceship ship = GameplayManager.spaceship;
         if (ship != null)
         {
             gun     = ship.gun;
             pickups = ship.pickups;
         }
     }
     else if (gun.enabled)
     {
         energybarSprite.color = defaultGunColor;
         currentScale.x        = gun.currentEnergy / gun.maxEnergy * initialScale.x;
     }
     else if (pickups.currentPickup != null)
     {
         if (pickups.currentPickup is PickupFlamethrower)
         {
             energybarSprite.color = flamethrowerColor;
             PickupFlamethrower auroraCannon = pickups.currentPickup as PickupFlamethrower;
             currentScale.x = auroraCannon.currentEnergy / auroraCannon.maxEnergy * initialScale.x;
         }
         else if (pickups.currentPickup is PickupMissiles)
         {
             energybarSprite.color = missilesColor;
             PickupMissiles missiles = pickups.currentPickup as PickupMissiles;
             currentScale.x = ((float)missiles.currentShots) / missiles.maxShots * initialScale.x;
         }
         else if (pickups.currentPickup is PickupStickyMines)
         {
             energybarSprite.color = stickyMinesColor;
             PickupStickyMines stickyMines = pickups.currentPickup as PickupStickyMines;
             currentScale.x = ((float)stickyMines.currentShots) / stickyMines.maxShots * initialScale.x;
         }
     }
     this.transform.localScale = currentScale;
 }
Example #38
0
    private string SpaceshipsToJson()
    {
        StringBuilder sb = new StringBuilder();
        StringWriter  sw = new StringWriter(sb);

        using (JsonWriter writer = new JsonTextWriter(sw))
        {
            writer.Formatting = Formatting.None;
            writer.WriteStartArray();

            foreach (GameObject spaceshipGameObject in spaceships)
            {
                Spaceship spaceship = spaceshipGameObject.GetComponent <Spaceship>();
                writer.WriteStartObject();

                writer.WritePropertyName("name");
                writer.WriteValue(spaceshipGameObject.name);

                writer.WritePropertyName("model");
                writer.WriteValue(spaceship.getModel());

                writer.WritePropertyName("owner");
                writer.WriteValue(spaceship.GetOwnerName());

                writer.WritePropertyName("spaceshipMain");
                writer.WriteRawValue(JsonUtility.ToJson(spaceship));

                writer.WritePropertyName("position");
                writer.WriteStartArray();
                writer.WriteRawValue(spaceshipGameObject.transform.position.ToString().Replace("(", "").Replace(")", ""));
                writer.WriteEndArray();

                writer.WriteEndObject();
            }

            writer.WriteEndArray();
        }
        return(sb.ToString());
    }
Example #39
0
        public void Scan_SpaceshipInSecondQuadrant_BothShips()
        {
            Spaceship spaceship  = new Spaceship("100", "spaceship", -10, 10);
            Spaceship spaceship1 = new Spaceship("101", "spaceship", -20, 20);
            Spaceship spaceship2 = new Spaceship("102", "spaceship", -30, 5);

            spaceship2.Capacity = 1000;


            String presentInScan = "";

            presentInScan = spaceship.Scan(135, 90, 50);

            presentInScan = presentInScan.Replace(" ", string.Empty);


            if (StringDistance.Compute(presentInScan, spaceship1.Code) > 0 &&
                StringDistance.Compute(presentInScan, spaceship1.Code) > 0)
            {
                Assert.Pass();
            }
        }
Example #40
0
    // Use this for initialization
    IEnumerator Start()
    {
        spaceship = GetComponent <Spaceship>();

        Move(transform.up * -1);
        if (!spaceship.canShot)
        {
            yield break;
        }


        //while (true)
        //{
        //    for(int i = 0; i < transform.childCount; i++)
        //    {
        //        Transform shotPosition = transform.GetChild(i);

        //        spaceship.Shoot();
        //    }
        //    yield return new WaitForSeconds(spaceship.shotDelay);
        //}
    }
Example #41
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        Spaceship spaceship = other.gameObject.GetComponent <Spaceship>();

        if (spaceship != null)
        {
            spaceship.TakeDamage(Random.Range(minDamage, maxDamage));
        }

        if (other.gameObject.GetComponent <Bullet>() != null)
        {
            TakeDamage(1f);
            return;
        }

        if (other.gameObject.GetComponent <Rocket>() != null)
        {
            TakeDamage(3f);
            return;
        }

        Destroy();
    }
Example #42
0
    void InitNeuralNetworks()
    {
        if (PopulationSize % 2 != 0)
        {
            PopulationSize = 4;
        }

        _nets.Clear();
        for (int i = 0; i < PopulationSize; i++)
        {
            NeuralNetwork net = new NeuralNetwork(_topology);
            _nets.Add(net);
        }

        _spaceships.Clear();
        for (int i = 0; i < PopulationSize; i++)
        {
            Spaceship spaceship = Instantiate(SpaceshipPrefab).GetComponent <Spaceship>();
            spaceship.Init(_nets[i], Planet.transform, MatchTime);
            _spaceships.Add(spaceship);
        }
        ResetSpaceships();
    }
Example #43
0
        public static Spaceship Generate()
        {
            var spaceShip = new Spaceship
            {
                Id             = RandomGenerator.GetId(),
                Name           = "Fury - A" + RandomGenerator.RandomName(),
                MaxSpeed       = 6,
                Speed          = 6,
                Classification = CelestialObjectTypes.SpaceshipNpcEnemy.ToInt(),
                IsScanned      = false,
                Signature      = 12
            };

            spaceShip.Modules.Add(Factory.CreateShieldModule(spaceShip.Id, "SSM5001"));
            spaceShip.Modules.Add(Factory.CreateGeneralModule(spaceShip.Id, "GRM5002"));
            spaceShip.Modules.Add(Factory.CreateWeaponModule(spaceShip.Id, "WRS5003"));
            spaceShip.Modules.Add(Factory.CreateMicroWarpDrive(spaceShip.Id, "PMV5002"));
            //CreateMicroWarpDrive

            spaceShip.Initialization();

            return(spaceShip);
        }
Example #44
0
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship = GetComponent <Spaceship>();

        // ローカル座標のY軸のマイナス方向に移動する
        Move(transform.up * -1);
        if (!spaceship.canShot)
        {
            yield break;
        }

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

            yield return(new WaitForSeconds(spaceship.shotDelay));
        }
    }
Example #45
0
        public async Task <Spaceship> Add(SpaceshipDto dto)
        {
            Spaceship      spaceship = new Spaceship();
            FileToDatabase file      = new FileToDatabase();

            spaceship.Id         = Guid.NewGuid();
            spaceship.CrewSize   = dto.CrewSize;
            spaceship.Armament   = dto.Armament;
            spaceship.Role       = dto.Role;
            spaceship.CreatedAt  = DateTime.Now;
            spaceship.ModifiedAt = DateTime.Now;

            if (dto.Files != null)
            {
                file.ImageData = UploadFile(dto, spaceship);
            }

            await _context.Spaceship.AddAsync(spaceship);

            await _context.SaveChangesAsync();

            return(spaceship);
        }
    private void Update()
    {
        if (!GameManager.Instance.PlayerAlive)
        {
            SpriteRenderer.enabled = false;
            return;
        }

        Spaceship subject = GameManager.Instance.PlayerController;
        Dictionary <int, RadarProfile> radarProfiles = Omniscience.Instance.PingRadar();

        if (subject.HasValidTarget && radarProfiles.ContainsKey(subject.TargetUID))
        {
            SpriteRenderer.enabled = true;
            transform.position     = radarProfiles[subject.TargetUID].Position;
            float angle = (transform.eulerAngles.z + TurnRate * Time.deltaTime) % 360;
            transform.eulerAngles = new Vector3(0, 0, angle);
        }
        else
        {
            SpriteRenderer.enabled = false;
        }
    }
Example #47
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            Spaceship spaceshipInstance = other.GetComponent <Spaceship>();
            spaceshipInstance.RemoveLife();
        }

        if (other.CompareTag("WorldBounds"))
        {
            if (Pattern == eBehaviour.LINEAR_SWIPE)
            {
                if (firstRebound)
                {
                    firstRebound = false;
                }
                else
                {
                    movement.z = -movement.z;
                }
            }
        }
    }
        private void AddDetailItem(Detail detail, Spaceship spaceship, int level = 1, bool isBody = true)
        {
            DetailItem newItem = new DetailItem(detail, level);

            if (detail is Engine engine)
            {
                newItem = new EngineItem(engine, level);
            }
            else if (detail is Tank tank)
            {
                newItem = new TankItem(tank, level);
            }
            newItem.detachButton.Click += (o, e) => { world.Detach(detail); UpdateList(); };
            if (isBody)
            {
                newItem.detachButton.Dispose();
            }
            layoutFlowPanel.Controls.Add(newItem);
            foreach (Detail child in detail.Children)
            {
                AddDetailItem(child, spaceship, level + 1, false);
            }
        }
Example #49
0
    public void SetTexts()
    {
        GameManager gm     = GameManager.Get();
        Spaceship   player = gm.player.GetComponent <Spaceship>();

        if (score != gm.score)
        {
            score          = gm.score;
            scoreText.text = "SCORE " + score.ToString("0000");
        }
        if (fuel != player.fuel)
        {
            fuel          = player.fuel;
            fuelText.text = "FUEL " + fuel.ToString("0000");
        }
        if (verticalSpeed != (int)player.velocity.y)
        {
            verticalSpeed          = (int)player.velocity.y;
            verticalSpeedText.text = "VERTICAL SPEED " + verticalSpeed.ToString();
        }
        if (horizontalSpeed != (int)player.velocity.x)
        {
            horizontalSpeed          = (int)player.velocity.x;
            horizontalSpeedText.text = "HORIZONTAL SPEED " + horizontalSpeed.ToString();
        }
        if (altitude != (int)player.altitude)
        {
            altitude          = (int)player.altitude;
            altitudeText.text = "ALTITUDE " + altitude.ToString();
        }
        if (gm.playing)
        {
            string minutes = ((int)gm.currentGameTime / 60).ToString();
            string seconds = (gm.currentGameTime % 60).ToString("00");
            timeText.text = minutes + ":" + seconds;
        }
    }
    IEnumerator Start()
    {
        // Spaceshipコンポーネントを取得
        spaceship = GetComponent <Spaceship>();

        sprite = GetComponent <SpriteRenderer>();

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

        rad = Mathf.Atan2(TargetObjects[intCurrentNum].transform.position.y - transform.position.y,
                          TargetObjects[intCurrentNum].transform.position.x - transform.position.x);

        while (true)
        {
            if (blnBossDestroy == true)
            {
                break;
            }

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

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

            // shotDelay秒待つ
            yield return(new WaitForSeconds(spaceship.shotDelay));
        }
    }
Example #51
0
        internal static SpaceshipData newSpaceshipData(this MemoryCard memoryCard, Spaceship.Rarity rarity, Color?color = null)
        {
            SpaceshipData spaceshipData = memoryCard.insert <SpaceshipData>();

            if (color == null)
            {
                color = Spaceship.randomColor();
            }

            spaceshipData.colorRed   = color.Value.R / 255.0f;
            spaceshipData.colorGreen = color.Value.G / 255.0f;
            spaceshipData.colorBlue  = color.Value.B / 255.0f;
            spaceshipData.baseDamage = GameMath.randomBaseDamage(rarity);
            spaceshipData.level      = 1;
            spaceshipData.baseLife   = GameMath.randomBaseLife(rarity);
            spaceshipData.baseRange  = GameMath.randomBaseRange(rarity);
            spaceshipData.baseSpeed  = GameMath.randomBaseSpeed(rarity);
            spaceshipData.rarity     = rarity.GetHashCode();

            spaceshipData.skin = SKNode.random.Next(Spaceship.skins.Count());
            spaceshipData.xp   = 0;

            return(spaceshipData);
        }
        public void MovePeopleToShip(int id)
        {
            Planet    currentPlanet = planetRepo.Read().FirstOrDefault(p => p.Id.Equals(id));
            Spaceship loadShip      = spaceShipRepo.Read().First();

            int placesLeft = loadShip.MaxCapacity - loadShip.Utilization;

            if (placesLeft > 0 || currentPlanet.Population < 1)
            {
                if (currentPlanet.Population >= placesLeft)
                {
                    loadShip.Utilization     += placesLeft;
                    currentPlanet.Population -= placesLeft;
                }
                else if (currentPlanet.Population < placesLeft)
                {
                    loadShip.Utilization    += (int)currentPlanet.Population;
                    currentPlanet.Population = 0;
                }
            }

            spaceShipRepo.Update(loadShip);
            planetRepo.Update(currentPlanet);
        }
    //========== メンバ変数 ==========
    //None


    IEnumerator Start()
    {
        // コンポーネントを取得
        followerMng    = FindObjectOfType <FollowerManager> ();
        playerlife     = GetComponent <Life> ();
        managerObj     = FindObjectOfType <Manager> ();
        shotTypeObj    = GetComponent <ShotType> ();
        spaceship      = GetComponent <Spaceship> ();
        superShot      = GetComponent <SuperShot> ();
        audioObj       = FindObjectOfType <AudioManager> ();
        shotChangerObj = FindObjectOfType <ShotTypeChanger> ();


        //初期の弾の種類を設定
        shotTypeObj.setDefaultShot();

        // 弾をプレイヤーと同じ位置/角度で作成
        while (true)
        {
            int selectedShotType = shotTypeObj.getShotType();
            Attack(selectedShotType);
            yield return(new WaitForSeconds(shotTypeObj.getPlayerShotDelay()));
        }
    }
    public void Initialize(HarpoonAttackManager manager, Spaceship attacker, Vector2 position, Vector2 direction, Vector2 initialVelocity, float speed, float range, float duration)
    {
        Manager  = manager;
        Attacker = attacker;
        Speed    = speed;
        Range    = range;
        Duration = duration;

        float angle = Vector2.SignedAngle(Vector2.right, direction);

        Hook = Instantiate(GeneralPrefabs.Instance.HarpoonHook, position + (MINIMUM_DISTANCE_JOINT_LENGTH * direction.normalized), Quaternion.Euler(0, 0, angle));
        Hook.transform.SetParent(transform);
        HookVelocity = Speed * direction.normalized + initialVelocity;
        Hook.GetComponent <Rigidbody2D>().velocity = HookVelocity;
        Hook.GetComponent <HarpoonHookController>().AssignManager(manager);
        RootLink = Hook;

        TotalDistanceJoint = Attacker.gameObject.AddComponent <DistanceJoint2D>();
        TotalDistanceJoint.connectedBody = Hook.GetComponent <Rigidbody2D>();
        TotalDistanceJoint.autoConfigureConnectedAnchor = false;
        TotalDistanceJoint.anchor                = Vector2.zero;
        TotalDistanceJoint.connectedAnchor       = Hook.GetComponent <HarpoonLinkData>().ConnectedAnchorOffset;
        TotalDistanceJoint.autoConfigureDistance = false;
        TotalDistanceJoint.distance              = MINIMUM_DISTANCE_JOINT_LENGTH;
        TotalDistanceJoint.maxDistanceOnly       = true;

        RootDistanceJoint = Attacker.gameObject.AddComponent <DistanceJoint2D>();
        RootDistanceJoint.connectedBody = Hook.GetComponent <Rigidbody2D>();
        RootDistanceJoint.autoConfigureConnectedAnchor = false;
        RootDistanceJoint.connectedAnchor       = Hook.GetComponent <HarpoonLinkData>().ConnectedAnchorOffset;
        RootDistanceJoint.autoConfigureDistance = false;
        RootDistanceJoint.distance        = MINIMUM_DISTANCE_JOINT_LENGTH;
        RootDistanceJoint.maxDistanceOnly = true;

        RootLinkIsVertical = false;
    }
Example #55
0
        public byte[] UploadFile(SpaceshipDto dto, Spaceship spaceship)
        {
            if (dto.Files != null && dto.Files.Count > 0)
            {
                foreach (var photo in dto.Files)
                {
                    using (var target = new MemoryStream())
                    {
                        FileToDatabase objfiles = new FileToDatabase
                        {
                            Id          = Guid.NewGuid(),
                            ImageTitle  = photo.FileName,
                            SpaceshipId = spaceship.Id
                        };

                        photo.CopyTo(target);
                        objfiles.ImageData = target.ToArray();

                        _context.FileToDatabase.Add(objfiles);
                    }
                }
            }
            return(null);
        }
        public void SetsElementsFromCollection()
        {
            var astronautMapper = new XmlMapper <Astronaut>
            {
                { "name", a => a.Name },
            };

            var mapper = new XmlMapper <Spaceship>
            {
                { "crew/member", o => o.Crew, astronautMapper },
            };

            var spaceship = new Spaceship
            {
                Crew = new List <Astronaut>
                {
                    new Astronaut {
                        Name = "Buzz Aldrin"
                    },
                    new Astronaut {
                        Name = "Neil Armstrong"
                    },
                }
            };


            var actual = mapper.ToXml(spaceship, "spaceship");

            var crew = actual.Element("crew");

            Assert.NotNull(crew);
            Assert.Equal(2, crew.Elements("member").Count());

            Assert.Contains("Buzz Aldrin", crew.Elements("member").Select(x => x.Attribute("name").Value));
            Assert.Contains("Neil Armstrong", crew.Elements("member").Select(x => x.Attribute("name").Value));
        }
Example #57
0
        private static bool isPlayerShipHitEnemy( List<Shell> shells,List<Spaceship> enemyShips)
        {
            bool IsEnemyHit = false;
            for (int j = 0; j < enemyShips.Count; j++)
            {
                Shell currentShell = new Shell();
                Spaceship enemyShip = enemyShips[j];
                string[] EnemySpaceshipLines = enemyShip.spaceshipDesign.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

                int playerHight = EnemySpaceshipLines.GetLength(0);
                int playerWidth = EnemySpaceshipLines[1].Length;

                for (int i = 0; i < shells.Count; i++)
                {
                    currentShell = shells[i];
                    if (currentShell.y >= enemyShip.y && currentShell.y <= enemyShip.y + playerHight - 1
                        && currentShell.x >= enemyShip.x && currentShell.x <= enemyShip.x + playerWidth - 1)
                    {

                        if (EnemySpaceshipLines[currentShell.y - enemyShip.y][currentShell.x - enemyShip.x] != ' ')
                        {
                            IsEnemyHit = true;
                            enemyShips.Remove(enemyShip);// премахваме вражеският кораб от списъка с кораби
                            foreach (var line in EnemySpaceshipLines)
                            {
                                enemyShip.spaceshipDesign = "  ";
                            }

                            UpdateScreen(); //  би трябвало екрана да се обнови след като се "изтрие" ударения кораб
                            return IsEnemyHit;
                        }
                    }
                }
            }
            return IsEnemyHit;
         }
Example #58
0
    /// <summary>
    /// Occurs when there is a collision between a projectile shot by
    /// the shooter and a interactive game object.
    /// It destroys the <param name="other"/> collider if it's an
    /// ennemy spaceship.
    /// Projectile destroys himself by encountering another collider.
    /// </summary>
    /// <param name="other">A game object with a 2D collider which got hit by a projectile.</param>
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }
        if (other.tag == "Bonus")
        {
            return;
        }
        if (other.tag == "Player")
        {
            Spaceship spaceship = other.GetComponent <Spaceship>();
            if (spaceship == shooter)
            {
                Destroy(gameObject);
                return;
            }

            Destroy(other.gameObject);
        }

        Destroy(gameObject);
    }
Example #59
0
        // end of STARS !
        
        // pravi prowerka dali ima sblusuk meghdu vragheskata strelba i koraba na igracha
        private static bool isEnemyShipHitPlayer(Spaceship playerShip, List<List<int>> shots)
        {
            bool isPlayerHited = false;
            string[] playerSpaceshipLines = playerShip.spaceshipDesign.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            int playerHight = playerSpaceshipLines.GetLength(0);
            int playerWidth = playerSpaceshipLines[1].Length;
            //prowerqwa za wseki edin shot ot lista dali ne e uluchil koraba na igracha
            for (int i = 0; i < shots.Count; i++)
            {
                if (shots[i][1] >= playerShip.y && shots[i][1] <= playerShip.y + playerHight - 1
                    && shots[i][0] >= playerShip.x && shots[i][0] <= playerShip.x + playerWidth - 1)
                {
                    //proverqwa w mqstoto na sblusuka meghdu shota i koraba dali ima simvoli w matricata na koraba
                    if (playerSpaceshipLines[shots[i][1] - playerShip.y][shots[i][0] - playerShip.x] != ' ')
                    {
                        isPlayerHited = true;
                        //playerShip.lives--; // towa moghe i na drugo mqsto da se sloghi
                        return isPlayerHited;
                    }
                }
            }
            return isPlayerHited;
        }
 public void init()
 {
     FindBarrel();
     // 设定移动速度
     if (followTarget != null && useTargetSpeed)
     {
         Spaceship spaceshipScript = followTarget.GetComponent <Spaceship>();
         Option    optionScript    = followTarget.GetComponent <Option>();
         if (spaceshipScript != null)
         {
             speed = spaceshipScript.speed;
         }
         else if (optionScript != null)
         {
             speed = optionScript.speed;
         }
     }
     // 计算跟踪数组长度
     trackLength = (int)(followDistance / speed / 0.015);
     // 初始化耿宗数组
     InitTrack();
     //
     transform.position = followTarget.transform.position;
 }