コード例 #1
0
ファイル: Unit.cs プロジェクト: Jay2645/ludum-dare-7dRTS
 public virtual void RegisterLeader(Leader newLeader)
 {
     if (newLeader == null)
         return;
     leader = newLeader;
     if (!leader.IsOwnedByPlayer())
         Destroy(label);
     Deselect();
     ResetTarget();
     lastOrderer = null;
     aBase = leader.aBase;
     teamColor = leader.teamColor;
     leader.RegisterUnit(this);
     renderer.material.color = teamColor;
     SetOutlineColor(outlineColor);
     float distanceFromLeader = Vector3.Distance(transform.position, leader.transform.position);
     if (leader != (Leader)Commander.player && distanceFromLeader >= MOVE_TO_LEADER_DISTANCE)
     {
         OrderData supportLeader = new OrderData(leader, this);
         supportLeader.SetOrder(Order.move, false);
         supportLeader.SetMoveType(MoveType.DefendSelf);
         supportLeader.SetTarget(leader.transform);
         RecieveOrder(supportLeader);
     }
     else
     {
         leader.UnitRequestOrders(this);
     }
     if (IsOwnedByPlayer() && !IsLedByPlayer())
         MessageList.Instance.AddMessage(uName + ", acknowledging " + leader.name + " as my new leader.");
 }