Example #1
0
    public void Dock( DockingBay.DockingSlot _slot )
    {
        if ( state == FIGHTERSTATE.UNDOCKING )
        {
            DebugConsole.Log( "Skipping dock", this );
            return;
        }

        DebugConsole.Log( "Proceeding with dock", this );

        this.movement.desiredSpeed = 0;
        this.GetComponent<Rigidbody>().velocity = Vector3.zero;
        this.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
        this.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
        this.transform.position = _slot.landedPosition.position;
        this.transform.rotation = _slot.landedPosition.rotation;

        this.currentSlot = _slot;
        this.state = FIGHTERSTATE.DOCKED;
        this.transform.parent = _slot.landedPosition;

        if ( Network.peerType != NetworkPeerType.Disconnected )
        {
            GameNetworkManager.instance.SendDockedMessage( this.GetComponent<NetworkView>().viewID, this.health.Owner.team, _slot.slotID );
        }
    }
Example #2
0
    public void OnLethalDamage()
    {
        respawnTimer = respawnDelay;

        this.state = FIGHTERSTATE.OUT_OF_CONTROL;

        if ( this.health.LastHitBy != null )
        {
            string msg = "Player " + Common.MyNetworkID() + " was killed by " + this.health.LastHitBy.id;
            MessageManager.instance.CreateMessageLocal( msg, MESSAGE_TYPE.TO_ALL );
            ScoreManager.instance.AddScore( SCORE_TYPE.FIGHTER_KILL, this.health.LastHitBy, true );

            GamePlayerManager.instance.AddKill( this.health.LastHitBy.id, true );
        }

        GamePlayerManager.instance.AddDeath( this.health.Owner.id, true );

        this.GetComponent<Rigidbody>().AddTorque( Common.RandomDirection() );
    }
Example #3
0
 public void OnDestroyFighterNetworkMessage()
 {
     this.state = FIGHTERSTATE.DEAD;
     this.ToggleEnabled( false, false );
 }
Example #4
0
 public void ExitDock()
 {
     this.state = FIGHTERSTATE.FLYING;
 }
Example #5
0
    private void OnOutOfControlExpiration()
    {
        this.state = FIGHTERSTATE.DEAD;
        this.ToggleEnabled( false, true );

        if ( Network.peerType != NetworkPeerType.Disconnected )
        {
            GameNetworkManager.instance.SendDeadFighterMessage( Common.MyNetworkID() );
        }
    }
Example #6
0
    public void Undock()
    {
        this.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
        this.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;

        this.state = FIGHTERSTATE.UNDOCKING;
        this.currentSlot.landedFighter = null;

        this.transform.parent = null;

        PlayerUpgrader.instance.UpdateLevels (GamePlayerManager.instance.GetPlayerWithID( this.health.Owner.id ) );

        if ( Network.peerType != NetworkPeerType.Disconnected )
        {
            GameNetworkManager.instance.SendUndockedMessage( this.GetComponent<NetworkView>().viewID, this.health.Owner.team, this.currentSlot.slotID );
        }
        this.currentSlot = null;
    }
Example #7
0
    public void Respawn()
    {
        //Find an empty spot on the friendly capital ship and dock there
        DockingBay[] bays = FindObjectsOfType( typeof(DockingBay) ) as DockingBay[];

        DockingBay bay = null;

        //TODO: This could be done better with a script on the capital ship
        if ( bays.Length > 0 )
        {
            int index = (int)Random.Range( 0, bays.Length );
            int startingIndex = index;

            while ( true )
            {
                if ( index == bays.Length )
                {
                    index = 0;
                }

                if( bays[index].capitalShip.health.Owner.team == this.health.Owner.team )
                {
                    bay = bays[index];
                    break;
                }
                ++index;
                if ( index == startingIndex )
                {
                    DebugConsole.Warning("Could not find an empty docking bay (somehow)");
                    break;
                }
            }
        }

        this.ToggleEnabled( true, true );

        if ( Network.peerType != NetworkPeerType.Disconnected )
        {
            GameNetworkManager.instance.SendRespawnedFighterMessage( this.GetComponent<NetworkView>().viewID );
        }

        if ( bay != null )
        {
            this.Dock( bay.GetFreeSlot() );
        }
        else
        {
            DebugConsole.Warning( "No docking bays found", this );
            this.transform.position = Vector3.zero;
            this.transform.rotation = Quaternion.identity;
            this.GetComponent<Rigidbody>().velocity = Vector3.zero;
            this.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
            this.state = FIGHTERSTATE.FLYING;
        }
    }
Example #8
0
 public void OnRespawnFighterNetworkMessage()
 {
     this.state = FIGHTERSTATE.FLYING;
     this.ToggleEnabled( true, false );
 }
Example #9
0
 public void OnOutOfControlNetworkMessage()
 {
     this.state = FIGHTERSTATE.OUT_OF_CONTROL;
 }