Exemple #1
0
 public void RequestAction(ShuttleAction action)
 {
     if (PossibleAction(action))
     {
         nextAction = action;
     }
 }
Exemple #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (nextAction != ShuttleAction.none)
        {
            if (!launched)
            {
                if (nextAction == ShuttleAction.launch)
                {
                    StartCoroutine(DoLaunch());
                    previousPosition = transform.position;
                }
            }
            else
            {
                if (fuel > 0)
                {
                    if (nextAction == ShuttleAction.left)
                    {
                        rb.AddForce(this.transform.TransformVector(Vector3.left) * forceSideways);
                        rb.AddTorque(transform.up * -forceTorque);
                        action = true;
                    }
                    else if (nextAction == ShuttleAction.right)
                    {
                        rb.AddForce(this.transform.TransformVector(Vector3.right) * forceSideways);
                        rb.AddTorque(transform.up * forceTorque);
                        action = true;
                    }
                    else if (nextAction == ShuttleAction.forward)
                    {
                        rb.AddForce(this.transform.TransformVector(Vector3.forward) * forceFoward);
                        action = true;
                    }
                    else if (nextAction == ShuttleAction.backwards)
                    {
                        rb.AddForce(this.transform.TransformVector(Vector3.back) * forceFoward);
                        rb.AddTorque(transform.up * -forceTorque);
                        action = true;
                    }

                    /* else if (nextAction == ShuttleAction.stabilize)
                     * {
                     *
                     *
                     *   action = true;
                     * }*/
                }
            }
        }
        if (nextAction == ShuttleAction.deactivate)
        {
            if (hp > 0)
            {
                pastLine.startColor    = pastLine.endColor = Color.gray;
                updatedLine.startColor = updatedLine.endColor = Color.gray;
                for (int c = 0; c < shipModel.transform.childCount; ++c)
                {
                    GameObject gChild = shipModel.transform.GetChild(c).gameObject;
                    Renderer   renderer;
                    renderer = gChild.GetComponent <MeshRenderer>();
                    if (renderer != null)
                    {
                        renderer.material.color = Color.gray;
                    }
                    else
                    {
                        renderer = gChild.GetComponent <LineRenderer>();
                        if (renderer != null)
                        {
                            renderer.material.color = Color.gray;
                        }
                    }
                }
                active = false;
            }
        }

        /*float angle = -Vector3.Angle(rb.velocity, this.transform.TransformVector(Vector3.forward));
         * Debug.Log("stabilize:" + rb.velocity + "," + this.transform.TransformVector(Vector3.forward) + "::" + angle);
         * rb.AddTorque(transform.up * angle * Time.deltaTime*0.1f);
         */
        transform.LookAt(transform.position + rb.velocity, Vector3.up);

        nextAction = ShuttleAction.none;
    }
Exemple #3
0
 public bool PossibleAction(ShuttleAction action)
 {
     return(true); //TODO use profile
 }