Inheritance: MonoBehaviour
Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     _explosionAnimation = GameObject.Find("Explosion").GetComponent <Animator>();
     _spawnManager       = GameObject.Find("SpawnManager").GetComponent <SpawnManager>();
     _playerShip         = GameObject.Find("Ship").GetComponent <ShipMovement>();
     _destroyAudioClip   = GetComponent <AudioSource>();
 }
Esempio n. 2
0
    public override void DenyPower()
    {
        ShipMovement mover = ship.GetComponent <ShipMovement>();

        mover.hasThrustPowerup = false;
        base.DenyPower();
    }
 private void Start()
 {
     rb         = GetComponent <Rigidbody2D>();
     shipScr    = GameObject.Find("obj_player_ship").GetComponent <ShipMovement>();
     UIScr      = GameObject.Find("Game Manager").GetComponent <ui_manager_script>();
     oldGravity = rb.gravityScale;
 }
Esempio n. 4
0
    // Start is called before the first frame update
    void Start()
    {
        //_enemySpeed = Random.Range(4, 8);
        _playerShip = GameObject.Find("Ship").GetComponent <ShipMovement>();
        if (_playerShip == null)
        {
            Debug.LogError("Player ship is not found");
        }

        _uiManager = GameObject.Find("Canvas").GetComponent <UiManager>();
        if (_uiManager == null)
        {
            Debug.LogError("Canvas is not found");
        }

        _enemyDeathAnimator = GetComponent <Animator>();
        if (_enemyDeathAnimator == null)
        {
            Debug.LogError("Animator is not found");
        }

        _enemySprite = GetComponent <SpriteRenderer>();
        if (_enemySprite == null)
        {
            Debug.LogError("SpriteRenderer is not found");
        }

        _destroyAudioClip = GetComponent <AudioSource>();

        if (_playerShip == null)
        {
            Debug.Log("Ship GameObject can not be found");
        }
    }
    void Start()
    {
        RoutePlanner planner = new ElbowRoutePlanner(m_ElbowFactor);

        ShipMovement ship = new ShipMovement(planner);

        ship.PhysicsBody.Velocity.Value = m_StartingVelocity;
        ship.StartUpdate(m_Updater);

        ShipMovementEvent evt = new ShipMovementEvent(0, "Test", new Path(0, m_Points));

        ship.ReceiveEvent(evt);

        ship.PhysicsBody.Position.Subscribe(pos => m_TestVisuals.position = pos);

        foreach (var p in m_Points)
        {
            var go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.transform.position = p.Position;
        }

        m_View.Model = ship;


        //ship.PhysicsBody.Position.Subscribe(pos => Debug.Log(pos.ToString("F4")));
        //ship.PhysicsBody.Velocity.Subscribe(vel => Debug.Log(vel.ToString("F4")));
    }
 /// <summary>
 /// Start()
 /// Used for initialization
 /// </summary>
 void Start()
 {
     movement = GetComponent <ShipMovement>();
     //sprite = GetComponent<SpriteRenderer>();
     mesh = GetComponent <MeshRenderer>();
     info = GetComponent <ShipInfo>();
 }
Esempio n. 7
0
    /// <summary>
    /// Rotates the character Anti-Clockwise vertically
    /// </summary>
    private void SpinAntiClockwise(float rollSpeed)
    {
        Vector3 horzPosition     = new Vector3(transform.position.x, 0, transform.position.z);
        Vector3 verticalPosition = new Vector3(0, startingPosition.y, 0);

        // Caluclate the circular motion of the y axis
        verticalPosition.y = rollVerticalMovement + rollVerticalMovement * Mathf.Sin(Mathf.Deg2Rad * (rollTimer - 90));

        //Need to move the XZ independantly of the Y. transform.right cannot be used because of object rotation
        horzPosition   = horzPosition + (transform.forward * speed * Time.deltaTime) + (transform.right * rollLateralMovement * Time.deltaTime);
        horzPosition.y = 0;

        transform.position = horzPosition + verticalPosition;

        rollTimer += rollSpeed * Time.deltaTime;

        transform.Rotate(Vector3.forward, rollSpeed * Time.deltaTime, Space.Self);



        if (rollTimer > 360)
        {
            shipIs = ShipMovement.Normal;
            Vector3 ang = transform.rotation.eulerAngles;
            transform.rotation = Quaternion.Euler(ang.x, ang.y, 0.0f);
        }
    }
Esempio n. 8
0
    // Use this for initialization
    IEnumerator Start()
    {
        while (!GameManager.S.shipsReady)
        {
            yield return(null);
        }

        AIManager.debugMode = true;

        this.comShipMovement = gameObject.GetComponentInChildren <ShipMovement>();

        //TODO: Stop doing this
        this.playerShipMovement = GameObject.Find("Player1").GetComponentInChildren <ShipMovement>();

        this.navigationPointPrefab = Resources.Load <GameObject>("Prefabs/NavigationPoint");

        this.grid = new List <NavigationPoint>();
        this.currentlyTravellingPath = new TravelPath();

        //Determine point separation based on the longer side (horizontal length)
        this.pointSeparation = Mathf.Abs(this.comShipMovement.viewportMaxX - this.comShipMovement.viewportMinX) / this.gridLength;

        this.BuildGrid();
        this.BuildBorders();
        this.PopulateAdjacentPoints();

        this.shipScanLayerMask = 1 << LayerMask.NameToLayer("NavigationPoint");
    }
    void Awake()
    {
        //Only for debug purposes so i can start the main game scene without going on the menu before
        //Have to remove this try-catch model later, cannot not have a ShipSelector Instance
        try{
            shipSelectorController = GameObject.FindGameObjectWithTag("ShipSelectorController").GetComponent <ShipSelectorController>();
        }catch (Exception e) {
            Debug.Log("Missing ship selector object \n" + e.Message);
        }
        //SetDefaultBulletTypeSprite();
        SetBulletTypeImagesByIndex(this.shipSelectorController.currentShipTypeIndex);

        playerShip          = GameObject.FindGameObjectWithTag("Ship");
        shipAttackHandler   = playerShip.GetComponent <ShipAttack>();
        shipMovementHandler = playerShip.GetComponent <ShipMovement>();
        shipScoreController = GameObject.FindGameObjectWithTag("GameController").GetComponent <ScoreController>();
        weaponTypeTimeBar.SetActive(false);

        if (shipMovementHandler.shipHaveBoost)
        {
            boostBarPanel.SetActive(true);
        }
        else
        {
            boostBarPanel.SetActive(false);
        }
    }
    void CmdRequestPilotAuthority()
    {
        ShipMovement shipScriptRef = playerShipRef.GetComponent <ShipMovement>();

        //Debug.Log("Requesting pilot authority. pilotSeatOccupied is: " + shipScriptRef.pilotSeatOccupied);

        if (shipScriptRef.pilotSeatOccupied == false) // if, on serverside, pilot seat is NOT occupied
        {
            // pilot seat is vacant, give this player the pilot seat
            //Debug.Log("pilotSeatOccupied is false, therefore we are giving requesting player the pilot seat authority");
            NetworkIdentity   newPlayerID    = playerConnRef.GetComponent <NetworkIdentity>();
            NetworkIdentity   shipID         = playerShipRef.GetComponent <NetworkIdentity>();
            NetworkConnection otherShipOwner = shipID.clientAuthorityOwner;

            if (otherShipOwner != newPlayerID.connectionToClient)  //  if this player is not already set to own the ship
            {
                // Debug.Log("We are not the current owner of this pilot seat, so we will receive pilot seat authority");
                if (otherShipOwner != null)  //  if the ship actually DOES have any owner at all
                {
                    //Debug.Log("there actually was a different owner, so we are removing his authority");
                    shipID.RemoveClientAuthority(otherShipOwner);
                }
                shipID.AssignClientAuthority(newPlayerID.connectionToClient);  //  Give ownership to the requesting client
            }
            //else
            //{
            //    Debug.Log("We are already the owner of the ship. Doing nothing");
            //}
            shipScriptRef.setPilotSeatOccupied(true); // communicate to all clients that pilot seat is now occupied
            RpcReceivePilotSeat();                    // on proper client's computer, their ship will have pilot controls enabled
        }
    }
Esempio n. 11
0
 void Awake()
 {
     PatternComplete = new UnityEvent();
     _ship           = this.Find <ShipMovement>(GameTags.Player);
     _score          = this.Find <Score>(GameTags.Score);
     _ui             = this.Find <UI_Controller>(GameTags.IG_GUI);
 }
Esempio n. 12
0
        void Start()
        {
            ship   = GetComponent <ShipMovement>();
            player = GetComponent <ShipBehaviour>();

            _camera = Camera.main;
        }
Esempio n. 13
0
 private void Start()
 {
     shipScr  = GameObject.Find("obj_player_ship").GetComponent <ShipMovement>();
     uiScr    = GameObject.Find("Game Manager").GetComponent <ui_manager_script>();
     anim     = GetComponent <Animator>();
     oldDelay = delayToDeployEgg;
 }
Esempio n. 14
0
    public override void GrantPower()
    {
        ShipMovement mover = ship.GetComponent <ShipMovement>();

        mover.hasThrustPowerup = true;
        base.GrantPower();
    }
    /// <summary>
    /// Inicializa los stats generales/comunes de una nave
    /// </summary>
    /// <param name="ship">Nave a inicializar</param>
    /// <param name="baseStats">Stats de la nave a inicializar</param>
    public void InitializeEnemyGeneralStats(GameObject ship, NaveBaseSO baseStats, Vector2 position)
    {
        ship.transform.position = position;
        ShipMovement sm = ship.GetComponent <ShipMovement>();

        sm.SetSpeed(baseStats.movementSpeed);
        sm.SetSystemOnOff(true);

        ShipShootingSystem ss = ship.GetComponent <ShipShootingSystem>();

        ss.SetSystemOnOff(true);
        if (baseStats.bulletNum <= 0)
        {
            ss.SetSystemOnOff(false);
        }
        else
        {
            ss.SetSystemOnOff(true);
            ss.SetShotNumber(baseStats.bulletNum);
            ss.SetBulletSpeed(baseStats.bulletSpeed);
            ss.SetFireRate(baseStats.reloadime);
        }
        ship.GetComponent <EnemyShipManager>().SetAIStatus(true);
        ship.GetComponent <HealthManager>().ReplenishLife();
    }
Esempio n. 16
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ShipMovement ship = other.gameObject.GetComponent <ShipMovement>();

        if (ship)
        {
            if (ship.GetComponent <ShipHealth>().GetHealth() == 0)
            {
                if (!win)
                {
                    FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene(_cena);
                }
                else
                {
                    if (fim)
                    {
                        FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene("Fim");
                    }
                    else
                    {
                        FindObjectOfType <StageManager>().GetComponent <StageManager>().ChangeScene(_cenaWin);
                    }
                }
            }
            else
            {
                ship.GetComponent <ShipHealth>().Damage(_damage);
                ship.GetComponent <Rigidbody2D>().AddForce(Vector2.up * _force, ForceMode2D.Impulse);
            }
        }
    }
Esempio n. 17
0
 /// <summary>
 /// Checks if the character should implement movement
 /// </summary>
 private void ShouldMove()
 {
     //throw new System.NotImplementedException();
     if (ShouldAccelerate() && isPlayerShip)
     {
         Accelerate(speedAdjust);
     }
     if (ShouldDeccelerate() && isPlayerShip)
     {
         Accelerate(-speedAdjust);
     }
     if (ShouldStrafeLeft() && isPlayerShip)
     {
         //Debug.Log("Strafing Left");
         transform.position -= transform.right * strafeSpeed * Time.deltaTime;
     }
     if (ShouldStrafeRight() && isPlayerShip)
     {
         //Debug.Log("Strafing Right");
         transform.position += transform.right * strafeSpeed * Time.deltaTime;
     }
     if (ShouldRollLeft() && isPlayerShip)
     {
         shipIs           = ShipMovement.Rolling_Left;
         rollTimer        = 0;
         startingPosition = transform.position;
     }
     if (ShouldRollRight() && isPlayerShip)
     {
         shipIs           = ShipMovement.Rolling_Right;
         rollTimer        = 0;
         startingPosition = transform.position;
     }
     Move();
 }
Esempio n. 18
0
        protected virtual void OnEnable()
        {
            movement  = GetComponent <ShipMovement>();
            behaviour = GetComponent <ShipBehaviour>();

            StartEffect();
        }
Esempio n. 19
0
        /// <summary>
        /// Primary update method.
        /// </summary>
        /// <param name="gameTime">This game time variable is updated automagically.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keystate = Keyboard.GetState();

            BasicModel tempModel = _models[0];

            _movementDataReporter = ShipMovement.MoveShip(_movementDataReporter, gameTime, ref tempModel);
            _models[0]            = tempModel;

            if (keystate.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (_cameraType == CameraType.TargetCamera)
            {
                _camera.Update();
            }

            if (_cameraType == CameraType.FreeCamera)
            {
                _lastMouseState = ((FreeCamera)_camera).FreeCameraUpdate(gameTime, _camera, _lastMouseState);
            }

            _movementDataReporter = MouseGestures.CheckMouseClicked(_models, _boardPlane, _movementDataReporter, _camera, GraphicsDevice);



            base.Update(gameTime);
        }
Esempio n. 20
0
    IEnumerator WaitAndReset(ShipMovement shipmov)
    {
        yield return(new WaitForSeconds(5));

        shipmov.speed += speedModif;
        Destroy(gameObject);
    }
Esempio n. 21
0
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player")
        {
            Ship         shipHit        = other.gameObject.GetComponentInParent <Ship>();
            ShipMovement playerMovement = other.gameObject.GetComponentInParent <ShipMovement>();
            if (shipHit.playerEnum != owningPlayer)
            {
                //Do damage to the player hit
                shipHit.TakeDamage(damage);

                //Slow the player while in the beam
                playerMovement.SlowPlayer(slowingFactor);

                GameObject explosion = Instantiate(explosionPrefab, other.transform.position, new Quaternion()) as GameObject;
                Destroy(explosion, 5f);
            }
        }
        else if (other.tag == "ProtagShip")
        {
            DamageableObject otherShip = other.gameObject.GetComponentInParent <DamageableObject>();
            otherShip.TakeDamage(damage);

            GameObject explosion = Instantiate(explosionPrefab, other.transform.position, new Quaternion()) as GameObject;
            Destroy(explosion, 5f);
        }
    }
Esempio n. 22
0
    void OnRespawn(Vector3 spawnPosition, Quaternion spawnRotation)
    {
        transform.position = spawnPosition;
        transform.rotation = spawnRotation;

        SetVisibility(true);
        m_Health = 50;
        OnHealthChanged();

        //The OnRespawn functions of other components make sure that all values are properly reset to their initial values again
        ShipMovement.OnRespawn(spawnRotation.eulerAngles.y);
        ShipVisuals.OnRespawn();

        if (GetComponent <ShipInput>() != null)
        {
            GetComponent <ShipInput>().OnRespawn();
        }

        CameraShipFollow cameraFollow = Camera.main.GetComponent <CameraShipFollow>();

        if (cameraFollow != null && cameraFollow.GetTarget() == this)
        {
            cameraFollow.OnRespawn();
        }
    }
Esempio n. 23
0
 public void RemoveIntent(ShipMovement s)
 {
     if (intents.Contains(s))
     {
         intents.Remove(s);
         SendToThrusters(s, false);
     }
 }
Esempio n. 24
0
 // Use this for initialization
 void Start()
 {
     hitPoints    = maxHitpoints;
     selectionBox = GetComponentInChildren <SpriteRenderer> ();
     selected     = false;
     player       = GameObject.Find("Player " + team).GetComponent <Player>();
     mover        = GetComponent <ShipMovement> ();
 }
Esempio n. 25
0
 public void AddIntent(ShipMovement s)
 {
     if (!intents.Contains(s))
     {
         intents.Add(s);
         SendToThrusters(s, true);
     }
 }
Esempio n. 26
0
 void OnEnable()
 {
     SetWeaponPositions();
     DroneMovement = gameObject.GetComponent <ShipMovement>();
     DroneHealth   = gameObject.GetComponent <EnemyHealth>();
     StartCoroutine(AttackDecider());
     StartCoroutine(MovementDecider());
 }
Esempio n. 27
0
 private void Form1_KeyUp_1(object sender, KeyEventArgs e)
 {
     // Stop ship from moving when no keys are pressed
     if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Right || e.KeyCode == Keys.Left)
     {
         Ship = ShipMovement.None;
     }
 }
    public void Awake()
    {
        _movement = GetComponentInParent <ShipMovement>();
        _health   = GetComponentInParent <HealthScript>();

        _images = GetComponentsInChildren <Image>();
        _texts  = GetComponentsInChildren <Text>();
    }
Esempio n. 29
0
        public Ship(Team team, WaterCell cell, ShipMovement movement = ShipMovement.None)
        {
            Gold      = 0;
            this.team = team;
            Cell      = cell;

            SelectStrategy(movement);
        }
Esempio n. 30
0
    void Start()
    {
        TogglePanel(0);

        ship = FindObjectOfType <ShipMovement>();

        graphCreator = FindObjectOfType <GraphCreator>();
    }
 void OnCollisionEnter2D(Collision2D coll)
 {
     //Debug.Log ("collision");
     if (coll.gameObject.tag == "Bullet") {
         coll.gameObject.GetComponent<Bullet> ().explode ();
         Destroy (gameObject);
     } else if (coll.gameObject.tag == "Player") {
         //Debug.Log ("hit player!");
         ship = coll.gameObject.GetComponent<ShipMovement> ();
         ship.shieldAmt -= (int)Mathf.Abs (coll.gameObject.GetComponent<Rigidbody2D>().velocity.magnitude - velocityVector.magnitude);
         //Debug.Log (coll.gameObject.GetComponent<ShipMovement>().shieldAmt);
         if(ship.shieldAmt <= 0){
             GameObject obj = GameObject.Find ("SceneTransitionObject");
             obj.GetComponent<SceneTransition>().endTime = (int)(System.DateTime.UtcNow - new DateTime (1970, 1, 1)).TotalSeconds;
             DontDestroyOnLoad(GameObject.Find ("SceneTransitionObject"));
             Application.LoadLevel ("EndGame");
         }
     } else if (coll.gameObject.tag == "Asteroid") {
         velocityVector *= -1;
         coll.gameObject.GetComponent<AsteroidScript>().velocityVector *= -1;
     }
 }
 private void Start()
 {
     _shipMovement = target.GetComponent<ShipMovement>();
     _mainCamera = GetComponent<Camera>();
 }
Esempio n. 33
0
 // Use this for initialization
 void Start()
 {
     shipMovement=GetComponent<ShipMovement>();
 }
Esempio n. 34
0
 void Start()
 {
     parent = transform.parent.gameObject.GetComponent<ShipMovement>();
     gameObject.layer = LayerMask.NameToLayer("Player" + parent.joystickIndex.ToString());
 }
Esempio n. 35
0
	private void Start() {
		_shipMovement = GetComponent<ShipMovement>();
	}
Esempio n. 36
0
    // Use this for initialization
    void Start()
    {
        if (Input.GetKey(KeyCode.Alpha1))
            Application.LoadLevel("Level 1");

        _startMenu = GameObject.FindGameObjectWithTag("StartMenu");

        _copyright = GameObject.FindGameObjectWithTag("Copyright")
            .GetComponent<Text>();

        _scoreText = GameObject.FindGameObjectWithTag("Score")
            .GetComponent<Text>();

        _countdownText = GameObject.FindGameObjectWithTag("Countdown")
            .GetComponent<Text>();

        _gameWinText = GameObject.FindGameObjectWithTag("GameWin")
            .GetComponent<Text>();

        _gameLoseText = GameObject.FindGameObjectWithTag("GameLose")
            .GetComponent<Text>();

        _credits = GameObject.FindGameObjectWithTag("Credits");

        _credits.SetActive(false);

        var ship = GameObject.FindGameObjectWithTag("Player");

        _shipMovement = ship.GetComponentInChildren<ShipMovement>();

        _shipFireWeapon = ship.GetComponentInChildren<ShipFireWeapon>();

        var camera = GameObject.FindGameObjectWithTag("MainCamera");

        _cameraChase = camera.GetComponentInChildren<CameraChase>();
    }
Esempio n. 37
0
 // Use this for initialization
 void Start()
 {
     parent = transform.parent.gameObject.GetComponent<ShipMovement>();
     joystickIndex = parent.joystickIndex;
 }
Esempio n. 38
0
 void Start()
 {
     characterController = GetComponent<ShipMovement> ();
     shoot = GetComponent<Shoot> ();
     controlType = PlayerPrefs.GetInt("Controls");
 }
Esempio n. 39
0
    private void Start()
    {
        for(int i = 0; i < doorList.Count; i++) {
            doorList[i].GetComponent<DoorTrigger>().index = i;
        }

        player = GameObject.FindGameObjectWithTag("Player");
        _shipMovement = player.GetComponent<ShipMovement>();

        FillLevelTimeArray();
        FillLevelScoreArray();
    }
Esempio n. 40
0
 void Awake()
 {
     mouse = GetComponent<MouseLook>();
     movement = GetComponent<ShipMovement>();
     shooter = GetComponent<Shooter>();
 }
Esempio n. 41
0
 public virtual void Start()
 {
     this.movement = GameObject.FindGameObjectWithTag("ShipBlueprint").GetComponent<ShipMovement>();
 }