示例#1
0
    void Start()
    {
        if (overrideThrust)
        {
            thrust = overriddenThrust;
        }
        else
        {
            if (thrusterType == ThrusterType.LARGE)
            {
                thrust = 18.0f;
            }
            else if (thrusterType == ThrusterType.SMALL)
            {
                thrust = 27.0f;
            }
        }

        if (transform.rotation.eulerAngles.z >= -1.0f && transform.rotation.eulerAngles.z <= 1.0f)
        {
            orientation = ThrusterOrientation.STERN;
        }
        else if (transform.rotation.eulerAngles.z >= 179.0f && transform.rotation.eulerAngles.z <= 181.0f)
        {
            orientation = ThrusterOrientation.BOW;
        }
        else if (transform.rotation.eulerAngles.z >= 269.0f && transform.rotation.eulerAngles.z <= 271.0f)
        {
            orientation = ThrusterOrientation.PORT;
        }
        else if (transform.rotation.eulerAngles.z >= 89.0f && transform.rotation.eulerAngles.z <= 91.0f)
        {
            orientation = ThrusterOrientation.STARBOARD;
        }
    }
示例#2
0
    // Handle all the thrust movement
    void Thrust(ThrusterOrientation orientation, bool engage)
    {
        switch (orientation)
        {
        // Thrusters placed at the bottom end of the ship to move forward
        case ThrusterOrientation.STERN:
        {
            for (int i = 0; i < thrusters.Count; i++)
            {
                if (thrusters[i].orientation == ThrusterOrientation.STERN)
                {
                    if (engage)
                    {
                        thrusters[i].EngageThrust();
                    }
                    else
                    {
                        thrusters[i].DisengageThrust();
                    }
                }
            }
        } break;

        // Thrusters placed on the top end of the ship to move backward
        case ThrusterOrientation.BOW:
        {
            for (int i = 0; i < thrusters.Count; i++)
            {
                if (thrusters[i].orientation == ThrusterOrientation.BOW)
                {
                    if (engage)
                    {
                        thrusters[i].EngageThrust();
                    }
                    else
                    {
                        thrusters[i].DisengageThrust();
                    }
                }
            }
        } break;

        // Thrusters placed on the left side of the ship to move right
        case ThrusterOrientation.PORT:
        {
            for (int i = 0; i < thrusters.Count; i++)
            {
                if (thrusters[i].orientation == ThrusterOrientation.PORT)
                {
                    if (engage)
                    {
                        thrusters[i].EngageThrust();
                    }
                    else
                    {
                        thrusters[i].DisengageThrust();
                    }
                }
            }
        } break;

        // Thrusters placed on the right side of the ship to move left;
        case ThrusterOrientation.STARBOARD:
        {
            for (int i = 0; i < thrusters.Count; i++)
            {
                if (thrusters[i].orientation == ThrusterOrientation.STARBOARD)
                {
                    if (engage)
                    {
                        thrusters[i].EngageThrust();
                    }
                    else
                    {
                        thrusters[i].DisengageThrust();
                    }
                }
            }
        } break;

        default:
        {
            Debug.Log("Don't know which direction to thrust!");
        } break;
        }
    }