public HitInfo(EvilAI parent, int playerId, float hitAngle, float hitForce) { this.PlayerId = playerId; this.HitAngle = hitAngle; this.HitForce = hitForce; this._metricValue = parent.EmulateHit(playerId, hitAngle, this.HitForce); }
public static void SmallShipFactory(ServerGame game) { Rectangle spawnRect = new Rectangle((int)(game.WorldSize.X - 1000), 0, 1000, (int)(game.WorldSize.Y)); EvilAI c = new EvilAI(game); SmallShip ship3 = new SmallShip(game); SmallShip.ServerInitialize(ship3, Utils.RandomUtils.RandomVector2(spawnRect), new Vector2(0, 0), c, c); c.Focus = ship3; game.GameObjectCollection.Add(ship3); }
private void OnSceneLoaded(Scene scene) { Debug.Log("GameLogic got scene"); SimulationScene = scene; var rootGameObjects = SimulationScene.GetRootGameObjects(); var rootGameObject = rootGameObjects[0]; // Disable GameLoopManager in the physics scene. rootGameObject.GetComponentInChildren <GameLoopManager>().gameObject.SetActive(false); TargetHole = rootGameObject.GetComponentsInChildren <Transform>() .First(child => child.gameObject.name == "TargetHole").gameObject; // Disable cameras in the physics scene. foreach (var camera in rootGameObject.GetComponentsInChildren <Camera>()) { camera.gameObject.SetActive(false); } // Disable light in the physics scene. foreach (var light in rootGameObject.GetComponentsInChildren <Light>()) { light.gameObject.SetActive(false); } // Make all objects in the physics scene invisible. foreach (var renderer in rootGameObject.GetComponentsInChildren <Renderer>()) { renderer.enabled = false; } // Find player balls. PlayerBalls = rootGameObject.GetComponentsInChildren <PlayerBall>(); SimulationScene.GetPhysicsScene().Simulate(0.01f); // zero step for colliders if (PlayerBalls.Length != NumberOfPlayers) { throw new ArgumentException($"Inconsistent number of players: {PlayerBalls.Length} vs {NumberOfPlayers}"); } // Initialize AIs. for (int i = 0; i < NumberOfPlayers; i++) { switch (PlayerTypes[i]) { case PlayerType.Human: AIs[i] = null; Debug.Log(i + " is HUMAN"); break; case PlayerType.DummyAI: AIs[i] = new DummyAI(this, i); Debug.Log(i + " is DUMMYAI"); break; case PlayerType.EvilAI: AIs[i] = new EvilAI(this, i); Debug.Log(i + " is EVILAI"); break; default: throw new ArgumentException($"Unknown player type: {PlayerTypes[i]}"); } } NextMove(); }