Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        shipController playerControl = m_player.GetComponent <shipController>();
        float          speed         = Mathf.Round(playerControl.currSpeed) * 2;

        m_text.text = speed.ToString() + "MPH";
    }
Exemplo n.º 2
0
    void Update()
    {
        if (setPath)
        {
            RaycastHit hit;
            if (Input.GetButton("Fire1"))
            {
                readingPath = true;
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Returns a ray going from camera through a screen point.
                if (Physics.Raycast(ray, out hit))
                {
                    if (Vector3.Distance(previousPoint, hit.point) > minTubeLength)
                    {
                        currentPathAnimator.addLink(previousPoint, hit.point);
                        previousPoint = hit.point;
                        // print("adding link");
                    }

                    //transform.position = hit.point;
                    tempPath.Add(hit.point);
                }
            }

            if (Input.GetButtonUp("Fire1") && readingPath)
            {
                setPath     = false;
                readingPath = false;
                masterSelector.deselectAll();
                path = (Vector3[])tempPath.ToArray(typeof(Vector3));
                shipController currentController = masterSelector.selectedShip.GetComponent <shipController>();
                currentController.move(path);
                tempPath.Clear();
            }
        }
    }
Exemplo n.º 3
0
 public void deselectAll()
 {
     for (int i = 0; i < shipObjs.Length; i++)
     {
         shipController selectedController = shipObjs[i].GetComponent <shipController>();
         selectedController.onDeselect();
     }
 }
Exemplo n.º 4
0
    public AudioClip m_clip;                //audio played on boost

    void OnTriggerEnter(Collider other)
    {
        m_playerObj = other.gameObject;

        if (other.tag == "Player" || other.tag == "Enemy")
        {
            m_shipControl      = m_playerObj.GetComponent <shipController>();
            m_boostTimerActive = true;
            other.attachedRigidbody.AddRelativeForce(Vector3.forward * 300000);
            AudioSource.PlayClipAtPoint(m_clip, other.transform.position, 1f);
        }
    }
Exemplo n.º 5
0
    void Update()
    {
        if (Input.GetKeyDown("s"))
        {
            selectorMode = true;                         // toggle selection mode
        }
        if (waitingUnclick && Input.GetButtonUp("Fire1"))
        {
            toggleSetPath();
        }



        if (selectorMode)
        {
            shipObjs = GameObject.FindGameObjectsWithTag("ships");
            if (Input.GetButtonDown("Fire1"))  // if a click is detected
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Returns a ray going from camera through a screen point.
                if (Physics.Raycast(ray, out hit))                                  // if that click hits a collider
                {
                    float prevDist    = 1000000000.0f;                              // inf
                    int   selectedInt = -1;                                         // null case
                    for (int i = 0; i < shipObjs.Length; i++)                       // step through ships and find nearest to selection
                    {
                        float currentDist = Vector3.Distance(hit.point, shipObjs[i].transform.position);

                        if (currentDist < prevDist)
                        {
                            selectedInt = i;
                            prevDist    = currentDist;
                        }
                    }

                    selectedShip = shipObjs[selectedInt];
                    selectedShip.GetComponent <pathAnimator>();
                    shipController selectedController = shipObjs[selectedInt].GetComponent <shipController>();
                    deselectAll();
                    selectedController.onSelect();
                    selectorMode   = false;
                    waitingUnclick = true;
                }
            }
        }
    }
Exemplo n.º 6
0
    void ConditionUpdate()
    {
        if (isThePlayer())
        {
            pilot = shipController.player;
        }


        switch (condition)
        {
        case shipCondition.waiting:
            if (eHP > 0)
            {
                //if (throttle == 0)
                condition = shipCondition.active;
                //else
                //   condition = shipCondition.anchored;
            }
            else
            {
                condition = shipCondition.dead;
            }
            break;

        case shipCondition.adrift:
            if (!WeaponsOnline())
            {
                beDisabled();
            }
            break;

        case shipCondition.disabled:
            beDisabled();
            break;

        case shipCondition.dead:
            beDead();
            break;

        default:
            condition = shipCondition.waiting;
            break;
        }
    }
Exemplo n.º 7
0
    public bool m_drive;            //if allowed to drive



    private void Awake()
    {
        //get instance of shipcontroller
        m_ship = GetComponent <shipController>();
    }
Exemplo n.º 8
0
    private Transform m_target;                               //current waypoint transform

    /*
     * [SerializeField][Range(0, 1)]private float m_speedAlert = 0.05f; //percent of speed at max caution
     * [SerializeField][Range(0, 180)]private float m_angleAlert = 50f; //angle of corner to warrant caution
     * [SerializeField]private float m_angleVelocityAlert = 30f;       //ease off accel if spin
     * [SerializeField]private float m_distWander = 3f;                //wander amount from target
     * [SerializeField]private float m_distWanderSpeed = 0.1f;         //how often to change dist wander
     * [SerializeField][Range(0, 1)]private float m_accelWander = 0.1f;//wander of acceleration
     * [SerializeField]private float m_accelWanderSpeed = 0.1f;        //how often to change accel wander
     */

    void Start()  //init connections
    {
        m_RB   = GetComponent <Rigidbody>();
        m_ship = GetComponent <shipController>();
    }
Exemplo n.º 9
0
    private shipController m_controller;                     //controller instance

    //INIT
    void Start()
    {
        m_controller = GetComponent <shipController>();
    }