本文整理汇总了C#中Contract.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Contract.GetType方法的具体用法?C# Contract.GetType怎么用?C# Contract.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract
的用法示例。
在下文中一共展示了Contract.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddContractToListView
private void AddContractToListView(Contract contract, bool selected = false)
{
ContractListView.Items.Add(new ListViewItem(new[] { contract.Address, contract.GetType().ToString() })
{
Name = contract.Address,
Tag = contract
}).Selected = selected;
}
示例2: TargetBody
/// <summary>
/// Used externally to return the target Celestial Body
/// </summary>
/// <param name="cP">Instance of the requested Contract</param>
/// <returns>Celestial Body object</returns>
public static CelestialBody TargetBody(Contract c)
{
if (c == null || c.GetType() != typeof(DMMagneticSurveyContract))
return null;
DMMagneticSurveyContract Instance = (DMMagneticSurveyContract)c;
return Instance.body;
}
示例3: contractTypeName
public static string contractTypeName(Contract c)
{
if (c == null || c.GetType() != typeof(ConfiguredContract))
{
return "";
}
ConfiguredContract cc = (ConfiguredContract)c;
return cc.contractType != null ? cc.contractType.name : "";
}
示例4: contractGroupName
/// <summary>
/// Static method (used by other mods via reflection) to get the group name.
/// </summary>
public static string contractGroupName(Contract c)
{
if (c == null || c.GetType() != typeof(ConfiguredContract))
{
return "";
}
ConfiguredContract cc = (ConfiguredContract)c;
if (cc.contractType == null)
{
return "";
}
ContractGroup group = cc.contractType.group;
if (group == null)
{
return "";
}
while (group.parent != null)
{
group = group.parent;
}
return group.name;
}
示例5: contractContainer
public contractContainer(Contract c)
{
root = c;
try
{
id = root.ContractGuid;
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Guid not set, skipping...\n" + e);
root = null;
return;
}
try
{
title = root.Title;
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Title not set, using type name...\n" + e);
title = root.GetType().Name;
}
try
{
notes = root.Notes;
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Notes not set, blank notes used...\n" + e);
notes = "";
}
try
{
briefing = root.Description;
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Briefing not set, blank briefing used...\n" + e);
briefing = "";
}
try
{
canBeDeclined = root.CanBeDeclined();
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Decline state not set, using true...\n" + e);
canBeDeclined = true;
}
try
{
canBeCancelled = root.CanBeCancelled();
}
catch (Exception e)
{
Debug.LogError("[Contract Parser] Contract Cancel state not set, using true...\n" + e);
canBeCancelled = true;
}
if (root.Agent != null)
agent = root.Agent;
else
agent = AgentList.Instance.GetAgentRandom();
if (c.DateDeadline <= 0)
{
duration = double.MaxValue;
daysToExpire = "----";
}
else
{
duration = root.DateDeadline - Planetarium.GetUniversalTime();
//Calculate time in day values using Kerbin or Earth days
daysToExpire = timeInDays(duration);
}
updateTimeValues();
contractRewards();
contractPenalties();
contractAdvance();
decPen = HighLogic.CurrentGame.Parameters.Career.RepLossDeclined;
decPenString = decPen.ToString("F0");
totalFundsReward = rewards();
totalFundsPenalty = penalties();
totalRepReward = repRewards();
totalSciReward = sciRewards();
totalRepPenalty = repPenalties();
//Generate four layers of parameters
for (int i = 0; i < c.ParameterCount; i++)
{
//.........这里部分代码省略.........
示例6: OnContractOffered
protected void OnContractOffered(Contract c)
{
LoggingUtil.LogVerbose(this, "OnContractOffered: " + c.Title);
if (MissionControl.Instance == null)
{
return;
}
// Check we're in the right mode
if (!displayModeAll || MissionControl.Instance.displayMode != MissionControl.DisplayMode.Available)
{
if (MissionControl.Instance.displayMode != MissionControl.DisplayMode.Available)
{
MissionControl.Instance.ClearInfoPanel();
MissionControl.Instance.panelView.gameObject.SetActive(false);
MissionControl.Instance.RebuildContractList();
}
else
{
OnClickAvailable(true);
OnSelectContract(selectedButton, UIRadioButton.CallType.USER, null);
}
return;
}
ConfiguredContract cc = c as ConfiguredContract;
ContractContainer container = null;
if (cc != null)
{
ContractContainer foundMatch = null;
List<UIListData<KSP.UI.UIListItem>>.Enumerator enumerator = MissionControl.Instance.scrollListContracts.GetEnumerator();
while (enumerator.MoveNext())
{
KSP.UI.UIListItem item = enumerator.Current.listItem;
container = item.Data as ContractContainer;
if (container != null)
{
if (container.contractType == cc.contractType)
{
// Upgrade the contract type line item to a contract
if (container.contract == null)
{
container.contract = cc;
SetupContractItem(container);
// Check if the selection was this contract type
if (selectedButton != null)
{
ContractContainer contractContainer = selectedButton.GetComponent<KSP.UI.UIListItem>().Data as ContractContainer;
if (contractContainer != null && contractContainer == container)
{
OnSelectContract(selectedButton, UIRadioButton.CallType.USER, null);
}
}
break;
}
// Keep track of the list item - we'll add immediately after it
else
{
foundMatch = container;
}
}
continue;
}
}
// Got a match, do an addition
if (foundMatch != null)
{
container = new ContractContainer(cc);
container.parent = foundMatch.parent;
container.parent.childContracts.Add(container);
CreateContractItem(container, foundMatch.indent, foundMatch.mcListItem.container);
// Show/hide based on state of group line
container.mcListItem.gameObject.SetActive(container.parent.expanded && container.parent.mcListItem.gameObject.activeSelf);
}
}
else
{
List<UIListData<KSP.UI.UIListItem>>.Enumerator enumerator = MissionControl.Instance.scrollListContracts.GetEnumerator();
Type contractType = c.GetType();
GroupContainer closestGroup = null;
ContractContainer lastEntry = null;
ContractContainer foundMatch = null;
while (enumerator.MoveNext())
{
KSP.UI.UIListItem item = enumerator.Current.listItem;
// Check for a group to use for the position later if we need to add a group
GroupContainer groupContainer = item.Data as GroupContainer;
if (groupContainer != null)
{
if (closestGroup == null || string.Compare(groupContainer.DisplayName(), GroupContainer.DisplayName(contractType)) < 0)
{
closestGroup = groupContainer;
}
}
//.........这里部分代码省略.........
示例7: OrderKey
public static string OrderKey(Contract c)
{
ConfiguredContract cc = c as ConfiguredContract;
if (cc != null)
{
string key = cc.contractType.group == null ? "aaa" : cc.contractType.group.sortKey;
for (ContractGroup group = cc.contractType.group; group != null; group = group.parent)
{
if (group.parent != null)
{
key = group.parent.sortKey + "." + key;
}
}
key += "." + cc.contractType.sortKey;
return key;
}
else
{
return DisplayName(c.GetType()) + "." + c.Title;
}
}
示例8: ContractTypeMatches
private bool ContractTypeMatches(Contract contract)
{
// Get the contract type
Type contractType = contract.GetType();
string contractTypeName = contractType.Name;
if (contractTypeName == "ConfiguredContract")
{
contractTypeName = ConfiguredContract.contractGroupName(contract);
}
// Check if contract type matches
return contractTypes.Contains(contractTypeName);
}