예제 #1
0
    private void Start()
    {
        this.currentMovementSpeed = (this.maxMoveSpeed + this.minMoveSpeed) / 2;
        #if UNITY_EDITOR
        if ( this.master.isDummyShip == false )
        #endif
        {
            this.tentativePathLine.SetVertexCount( lineVertexCount );

            this.CreateRotationSegments();
        }

        CapitalShipMovement[] otherScripts = GameObject.FindObjectsOfType<CapitalShipMovement>() as CapitalShipMovement[];
        foreach ( CapitalShipMovement other in otherScripts )
        {
            if ( other != this )
            {
                this.otherShip = other;
            }
        }
    }
예제 #2
0
    public void OnAvoidanceAreaEnter( CapitalShipMovement _otherShip )
    {
        this.otherShip = _otherShip;

        if ( this.currentAvoidanceState == AVOIDANCE_STATE.UP_RETURN
          || this.currentAvoidanceState == AVOIDANCE_STATE.UP_START )
        {
            this.currentAvoidanceState = AVOIDANCE_STATE.UP_START;
        }
        else if ( this.currentAvoidanceState == AVOIDANCE_STATE.DOWN_RETURN
               || this.currentAvoidanceState == AVOIDANCE_STATE.DOWN_START )
        {
            this.currentAvoidanceState = AVOIDANCE_STATE.DOWN_START;
        }
        else
        {
            // Determine which ship is on the left or right of the intercept line
            Vector3 f1 = this.transform.forward;
            Vector3 f2 = this.otherShip.transform.forward;
            float direction = Vector3.Cross( f1, f2 ).y;

            if ( direction > 0.0f )
            {
                this.currentAvoidanceState = AVOIDANCE_STATE.DOWN_START;
            }
            else
            {
                this.currentAvoidanceState = AVOIDANCE_STATE.UP_START;
            }
        }
    }