void RpcSendMessageToFaction(Message message, FactionName faction) { if (faction == PlayerManager.GetPlayerManager.Player.Faction) { AddMessageToList(message); } }
public bool fire(Transform barrelEnd, Transform barrelStart, FactionName factionThatFiredShot, bool isAiming = false) { //print (fireModes.Length); if (magazines.Count != 0) { currentMag = currentMag % magazines.Count; } else { currentMag = 0; } if (stateOfWeapon == WeaponState.Ready && magazines.Count > 0) { magazines[currentMag] -= fireModes [currentFireMode].fire(barrelEnd.position, barrelStart.position, magazines[currentMag], factionThatFiredShot, isAiming); if (!discardOnFire && magazines[currentMag] <= 0) { magazines.RemoveAt(currentMag); if (magazines.Count > 0) { currentMag = currentMag % magazines.Count; } return(true); } } else { //print () } return(false); }
public bool fire(FactionName factionThatFiredShot, bool isAiming = false, bool fireButtonHeldDown = true, bool fireButtonPressed = false) { if (enabled && weapon.willFire(fireButtonHeldDown, fireButtonPressed)) { if ((Time.time - timeWhenLastSoundWasRemoved) > soundRemovalInterval && numSounds > 0) { timeWhenLastSoundWasRemoved = Time.time; numSounds -= 1; } if (fireSoundSource != null && fireSound != null && weapon.magazines.Count > 0 && weapon.magazines[weapon.currentMag] > 0 && numSounds < maxNumSounds) { fireSoundSource.PlayOneShot(fireSound); numSounds += 1; } bool result = weapon.fire(barrelEnd, barrelStart, factionThatFiredShot, isAiming); if (weapon.discardOnFire && weapon.stateOfWeapon != WeaponState.Dropped) { weapon.stateOfWeapon = WeaponState.Dropped; weapon.dropWeapon(barrelEnd.position); //gameObject.rem } return(result); } return(false); }
/// <summary> /// 寻找周围的能量建筑 不包括GaiaBuilding /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="name"></param> /// <returns></returns> public List <Tuple <int, int> > GetSurroundhexWithBuild(int x, int y, FactionName name, int?dis = null) { //吸能量大小范围 var ret = new List <Tuple <int, int> >(); int distance = 0; if (dis.HasValue) { distance = dis.Value; } else { distance = 1; } for (int i = Math.Max(x - distance, 0); i <= Math.Min(x + distance, m_mapHeight - 1); i++) { for (int j = Math.Max(y - distance, 0); j <= Math.Min(j + distance, m_mapWidth - 1); j++) { if (CalTwoHexDistance(x, y, i, j) <= distance) { //System.Diagnostics.Debug.WriteLine("row:" + i + " col:" + j); if ((HexArray[i, j] != null && HexArray[i, j].FactionBelongTo == name && !(HexArray[i, j].Building is GaiaBuilding)) || (name == FactionName.Lantida && HexArray[i, j] != null && HexArray[i, j].SpecialBuilding != null)) { ret.Add(new Tuple <int, int>(i, j)); } } } } return(ret); }
public bool AIfire(FactionName factionThatFiredShot, Vector3 barrelStart, Vector3 barrelEnd, bool isAiming = false) { if (enabled) { if (weapon.getCurrentFireMode().timeSinceLastShot > weapon.getCurrentFireMode().fireRate) { if ((Time.time - timeWhenLastSoundWasRemoved) > soundRemovalInterval && numSounds > 0) { timeWhenLastSoundWasRemoved = Time.time; numSounds -= 1; } if (fireSoundSource != null && fireSound != null && weapon.magazines.Count > 0 && weapon.magazines [weapon.currentMag] > 0 && numSounds < maxNumSounds) { fireSoundSource.PlayOneShot(fireSound); numSounds += 1; } } //barrelEnd.position +=startBarrelOffset; bool result = weapon.fire(barrelEnd, barrelStart, factionThatFiredShot, isAiming); //barrelStart.position-=startBarrelOffset; if (weapon.discardOnFire && weapon.stateOfWeapon != WeaponState.Dropped) { weapon.stateOfWeapon = WeaponState.Dropped; weapon.dropWeapon(barrelEnd); //gameObject.rem } return(result); } return(false); }
/// <summary> /// 寻找周围的空的能放卫星的格子 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="name"></param> /// <param name="dis"></param> /// <returns></returns> public List <Tuple <int, int> > GetSurroundhex(int x, int y, FactionName name, List <Tuple <int, int> > list) { //吸能量大小范围 var ret = new List <Tuple <int, int> >(); int distance = 1; for (int i = Math.Max(x - distance, 0); i <= Math.Min(x + distance, m_mapHeight - 1); i++) { for (int j = Math.Max(y - distance, 0); j <= Math.Min(j + distance, m_mapWidth - 1); j++) { if (CalTwoHexDistance(x, y, i, j) <= distance) { if (HexArray[i, j] != null && HexArray[i, j].TFTerrain == Terrain.Empty && !HexArray[i, j].Satellite.Contains(name)) { var surroundHex = GetSurroundhexWithBuildingAndSatellite(i, j, name); surroundHex.RemoveAll(z => list.Contains(z)); if (surroundHex.Count == 0) { ret.Add(new Tuple <int, int>(i, j)); } } } } } return(ret); }
public Player(string name, FactionName faction) { this.Name = name; this.Score = 0; switch (faction) { case FactionName.Dwarves: this.CurrentFaction = new DwarvesFaction(); break; case FactionName.Gauls: this.CurrentFaction = new GaulsFaction(); break; case FactionName.Vikings: this.CurrentFaction = new VikingsFaction(); break; default: throw new NotImplementedException(); } if (Name.StartsWith("AI-")) // Artificial Intelligence { isAI = true; aiTimer = new System.Windows.Threading.DispatcherTimer(); aiTimer.Tick += new EventHandler(aiLogic_Tick); aiTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); } }
public IActionResult LeechPower(string name, FactionName factionName, int power, FactionName leechFactionName, bool isLeech, bool?isPwFirst) { if (ServerStatus.IsStopSyntax == true) { return(Redirect("/home/serverdown")); } var task = _userManager.GetUserAsync(HttpContext.User); Task[] taskarray = new Task[] { task }; Task.WaitAll(taskarray, millisecondsTimeout: 1000); var faction = GameMgr.GetGameByName(name).FactionList.Find(x => x.FactionName.ToString().Equals(name)); var leech = isLeech ? "leech" : "decline"; var syntax = string.Format("{0}:{1} {2} from {3}", factionName, leech, power, leechFactionName); if (isPwFirst.HasValue) { var pwFirst = isPwFirst.GetValueOrDefault() ? "pw" : "pwt"; syntax = syntax + " " + pwFirst; } GaiaGame gaiaGame = GameMgr.GetGameByName(name); try { //GameMgr.WriteUserActionLog(syntax, task.Result.UserName); } catch { } gaiaGame.Syntax(syntax, out string log, dbContext: this.dbContext); //如果是即时制游戏,进行通知 if (gaiaGame.IsSocket) { NoticeWebSocketMiddleware.GameActive(gaiaGame, HttpContext.User); } return(Redirect("/home/viewgame/" + System.Net.WebUtility.UrlEncode(name))); }
public void AddSatellite(FactionName factionName) { if (Satellite != null) { Satellite.Add(factionName); } }
/* * This method damages a object, then it's parents. If the health is <=0 and the object should be destroyed when it dies (runs out of health) it is destroyed and a random death sound is played */ public virtual bool damage(float amount, FactionName factionThatFiredShot = FactionName.NONE, Vector3 shotDirection = default(Vector3)) { if (canBeDamaged && (c_soldierEntity.entity == null || c_soldierEntity.entity.faction != factionThatFiredShot)) { health -= amount; for (int i = 0; i < eventsToCallOnDamage.Count; ++i) { eventsToCallOnDamage [i] (this, amount, factionThatFiredShot, shotDirection); } if (parent != null) { parent.damage(amount, factionThatFiredShot, shotDirection); } } if (health <= 0 && destroyOnDeath) { GameObject.Destroy(gameObject); if (audioClipsToPlayOnDeath != null && audioClipsToPlayOnDeath.Length > 0) { AudioSource.PlayClipAtPoint(audioClipsToPlayOnDeath[(int)UnityEngine.Random.Range(0, audioClipsToPlayOnDeath.Length - 1)], gameObject.transform.position); } return(false); } return(true); }
public static FactionComponent Create(FactionName faction) { var component = new FactionComponent(); component.Faction = faction; return(component); }
public Region(IMap map, Stack <string> baddieNames, FactionName stockBaddieFaction, bool isNebulae = false) { this.Empty = true; this.Map = map; this.Name = String.Empty; this.Create(baddieNames, stockBaddieFaction, isNebulae); }
public Faction FactionDetails(FactionName faction) { this.Reset(); var factionElement = this.Get.Factions[faction.ToString()]; return(factionElement); }
public SoldierEntity(/*Collider[] CollidersForOtherSoldiersToCheckFor,*/ Transform [] LOSCheckTransforms, Collider[] LOSCheckColliders, FactionName faction, CharacterController mainLOSCollider, Transform centreOfMass) { //this.CollidersForOtherSoldiersToCheckFor = CollidersForOtherSoldiersToCheckFor; this.LOSCheckTransforms = LOSCheckTransforms; this.LOSCheckColliders = LOSCheckColliders; this.faction = faction; this.mainLOSCollider = mainLOSCollider; this.centreOfMass = centreOfMass; }
public static FactionName [] ActiveFactions() { FactionName[] activeFactions = new FactionName[Factions.Count]; for (int i = 0; i < Factions.Count; ++i) { activeFactions [i] = Factions [i].FactionName; } return(activeFactions); }
public Map(SetupOptions setupOptions, IOutputWrite write, IStarTrekKGSettings config, FactionName defaultHostile = null) { this.Config = config; this.Write = write; this.DefaultHostile = defaultHostile ?? FactionName.Klingon; this.Initialize(setupOptions); }
public void Create(Stack <string> baddieNames, FactionName stockBaddieFaction, bool addStars = true, bool makeNebulae = false) { if (this.Map == null) { throw new GameException("Set Map before calling this function"); } this.InitializeSectors(this, new List <Sector>(), baddieNames, stockBaddieFaction, addStars, makeNebulae); }
public static List <Entity> AdjacentHostiles(EncounterState state, FactionName parentFaction, EncounterPosition position) { var adjacentHostiles = new List <Entity>(); foreach (var newpos in state.AdjacentPositions(position)) { adjacentHostiles.AddRange(AIUtils.HostilesInPosition(state, parentFaction, newpos.X, newpos.Y)); } return(adjacentHostiles); }
/// <summary> /// Method to be used as event for when agent is damaged /// </summary> /// <param name="healthController">Health controller.</param> /// <param name="damage">Damage.</param> /// <param name="factionThatFiredShot">Faction that fired shot.</param> /// <param name="shotDirection">Shot direction.</param> public bool OnDamage(ControlHealth healthController, float damage, FactionName factionThatFiredShot, Vector3 shotDirection) { if (healthController.health <= 0) { Debug.Assert(GameData.scores.ContainsKey(factionThatFiredShot)); ++GameData.scores [factionThatFiredShot]; Respawn(); } return(false); }
public int CalShipDistanceNeed(int row, int col, FactionName factionName) { for (int i = 1; i < m_mapHeight; i++) { if (CalIsBuildValidate(row, col, factionName, i)) { return(i); } } throw new Exception("无法结算航海距离"); }
public List <string> FactionShips(FactionName faction) //todo: this is called multiple times, do we need to reload file? { this.Reset(); var factionElement = this.Get.Factions[faction.ToString()]; FactionShips factionShips = factionElement.FactionShips; var shipNames = (from RegistryNameTypeClass shipElement in factionShips select shipElement.name.Trim()).ToList(); return(shipNames); }
//used by AI, so that intelligent entities can respond to near misses. Needs empty body since we can't make method abstract public virtual void suppress(float damage, FactionName factionThatFiredShot = FactionName.NONE, Vector3 shotDirection = default(Vector3)) { float timeRatio = 1f / (1f + Time.time - lastSuppressionTime); //must add one to ensure that ratio is <=1 suppressionLevel = (1f - timeRatio) * (damage / maxhealth) + timeRatio * suppressionLevel; lastSuppressionTime = Time.time; if (parent != null) { parent.suppress(damage * weighting, factionThatFiredShot, shotDirection); } }
public static void RemoveFaction(FactionName factionName) { for (int i = 0; i < Factions.Count; ++i) { if (Factions [i].FactionName == factionName) { Factions.RemoveAt(i); --i; } } }
public static Faction getFaction(FactionName factionToGet) { for (int i = 0; i < Factions.Count; i++) { if (Factions[i].FactionName == factionToGet) { return(Factions[i]); } } //Factions.Add(new Faction(factionToGet)); return(Factions[Factions.Count - 1]); }
public OrderTrigger(OrderTriggerType triggerType, bool repeating, List <string> watchedUnitIds = null, List <UnitOrder> awaitedStandingOrders = null, float belowStrengthPercent = 9999, FactionName triggerFaction = FactionName.NEUTRAL, int activateOnTurn = -1) { this.TriggerType = triggerType; this.Repeating = repeating; this.WatchedUnitIds = watchedUnitIds; this.AwaitedStandingOrders = awaitedStandingOrders; this.BelowStrengthPercent = belowStrengthPercent; this.TriggerFaction = triggerFaction; this.ActivateOnTurn = activateOnTurn; }
private static void TryAddAttackAdjacent(EncounterState state, Entity parent, List <EncounterAction> actions, FactionName parentFaction, EncounterPosition targetEndPos) { var adjacentHostiles = AIUtils.AdjacentHostiles(state, parentFaction, targetEndPos); if (adjacentHostiles.Count > 0) { // TODO: don't attack randomly var target = adjacentHostiles[state.EncounterRand.Next(adjacentHostiles.Count)]; actions.Add(new MeleeAttackAction(parent.EntityId, target)); } }
public static int getNumEnemyEntities(FactionName faction) { int result = 0; for (int i = 0; i < Factions.Count; i++) { if (Factions[i].FactionName != faction) { result += Factions[i].Soldiers.Count; } } return(result); }
public void Create(IMap map, Stack <string> RegionNames, Stack <string> baddieNames, FactionName stockBaddieFaction, out int nameIndex, bool addStars = true, bool makeNebulae = false) { nameIndex = (Utility.Utility.Random).Next(baddieNames.Count); this.Map = map; this.InitializeSectors(this, new List <Sector>(), baddieNames, stockBaddieFaction, addStars, makeNebulae); if (RegionNames != null) { this.Name = RegionNames.Pop(); } }
public static List <Entity> HostilesInPosition(EncounterState state, FactionName parentFaction, int x, int y) { var hostiles = new List <Entity>(); foreach (Entity e in state.EntitiesAtPosition(x, y)) { var factionComponent = e.GetComponent <FactionComponent>(); if (factionComponent != null && factionComponent.Faction != parentFaction) { hostiles.Add(e); } } return(hostiles); }
public void PopulateMatchingItem(Region Region, ICollection <Sector> itemsToPopulate, int x, int y, Stack <string> baddieNames, FactionName stockBaddieFaction, bool isNebula) { var sectorItemToPopulate = SectorItem.Empty; try { if (itemsToPopulate != null) { if (itemsToPopulate.Count > 0) { Sector sectorToPopulate = itemsToPopulate.SingleOrDefault(i => i.X == x && i.Y == y); if (sectorToPopulate != null) { if ((Region.Type == RegionType.Nebulae) && (sectorToPopulate.Item == SectorItem.Starbase)) { sectorItemToPopulate = SectorItem.Empty; } else { if (!(isNebula && (sectorToPopulate.Item == SectorItem.Starbase))) { sectorItemToPopulate = sectorToPopulate.Item; } } } else { sectorItemToPopulate = SectorItem.Empty; } //todo: plop item down on map //what does Output read? cause output is blank //output reads SectorItem. Is sectorItem.Hostile being added? //todo: new ship(coordinates)? //todo: add to hostiles? } } } catch (Exception ex) { //throw new GameException(ex.Message); } this.AddSector(Region, x, y, sectorItemToPopulate, baddieNames, stockBaddieFaction); }
public static FactionName Opposite(this FactionName faction) { if (faction == FactionName.PLAYER) { return(FactionName.ENEMY); } else if (faction == FactionName.ENEMY) { return(FactionName.PLAYER); } else { throw new NotImplementedException(); } }
public void DockingRequest(FactionName dockingFactionName) { if (Faction.Standings[dockingFactionName] != FactionStanding.Enemy) { Debug.Log("Docking Request Accepted"); SaveManager.SaveGame(); //set the planet to be loaded, then change scenes DockedSceneManager.PlanetName = this.PlanetName; Application.LoadLevel("DockedScene"); } else { //TODO add docking request denied message to messages queue (once implemented) Debug.Log("Docking Request Denied"); } }
public PlayerBox() { InitializeComponent(); playerId = nbCreatedPlayers; txtName.Text = "Player " + (playerId + 1); switch(nbCreatedPlayers) { case 0: playerColor = Color.FromRgb(200, 64, 64); break; case 1: playerColor = Color.FromRgb(64, 64, 200); break; case 2: playerColor = Color.FromRgb(64, 200, 64); break; case 3: playerColor = Color.FromRgb(200, 180, 64); break; } rectColor.Fill = new SolidColorBrush(playerColor); nbCreatedPlayers++; Random rnd = new Random(); factionChosen = (rnd.Next(3) == 0) ? FactionName.Vikings : ((rnd.Next(2) == 0) ? FactionName.Gauls : FactionName.Dwarves); RefreshUI(); }
private void btnDwarf_Click(object sender, RoutedEventArgs e) { factionChosen = FactionName.Dwarves; RefreshUI(); }
private void btnGaul_Click(object sender, RoutedEventArgs e) { factionChosen = FactionName.Gauls; RefreshUI(); }
private void btnViking_Click(object sender, RoutedEventArgs e) { factionChosen = FactionName.Vikings; RefreshUI(); }
private void btnViking_Click(object sender, RoutedEventArgs e) { this.factionChosen = FactionName.Vikings; this.AnyButtonClick(); }
private void btnDwarf_Click(object sender, RoutedEventArgs e) { this.factionChosen = FactionName.Dwarves; this.AnyButtonClick(); }
public PlayerCreator() { InitializeComponent(); factionChosen = FactionName.Vikings; }