Ejemplo n.º 1
0
 // distanceThreshold: Ship will stop moving once within certain distance to destination
 public MoveCommand(Ship ship, Vector2 destination, float distanceThreshold = 0.1f)
 {
     this._ship                 = ship;
     this._thruster             = ship.CmpThruster;
     this._destination          = new Vector3(destination.x, destination.y, 0.0f);
     this._distanceThreshold    = distanceThreshold;
     this._sqrDistanceThreshold = Mathf.Pow(distanceThreshold, 2);
 }
Ejemplo n.º 2
0
    void InitCmpThruster(Ship ship)
    {
        CmpThruster cmp = ship.gameObject.GetComponent <CmpThruster>();

        if (!cmp)
        {
            return;
        }
        cmp.Init(ship);
    }
Ejemplo n.º 3
0
    // Add Thruster
    void AddThruster(Ship ship, ShipThruster thruster)
    {
        GameObject  shipObject = ship.gameObject;
        CmpThruster cmp        = shipObject.GetComponent <CmpThruster>();

        if (!cmp)
        {
            cmp = shipObject.AddComponent <CmpThruster>() as CmpThruster;
        }
        cmp.Add(thruster);
    }