public void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { direction = new Vector2(-1, 0); transform.localScale = new Vector3(1, 1, 1); transform.position = startPosition; gameObject.SetActive(true); }
protected override void Initialize() { var director = new Director (this); var gameState = new GameState (this); var sprites = new SpriteSheets (this); var checkpoint = new Checkpoint<MogateSaveData> (this); Services.AddService (typeof(IWorld), new World()); Services.AddService (typeof(IGameState), gameState); Services.AddService (typeof(ISpriteSheets), sprites); Services.AddService (typeof(IStatistics), new Statistics ()); Services.AddService (typeof(IDirector), director); Services.AddService (typeof(ICheckpoint<MogateSaveData>), checkpoint); Components.Add (sprites); Components.Add (gameState); Components.Add (director); Components.Add (checkpoint); director.RegisterScene (new GameScene (this, "game")); director.RegisterScene (new MainScene (this, "main")); director.RegisterScene (new InterScene (this, "inter")); director.RegisterScene (new PlayerSelectScene (this, "player_select")); sprites.AddSpriteSheet ("Content/Sprites/sprites.plist", "Sprites/sprites", Globals.CELL_WIDTH, Globals.CELL_HEIGHT); #if __IOS__ sprites.AddSpriteFont ("SpriteFont1", "Fonts/arial-22"); #else sprites.AddSpriteFont ("SpriteFont1", "Fonts/SpriteFont1"); #endif sprites.AddEffect ("light", "Content/Shaders/lighting.xnb"); base.Initialize (); }
public void RegisterCheckpoint(Checkpoint checkpoint) { if (checkpoint.checkpointOrder > lastCheckpoint) { lastCheckpoint = checkpoint.checkpointOrder; } }
public static bool hasCheckpointBeenUsed(Checkpoint checkpoint){ if(m_CurrentGameData != null){ return m_CurrentGameData.hasCheckpointBeenUsed(checkpoint); } // Return true if no game data is loaded to prevent saving because no save destination has been set return true; }
void OnTriggerEnter(Collider other) { if (other.tag != "Player") { return; } lastCheckpoint = this; }
private Checkpoint GetCheckpointInternal(IndexerCheckpoints checkpoint) { var chk = GetCheckpoint(checkpoint); if(IgnoreCheckpoints) chk = new Checkpoint(chk.CheckpointName, Configuration.Network, null, null); return chk; }
public static void TestCheckpoint() { PrimeSearcher primes = new PrimeSearcher(); Checkpoint<PrimeSearcher> checkpoint = new Checkpoint<PrimeSearcher>(); try { primes = checkpoint.Load(); } catch (Exception) { } for (long i = 0; i < 100; i++) { Stopwatch timer = Stopwatch.StartNew(); primes.Search(10); if (timer.ElapsedMilliseconds > 1000) { checkpoint.Save(primes); timer.Restart(); } } checkpoint.Save(primes); primes.PrintResults(); TestCheckpoint jk = new TestCheckpoint(); Checkpoint<TestCheckpoint> checkpoint2 = new Checkpoint<TestCheckpoint>(); }
public void OnTriggerEnter(Collider other) { last = this; if( TutorialText.active.step < setTutStep ) { TutorialText.active.NextStep(); } }
public void OnCollisionEnter(Collision other) { last = this; if( TutorialText.active.step < setTutStep ) { TutorialText.active.NextStep(); } }
public List<InvisibleBlockController> invisibleBlocks; //private pls public void Setup () { upsideDown = false; // print("Awake: " + name); endPos = transform.FindChild("EndPos"); if (!tag.Equals("StartPiece")) { checkpoint = transform.FindChild("Checkpoint").GetComponent<Checkpoint>(); checkpoint.SetVisibility(false); checkpoint.Setup(); if (tag.Equals("TutorialPiece")) { transform.FindChild("Checkpoint2").GetComponent<Checkpoint>().SetVisibility(false); transform.FindChild("Checkpoint2").GetComponent<Checkpoint>().Setup(); transform.FindChild("Checkpoint3").GetComponent<Checkpoint>().SetVisibility(false); transform.FindChild("Checkpoint3").GetComponent<Checkpoint>().Setup(); } } invisibleBlocks = new List<InvisibleBlockController>(); FindInvisibleBlocks(); }
void OnTriggerEnter( Collider other ) { Debug.Log ("hit"); if (other.GetComponent<Checkpoint>()) { Checkpoint hitCheckpoint = other.GetComponent<Checkpoint>(); if ( hitCheckpoint == currentCheckpoint ) { currentCheckpoint.setVisible(false); if (currentCheckpoint == track.endCheckpoint) { laps++; gameController.postTime(currentTime); currentTime = 0.0f; } else { } currentCheckpoint = other.GetComponent<Checkpoint>().nextCheckpoint; currentCheckpoint.setVisible(true); } print("Next checkpoint: " + currentCheckpoint); } }
int IncrementCheckpoint(int current,Checkpoint checkpoint) { if(current == checkpoint.number - 1) { current++; } return current; }
public Game(int id, string name, Checkpoint checkpoint, Theme theme, float budget, float time, float timeConsumption) : this(id, name) { this.CurrentCheckpoint = checkpoint; this.Theme = theme; this.Budget = budget; this.Time = time; this.TimeConsumption = timeConsumption; }
/* * @param checkpoint, the last checkpoint the Player Object has acquired * @param player, the Player Object * Method used to respawn this GameObject after the player respawns at the given checkpoint */ public void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { //transform.position = _startPosition; // initial position of this GameObject gameObject.SetActive(true); // shows this GameObject //transform.position = RespawnPosition.position; // position where this GameObject is respawned at // Resets health Health = MaxHealth; // sets current health to the GameObject's max health }
void AchaCheckpoint() { checkpoints = GameObject.FindGameObjectsWithTag ("Checkpoint"); for(int i=0;i<checkpoints.Length;i++) { checkpoint = checkpoints[i].GetComponent<Checkpoint>(); checkpoint.DesativaCheckpoint(); } }
/* * @param checkpoint, the last checkpoint the Player Object has acquired * @param player, the Player Object * Method used to respawn this GameObject after the player respawns at the given checkpoint */ public void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { // Re-initializes this GameObject's direction, and start position _direction = new Vector2(-1, 0); // the direction set to left transform.localScale = new Vector3(1, 1, 1); gameObject.SetActive(true); // shows this GameObject // Resets health Health = MaxHealth; // sets current health to the GameObject's max health }
//---------------------------------------- // handles //----------------------------------------- // function definitions void Start() { m_PlayerAlive = true; m_Checkpoint = GameObject.FindGameObjectWithTag("Checkpoint").GetComponent<Checkpoint>(); GameManager.GetPlayer().transform.localPosition = m_Checkpoint.GetActiveCheckPoints(); m_ScoreScript.Start(); m_HighScores.Start(); }
/// <summary> /// Zrespawnowanie przeciwnika w danym checkpoincie razem z graczem. /// </summary> /// <param name="checkpoint"></param> /// <param name="player"></param> public void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { /// Ustawienie jego kierunku. _direction = new Vector2 (-1, 0); /// Ustawienie jego skali w œwiecie gry jako domyœlnej. transform.localScale = new Vector3 (1, 1, 1); /// Ustawienie pozycji pocz¹tkowej. transform.position = _startPosition; /// Aktywowanie obiektu przeciwnika w œwiecie gry. gameObject.SetActive (true); }
public CheckpointList(string prefix, int numberOfCheckpoints) { float minDistance = 1.0f; checkpoints = new ArrayList (); for (int i = 0; i < numberOfCheckpoints; i++) { Debug.Log(prefix+(i+1)); Checkpoint new_checkpoint = new Checkpoint(GameObject.FindWithTag(prefix+(i+1)),minDistance); this.checkpoints.Add(new_checkpoint); } }
/* * @param checkpoint, the last checkpoint the Player Object has acquired * @param player, the Player Object * Method used to respawn this GameObject after the player respawns at the given checkpoint */ public void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { // Re-initializes this GameObject's direction, and start position _direction = new Vector2(-1, 0); transform.localScale = new Vector3(1, 1, 1); transform.position = _startPosition; // initial position of this GameObject gameObject.SetActive(true); // shows this GameObject transform.position = RespawnPosition.position; // position where this GameObject is respawned at // Resets health Health = MaxHealth; // sets current health to the GameObject's max health }
/// <summary> /// Constructor. /// </summary> public UserSubmissionResult( Section section, Checkpoint checkpoint, Submission submission) { CheckpointName = checkpoint.Name; CheckpointDisplayName = checkpoint.DisplayName; CheckpointDueDate = checkpoint.SectionDates .Single(sd => sd.Section == section) .DueDate; Submission = submission; }
public void ShouldDeleteData() { _database.Execute("create table Foo (Value [int])"); _database.InsertBulk(Enumerable.Range(0, 100).Select(i => new Foo { Value = i })); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM Foo").ShouldBe(100); var checkpoint = new Checkpoint(); checkpoint.Reset(_connection); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM Foo").ShouldBe(0); }
public override void OnPlayerRespawnInThisCheckpoint(Checkpoint checkpoint, Player player) { if (!player._died) { _isCollected = false; Renderer.enabled = true; } else if(player._died) { _isCollected = true; Renderer.enabled = false; } }
private void SetCurrentCheckpoint(Checkpoint checkpoint) { if (CurrentCheckpoint != null) { CurrentCheckpoint.gameObject.SetActive(false); CurrentCheckpoint.CheckpointActivated -= CheckpointActivated; } CurrentCheckpoint = checkpoint; CurrentCheckpoint.CheckpointActivated += CheckpointActivated; Arrow.Target = CurrentCheckpoint.transform; CurrentCheckpoint.gameObject.SetActive(true); }
public void ShouldIgnoreTables() { _database.Execute("create table Foo (Value [int])"); _database.Execute("create table Bar (Value [int])"); _database.InsertBulk(Enumerable.Range(0, 100).Select(i => new Foo { Value = i })); _database.InsertBulk(Enumerable.Range(0, 100).Select(i => new Bar { Value = i })); var checkpoint = new Checkpoint { TablesToIgnore = new[] {"Foo"} }; checkpoint.Reset(_connection); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM Foo").ShouldBe(100); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM Bar").ShouldBe(0); }
public void updateCheckpoint(Checkpoint c) { if(c==lastCheckpoint)return; if(gateCount==lastCheckpoint.number&&c.number==0&&lastCheckpoint.next.number==0){ //finished a lap! Debug.Log ("Lap completion detected!"); lapFinished = true; gateCount = 0; }else{ if(c.number>lastCheckpoint.number){ gateCount++; }else if(c.number<lastCheckpoint.number){ gateCount--; } } DebugHUD.setValue(name+" gateCount",gateCount); lastCheckpoint = c; lastCheckpointTrans = c.transform; }
public void ShouldDeleteData() { _database.Execute("create table \"foo\" (value int)"); for (int i = 0; i < 100; i++) { _database.Execute("INSERT INTO \"foo\" VALUES (@0)", i); } _database.ExecuteScalar<int>("SELECT COUNT(1) FROM \"foo\"").ShouldBe(100); var checkpoint = new Checkpoint { DbAdapter = DbAdapter.Postgres, SchemasToInclude = new [] { "public" } }; checkpoint.Reset(_connection); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM \"foo\"").ShouldBe(0); }
public void ShouldIgnoreTables() { _database.Execute("create table foo (value int)"); _database.Execute("create table bar (value int)"); for (int i = 0; i < 100; i++) { _database.Execute("INSERT INTO \"foo\" VALUES (@0)", i); _database.Execute("INSERT INTO \"bar\" VALUES (@0)", i); } var checkpoint = new Checkpoint { DbAdapter = DbAdapter.Postgres, SchemasToInclude = new[] { "public" }, TablesToIgnore = new[] { "foo" } }; checkpoint.Reset(_connection); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM foo").ShouldBe(100); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM bar").ShouldBe(0); }
public void ShouldExcludeSchemas() { _database.Execute("create schema A"); _database.Execute("create schema B"); _database.Execute("create table A.Foo (Value [int])"); _database.Execute("create table B.Bar (Value [int])"); for (int i = 0; i < 100; i++) { _database.Execute("INSERT A.Foo VALUES (" + i + ")"); _database.Execute("INSERT B.Bar VALUES (" + i + ")"); } var checkpoint = new Checkpoint { SchemasToExclude = new [] { "A" } }; checkpoint.Reset(_connection); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM A.Foo").ShouldBe(100); _database.ExecuteScalar<int>("SELECT COUNT(1) FROM B.Bar").ShouldBe(0); }
public static void save(Checkpoint cp) { // Update active checkpoint if (checkpoint != null && checkpoint != cp) { checkpoint.reset (); } checkpoint = cp; // Update SaveFile if (currentSave == null) { currentSave = new SaveFile (); } currentSave.save (Application.loadedLevel, cp.getPos ()); // We're cool with loading, now. newGame = false; // Actually save the data to a file. BinaryFormatter bf = new BinaryFormatter (); FileStream file = File.Create (savePath); bf.Serialize (file, currentSave); file.Close (); }
public IEnumerator InstantiateNewStuffTimed(Transform inRestartNewPrefab, Vector3 inRestartNewPrefabPosition, Checkpoint checkpoint) { /* change camera parameters - like Trigger() from Checkpoint.cs */ if (checkpoint) { savedCheckpointVirtual = new Checkpoint(); savedCheckpointVirtual.newOffsetFromFocusPoint = checkpoint.newOffsetFromFocusPoint; savedCheckpointVirtual.newDistance = checkpoint.newDistance; savedCheckpointVirtual.fastX = checkpoint.fastX; } var newOffsetFromFocusPoint = savedCheckpointVirtual.newOffsetFromFocusPoint; var newDistance = savedCheckpointVirtual.newDistance; var fastX = savedCheckpointVirtual.fastX; /* ====================================== */ yield return(new WaitForSeconds(2f)); var inst = Instantiate(inRestartNewPrefab); inst.position = new Vector3(inRestartNewPrefabPosition.x, GameObject.Find("Character").transform.position.y, GameObject.Find("Character").transform.position.z); LevelDebugManager levelDebugManager = GameObject.Find("LevelDebugManager").transform.GetComponent <LevelDebugManager>(); levelDebugManager.inRestartNewPrefab = inRestartNewPrefab; levelDebugManager.inRestartNewPrefabPosition = inRestartNewPrefabPosition; var gameCamera = GameObject.FindGameObjectWithTag("MainCamera").transform; var cameraTarget = GameObject.Find("CameraTarget").transform; cameraTarget.GetComponent <CameraTarget>().offsetFromFocusPoint = newOffsetFromFocusPoint; if (newDistance > 0) { gameCamera.GetComponent <CameraMove>().distance = newDistance; } cameraTarget.GetComponent <CameraTarget>().fastX = fastX; gameCamera.GetComponent <CameraMove>().isRotY = fastX; }
public void SetCheckpoint(Checkpoint checkpoint) { _lastCheckpoint = checkpoint; }
private void SetLastActiveCheckpoint(Checkpoint checkpoint) { LastActiveCheckpoint = checkpoint; }
// Update is called once per frame void Update() { targetDirection = Quaternion.LookRotation((PlayerController.singleton.transform.position - Checkpoint.GetGoal()).normalized, Vector3.up); transform.rotation = Quaternion.Slerp(transform.rotation, targetDirection, 0.1f); //Debug.Log(targetDirection); }
/// <summary> /// Set up a basic Player Controller with the default settings. /// </summary> public PlayerController() { Score = 0; Lives = 2; currentCheckpoint = null; }
public static void Invoke(string id, string next_id, Checkpoint checkpoint) { checkpoint(); }
public void InstantiateNewStuff(Transform inRestartNewPrefab, Vector3 inRestartNewPrefabPosition, Checkpoint checkpoint) { StartCoroutine(InstantiateNewStuffTimed(inRestartNewPrefab, inRestartNewPrefabPosition, checkpoint)); }
public EditCharacterCommandHandlerTest(TestFixture fixture) { _testFixture = fixture; _checkpoint = new Checkpoint(); }
protected async Task StoreCheckpoint(long position, CancellationToken cancellationToken) { _lastProcessedPosition = position; var checkpoint = new Checkpoint(_subscriptionName, position); await _checkpointStore.StoreCheckpoint(checkpoint, cancellationToken); }
/// <summary> /// Creates a jail point /// </summary> private void CreateJailPoint() { jailCheckpoint = new Checkpoint(this.prisonEntranceLocation, this.OnEnterCheckpoint, this.OnExitCheckpoint, 1, prisonEntranceCircleSize, 0); }
public Int32 GetNextCheckpoint(Checkpoint cType) { return(CheckpointSet.GetNextCheckpoint(cType)); }
public void ResetCheckpoint(Checkpoint cType) { CheckpointSet.ResetCheckpoint(cType); }
public void OnPlayerEnterCheckpoint(Checkpoint checkpoint, Client player) { if (NAPI.Data.HasEntityData(player, EntityData.PLAYER_DRIVING_COLSHAPE) && NAPI.Data.HasEntityData(player, EntityData.PLAYER_DRIVING_EXAM) == true) { if (NAPI.Player.IsPlayerInAnyVehicle(player) == true && NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_EXAM) == Constants.CAR_DRIVING_PRACTICE) { Vehicle vehicle = NAPI.Player.GetPlayerVehicle(player); if (checkpoint == NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_COLSHAPE) && NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_FACTION) == Constants.FACTION_DRIVING_SCHOOL) { Checkpoint currentCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_COLSHAPE); int checkPoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT); if (checkPoint < Constants.CAR_LICENSE_CHECKPOINTS.Count - 2) { NAPI.Entity.SetEntityPosition(currentCheckpoint, Constants.CAR_LICENSE_CHECKPOINTS[checkPoint + 1]); NAPI.Checkpoint.SetCheckpointDirection(currentCheckpoint, Constants.CAR_LICENSE_CHECKPOINTS[checkPoint + 2]); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else if (checkPoint == Constants.CAR_LICENSE_CHECKPOINTS.Count - 2) { NAPI.Entity.SetEntityPosition(currentCheckpoint, Constants.CAR_LICENSE_CHECKPOINTS[checkPoint + 1]); NAPI.Checkpoint.SetCheckpointDirection(currentCheckpoint, NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_POSITION)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else if (checkPoint == Constants.CAR_LICENSE_CHECKPOINTS.Count - 1) { Vector3 lastCheckPointPosition = NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_POSITION); NAPI.Entity.SetEntityPosition(currentCheckpoint, lastCheckPointPosition); NAPI.Entity.SetEntityModel(currentCheckpoint, (int)CheckpointType.Checkerboard); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else { // Exam finished FinishDrivingExam(player, vehicle); // We add points to the license SetPlayerLicense(player, Constants.LICENSE_CAR, 12); // Confirmation message sent to the player NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_SUCCESS + Messages.SUC_LICENSE_DRIVE_PASSED); } } } else if (NAPI.Player.IsPlayerInAnyVehicle(player) == true && NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_EXAM) == Constants.MOTORCYCLE_DRIVING_PRACTICE) { Vehicle vehicle = NAPI.Player.GetPlayerVehicle(player); if (checkpoint == NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_COLSHAPE) && NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_FACTION) == Constants.FACTION_DRIVING_SCHOOL) { Checkpoint currentCheckpoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_COLSHAPE); int checkPoint = NAPI.Data.GetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT); if (checkPoint < Constants.BIKE_LICENSE_CHECKPOINTS.Count - 2) { NAPI.Entity.SetEntityPosition(currentCheckpoint, Constants.BIKE_LICENSE_CHECKPOINTS[checkPoint + 1]); NAPI.Checkpoint.SetCheckpointDirection(currentCheckpoint, Constants.BIKE_LICENSE_CHECKPOINTS[checkPoint + 2]); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else if (checkPoint == Constants.BIKE_LICENSE_CHECKPOINTS.Count - 2) { NAPI.Entity.SetEntityPosition(currentCheckpoint, Constants.BIKE_LICENSE_CHECKPOINTS[checkPoint + 1]); NAPI.Checkpoint.SetCheckpointDirection(currentCheckpoint, NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_POSITION)); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else if (checkPoint == Constants.BIKE_LICENSE_CHECKPOINTS.Count - 1) { Vector3 lastCheckPointPosition = NAPI.Data.GetEntityData(vehicle, EntityData.VEHICLE_POSITION); NAPI.Entity.SetEntityPosition(currentCheckpoint, lastCheckPointPosition); NAPI.Entity.SetEntityModel(currentCheckpoint, (int)CheckpointType.Checkerboard); NAPI.Data.SetEntityData(player, EntityData.PLAYER_DRIVING_CHECKPOINT, checkPoint + 1); // We place a mark on the map NAPI.ClientEvent.TriggerClientEvent(player, "showLicenseCheckpoint", currentCheckpoint.Position); } else { // Exam finished FinishDrivingExam(player, vehicle); // We add points to the license SetPlayerLicense(player, Constants.LICENSE_MOTORCYCLE, 12); // Confirmation message sent to the player NAPI.Chat.SendChatMessageToPlayer(player, Constants.COLOR_SUCCESS + Messages.SUC_LICENSE_DRIVE_PASSED); } } } } }
void FetchReferences() { currentCheckpoint = null; InitializePositionLogging(); SetScoreText(); }
public int ShouldUseItem() { //print("ShouldUseItem()"); // TODO: foreach item in inventory, // if any item would give the player any value // set itemToUseIndex to be the item that offers the greatest value and return success // else if none of the items give any value at this moment (ex: no targets, etc...) // return failure int missileIndex = Inventory.GetItemIndex("Rocket"); int boostIndex = Inventory.GetItemIndex("Boost"); int shieldIndex = Inventory.GetItemIndex("Shield"); int oilSpillIndex = Inventory.GetItemIndex("Oil Spill"); if (boostIndex != -1) { itemToUseIndex = boostIndex; } else if (missileIndex != -1) { // check if other players are in sight for missile target foreach (AbstractPlayer p in GameplayManager.Instance.Players) { RaycastHit[] hits = Physics.RaycastAll(transform.position + (Vector3.up * 0.5f), p.transform.position - transform.position); foreach (RaycastHit hit in hits) { // we are colliding with ourself if (hit.transform == transform) { continue; } if (hit.collider.tag.Equals("HumanPlayer") || hit.collider.tag.Equals("AIPlayer")) { AbstractPlayer potentialTarget = hit.collider.GetComponent <AbstractPlayer>(); // check if potentialTarget is in equal or higher place standing. If not, then do not waste the missile on them. if (potentialTarget.checkpoints.Count <= checkpoints.Count) { playerAttackTarget = potentialTarget; itemToUseIndex = missileIndex; } break; } } } } else if (shieldIndex != -1) { // check if player is in sight for foreign missiles foreach (AbstractPlayer p in GameplayManager.Instance.Players) { if (p.Inventory.GetItemIndex("Rocket") != -1) { RaycastHit[] hits = Physics.RaycastAll(p.transform.position + (Vector3.up * 0.5f), transform.position - p.transform.position); Debug.DrawRay(p.transform.position, transform.position - p.transform.position, Color.red, 10000); foreach (RaycastHit hit in hits) { // the ray has hit us if (hit.transform == transform) { itemToUseIndex = shieldIndex; } } // itemToUseIndex = shieldIndex; } } } else if (oilSpillIndex != -1) { // we can only place oil spills on neighbor nodes around us IWeightedDiGraph <GameObject, float> graph = PositionNode.mbGraph.graph; List <GameObject> potentialOilTargets = new List <GameObject>(); foreach (GraphNode <GameObject> graphNode in graph.Neighbors(PositionNode.nodeId)) { // CalculatePathToGoal() and if this node is on that path then do not add it to the list (otherwise we'd be hindering ourselves) potentialOilTargets.Add(graphNode.Data); } Checkpoint checkpointTarget = GetClosestCheckpoint(); MBGraphNode checkpointNode = checkpointTarget == null ? null : checkpointTarget.node; GraphNode <GameObject> optimalGraphNode = reachableNodeIds.Count > 0 ? GameplayManager.Instance.gridGraph.graph[reachableNodeIds[0]] : null; float dist = Mathf.Infinity; foreach (string nodeId in reachableNodeIds) { GraphNode <GameObject> gNode = GameplayManager.Instance.gridGraph.graph[nodeId]; float tempDist = (gNode.Data.transform.position - checkpointNode.transform.position).magnitude; if (tempDist < dist) { optimalGraphNode = gNode; dist = tempDist; } } if (optimalGraphNode != null) { List <GraphNode <GameObject> > path = pathFinding.FindPath(PositionNode.nodeId, optimalGraphNode.Id, MovementHeuristic, checkpoints.Count <= 1); if (path.Count > 0) { path.RemoveAt(0); } if (path.Count == 0) { return((int)BTNode.EState.Failure); } // If there 1 or less nodes that don't have an oil spill on them then don't place the oil spill or else we would be trapping ourselves if (potentialOilTargets.Count > 1) { // select the first potential oil target nodeToSpillOn = potentialOilTargets[0]; foreach (GameObject ot in potentialOilTargets) { if (!path.Contains(GameplayManager.Instance.gridGraph.graph[ot.GetComponent <MBGraphNode>().nodeId])) { nodeToSpillOn = ot; itemToUseIndex = oilSpillIndex; break; } } } } } return(itemToUseIndex >= 0 ? (int)BTNode.EState.Success : (int)BTNode.EState.Failure); }
protected abstract IAllStreamSubscription Subscribe( Checkpoint checkpoint, CancellationToken cancellationToken );
public int MoveToCover() { //print("MoveToCover()"); // foreach player in the playerAttackThreats list, check if they have ranged/attack items // if they do, then foreach spot that the player can reach choose the one that is safest // and add the CRMove() coroutine to the queue (see below) and return success // else if there is no cover available then return failure List <MBGraphNode> coverNodes = reachableNodeIds.Select(nId => GameplayManager.Instance.gridGraph.graph[nId].Data.GetComponent <MBGraphNode>()).ToList(); foreach (AbstractPlayer player in playerAttackThreats) { int pMissileIndex = player.Inventory.GetItemIndex("Rocket"); if (pMissileIndex != -1) { for (int i = 0; i < coverNodes.Count; ++i) { MBGraphNode node = coverNodes[i]; bool coverAvailable = false; // check for guaranteed shield PU_Base item = node.transform.GetComponentInChildren <PU_Base>(); if (item != null && item.powerUpScript is PU_Shield) { coverAvailable = true; coverNodes.Clear(); coverNodes.Add(node); break; } if (!coverAvailable) { // if we don't hit something, then there is no cover at this node and so, we remove it from the cover list RaycastHit[] hits = Physics.RaycastAll(player.transform.position + (Vector3.up * 0.5f), node.transform.position - player.transform.position); //Debug.DrawRay(player.transform.position, node.transform.position - player.transform.position, Color.red, 10000); foreach (RaycastHit hit in hits) { // ignore ourselves if (hit.collider.transform == transform) { continue; } //print(node.transform.localPosition); coverAvailable = true; break; } } if (!coverAvailable) { coverNodes.RemoveAt(i); --i; } } } } if (coverNodes.Count > 0) { // Get cover node that is closest to the closest checkpoint/goal Checkpoint checkpointTarget = GetClosestCheckpoint(); MBGraphNode optimalCoverNode = checkpointTarget == null ? coverNodes[0] : checkpointTarget.node; if (checkpointTarget != null) { float coverToCPDist = Mathf.Infinity; foreach (MBGraphNode coverNode in coverNodes) { float tempDist = (coverNode.transform.position - checkpointTarget.transform.position).magnitude; if (tempDist < coverToCPDist) { optimalCoverNode = coverNode; coverToCPDist = tempDist; } } } List <GraphNode <GameObject> > path = pathFinding.FindPath(PositionNode.nodeId, optimalCoverNode.nodeId, MovementHeuristic, checkpoints.Count <= 1); if (path.Count > 0) { path.RemoveAt(0); } if (path.Count == 0) { return((int)BTNode.EState.Failure); } Move(path); return((int)BTNode.EState.Success); } else { return((int)BTNode.EState.Failure); } }
internal static ScVmmVirtualMachineData DeserializeScVmmVirtualMachineData(JsonElement element) { ExtendedLocation extendedLocation = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> inventoryItemId = default; Optional <string> vmmServerId = default; Optional <string> cloudId = default; Optional <string> templateId = default; Optional <string> checkpointType = default; Optional <IList <Checkpoint> > checkpoints = default; Optional <IList <AvailabilitySetListItem> > availabilitySets = default; Optional <OSProfile> osProfile = default; Optional <HardwareProfile> hardwareProfile = default; Optional <NetworkProfile> networkProfile = default; Optional <StorageProfile> storageProfile = default; Optional <string> vmName = default; Optional <string> uuid = default; Optional <int> generation = default; Optional <string> powerState = default; Optional <string> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("extendedLocation")) { extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = new AzureLocation(property.Value.GetString()); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("inventoryItemId")) { inventoryItemId = property0.Value.GetString(); continue; } if (property0.NameEquals("vmmServerId")) { vmmServerId = property0.Value.GetString(); continue; } if (property0.NameEquals("cloudId")) { cloudId = property0.Value.GetString(); continue; } if (property0.NameEquals("templateId")) { templateId = property0.Value.GetString(); continue; } if (property0.NameEquals("checkpointType")) { checkpointType = property0.Value.GetString(); continue; } if (property0.NameEquals("checkpoints")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <Checkpoint> array = new List <Checkpoint>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(Checkpoint.DeserializeCheckpoint(item)); } checkpoints = array; continue; } if (property0.NameEquals("availabilitySets")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <AvailabilitySetListItem> array = new List <AvailabilitySetListItem>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(AvailabilitySetListItem.DeserializeAvailabilitySetListItem(item)); } availabilitySets = array; continue; } if (property0.NameEquals("osProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } osProfile = OSProfile.DeserializeOSProfile(property0.Value); continue; } if (property0.NameEquals("hardwareProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } hardwareProfile = HardwareProfile.DeserializeHardwareProfile(property0.Value); continue; } if (property0.NameEquals("networkProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value); continue; } if (property0.NameEquals("storageProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } storageProfile = StorageProfile.DeserializeStorageProfile(property0.Value); continue; } if (property0.NameEquals("vmName")) { vmName = property0.Value.GetString(); continue; } if (property0.NameEquals("uuid")) { uuid = property0.Value.GetString(); continue; } if (property0.NameEquals("generation")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } generation = property0.Value.GetInt32(); continue; } if (property0.NameEquals("powerState")) { powerState = property0.Value.GetString(); continue; } if (property0.NameEquals("provisioningState")) { provisioningState = property0.Value.GetString(); continue; } } continue; } } return(new ScVmmVirtualMachineData(id, name, type, systemData, tags, location, extendedLocation, inventoryItemId.Value, vmmServerId.Value, cloudId.Value, templateId.Value, checkpointType.Value, Optional.ToList(checkpoints), Optional.ToList(availabilitySets), osProfile.Value, hardwareProfile.Value, networkProfile.Value, storageProfile.Value, vmName.Value, uuid.Value, Optional.ToNullable(generation), powerState.Value, provisioningState.Value)); }
public void OneTimeSetUp() { checkpoint = new Checkpoint(); }
protected override async Task <EventSubscription> Subscribe( Checkpoint checkpoint, CancellationToken cancellationToken ) { var subTask = checkpoint.Position == null ? EventStoreClient.SubscribeToStreamAsync( _options.StreamName, HandleEvent, _options.ResolveLinkTos, HandleDrop, _options.ConfigureOperation, _options.Credentials, cancellationToken ) : EventStoreClient.SubscribeToStreamAsync( _options.StreamName, StreamPosition.FromInt64((long)checkpoint.Position), HandleEvent, _options.ResolveLinkTos, HandleDrop, _options.ConfigureOperation, _options.Credentials, cancellationToken ); var sub = await subTask.Ignore(); return(new EventSubscription(SubscriptionId, new Stoppable(() => sub.Dispose()))); async Task HandleEvent(EventStore.Client.StreamSubscription _, ResolvedEvent re, CancellationToken ct) { await Handler(AsReceivedEvent(re), ct).Ignore(); } void HandleDrop(EventStore.Client.StreamSubscription _, SubscriptionDroppedReason reason, Exception?ex) => Dropped(EsdbMappings.AsDropReason(reason), ex); ReceivedEvent AsReceivedEvent(ResolvedEvent re) { var evt = DeserializeData( re.Event.ContentType, re.Event.EventType, re.Event.Data, re.Event.EventStreamId, re.Event.EventNumber ); return(new ReceivedEvent( re.Event.EventId.ToString(), re.Event.EventType, re.Event.ContentType, re.Event.Position.CommitPosition, re.Event.EventNumber, re.Event.EventStreamId, re.Event.EventNumber, re.Event.Created, evt // re.Event.Metadata )); } }
public void OnPlayerRespawnAtThisCheckpoint(Checkpoint checkpoint, Player player) { gameObject.SetActive(true); _isCollected = false; }
public void OnReachCheckpoint(Checkpoint checkpoint) { this.AddReward(rewardOnCheckpoint); }
/// <summary> /// Called to update the player's current checkpoint information. /// <param name="reached">The checkpoint which was aquired.</param> /// </summary> public void CheckpointReched(Checkpoint reached) { // Update current checkpoint. currentCheckpoint = reached; }
public void SetLastActivatedCheckpoint(Checkpoint checkpoint) { progression.SetLastActivatedCheckpoint(SceneManager.GetActiveScene().name, new MinifiedCheckpoint { id = checkpoint.GetId(), name = checkpoint.name, position = checkpoint.CheckpointTransform.position }); }
public void Use(Checkpoint checkpoint) { checkpoint.next?.TurnOn(); this.checkpoint = checkpoint; }
public override void ProcessCheckpoint(Checkpoint cp, Metadata metadata) { throw new NotImplementedException(); }
private void OnExitCheckpoint(Checkpoint point, Character character) { }
public void OnPlayerEnterCheckpoint(Checkpoint checkpoint, Client player) { if (player.GetData(EntityData.PLAYER_JOB) == Constants.JOB_FASTFOOD) { // Get the player's deliver checkpoint Checkpoint playerDeliverColShape = player.GetData(EntityData.PLAYER_JOB_CHECKPOINT); if (playerDeliverColShape == checkpoint) { if (player.HasData(EntityData.PLAYER_DELIVER_START) == true) { if (!player.IsInVehicle) { Vehicle vehicle = player.GetData(EntityData.PLAYER_JOB_VEHICLE); playerDeliverColShape.Position = vehicle.GetData(EntityData.VEHICLE_POSITION); int elapsed = Globals.GetTotalSeconds() - player.GetData(EntityData.PLAYER_DELIVER_START); int extra = (int)Math.Round((player.GetData(EntityData.PLAYER_DELIVER_TIME) - elapsed) / 2.0f); int amount = GetFastFoodOrderAmount(player) + extra; player.ResetData(EntityData.PLAYER_DELIVER_START); player.SetData(EntityData.PLAYER_JOB_WON, amount > 0 ? amount : 25); player.TriggerEvent("fastFoodDeliverBack", playerDeliverColShape.Position); player.SendChatMessage(Constants.COLOR_INFO + InfoRes.deliver_completed); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.deliver_in_vehicle); } } else { Vehicle vehicle = player.GetData(EntityData.PLAYER_JOB_VEHICLE); if (player.Vehicle == vehicle && player.VehicleSeat == (int)VehicleSeat.Driver) { int won = player.GetData(EntityData.PLAYER_JOB_WON); int money = player.GetSharedData(EntityData.PLAYER_MONEY); int orderId = player.GetData(EntityData.PLAYER_DELIVER_ORDER); string message = string.Format(InfoRes.job_won, won); Globals.fastFoodOrderList.RemoveAll(order => order.id == orderId); playerDeliverColShape.Delete(); player.WarpOutOfVehicle(); player.SetSharedData(EntityData.PLAYER_MONEY, money + won); player.SendChatMessage(Constants.COLOR_INFO + message); player.ResetData(EntityData.PLAYER_DELIVER_ORDER); player.ResetData(EntityData.PLAYER_JOB_CHECKPOINT); player.ResetData(EntityData.PLAYER_JOB_VEHICLE); player.ResetData(EntityData.PLAYER_JOB_WON); player.TriggerEvent("fastFoodDeliverFinished"); // We get the motorcycle to its spawn point RespawnFastfoodVehicle(vehicle); } else { player.SendChatMessage(Constants.COLOR_ERROR + ErrRes.not_your_job_vehicle); } } } } }
public void OnPlayerRespawnInThicCheckpoint(Checkpoint Checkpoint, Player player) { _isCollected = false; Renderer.enabled = true; }
private void Start() { checkpointObject = gameObject.transform.parent.GetComponent <Checkpoint>(); }