本文整理汇总了C#中Faction类的典型用法代码示例。如果您正苦于以下问题:C# Faction类的具体用法?C# Faction怎么用?C# Faction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Faction类属于命名空间,在下文中一共展示了Faction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetZoneOfControl
// Unit moved to a hex adjacent to this edge. Increase the cost of this edge for enemy units to traverse
public void SetZoneOfControl(Faction faction)
{
if (faction.faction_ID == 1)
cost[2] = 5;
else if (faction.faction_ID == 2)
cost[1] = 5;
}
示例2: InitFaction
private Faction InitFaction(XmlNode factionNode)
{
Faction faction = new Faction(village, factionNode.SelectSingleNode("Name").InnerText);
if (factionNode.SelectSingleNode("Evil") != null) {
faction.Alignment = Alignment.Evil;
}
if(factionNode.SelectSingleNode("Nightkill") != null ) {
faction.AddPower(new Powers.NightkillPower());
}
if(factionNode.SelectSingleNode("KnowsGroup") != null) {
faction.AddPower(new Powers.MembersPower());
}
string[] conditions = factionNode.SelectSingleNode("WinsWhen").InnerText.Split('|');
foreach (string condition in conditions) {
switch (condition) {
case "MajorityOrEqual":
faction.WinConditions.Add(new MajorityOrEqualCondition());
break;
case "NoEvilLeft":
faction.WinConditions.Add(new NoEvilLeftCondition());
break;
}
}
return faction;
}
示例3: ApplyCollarEffects
public void ApplyCollarEffects( Pawn pawn, Apparel collar )
{
if( originalFaction == null )
{
if( pawn.Faction == Faction.OfPlayer )
{
originalFaction = Find.FactionManager.FirstFactionOfDef( FactionDefOf.Spacer );
}
else
{
originalFaction = pawn.Faction;
}
}
if( originalPawnKind == null )
{
originalPawnKind = pawn.kindDef;
}
pawn.kindDef = Data.PawnKindDefOf.Slave;
if(
( pawn.story != null )&&
( pawn.story.traits != null )&&
( !pawn.story.traits.HasTrait( Data.TraitDefOf.Enslaved ) )
)
{
pawn.story.traits.GainTrait( new Trait( Data.TraitDefOf.Enslaved ) );
}
}
示例4: getNodeClosestToEnemies
/// <summary>
/// Gets the node closest from any enemy combatants, inclusive of current nodea.
///
/// FUTURE: Add calculations for safety based on effective range of the weapon they are holding.
/// e.g., One is much safer ten meters away from a sniper than one half-kilometer away.
/// </summary>
/// <returns>
/// The most dangerous node.
/// </returns>
public PFNode getNodeClosestToEnemies(GameObject[] enemies, Faction allegiance = Faction.Evil)
{
float leastDangerous = 0f;
int index = -1;
int i = 0;
foreach (GameObject e in enemies) {
// Change the != to whatever the faction relationship system is.
if (e.GetComponent<Enemy>().faction != allegiance) leastDangerous +=
(currentNode.transform.position- e.transform.position).sqrMagnitude;
}
if (debugMode) print ("Risk for " + currentNode.name + " is "+leastDangerous);
foreach (PFNodeEntry node in currentNode.Nodes) {
float riskFactor = 0;
if (debugMode) foreach (GameObject g in enemies)print (g.name);
foreach (GameObject e in enemies) {
if (e.GetComponent<Enemy>().faction != allegiance) riskFactor +=
(node.node.transform.position - e.transform.position).sqrMagnitude;
//if (debugMode) print ("Calculated for " + e.name + " near " + node.node.gameObject.name);
}
if (debugMode) print ("Risk for " + node.node.name + " is "+riskFactor);
if (riskFactor < leastDangerous) {
index = i;
leastDangerous = riskFactor;
}
i++;
}
choice=(index == -1) ? currentNode : currentNode.Nodes[index].node;
return (index == -1) ? currentNode : currentNode.Nodes[index].node;
}
示例5: Damageable
public Damageable(Sprite sprite, Faction faction, int maxHP, int currentHP, bool collideable)
: base(sprite, collideable)
{
this.Faction = faction;
this.MaxHealth = maxHP;
this.Health = currentHP;
}
示例6: createFactions
private void createFactions()
{
factions = new List<Faction>();
Random random = new Random();
//Erstelle alle Factions zuerst
foreach (FactionEnum item in Enum.GetValues(typeof(FactionEnum)))
{
Faction tmpFaction = new Faction(item);
factions.Add(tmpFaction);
}
//Bilde in jeder Faction eine Referenz auf jede andere Faction mit einem Zufallswert zwischen 0 und 100
foreach (Faction faction in factions)
{
foreach (Faction faction2 in factions)
{
if (faction == faction2)
{
faction.addItem(new BehaviourItem<Faction>(faction2, 100));
}
else
{
faction.addItem(new BehaviourItem<Faction>(faction2, random.Next(0, 100)));
}
}
}
}
示例7: Start
void Start()
{
rigidbody.freezeRotation = true;
faction = gameObject.GetComponent<Faction> ();
walking = gameObject.GetComponent<Walking> ();
rotating = gameObject.GetComponent<Rotating> ();
}
示例8: AddNewCharacter
/// <summary>
/// add a new character to this account, if the newly created character abides to some rules
/// </summary>
/// <param name="name">name of the character</param>
/// <param name="level">level of the character</param>
/// <param name="race">race of the character</param>
/// <param name="faction">faction of the character</param>
/// <param name="class">class of the character</param>
/// <returns>return true if the creation wnet smoothly</returns>
public bool AddNewCharacter(Guid id, string name, int level, Race race, Faction faction, Class @class)
{
var newCharacter = new Character()
{
Id = id,
Name = name,
Level = level,
Race = race,
Faction = faction,
Class = @class
};
if ( CharacterSpecifications.Factions
.And(CharacterSpecifications.DruidSpecifications)
.And(CharacterSpecifications.BloodElfSpecifications)
.IsSatisfiedBy(newCharacter)
&& AccountSpecifications.DeathKnightSpecifications(newCharacter)
.IsSatisfiedBy(this))
{
Characters.Add(newCharacter);
return true;
}
else
return false;
}
示例9: SpawnBase
public GameObject SpawnBase(Faction a_faction)
{
GameObject prefab = null;
switch (a_faction)
{
case Faction.NONE:
Debug.LogError("Can't load 'NONE' faction!");
return null;
case Faction.NAVY:
prefab = navyBase;
break;
case Faction.PIRATES:
prefab = piratesBase;
break;
case Faction.TINKERERS:
prefab = tinkerersBase;
break;
case Faction.VIKINGS:
prefab = vikingsBase;
break;
}
// Spawn base and setup base
if (baseType == BaseSpawnerType.FFA_ONLY &&
m_scoreManager.gameType != EGameType.FreeForAll)
{
// Don't spawn FFA base in teams gamemode
return null;
}
else if ((baseType == BaseSpawnerType.TEAM_ALPHA || baseType == BaseSpawnerType.TEAM_OMEGA) &&
m_scoreManager.gameType != EGameType.TeamGame)
{
// Don't spawn Team base in FFA gamemode
return null;
}
GameObject baseObject = Instantiate(prefab, transform.position, transform.rotation) as GameObject;
baseObject.tag = this.tag;
switch (m_scoreManager.gameType)
{
case EGameType.FreeForAll:
SetupBaseForFFA(baseObject);
break;
case EGameType.TeamGame:
SetupBaseForTeams(baseObject);
break;
}
DestroyImmediate(this.gameObject);
return baseObject;
}
示例10: AStarFindPath
float y_offset = 1.622f; //1.89f;
#endregion Fields
#region Methods
// Finds the most efficient path between two hexes, using the cost of the edges between the edges as the evaluator
public List<Hex> AStarFindPath(Hex start, Hex finish, int maximum_cost_allowed, Faction faction)
{
// Reset hex search scores
resetCellSearchScores();
List<Hex> closedSet = new List<Hex>();
List<Hex> openSet = new List<Hex>();
openSet.Add(start);
start.came_from = null;
start.g_score = 0; // Cost of best known path
start.f_score = start.g_score + estimatedCost(start.coordinate, finish.coordinate); // Estimated cost of path from start to finish
// Keep going until openset is empty
while (openSet.Count > 0)
{
openSet.Sort();
Hex current = openSet[0];
// Check if we found the goal
if (current == finish && current.g_score <= maximum_cost_allowed)
{
return constructPath(current, start);
}
openSet.Remove(current);
closedSet.Add(current);
foreach (Edge neighbourEdge in current.neighbours)
{
int tentative_g_score = current.g_score + neighbourEdge.GetCost(faction);
// Check if have exceeded our allowed movement
if (current.g_score >= maximum_cost_allowed || (closedSet.Contains(neighbourEdge.destination) && tentative_g_score >= neighbourEdge.destination.g_score))
{
continue;
}
if (!openSet.Contains(neighbourEdge.destination) || tentative_g_score < neighbourEdge.destination.g_score)
{
neighbourEdge.destination.came_from = current;
neighbourEdge.destination.g_score = tentative_g_score;
neighbourEdge.destination.f_score = neighbourEdge.destination.g_score +
estimatedCost(neighbourEdge.destination.coordinate, finish.coordinate);
if (!openSet.Contains(neighbourEdge.destination))
{
openSet.Add(neighbourEdge.destination);
neighbourEdge.destination.came_from = current;
}
}
}
}
// Return failure
Debug.Log("Failed to find path between " + start.coordinate + " and " + finish.coordinate);
return new List<Hex>();
}
示例11: Tower
public Tower(TowerBase towerBase, Faction faction, int _towerNum)
{
sections = new List<Section>();
dotManager = new DotManager();
this.towerBase = towerBase;
this.faction = faction;
towerNum = _towerNum;
}
示例12: GetBribeCount
public int GetBribeCount(Faction faction)
{
if (faction == null) throw new NullReferenceException("Faction not set.");
int result;
if (bribeCount.TryGetValue(faction.randomKey, out result)) return result;
return 0;
}
示例13: Bribe
public void Bribe(Faction faction)
{
if (faction == null) throw new NullReferenceException("Faction not set.");
bribeCount[faction.randomKey] = GetBribeCount(faction) + 1;
CheckForMapComponent();
}
示例14: Card
public Card(string name, Faction faction, GameAction mainAction, GameAction allyAction = null, GameAction trashAction = null)
{
Name = name;
Faction = faction;
MainAction = mainAction;
AllyAction = allyAction;
TrashAction = trashAction;
}
示例15: CreateInstance
public static GameObject CreateInstance( double time , Vector3 pos, Vector3 dir , Faction faction, FireBallCaster caster)
{
GameObject obj = (GameObject)GameObject.Instantiate(
Resources.Load("Prefab/Skill/FireBallBullet"), pos, Quaternion.LookRotation(dir)
);
obj.GetComponent<FireBallBullet>().SetCreationParameters(pos, dir, time, caster);
obj.GetComponent<Faction>().SetFaction(faction);
return obj;
}