Пример #1
0
    private void Awake()
    {
        _spaceshipController = gameObject.GetComponent <SpaceshipController>();

        var cameraGameObject = GameObject.FindWithTag("MainCamera");

        if (cameraGameObject == null)
        {
            Debug.Log("Cannot find 'MainCamera' gameObject");
        }
        else
        {
            _camera = cameraGameObject.GetComponent <Camera>();
        }

        var gameController = GameObject.FindWithTag("GameController");

        if (gameController == null)
        {
            Debug.Log("Cannot find 'GameController' gameObject");
        }
        else
        {
            _gameController = gameController.GetComponent <GameController>();
            _shootArea      = _gameController.ShootArea;
        }
    }
Пример #2
0
        public void Init(SpaceshipController spaceship)
        {
            _weaponsLogos = new Dictionary <IWeapon, Image>();

            IWeapon[] weapons = spaceship.Weapons;
            float     width   = _logoPrefab.rectTransform.rect.width + _spacing;
            float     y       = _logosPanelAnchor.transform.position.y;

            for (int i = 0; i < weapons.Length; i++)
            {
                IWeapon weapon = weapons[i];
                float   x      = _logosPanelAnchor.position.x;
                x += (i + 0.5f - (weapons.Length / 2.0f)) * width;

                Vector2 position = new Vector2(x, y);
                Image   image    = Instantiate(_logoPrefab, position, Quaternion.identity, _logosPanelAnchor);

                image.sprite = weapon.WeaponLogo;

                _weaponsLogos.Add(weapon, image);

                List <IWeaponComponent> components = weapon.WeaponComponents;

                foreach (IWeaponComponent component in components)
                {
                    component.GenerateUI(_logoPrefab, image.transform);
                }
            }

            _selectionForeground        = Instantiate(_logoPrefab, _logosPanelAnchor.position, Quaternion.identity, _logosPanelAnchor);
            _selectionForeground.sprite = _selectionForegroundSprite;

            spaceship.WeaponSet += OnWeaponSet;
        }
Пример #3
0
        public EngineSubsystem(SpaceshipController _spaceship) : base(_spaceship)
        {
            ExecuteType = EnumSubsystemExecuteType.FixedUpdate;

            rigidbody = _spaceship.Rigidbody;
            transform = rigidbody.transform;
        }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     mr        = GetComponent <MeshRenderer>();
     mat       = mr.materials[0];
     offset    = mat.mainTextureOffset;
     spaceship = GameObject.FindGameObjectWithTag("Spaceship").GetComponent <SpaceshipController>();
 }
Пример #5
0
        /// <summary>
        /// This method runs in an endless cycle in the Azure Worker Role.
        /// Its task is to periodically poll the player's status and call the ShipLanded() and ShipFlying()
        /// methods to execute the player's code.
        /// </summary>
        private static async Task Run(AndromedaServiceClient client, Guid playerGuid)
        {
            //This call tells the Andromeda server whether the player is running his code from the
            //emulator or from Azure.
            //As stated in the game's rules, only code running from Azure is eligible for the competition's prizes.
            //Naturally this call can be faked very easily, but we'll manually check the winners by their IP
            //addresses, so this is not worth doing. :)
            await client.RegisterRunLocationAsync(playerGuid, false); //TODO: RoleEnvironment.IsEmulated);

            //Load all the ships of the player
            var spaceshipGuids = await client.GetOwnedShipsAsync(playerGuid);

            //Check the status of each ship and call the appropriate control method
            foreach (var spaceshipGuid in spaceshipGuids)
            {
                //We try to download the list of the player's ships (the server will throw an exception
                //if the player ID is invalid
                var spaceship = await client.GetSpaceshipStatusAsync(spaceshipGuid);

                //Ship list successfully downloaded. If the ship is on a planet, call ShipLanded(); otherwise
                //call ShipFlying().
                NavigationComputer.CommandedShip = spaceshipGuid; //Point the NavigationComputer to this ship
                if (!spaceship.IsInTransit)
                {
                    await SpaceshipController.ShipLandedAsync(spaceshipGuid);
                }
                else
                {
                    await SpaceshipController.ShipFlying(spaceshipGuid);
                }
            }
        }
    /// <summary>
    /// Mark intercepts with the designated symbols and return a list of intercepts found
    /// for the predicted path of ship intersecting with the path of the target.
    /// </summary>
    ///
    /// <param name="ship">The ship</param>
    /// <param name="target">The target</param>
    ///
    /// <returns>The intercepts.</returns>
    private List <TrajectoryData.Intercept> MarkIntercepts(SpaceshipController shipCtrl, NBody target)
    {
        // delta distance is scale dependent. For now use an ugly *if*
        float deltaDistance = 1f;

        if (GravityEngine.Instance().units == GravityScaler.Units.ORBITAL)
        {
            deltaDistance = 20f;
        }
        const float deltaTime    = 2f;
        const float rendezvousDT = 1f;

        trajIntercepts.spaceship = shipCtrl.GetTrajectory();
        Trajectory trajectory = target.GetComponentInChildren <Trajectory>();

        if (trajectory == null)
        {
            Debug.LogError("Target requires a child with a trajectory component");
            return(new List <TrajectoryData.Intercept>());
        }
        trajIntercepts.target = trajectory;
        trajIntercepts.ComputeAndMarkIntercepts(deltaDistance, deltaTime, rendezvousDT);
        intercepts = trajIntercepts.GetIntercepts();
        return(intercepts);
    }
    public IEnumerator _13_SpaceshipIsWarpedToTheOtherSideOfTheScreenAfterMovingOffscreen()
    {
        ClearScene();
        Object.Instantiate(cameraPrefab);
        SpaceshipController spaceship = Object.Instantiate(spaceshipPrefab, Vector2.right * 100.0f, Quaternion.identity).GetComponent <SpaceshipController>();

        yield return(null);

        Assert.IsTrue(spaceship.transform.position.x < 0.0f);
        spaceship.transform.position = Vector2.left * 100.0f;

        yield return(null);

        Assert.IsTrue(spaceship.transform.position.x > 0.0f);
        spaceship.transform.position = Vector2.up * 100.0f;

        yield return(null);

        Assert.IsTrue(spaceship.transform.position.y < 0.0f);
        spaceship.transform.position = Vector2.down * 100.0f;

        yield return(null);

        Assert.IsTrue(spaceship.transform.position.y > 0.0f);
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     motionBlurFilter    = Camera.main.GetComponent <MotionBlur>();
     fisheye             = Camera.main.GetComponent <Fisheye>();
     depthOfField        = Camera.main.GetComponent <DepthOfField>();
     spaceshipController = GetComponent <SpaceshipController>();
 }
 void Start()
 {
     if (startEnabled)
     {
         spaceship = Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.identity).GetComponent <SpaceshipController>();
     }
 }
Пример #10
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         SpaceshipController spaceship = other.GetComponent <SpaceshipController>();
         if (spaceship != null)
         {
             spaceship.ChangeHealth(-1);
         }
         Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
     }
     else
     {
         Destroy(other.gameObject);
     }
     if (hit < n_hit)
     {
         hit++;
     }
     else
     {
         Instantiate(explosion, transform.position, transform.rotation);
         var obj = Instantiate(floatingText, scorePosition.position, Quaternion.identity);
         GameController.Instance.AddScore(scoreValue);
         obj.GetComponent <FloatingText>().value = scoreValue;
         Destroy(gameObject);
         GameObject[] enermies = GameObject.FindGameObjectsWithTag("Enemy");
         source.PlayOneShot(audioClip);
         foreach (GameObject enermy in enermies)
         {
             Destroy(enermy);
         }
         GameController.Instance.DiplayWinningScreen();
     }
 }
    public void _12_SpaceshipMovesAccordingToItsDirectionVector()
    {
        ClearScene();
        SpaceshipController spaceship = Object.Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.Euler(0.0f, 0.0f, 0.0f)).GetComponent <SpaceshipController>();

        spaceship.Thrust(1.0f);
        spaceship.Move();
        Assert.IsTrue(spaceship.transform.position.y >= 0.0f && spaceship.transform.position.x == 0.0f);
    }
    public void _10_SpaceshipCanMove()
    {
        ClearScene();
        SpaceshipController spaceship = Object.Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.identity).GetComponent <SpaceshipController>();

        spaceship.direction = Vector2.up;
        spaceship.Move();
        Assert.IsTrue(spaceship.transform.position != Vector3.zero);
    }
    public void _14_SpaceshipCanFireProjectiles()
    {
        ClearScene();
        SpaceshipController spaceship = Object.Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.Euler(0.0f, 0.0f, 0.0f)).GetComponent <SpaceshipController>();

        spaceship.Shoot();
        ProjectileController projectile = Object.FindObjectOfType <ProjectileController>();

        Assert.IsTrue(projectile != null);
    }
Пример #14
0
    void Start()
    {
        rb          = gameObject.GetComponent <Rigidbody2D>();
        spaceshipRb = GameObject.FindGameObjectWithTag("Spaceship").GetComponent <SpaceshipController>();
        gameObject.GetComponent <SpriteRenderer> ().sprite = planetSkin[Random.Range(0, planetSkin.Length - 1)];
        float size = Random.Range(2, 5);

        transform.localScale = new Vector2(size, size);
        GetComponent <SpriteRenderer>().sortingLayerName = "Background";
    }
Пример #15
0
    public virtual void Initialize(ItemData _data, SpaceshipController _spaceship)
    {
        data      = _data;
        spaceship = _spaceship;

        ApplySelfParameters();

        isShootPreparation = false;

        ActivateWeapon();
    }
Пример #16
0
 public virtual void Initialize(SpaceshipController _spaceship)
 {
     if (_spaceship != null)
     {
         spaceship = _spaceship;
     }
     else
     {
         spaceship = FindSpaceshipController();
     }
 }
Пример #17
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.tag == "Player")
     {
         SpaceshipController spaceship = collider.GetComponent <SpaceshipController>();
         if (spaceship != null)
         {
             spaceship.ChangeHealth(1);
             Destroy(gameObject);
         }
     }
 }
    public IEnumerator _04_GameManagerCanSpawnSpaceshipOnLoad()
    {
        ClearScene();
        Object.Instantiate(gameManagerPrefab).GetComponent <GameManager>();
        GameManager.InitializeTestingEnvironment(true, false, false, false, false);

        yield return(null);

        SpaceshipController spaceship = Object.FindObjectOfType <SpaceshipController>();

        Assert.IsTrue(spaceship != null);
    }
Пример #19
0
 void OnTriggerEnter(Collider collider)
 {
     if (collider.tag == "Player")
     {
         SpaceshipController spaceship = collider.GetComponent <SpaceshipController>();
         if (spaceship != null)
         {
             //Power up
             spaceship.powerLevel++;
             Destroy(gameObject);
         }
     }
 }
Пример #20
0
    //------------------------------------------------------------------
    #region TEST
    protected virtual void UpdateShowedParameters()
    {
#if UNITY_EDITOR
        if (!spaceship)
        {
            spaceship = FindSpaceshipController();
        }

        Armor  = spaceship.GetArmor();
        Shield = spaceship.GetShield();
        Speed  = spaceship.GetSpeed();
#endif
    }
        private void UpdateLocalInput()
        {
            var player = matchManager.playerManager.GetPlayerById(localPlayerId);

            if (player == null)
            {
                return;
            }

            var playerSpaceship = matchManager.entityManager.TryGetEntity(player.SpaceshipPointer);

            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                if (playerSpaceship == null)
                {
                    SendLocalPlayerCommand(new Commands.Respawn(), true);
                }
            }

            if (playerSpaceship != null)
            {
                var move = 0;
                if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
                {
                    move = 1;
                }
                else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
                {
                    move = -1;
                }

                var rotation = 0;
                if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
                {
                    rotation = 1;
                }
                else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
                {
                    rotation = -1;
                }

                var controls = SpaceshipController.PackControls(move, rotation, Input.GetKey(KeyCode.Space), Input.GetKey(KeyCode.E));

                SendLocalPlayerCommand(new Commands.SetSpaceshipControls {
                    shipEntityPointer = player.SpaceshipPointer, controls = controls
                }, false);
            }
        }
Пример #22
0
    public override void OnInspectorGUI()
    {
        SpaceshipController flightCC = (SpaceshipController)target;

        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Objects", "For the main ship Game Object and weapons"));

        flightCC.actual_model = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Ship Game Object", "Point this to the Game Object that actually contains the mesh for the ship. Generally, this is the first child of the empty container object this controller is placed in."), flightCC.actual_model, typeof(GameObject), true);
        //flightCC.weapon_hardpoint_1 = (Transform) EditorGUILayout.ObjectField(new GUIContent("Weapon Hardpoint", "Transform for the barrel of the weapon"), flightCC.weapon_hardpoint_1, typeof(Transform), true);
        //flightCC.bullet = (GameObject) EditorGUILayout.ObjectField(new GUIContent("Projectile Game Object", "Projectile that will be fired from the weapon hardpoint."), flightCC.bullet, typeof(GameObject), true);

        //new GUIContent("", "")
        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Core Movement", "Controls for the various speeds for different operations."));

        flightCC.speed                   = EditorGUILayout.FloatField(new GUIContent("Base Speed", "Primary flight speed, without afterburners or brakes"), flightCC.speed);
        flightCC.slow_speed              = EditorGUILayout.FloatField(new GUIContent("Brake Speed", "Speed when the button for negative thrust is being held down"), flightCC.slow_speed);
        flightCC.afterburner_speed       = EditorGUILayout.FloatField(new GUIContent("Afterburner Speed", "Speed when the button for positive thrust is being held down"), flightCC.afterburner_speed);
        flightCC.thrust_transition_speed = EditorGUILayout.FloatField(new GUIContent("Thrust Transition Speed", "How quickly afterburners/brakes will reach their maximum effect"), flightCC.thrust_transition_speed);
        flightCC.turnspeed               = EditorGUILayout.FloatField(new GUIContent("Turn/Roll Speed", "How fast turns and rolls will be executed"), flightCC.turnspeed);
        //flightCC.rollSpeedModifier = EditorGUILayout.FloatField(new GUIContent("Roll Speed", "Multiplier for roll speed. Base roll is determined by turn speed"), flightCC.rollSpeedModifier);
        flightCC.pitchYaw_strength = EditorGUILayout.FloatField(new GUIContent("Pitch/Yaw Multiplier", "Controls the intensity of pitch and yaw inputs"), flightCC.pitchYaw_strength);

        EditorGUILayout.Separator();

        GUILayout.Label(new GUIContent("Banking", "Visuals only--has no effect on actual movement"));


        //flightCC.use_banking = EditorGUILayout.BeginToggleGroup(new GUIContent("Use Banking", "The ship will bank when doing turns."), flightCC.use_banking);

        flightCC.bank_rotation_speed      = EditorGUILayout.FloatField(new GUIContent("Bank Rotation Speed", "Rotation speed along the Z axis when yaw is applied. Higher values will result in snappier banking."), flightCC.bank_rotation_speed);
        flightCC.bank_rotation_multiplier = EditorGUILayout.FloatField(new GUIContent("Bank Rotation Multiplier", "Bank amount along the Z axis when yaw is applied."), flightCC.bank_rotation_multiplier);
        flightCC.bank_angle_clamp         = EditorGUILayout.FloatField(new GUIContent("Bank Angle Clamp", "Maximum angle the spacecraft can rotate along the Z axis."), flightCC.bank_angle_clamp);
        EditorGUILayout.EndToggleGroup();


        EditorGUILayout.Separator();

        flightCC.screen_clamp = EditorGUILayout.FloatField(new GUIContent("Screen Clamp (Pixels)", "Once the pointer is more than this many pixels from the center, the input in that direction(s) will be treated as the maximum value."), flightCC.screen_clamp);
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }

        GUIUtility.ExitGUI();
    }
    public IEnumerator _18_SpaceshipDoesntMoveDuringPause()
    {
        ClearScene();
        SpaceshipController spaceship = Object.Instantiate(spaceshipPrefab, Vector3.zero, Quaternion.identity).GetComponent <SpaceshipController>();

        spaceship.direction = Vector2.up;
        Vector3 startPosition = spaceship.transform.position;

        GameManager.IsPaused = true;

        for (int i = 0; i < 20; i++)
        {
            yield return(null);
        }

        Assert.IsTrue(spaceship.transform.position == startPosition);
    }
Пример #24
0
        public static SubsystemBase Create(EnumSubsystems _subsystem, SpaceshipController _spaceship)
        {
            SubsystemBase result = null;

            switch (_subsystem)
            {
            case EnumSubsystems.Maneuver:
                result = new ManeuverSubsystem(_spaceship);
                break;

            case EnumSubsystems.Engine:
                result = new EngineSubsystem(_spaceship);
                break;
            }

            return(result);
        }
Пример #25
0
    private void Start()
    {
        if (player is null)
        {
            var playerGameObject = Instantiate(GlobalState.Instance.SelectedSpaceCraft, playerSpawnLocation, Quaternion.Euler(-90f, 0f, 0f));
            player = playerGameObject.GetComponent <SpaceshipController>();
        }
        // player stats
        player.meta.attack += progress.attackLevel;
        player.meta.health += progress.healthLevel;
        player.meta.reload -= 0.09f * progress.reloadLevel;


        inputs        = GetComponent <PlayerInput>();
        increaseScore = GetComponent <IncreaseScore>();
        SetupGUI();
    }
    public IEnumerator RespawnShipCoroutine(float delay)
    {
        deaths++;
        if (LifeCounter.instance)
        {
            LifeCounter.instance.SetLives(3 - deaths);
        }
        yield return(new WaitForSeconds(delay));

        if (deaths < 3)
        {
            spaceship = Instantiate(spaceshipPrefab, Vector2.zero, Quaternion.identity).GetComponent <SpaceshipController>();
        }
        else
        {
            StartCoroutine(ReloadScene());
        }
    }
    public IEnumerator _12_ReachingCertainScoreChangesSpaceshipWeapons()
    {
        ClearScene();
        Object.Instantiate(gameManagerPrefab);
        GameManager.InitializeTestingEnvironment(true, false, false, false, false);

        yield return(null);

        for (int i = 0; i < 8; i++)
        {
            GameManager.AddToScore(0);
        }

        SpaceshipController spaceship = Object.FindObjectOfType <SpaceshipController>();

        Assert.IsTrue(spaceship != null);
        // Weapon changes to laser upon reaching 8000 points
        Assert.IsTrue(spaceship.currentWeapon == SpaceshipController.Weapon.Laser);
    }
Пример #28
0
        public async Task GetSpaceshipById_Status200OKIsType_ReturnedIdEqualsInput()
        {
            // Arrange
            int expected = 1;
            var mockRepo = new Mock <ISpaceshipRepo>();

            mockRepo.Setup(repo => repo.GetSpaceshipById(expected)).Returns(Task.FromResult(GetTestSession()));
            var controller = new SpaceshipController(mockRepo.Object);

            // Act
            var result = await controller.GetSpaceshipById(expected);

            // Assert
            var okResult    = Assert.IsType <OkObjectResult>(result);
            var returnValue = Assert.IsType <SpaceshipModel>(okResult.Value);
            var actual      = returnValue;

            Assert.Equal(expected, actual.ID);
            Assert.Contains(expected.ToString(), actual.ID.ToString());
        }
Пример #29
0
    void OnTriggerEnter(Collider other)
    {
        //Instantiate(explosion, transform.position, transform.rotation);
        if (other.tag == "Player")
        {
            Debug.Log("atk");
            SpaceshipController spaceship = other.GetComponent <SpaceshipController>();
            if (spaceship != null)
            {
                spaceship.ChangeHealth(-1);
            }
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
        }
        else
        {
            Destroy(other.gameObject);
        }

        Destroy(gameObject);
    }
Пример #30
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        Time.timeScale = 1.0f;

        pauseObjects = GameObject.FindGameObjectsWithTag("Menu");
        healthBar    = GameObject.FindGameObjectWithTag("Health");

        ui = FindObjectOfType <UIManager>();

        if (SceneManager.GetActiveScene().name == "SelectionScene" || SceneManager.GetActiveScene().name == "DemoScene")
        {
            audioSrc = ui.audioSrc;
        }

        controller = new SpaceshipController();

        if (SceneManager.GetActiveScene().name == "DemoScene")
        {
            HidePaused();
        }
    }
Пример #31
0
    // Use this for initialization
    void Start()
    {
        //if (spaceShipType == VANISHED) {
        anim=GetComponentInChildren<Animator>();

        audioSource = GetComponent<AudioSource> ();
        rend = GetComponentInChildren<Renderer> ();
        aliens = (GameObject[])GameObject.FindGameObjectsWithTag ("Alien");
        alienController = GameObject.FindObjectOfType<AlienController> ();
        spaceshipController = GameObject.FindObjectOfType<SpaceshipController> ();

        //transform.rotation = Quaternion.identity;
        planet = GameObject.FindGameObjectWithTag ("Planet");
        Random.seed = (int)System.DateTime.Now.Ticks;
        setUpSpaceShip ();
        functioningSpaceShip ();
        //	if(spaceShipType=)
        //audioSource.PlayOneShot(disappearSound);
        //curScale  = this.transform.localScale.x;
        //LeanTween.scale( this.gameObject, new Vector3 (curScale + 0.1f, curScale + 0.1f, curScale + 0.1f), 0.25f).setEase(LeanTweenType.easeOutCirc).setLoopPingPong(-1);
    }
    void Start()
    {
        shipController = GetComponent<SpaceshipController> ();
        satelliteController = GetComponent<SatelliteController> ();
        currentHealth = maximumHealth;

        shield = maxShield;
        //		healthBarLength = Screen.width / 6;
        if (base.isLocalPlayer) {
            HUDCanvasManager.singleton.setHealthMaxValue (maximumHealth);
            HUDCanvasManager.singleton.updateHealth (currentHealth);
            HUDCanvasManager.singleton.updateShield((int)(shield / maxShield) * 100);
            HUDCanvasManager.singleton.setMaxCooldown(maxShield);
            HUDCanvasManager.singleton.setCooldown(shield);
            //deathAnimation.GetComponent<ParticleSystem>().Stop();
        }

        if (NetworkClient.active)
        {
            EventWeaponHit += Pulse;
        }
    }
Пример #33
0
    // Use this for initialization
    void Start()
    {
        rend = GetComponentInChildren<Renderer> ();
        aliens = (GameObject[])GameObject.FindGameObjectsWithTag("Alien");
        alienController = GameObject.FindObjectOfType<AlienController>();
        spaceshipController = GameObject.FindObjectOfType<SpaceshipController>();

        //transform.rotation = Quaternion.identity;
        planet = GameObject.FindGameObjectWithTag("Planet");
        Random.seed = (int)System.DateTime.Now.Ticks;
        setUpSpaceShip();
        functioningSpaceShip ();
    }
Пример #34
0
 // Use this for initialization
 void Start()
 {
     audioSource = GetComponent<AudioSource> ();
     spaceshipController = GameObject.FindObjectOfType<SpaceshipController> ();
     InvokeRepeating ("updateTimer", 0.01f, 0.01f);
 }