コード例 #1
0
 void Start()
 {
     cannon       = GetComponent <CannonController>();
     motor        = GetComponent <ShipMotor>();
     ship         = GetComponent <Ship>();
     ship.OnDead += OnDead;
 }
コード例 #2
0
    void Start()
    {
        motor = GetComponent <ShipMotor>();
        motor.OnStartBoost += OnStartBoost;

        initialTrailColor = thrusterTrail.startColor;
    }
コード例 #3
0
        private void ChaseTarget(ShipStateController controller)
        {
            ShipMotor shipMotor = controller.GetMotor();
            Rigidbody ship      = controller.GetRigidbody();
            Rigidbody target    = controller.GetTarget();

            if (target == null)
            {
                return;
            }

            Steer(shipMotor, ship, target);

            AdjustThrottle();

            Vector3 toTarget = target.position - ship.position;

            float angle = Vector3.Angle(ship.transform.forward, toTarget);



            Vector3 velocityDifference = ship.velocity - target.velocity;

            //Check throttle
            //Check angle from player
            //Check velocity differences
            //Adjust throttle

            //steer based on stats/throttle
        }
コード例 #4
0
ファイル: PlayerInput.cs プロジェクト: Chaosed0/foxstar
    private void Start()
    {
        motor = GetComponent<ShipMotor>();
        cannon = GetComponent<CannonController>();

        lockCursor();
    }
コード例 #5
0
ファイル: PlayerInput.cs プロジェクト: Chaosed0/foxstar
    private void Start()
    {
        motor  = GetComponent <ShipMotor>();
        cannon = GetComponent <CannonController>();

        lockCursor();
    }
コード例 #6
0
    void Start()
    {
        motor = GetComponent<ShipMotor>();
        motor.OnStartBoost += OnStartBoost;

        initialTrailColor = thrusterTrail.startColor;
    }
コード例 #7
0
    void Awake()
    {
        motor = GetComponent <ShipMotor>();

        //*
        motor.MaxSpeed = motor.baseMaxSpeed;

        //bullets = new List<PlayerBullet>();

        if (!gameCamera && GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>())
        {
            gameCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        }

        if (!collider && GetComponent <CircleCollider2D>())
        {
            collider = GetComponent <CircleCollider2D>();
        }

        if (!bmManager && GetComponent <BulletModifierManager>())
        {
            bmManager = GetComponent <BulletModifierManager>();
        }

        if (!safeZoneOnRespawn && GetComponent <SafeZoneOnRespawn>())
        {
            safeZoneOnRespawn = GetComponent <SafeZoneOnRespawn>();
        }

        initalPosition = transform.position;
    }
コード例 #8
0
 void Start()
 {
     cannon = GetComponent<CannonController>();
     motor = GetComponent<ShipMotor>();
     ship = GetComponent<Ship>();
     ship.OnDead += OnDead;
 }
コード例 #9
0
ファイル: Bullet.cs プロジェクト: jamjnsn/space-shooter-2d
    void Update()
    {
        transform.position += direction.ToVector3() * Speed * Time.deltaTime;

        Ray ray = new Ray(transform.position, (transform.rotation * Vector3.up));

        Debug.DrawRay(ray.origin, ray.direction, Color.red);
        RaycastHit2D[] hits = Physics2D.RaycastAll(ray.origin.ToVector2(), ray.direction.ToVector2(), 0.0f);
        foreach (RaycastHit2D hit in hits)
        {
            if (hit.collider.gameObject == this.gameObject)
            {
                continue;
            }

            Ship ship = hit.collider.gameObject.GetComponent <Ship>();

            if (ship != null && ship.Team != Team)
            {
                ShipMotor motor = hit.collider.gameObject.GetComponent <ShipMotor>();
                if (motor.Destroyed)
                {
                    break;
                }
                motor.Damage(Team, Damage);
                if (!Piercing)
                {
                    Destroy(this.gameObject);
                }
            }
        }
    }
コード例 #10
0
ファイル: Slow.cs プロジェクト: MateoMoretti98/SOLID-1
 protected override void Interact(ShipMotor shipMotor)
 {
     foreach (var asteroid in GameObject.FindObjectsOfType <Asteroid>())
     {
         asteroid.StopForXTime(slow);
     }
     Destroy(gameObject);
 }
コード例 #11
0
    // Use this for initialization
    void Start()
    {
        ship_input = ship_settings.UseAi ?
                     new AIInput() as IShipInput :
                     new ControllerInput();

        ship_motor = new ShipMotor(ship_input, transform, ship_settings);
    }
コード例 #12
0
ファイル: PowerUp.cs プロジェクト: MateoMoretti98/SOLID-1
    void OnTriggerEnter2D(Collider2D other)
    {
        ShipMotor shipMotor = other.gameObject.GetComponent <ShipMotor>();

        if (shipMotor != null)
        {
            Interact(shipMotor);
        }
    }
コード例 #13
0
 void Start()
 {
     motor = GetComponent <ShipMotor>();
     cam   = Camera.main;
     if (cam == null)
     {
         Debug.Log("No Camera Found");
     }
 }
コード例 #14
0
 void Start()
 {
     health = maxHealth;
     motor  = GetComponent <ShipMotor>();
     if (OnHealthChange != null)
     {
         OnHealthChange(health, 0);
     }
 }
コード例 #15
0
ファイル: HUD.cs プロジェクト: Chaosed0/foxstar
    void Start()
    {
        motor                = ship.GetComponent <ShipMotor>();
        canvas               = GetComponent <Canvas>();
        rectTransform        = GetComponent <RectTransform>();
        ship.OnHealthChange += OnHealthChange;
        ship.OnScoreChange  += OnScoreChange;
        motor.OnBoostChange += OnBoostChange;

        SetScoreVisible(ship.GetScore());
    }
コード例 #16
0
    void Start()
    {
        if (soundSystem == null) {
            this.enabled = false;
            return;
        }

        cannon = GetComponent<CannonController>();
        motor = GetComponent<ShipMotor>();
        ship = GetComponent<Ship>();

        Bind();

        shootSoundPriority = soundSystem.MinPriority();
        boostSoundPriority = soundSystem.MaxPriority();
    }
コード例 #17
0
    void Start()
    {
        if (soundSystem == null)
        {
            this.enabled = false;
            return;
        }

        cannon = GetComponent <CannonController>();
        motor  = GetComponent <ShipMotor>();
        ship   = GetComponent <Ship>();

        Bind();

        shootSoundPriority = soundSystem.MinPriority();
        boostSoundPriority = soundSystem.MaxPriority();
    }
コード例 #18
0
ファイル: Missile.cs プロジェクト: Tbarkin121/TileSetDemo
 void OnTriggerEnter2D(Collider2D hitInfo)
 {
     Debug.Log(hitInfo.name);
     if (armed)
     {
         ShipMotor ship = hitInfo.GetComponent <ShipMotor>();
         if (ship != null)
         {
             ship.TakeDamage(damage);
             Instantiate(smokePrefab, transform.position, transform.rotation);
             Destroy(gameObject);
         }
         else
         {
             Instantiate(smokePrefab, transform.position, transform.rotation);
             Destroy(gameObject);
         }
     }
 }
コード例 #19
0
ファイル: CameraFollow.cs プロジェクト: Chaosed0/foxstar
    void Start()
    {
        camera         = GetComponent <Camera>();
        curRollDamping = rollDamping;

        motor = ship.GetComponent <ShipMotor>();
        motor.OnStartManeuver += OnStartManeuver;
        motor.OnStopManeuver  += OnStopManeuver;
        motor.OnStartBoost    += OnStartBoost;
        motor.OnStopBoost     += OnStopBoost;

        ship.OnRespawn      += OnRespawn;
        ship.OnHealthChange += OnHealthChange;

        normalFov = camera.fieldOfView;
        boostFov  = normalFov * boostFovFactor;
        fovTarget = normalFov;

        shakeTimer = shakeTime;
    }
コード例 #20
0
ファイル: CameraFollow.cs プロジェクト: Chaosed0/foxstar
    void Start()
    {
        camera = GetComponent<Camera>();
        curRollDamping = rollDamping;

        motor = ship.GetComponent<ShipMotor>();
        motor.OnStartManeuver += OnStartManeuver;
        motor.OnStopManeuver += OnStopManeuver;
        motor.OnStartBoost += OnStartBoost;
        motor.OnStopBoost += OnStopBoost;

        ship.OnRespawn += OnRespawn;
        ship.OnHealthChange += OnHealthChange;

        normalFov = camera.fieldOfView;
        boostFov = normalFov * boostFovFactor;
        fovTarget = normalFov;

        shakeTimer = shakeTime;
    }
コード例 #21
0
 void Start()
 {
     motor = GetComponent<ShipMotor>();
     initialRotation = new Vector3(270.0f, 0.0f, 0.0f);
 }
コード例 #22
0
    void Awake()
    {
        shipMotor = GetComponent<ShipMotor>();

        tiltJoystick = GetComponent<TiltJoystick>();
    }
コード例 #23
0
    void Awake()
    {
        shipMotor = GetComponent <ShipMotor>();

        tiltJoystick = GetComponent <TiltJoystick>();
    }
コード例 #24
0
ファイル: HUD.cs プロジェクト: Chaosed0/foxstar
    void Start()
    {
        motor = ship.GetComponent<ShipMotor>();
        canvas = GetComponent<Canvas>();
        rectTransform = GetComponent<RectTransform>();
        ship.OnHealthChange += OnHealthChange;
        ship.OnScoreChange += OnScoreChange;
        motor.OnBoostChange += OnBoostChange;

        SetScoreVisible(ship.GetScore());
    }
コード例 #25
0
 void Start()
 {
     motor           = GetComponent <ShipMotor>();
     initialRotation = new Vector3(270.0f, 0.0f, 0.0f);
 }
コード例 #26
0
    void Update()
    {
        //Calculate Total Engine Force (Break down into engines later)
        float _xMov = Input.GetAxisRaw("Horizontal");
        float _zMov = Input.GetAxisRaw("Vertical");

        Vector2 _movVerticle = transform.up * _zMov;
        Vector2 _velocity    = (_movVerticle).normalized * speed;

        // Debug.Log("Velocity : [" + _velocity[0] + ", " + _velocity[1] + "]");

        //Apply movment
        motor.Move(_velocity);
        motor.Rot(-turnForce * _xMov);
        // gameObject.GetComponent<Rigidbody2D>().AddTorque(1.0f*Time.deltaTime);


        if (Input.GetButtonDown("Fire1"))
        {
            ShootMissile();
        }
        if (Input.GetButtonDown("Fire2"))
        {
            StartCoroutine(ShootMachineGun());
        }
        void ShootMissile()
        {
            if (whichBay)
            {
                whichBay = false;
                GameObject _missile = Instantiate(missilePrefab, firePointRight.position, firePointRight.rotation);
                _missile.GetComponent <Rigidbody2D>().velocity        = gameObject.GetComponent <Rigidbody2D>().velocity;
                _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity;
                _missile.GetComponent <Rigidbody2D>().AddForce(transform.right * MissileForce);
            }
            else
            {
                whichBay = true;
                GameObject _missile = Instantiate(missilePrefab, firePointLeft.position, firePointLeft.rotation);
                _missile.GetComponent <Rigidbody2D>().velocity        = gameObject.GetComponent <Rigidbody2D>().velocity;
                _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity;
                _missile.GetComponent <Rigidbody2D>().AddForce(-1.0f * transform.right * MissileForce);
            }
        }

        IEnumerator ShootMachineGun()
        {
            RaycastHit2D hitInfoL = Physics2D.Raycast(machinegunLeft.position + machinegunLeft.up, machinegunLeft.up);
            RaycastHit2D hitInfoR = Physics2D.Raycast(machinegunRight.position + machinegunRight.up, machinegunRight.up);

            if (hitInfoL)
            {
                ShipMotor ship = hitInfoL.transform.GetComponent <ShipMotor>();
                if (ship != null)
                {
                    ship.TakeDamage(damage);
                    Instantiate(impactEffect, hitInfoL.point, Quaternion.identity);
                    lineRendererL.SetPosition(0, machinegunLeft.position);
                    lineRendererL.SetPosition(1, hitInfoL.point);
                }
            }
            else
            {
                lineRendererL.SetPosition(0, machinegunLeft.position);
                lineRendererL.SetPosition(1, machinegunLeft.position + machinegunLeft.up * 100);
            }
            if (hitInfoR)
            {
                ShipMotor ship = hitInfoR.transform.GetComponent <ShipMotor>();
                if (ship != null)
                {
                    ship.TakeDamage(damage);
                    Instantiate(impactEffect, hitInfoR.point, Quaternion.identity);
                    lineRendererR.SetPosition(0, machinegunRight.position);
                    lineRendererR.SetPosition(1, hitInfoR.point);
                }
            }
            else
            {
                lineRendererR.SetPosition(0, machinegunRight.position);
                lineRendererR.SetPosition(1, machinegunRight.position + machinegunRight.up * 100);
            }
            lineRendererL.enabled = true;
            lineRendererR.enabled = true;
            yield return(0);

            lineRendererL.enabled = false;
            lineRendererR.enabled = false;
        }
    }
コード例 #27
0
ファイル: CannonController.cs プロジェクト: Chaosed0/foxstar
 void Start()
 {
     colliders = player.GetComponents <Collider>();
     motor     = GetComponent <ShipMotor>();
     ship      = GetComponent <Ship>();
 }
コード例 #28
0
ファイル: PowerUp.cs プロジェクト: MateoMoretti98/SOLID-1
 protected abstract void Interact(ShipMotor shipMotor);
コード例 #29
0
    void Update()
    {
        // If you want to disable input while you are using menues... no thanks
        // if (EventSystem.current.IsPointerOverGameObject())
        //     return;
        //Calculate Total Engine Force (Break down into engines later)
        float _xMov = Input.GetAxisRaw("Horizontal");
        float _zMov = Input.GetAxisRaw("Vertical");

        Vector2 _movVerticle = transform.up * _zMov;
        Vector2 _velocity    = (_movVerticle).normalized * speed;

        // Debug.Log("Velocity : [" + _velocity[0] + ", " + _velocity[1] + "]");

        //Apply movment
        motor.Move(_velocity);
        motor.Rot(-turnForce * _xMov);
        // gameObject.GetComponent<Rigidbody2D>().AddTorque(1.0f*Time.deltaTime);

        if (Input.GetMouseButtonDown(0))
        {
            ShootMissile();

            Vector3      mousePos   = GetWorldPositionOnPlane(Input.mousePosition, 0f);
            Vector2      mousePos2D = new Vector2(mousePos.x, mousePos.y);
            RaycastHit2D hit        = Physics2D.Raycast(mousePos2D, Vector2.zero);
            // Debug.Log("MousePosition" + Input.mousePosition);
            // Debug.Log("MousePositionWorldPoint" + mousePos);
            if (hit.collider != null)
            {
                Debug.Log("We Hit" + hit.collider.name + " " + hit.point);
            }
            RemoveFocus();
        }
        if (Input.GetMouseButtonDown(1))
        {
            StartCoroutine(ShootMachineGun());
            Vector3      mousePos   = GetWorldPositionOnPlane(Input.mousePosition, 0f);
            Vector2      mousePos2D = new Vector2(mousePos.x, mousePos.y);
            RaycastHit2D hit        = Physics2D.Raycast(mousePos2D, Vector2.zero);
            // Debug.Log("MousePosition" + Input.mousePosition);
            // Debug.Log("MousePositionWorldPoint" + mousePos);
            if (hit.collider != null)
            {
                Interactable interactable = hit.collider.GetComponent <Interactable>();
                if (interactable != null)
                {
                    SetFocus(interactable);
                }
            }
        }

        // if(Input.GetButtonDown("Fire1"))
        // {
        //     ShootMissile();
        // }
        // if(Input.GetButtonDown("Fire2"))
        // {
        //     StartCoroutine(ShootMachineGun());
        // }
        void ShootMissile()
        {
            if (whichBay)
            {
                whichBay = false;
                GameObject _missile = Instantiate(missilePrefab, firePointRight.position, firePointRight.rotation);
                _missile.GetComponent <Rigidbody2D>().velocity        = gameObject.GetComponent <Rigidbody2D>().velocity;
                _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity;
                _missile.GetComponent <Rigidbody2D>().AddForce(transform.right * 20f);
            }
            else
            {
                whichBay = true;
                GameObject _missile = Instantiate(missilePrefab, firePointLeft.position, firePointLeft.rotation);
                _missile.GetComponent <Rigidbody2D>().velocity        = gameObject.GetComponent <Rigidbody2D>().velocity;
                _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity;
                _missile.GetComponent <Rigidbody2D>().AddForce(-1.0f * transform.right * 20f);
            }
        }

        IEnumerator ShootMachineGun()
        {
            RaycastHit2D hitInfoL = Physics2D.Raycast(machinegunLeft.position + machinegunLeft.up, machinegunLeft.up);
            RaycastHit2D hitInfoR = Physics2D.Raycast(machinegunRight.position + machinegunRight.up, machinegunRight.up);

            if (hitInfoL)
            {
                ShipMotor ship = hitInfoL.transform.GetComponent <ShipMotor>();
                if (ship != null)
                {
                    ship.TakeDamage(damage);
                    Instantiate(impactEffect, hitInfoL.point, Quaternion.identity);
                    lineRendererL.SetPosition(0, machinegunLeft.position);
                    lineRendererL.SetPosition(1, hitInfoL.point);
                }
            }
            else
            {
                lineRendererL.SetPosition(0, machinegunLeft.position);
                lineRendererL.SetPosition(1, machinegunLeft.position + machinegunLeft.up * 100);
            }
            if (hitInfoR)
            {
                ShipMotor ship = hitInfoR.transform.GetComponent <ShipMotor>();
                if (ship != null)
                {
                    ship.TakeDamage(damage);
                    Instantiate(impactEffect, hitInfoR.point, Quaternion.identity);
                    lineRendererR.SetPosition(0, machinegunRight.position);
                    lineRendererR.SetPosition(1, hitInfoR.point);
                }
            }
            else
            {
                lineRendererR.SetPosition(0, machinegunRight.position);
                lineRendererR.SetPosition(1, machinegunRight.position + machinegunRight.up * 100);
            }
            lineRendererL.enabled = true;
            lineRendererR.enabled = true;
            yield return(0);

            lineRendererL.enabled = false;
            lineRendererR.enabled = false;
        }
    }
コード例 #30
0
ファイル: Heal.cs プロジェクト: MateoMoretti98/SOLID-1
 protected override void Interact(ShipMotor shipMotor)
 {
     shipMotor.UpdateLife(healAmount);
     Destroy(gameObject);
 }
コード例 #31
0
ファイル: ShipController.cs プロジェクト: snarf95/SpaceMess
 void Start()
 {
     motor = gameObject.GetComponent<ShipMotor>();
 }
コード例 #32
0
 public ShipController(ShipMotor shipMotorInstance)
 {
     _shipMotorInstance = shipMotorInstance;
 }
コード例 #33
0
        public override void Update()
        {
            UpdateLight();

            motor = getChunk().getVoxelObject().component.GetComponent <ShipMotor>();
        }
コード例 #34
0
ファイル: CannonController.cs プロジェクト: Chaosed0/foxstar
 void Start()
 {
     colliders = player.GetComponents<Collider>();
     motor = GetComponent<ShipMotor>();
     ship = GetComponent<Ship>();
 }
コード例 #35
0
        private void Steer(ShipMotor shipMotor, Rigidbody ship, Rigidbody target)
        {
            Vector3 toTarget = target.position - ship.position;

            Vector3 targetAngle = Quaternion.LookRotation(toTarget).eulerAngles;
            Vector3 shipAngles  = ship.rotation.eulerAngles;

            //Yaw (Left/Right)
            float shipXAngle   = shipAngles.x;
            float targetXAngle = targetAngle.x;

            if (shipXAngle > targetXAngle)
            {
                shipXAngle -= 360;
            }
            float clockwise = targetXAngle - shipXAngle;

            shipXAngle = shipAngles.x;
            if (targetXAngle > shipXAngle)
            {
                targetXAngle -= 360;
            }
            float counterClockwise = shipXAngle - targetXAngle;

            bool useClockwise = (clockwise <= counterClockwise);

            if (useClockwise)
            {
                shipMotor.Pitch(-1f * Time.fixedDeltaTime);
            }
            else
            {
                shipMotor.Pitch(1f * Time.fixedDeltaTime);
            }

            //Pitch (Up/Down)
            float shipYAngle   = shipAngles.y;
            float targetYAngle = targetAngle.y;

            if (shipYAngle > targetYAngle)
            {
                shipYAngle -= 360;
            }
            clockwise = targetYAngle - shipYAngle;

            shipYAngle = shipAngles.y;
            if (targetYAngle > shipYAngle)
            {
                targetYAngle -= 360;
            }
            counterClockwise = shipYAngle - targetYAngle;

            useClockwise = (clockwise <= counterClockwise);

            if (useClockwise)
            {
                shipMotor.Yaw(-1f * Time.fixedDeltaTime);
            }
            else
            {
                shipMotor.Yaw(1f * Time.fixedDeltaTime);
            }
        }
コード例 #36
0
 void Start()
 {
     motor = GetComponent <ShipMotor>();
 }