public EmbankStateManager(IemStateManager.IStateMachine initialState, IemGameEmbankmentGame newEg) : base(initialState) { IemUtils.GLog("eg is " + newEg); eg = newEg; }
public TeamSelectLobby(string copypastefile, IemGameBase.IemTeamGame newTeamGame) { teamGame = newTeamGame; location = me.IemUtils.NextFreeLocation(); me.Puts("yield new vector " + location); //location = new Vector3(x, y, z); Vector3 centre_location = new Vector3(location.x - 7, location.y, location.z - 2); partition = new IemObjectPlacement.CopyPastePlacement( copypastefile, location); CreateZoneForLobby(); int i = 0; foreach (var team in teamGame.Teams) { // me.Puts("centre loc is " + centre_location); // me.Puts("loc is " + locs[i]); spheres.Add(IemUtils.CreateZone("team_" + team.Value.GetGuid(), locs[i] + centre_location, 6)); zonelist.Add("zone_team_" + team.Value.GetGuid()); me.zonelist.Add("zone_team_" + team.Value.GetGuid()); i++; } PlayerEnteredZone += PlayerEnteredTeamZone; }
void CreateZoneForLobby() { Vector3 centre_location = new Vector3(location.x - 7, location.y, location.z - 2); // me.CreateZone("lobby", new Vector3(-235, 3, 18), 16); me.zonelist.Add("lobby_" + centre_location.ToString()); zonelist.Add("lobby_" + centre_location.ToString()); me.ZoneManager.Call("CreateOrUpdateZone", "lobby_" + centre_location.ToString(), new string[] { "radius", "34", "autolights", "true", "eject", "false", "enter_message", "", "leave_message", "", "killsleepers", "true", "nosuicide", "false", "undestr", "true", "nobuild", "true", "nodecay", "true", "nocorpse", "true", "nogather", "true", "noplayerloot", "true", "nowounded", "true", "nodrown", "true", "nostability", "true", "noupgrade", "true", "nobleed", "true", "pvpgod", "true", "nodeploy", "true" }, location); spheres.Add(IemUtils.CreateSphere(centre_location, (34 * 2) + 1)); }
public void ScorePlayerKill(BasePlayer victim, HitInfo hitInfo) { IemUtils.GLog("player died in game phase, calculate new score"); if (victim.ToPlayer() != null) { IemUtils.GLog("player died - hook called"); BasePlayer player = victim.ToPlayer(); if (hitInfo?.Initiator != null && hitInfo?.Initiator?.ToPlayer() != null && victim.ToPlayer() != null) { IemUtils.GLog("found player hit, found player scoring kill"); // PlayerDying(player, info); IemUtils.IIemTeamPlayer iemTeamPlayer = GetIemPlayerById(victim.UserIDString); if (iemTeamPlayer != null) { IemUtils.GLog("incrementing score"); GetIemPlayerById(hitInfo?.Initiator?.ToPlayer().UserIDString).Score += 1; GetIemPlayerById(hitInfo?.Initiator?.ToPlayer().UserIDString).Team.Score += 1; } } } }
public new void Enter(IemStateManager.StateManager sm) { TargetPracticeStateManager gsm = (TargetPracticeStateManager)sm; List <ReactiveTarget> targets = IemUtils.FindComponentsNearToLocation <ReactiveTarget>(gsm.location, 50); foreach (var target in targets) { target.SetFlag(BaseEntity.Flags.On, false); } gsm.eg.EndGame(); double totalTime = 0; foreach (TPGameLevel level in gsm.eg.gamelevels) { totalTime += level.LevelTime(); } IemUI.CreateGameBanner(gsm.eg.player, "Game is complete! - your time was " + IemUtils.GetTimeFromSeconds(totalTime) + " seconds"); IemUI.Confirm(gsm.eg.player, "Game completed!\nreturn to the map", "Back", gsm.eg.backToTheMap); }
public void SuddenDeath(BaseCombatEntity entity, HitInfo hitInfo) { if (entity as BasePlayer == null || hitInfo == null) { return; } if (entity.ToPlayer() != null) { IemUtils.DLog("player died"); BasePlayer player = entity.ToPlayer(); if (GetIemPlayerById(player.UserIDString) != null) { IemUtils.GLog("scaling damage"); hitInfo.damageTypes.Scale(DamageType.Bullet, 1000f); hitInfo.damageTypes.Scale(DamageType.Arrow, 1000f); hitInfo.damageTypes.Scale(DamageType.Blunt, 1000f); hitInfo.damageTypes.Scale(DamageType.Explosion, 1000f); hitInfo.damageTypes.Scale(DamageType.Stab, 1000f); //hitInfo.damageTypes.Scale(DamageType., 1000f); } else { IemUtils.GLog("not found player"); } } }
/// <summary> /// this method is used to send a signal to the implementation /// to wrap things up. /// </summary> /// <returns></returns> public virtual bool CancelGame() { IemUtils.DLog("calling CancelGame in IemGame"); CurrentState = IemUtils.State.Cancelled; CleanUp(); Interface.Oxide.CallHook("OnGameCancelled", this); return(true); }
public void CloseDoors() { List <Door> doors = IemUtils.FindComponentsNearToLocation <Door>(location, 50); foreach (var door in doors) { door.SetFlag(BaseEntity.Flags.Open, false); } }
public virtual void RestoreBasePlayers() { foreach (var player in Players.Values) { IemUtils.TeleportPlayerPosition(BasePlayer.Find(player.PlayerId), player.PreviousLocation); me.IemUtils.RestoreInventory(BasePlayer.Find(player.PlayerId), GetGuid()); } }
public override IemUtils.IIemTeamPlayer AddPlayer(BasePlayer player) { if (!Players.ContainsKey(player.UserIDString)) { Players[player.UserIDString] = new IemEmbankmentPlayer(player, this); } IemUI.ShowTeamUiForPlayer(player, this); IemUtils.TeleportPlayerPosition(player, teamLobby.location); return((IemUtils.IIemTeamPlayer)Players[player.UserIDString]); }
public new void Enter(IemStateManager.StateManager sm) { TargetPracticeStateManager gsm = (TargetPracticeStateManager)sm; gsm.eg.returnZone.Destroy(); IemUtils.MovePlayerToTeamLocation(gsm.eg.player, gsm.eg.iemPlayer.PreviousLocation); gsm.partition.Remove(); me.IemUtils.RestoreInventory(gsm.eg.player, gsm.eg.GetGuid()); }
public new void Exit(IemStateManager.StateManager sm) { TargetPracticeStateManager gsm = (TargetPracticeStateManager)sm; CuiHelper.DestroyUi(gsm.eg.player, "CreateFadeoutBanner"); foreach (IemGameBase.IemPlayer iemPlayer in gsm.eg.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); IemUI.CreateGameBanner(player, ""); } }
public override bool StartGame() { IemUtils.GLog("calling StartGame in IemGameEmbankmentGame"); if (gsm == null) { base.StartGame(); gsm = new EmbankStateManager(EmbankStateManager.Created.Instance, this); gsm.ChangeState(EmbankStateManager.GameLobby.Instance); } return(true); }
public bool MovePlayerToTeamLocation(BasePlayer player, Vector3 location) { IemUtils.GLog("moving players to game"); if (!IemUtils.CheckPointNearToLocation( player.transform.position, location, 2)) { IemUtils.TeleportPlayerPosition(player, location); } return(true); }
public virtual bool StartGame() { IemUtils.DLog("calling StartGame in IemGameBase"); if (!CanStart()) { return(false); } CurrentState = IemUtils.State.Running; StartedTime = DateTime.Now; Interface.Oxide.CallHook("OnGameStarted", this); return(true); }
//in the state patten, this is used to execute the current state //not sure if this is relevant to this system??? public void Update() { if ((currentState == null)) { throw new Exception("currentState state is null"); } string buf = currentState.ToString(); IemUtils.SLog(this.GetType().Name + ":Executing:" + buf); currentState.Execute(this); IemUtils.SLog(this.GetType().Name + ":Executed:" + buf); }
public void ShowGameTimer(int countdown) { string status = ""; foreach (IemGameBase.IemTeam iemTeam in Teams.Values) { foreach (IemGameBase.IemPlayer iemPlayer in iemTeam.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); IemUI.CreateGameTimer(player, countdown); } } }
public new void Enter(IemStateManager.StateManager sm) { TargetPracticeStateManager gsm = (TargetPracticeStateManager)sm; gsm.partition = new IemObjectPlacement.CopyPastePlacement( "tp_v1_" + gsm.eg.difficultyLevel, gsm.location); ResearchTable researchtable = IemUtils.FindComponentNearestToLocation <ResearchTable>( gsm.location, 50); Vector3 playerstart = researchtable.transform.position; researchtable.Kill(BaseNetworkable.DestroyMode.None); RepairBench repairbench = IemUtils.FindComponentNearestToLocation <RepairBench>( gsm.location, 50); Vector3 playerlook = repairbench.transform.position; repairbench.Kill(BaseNetworkable.DestroyMode.None); me.Puts("player start location is " + playerstart); me.Puts("player look location is " + playerlook); me.Puts("swutcged " + IemUtils.SwitchTypesToTarget <BaseOven>(gsm.location)); gsm.eg.player.inventory.Strip(); EntitiesTakingDamage += gsm.eg.PlayerImmortal; IemUtils.MovePlayerToTeamLocation(gsm.eg.player, playerstart); Vector3 relativePos = playerstart - playerlook; Quaternion rotation = Quaternion.LookRotation(relativePos); gsm.eg.player.transform.rotation = rotation; IemUtils.SetMetabolismValues(gsm.eg.player); IemUtils.ClearInventory(gsm.eg.player); IemUI.CreateGameBanner(gsm.eg.player, "GAME LOBBY"); IemUtils.PlaySound(gsm.eg.player); gsm.eg.returnZone = new IemUtils.ReturnZone(playerstart, gsm.eg.player); IemUI.Confirm(gsm.eg.player, $"Weclome to target practice\n" + $"Knock down the targets to proceed to the next level.\n" + $"each level timer will start when you fire the first shot", "Start Shootin'", gsm.proceedAction); gsm.eg.targets = IemUtils.FindComponentsNearToLocation <ReactiveTarget>(gsm.location, 50); me.Puts("targets count is " + gsm.eg.targets.Count()); }
public override bool CanStart() { //if (ForceStart) // return true; int totalPlayers = 0; foreach (KeyValuePair <string, IemUtils.IIemTeam> team in Teams) { if (team.Value.Players.Count < MinPlayersPerTeam) { IemUtils.DLog("too few players on team for Game MinPlayersPerTeam " + team.Value.Name); return(false); } if (team.Value.Players.Count > MaxPlayersPerTeam) { IemUtils.DLog("too many players on team Game MaxPlayersPerTeam" + team.Value.Name); return(false); } if (team.Value.Players.Count < team.Value.MinPlayers) { IemUtils.DLog("too few players on team for Team MinPlayers " + team.Value.Name); return(false); } if (team.Value.Players.Count > team.Value.MaxPlayers) { IemUtils.DLog("too many players on team Team MaxPlayers " + team.Value.Name); return(false); } totalPlayers = totalPlayers + team.Value.Players.Count; } if (totalPlayers < MinPlayers) { IemUtils.DLog("below min players"); return(false); } if (totalPlayers > MaxPlayers) { IemUtils.DLog("above max players"); return(false); } return(base.CanStart()); }
public override bool CleanUp() { base.CleanUp(); IemUtils.DDLog("cleaning up the game"); teamLobby?.Destroy(); foreach (var partition in gsm.partitions) { partition?.Remove(); } return(true); }
public IemTeam AddTeam(IemTeam team) { if (Teams.Count >= MaxTeams) { IemUtils.DLog("returning null"); return(null); } if (!Teams.ContainsKey(team.GetGuid().ToString())) { Teams.Add(team.GetGuid().ToString(), team); } team.TeamGame = this; return(team); }
IemUtils.IIemTeam GetTeamFromZone(string ZoneID) { //IemUtils.DLog("team substring is " + ZoneID.Substring(10)); foreach (var team in teamGame.Teams) { // IemUtils.DLog("checking team is " + team.Key); if (team.Key == ZoneID.Substring(10)) { IemUtils.DLog("returning team is " + team.Value.Name); return(team.Value); } } return(null); }
public void PlayerDied(BasePlayer victim, HitInfo info) { IemUtils.GLog("player died in one life phase"); if (victim.ToPlayer() != null) { IemUtils.GLog("player died - setting player dead"); BasePlayer player = victim.ToPlayer(); GetIemPlayerById(victim.UserIDString).PlayerState = IemUtils.PlayerState.Dead; } }
public int GetCountOfLivingPlayers(IemGameBase.IemTeam iemTeam) { int count = 0; foreach (IemGameBase.IemPlayer iemPlayer in iemTeam.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); if (iemPlayer.PlayerState == IemUtils.PlayerState.Alive) { count++; } } return(count); }
public override bool StartGame() { IemUtils.GLog("calling StartGame in IemGameTargetPracticeGame"); if (gsm.IsAny(TargetPracticeStateManager.Created.Instance)) { base.StartGame(); gsm.ChangeState(TargetPracticeStateManager.GameLobby.Instance); } else if (gsm.IsAny(TargetPracticeStateManager.GameLobby.Instance, TargetPracticeStateManager.GameRunning.Instance )) { IemUtils.GLog("gsm already created"); } return(true); }
public virtual void SubStateReturn() { if ((previousState == null)) { throw new Exception("previousState is null"); } if ((currentState == null)) { throw new Exception("currentState state is null"); } IemUtils.SLog(this.GetType().Name + ":ChangeState:PrevState:" + currentState); IemUtils.SLog(this.GetType().Name + ":ChangeState:Reverting:" + previousState); currentState.Exit(this); currentState = previousState; }
public override IemUtils.IIemTeam Winner() { IemUtils.IIemTeam team = null; int bestscore = 0; foreach (var iemTeam in Teams.Values) { if (iemTeam.Score > bestscore) { bestscore = iemTeam.Score; team = iemTeam; } IemUtils.GLog("best score is " + bestscore); } return(team); }
public StateManager(IStateMachine initialState) { if ((initialState == null)) { throw new Exception("initialState cannot be null"); } IemUtils.SLog(this.GetType().Name + ":CREATING"); //set the initial state currentState = initialState; //@todo not sure if this is correct. should we enter the initial state? currentState.Enter(this); IemUtils.SLog(this.GetType().Name + ":initialstate:" + currentState.ToString().Replace("Oxide.Plugins.", "")); }
public bool CheckGameState() { bool someoneWon = false; foreach (IemGameBase.IemTeam iemTeam in Teams.Values) { if (iemTeam.State != IemUtils.TeamState.Empty) { int count = 0; foreach (IemGameBase.IemPlayer iemPlayer in iemTeam.Players.Values) { BasePlayer player = IemUtils.FindPlayerByID(iemPlayer.PlayerId); if (iemPlayer.PlayerState == IemUtils.PlayerState.Alive) { count++; } } if (count == 0) { iemTeam.State = IemUtils.TeamState.Lost; } } } int teamsNotLost = 0; IemGameBase.IemTeam winTeam = null; foreach (IemGameBase.IemTeam iemTeam in Teams.Values) { if (iemTeam.State != IemUtils.TeamState.Empty && iemTeam.State != IemUtils.TeamState.Lost) { teamsNotLost++; winTeam = iemTeam; } } if (teamsNotLost == 1) { someoneWon = true; winTeam.State = IemUtils.TeamState.Won; } if (someoneWon) { gsm.ChangeState(EmbankStateManager.GameComplete.Instance); } return(someoneWon); }
/// <summary> /// enter a substate, where you want to revert to the previous state /// </summary> /// <param name="newState"></param> public virtual void SubState(IStateMachine newState) { if ((currentState == null)) { throw new Exception("currentState state is null"); } if ((newState == null)) { throw new Exception("newState is null"); } IemUtils.SLog(this.GetType().Name + ":ChangeState:PrevState:" + currentState); previousState = currentState; currentState = newState; currentState.Enter(this); IemUtils.SLog(this.GetType().Name + ":ChangeState:newstate:" + newState); }