public static void Read(Nettention.Proud.Message msg, out ShipObjectArray objArray) { int count = 0; msg.Read(out count); if (count > 0) { ShipObject[] worldData = new ShipObject[count]; for (int i = 0; i < count; i++) { ShipObject data = new ShipObject(); msg.Read(out data.Owner); msg.Read(out data.LocalID); msg.Read(out data.Position.x); msg.Read(out data.Position.y); msg.Read(out data.Position.z); msg.Read(out data.resIndex); worldData[i] = data; } objArray = new ShipObjectArray(worldData); } else { objArray = new ShipObjectArray(); } }
private bool _drawDebugInfo; // true if the collision shapes should be drawn for debugging. public ContentPipelineSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; GraphicsScreen.ClearBackground = true; GraphicsScreen.BackgroundColor = Color.CornflowerBlue; SetCamera(new Vector3F(0, 1, 10), 0, 0); // Initialize collision detection. // Note: The physics Simulation also has a collision domain (Simulation.CollisionDomain) // which we could use and which is updated together with the Simulation in // SampleGame.cs. But in this example we create our own CollisionDomain for demonstration // purposes. _collisionDomain = new CollisionDomain(new CollisionDetection()); // Register CollisionDomain in service container. Services.Register(typeof(CollisionDomain), null, _collisionDomain); // Add game objects which manage graphics models and their collision representations. _saucerObject = new SaucerObject(Services) { Name = "Saucer" }; _shipObjectA = new ShipObject(Services) { Name = "ShipA" }; _shipObjectB = new ShipObject(Services) { Name = "ShipB" }; GameObjectService.Objects.Add(_saucerObject); GameObjectService.Objects.Add(_shipObjectA); GameObjectService.Objects.Add(_shipObjectB); // Position the second ship right of the first ship with an arbitrary rotation. _shipObjectB.Pose = new Pose(new Vector3F(2, 0, 0), QuaternionF.CreateRotationY(0.7f) * QuaternionF.CreateRotationX(1.2f)); // Position the saucer left of the first ship with an arbitrary rotation. _saucerObject.Pose = new Pose(new Vector3F(-2.5f, 0, 0), QuaternionF.CreateRotationY(0.2f) * QuaternionF.CreateRotationX(0.4f)); }
public override void _Ready() { asteroidPool = GetNode("AsteroidPool") as Node; commandStartPoint = GetNode("CommandStartPoint") as Position2D; deathSound = GetNode("DeathSound") as AudioStreamPlayer; bgm = GetNode("BGM") as AudioStreamPlayer; gameplayHUD = GetNode("GameplayHUD") as GameplayHUDObject; gameOverHUD = GetNode("GameOverHUD") as GameOverHUD; ship = GetNode("Ship") as ShipObject; commandExecutePoint = GetNode("CommandExecutePoint") as CommandExecutePoint; messageTimer = GetNode("GameplayHUD/MessageTimer") as Timer; blackHolePool = GetNode("BlackHolePool") as Node; spawnTimer = GetNode("SpawnTimer") as Timer; this.globals = (Autoload)GetNode("/root/Autoload"); this.globals.Randomize(); ship.Connect("Hit", this, "GameOver"); gameOverHUD.Connect("BackToMainMenu", this, "GotoMainmenu"); gameOverHUD.Connect("RestartGame", this, "RestartGameplay"); commandExecutePoint.Connect("CallRight", this, "ForceShipTurnRight"); commandExecutePoint.Connect("CallLeft", this, "ForceShipTurnLeft"); commandExecutePoint.Connect("CallShoot", this, "ForceShipShootLaser"); SetProcess(true); NewGame(); StartNextLevel(); }
public void SetMoveController(ShipObject shipObject, float playerSpeed) { ShipObject = shipObject; PlayerSpeed = playerSpeed; _rigidBody = ShipObject.GetComponent <Rigidbody2D>(); ChangeMoveMode(3); }
// Use this for initialization void Awake() { //get player ship //temp = GameObject.FindGameObjectWithTag("PlayerInstance"); // temp = manager.GetPlayer().Ship; manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManagerScript>(); if (manager.GetPlayer() == null) { print("null ship"); } player = manager.GetPlayer().Ship; //get player healthbar and hull bar. I dont think this is safe playerHealthBar = (GameObject.FindGameObjectWithTag("PlayerHealthBar")).GetComponent <Slider>(); playerHull = (GameObject.FindGameObjectWithTag("PlayerHullBar")).GetComponent <Slider>(); //get enemy healthbar and hull bar. I dont think this is safe //enemyHealthBar = (GameObject.FindGameObjectWithTag("EnemyHealthBar")).GetComponent<Slider>(); //enemyHull = (GameObject.FindGameObjectWithTag("EnemyHullBar")).GetComponent<Slider>(); playerMaxHealth = player.Health; //set max values playerHealthBar.maxValue = playerMaxHealth; //PlayerMaxHull = player.maxHull; }
protected override void Start() { base.Start(); gameManager = GameManager.Instance; CurrentGraph = gameManager.Graphs[0]; ship = GameObject.FindGameObjectWithTag("Ship").GetComponent <ShipObject>(); QueuedDestination = new Queue <KeyValuePair <Vector3, GraphMask> >(); }
/// <summary> /// Reads Tiles json that defines what tiles the ship occupies when unwrapped /// and writes them to the tile type array. /// </summary> /// <param name="reader">The JToken.</param> private void ReadJsonTiles(JToken tilesToken) { foreach (JToken tileToken in tilesToken) { ShipObject tile = new ShipObject((string)tileToken["Type"], (int)tileToken["X"], (int)tileToken["Y"]); tiles.Add(tile); } }
/// <summary> /// Reads furniture types that the ship contains while unwrapped and /// writes them to the furniture type array. /// </summary> /// <param name="reader">The JToken.</param> private void ReadJsonFurnitures(JToken furnituresToken) { foreach (JToken furnitureToken in furnituresToken) { ShipObject furniture = new ShipObject((string)furnitureToken["Type"], (int)furnitureToken["X"], (int)furnitureToken["Y"]); furnitures.Add(furniture); } }
public void Collision(Collision2D collision) { _ship = collision.collider.GetComponent <ShipObject>(); if (_ship != null) { _ship.ChangeHealth(-Damage); Demolish(); } }
void OnMouseDown() { GameObject.Find("IfClicked").GetComponent <Text>().text = "Clicked: " + id + "\nIs ship: " + IsShip.ToString(); if (IsShip && !IsDamaged) { IsDamaged = true; ShipHandler.shipsList.Find(t => t.Id == ShipId).Damage(); ShipObject.GetComponent <SOMETHING>().DAMAGE_PART(ShipPartNumber); } }
void Start() { grid = GetComponent <GridManager>(); grid.Initialize(); ghost = Instantiate(ghost); ghost.SetActive(false); ghostRenderer = ghost.GetComponent <SpriteRenderer>(); ship = new ShipObject(grid.cols, grid.rows); representation.rooms = new GameObject[grid.cols, grid.rows]; representation.mechanisms = new GameObject[grid.cols, grid.rows]; hasNavUnit = ship.HasNavUnit(); }
private void SpawnShipAndWeapons() { _shipGO = Instantiate(_ship.ShipObject, PlayerSpawnPoint.position, Quaternion.identity); _shipGO.transform.Rotate(new Vector3(0, 0, -90)); for (int i = 0; i < _ship.Weapons.Count; i++) { Debug.Log("weapon: " + _ship.Weapons[i].Name); _weaponPrefab = StaticTagFinder.GameManager.GetWeaponByID(_ship.Weapons[i].Id).WeaponPrefab; _weaponPos = PlayerSpawnPoint.position + _weaponPrefab.transform.position; WeaponObject weapon = Instantiate(_weaponPrefab, _weaponPos, Quaternion.identity, _shipGO.transform); weapon.gameObject.SetActive(false); _ship.Weapons[i].WeaponObject = weapon; } }
private IEnumerator Init() { while (ship.Keel == null) { yield return(new WaitForSeconds(0.1f)); } if (ship == null || ship != GameManager.Instance.Ship) { ship = GameManager.Instance.EnemyShip; } maxHealth = ship.Keel.Health; }
private void Start() { if (Instance == null) { Instance = this; } else { Destroy(this); } ship = GameObject.FindGameObjectWithTag("Ship").GetComponent <ShipObject>(); SetupPrefabs(); SetupCannonBalls(); }
public void SetFireController(ShipObject shipGO, List <Weapon> weapons, List <Ammo> ammo) { Weapons = weapons; ActiveWeapon = Weapons[0]; Ammo = ammo; ActiveAmmo = Ammo[0]; _bulletSpawnPoint = ActiveWeapon.WeaponObject.BulletSpawnPoint; WeaponText.text = ActiveWeapon.Name; _playerGO = shipGO; _communique = Globals.Communique; ActiveWeapon = Weapons[0]; ActiveWeapon.WeaponObject.gameObject.SetActive(true); SetAmmo(ActiveWeapon.Ammo[0]); GameUI.WeaponUI.SetUI(ActiveWeapon); OnLaserActive += GameUI.UiLaserOverheat.SetActive; }
private bool _drawDebugInfo; // true if the collision shapes should be drawn for debugging. public ContentPipelineSample(Microsoft.Xna.Framework.Game game) : base(game) { SampleFramework.IsMouseVisible = false; GraphicsScreen.ClearBackground = true; GraphicsScreen.BackgroundColor = Color.CornflowerBlue; SetCamera(new Vector3(0, 1, 10), 0, 0); // Initialize collision detection. // Note: The physics Simulation also has a collision domain (Simulation.CollisionDomain) // which we could use and which is updated together with the Simulation in // SampleGame.cs. But in this example we create our own CollisionDomain for demonstration // purposes. _collisionDomain = new CollisionDomain(new CollisionDetection()); // Register CollisionDomain in service container. Services.Register(typeof(CollisionDomain), null, _collisionDomain); // Add game objects which manage graphics models and their collision representations. _saucerObject = new SaucerObject(Services) { Name = "Saucer" }; _shipObjectA = new ShipObject(Services) { Name = "ShipA" }; _shipObjectB = new ShipObject(Services) { Name = "ShipB" }; GameObjectService.Objects.Add(_saucerObject); GameObjectService.Objects.Add(_shipObjectA); GameObjectService.Objects.Add(_shipObjectB); // Position the second ship right of the first ship with an arbitrary rotation. _shipObjectB.Pose = new Pose(new Vector3(2, 0, 0), Quaternion.CreateRotationY(0.7f) * Quaternion.CreateRotationX(1.2f)); // Position the saucer left of the first ship with an arbitrary rotation. _saucerObject.Pose = new Pose(new Vector3(-2.5f, 0, 0), Quaternion.CreateRotationY(0.2f) * Quaternion.CreateRotationX(0.4f)); }
public static void Write(Nettention.Proud.Message msg, ShipObjectArray objArray) { if (objArray == null) { return; } msg.Write(objArray.Count); for (int i = 0; i < objArray.Count; i++) { ShipObject data = objArray.data[i]; msg.Write(data.Owner); msg.Write(data.LocalID); msg.Write(data.Position.x); msg.Write(data.Position.y); msg.Write(data.Position.z); msg.Write(data.resIndex); } }
public override void _Ready() { ship = GetNode("PlayerShip") as ShipObject; Position2D temp = GetNode("PlayerShipPoints/2") as Position2D; commandStartPoint = GetNode("CommandPanel/CommandStartPoint") as Position2D; commandExecutionPoint = GetNode("CommandPanel/CommandExecutionPoint") as CommandExecutionPointObject; reefSpawnTimer = GetNode("ReefSpawnTimer") as Timer; reefPool = GetNode("ReefPool") as Node; remainingNMileLabel = GetNode("CommandPanel/RemainingNMileLabel") as Label; messageLabel = GetNode("MessageLabel") as Label; messageTimer = GetNode("MessageTimer") as Godot.Timer; weaterStatusLabel = GetNode("CommandPanel/WeaterStatusLabel") as Label; gameOverSound = GetNode("GameOverSound") as AudioStreamPlayer; missionCompleteSound = GetNode("MissionCompleteSound") as AudioStreamPlayer; bgm = GetNode("BGM") as AudioStreamPlayer; this.globals = (Autoload)GetNode("/root/Autoload"); this.globals.Randomize(); ship.SetStartPosition(temp.Position, Int32.Parse(temp.Name)); velocity = commandVelocity[weatherFactor]; reefSpawnTimer.Start(); distanceFromGoal *= 60; //multiply with 60 because frame-per-sec principle this.globals.missionComplete = false; difficult = 0; weatherFactor = 0; messageLabel.Hide(); messageTimer.Stop(); SetWeatherStatusLabel(); gameOverSound.Stop(); missionCompleteSound.Stop(); bgm.Stop(); bgm.Play(); commandExecutionPoint.Connect("CallRight", this, "ForceShipTurnRight"); commandExecutionPoint.Connect("CallLeft", this, "ForceShipTurnLeft"); ship.Connect("Hit", this, "DoGameOver"); }
private void SetShip() { shipObject = FindObjectOfType <GameSession>().shipObjects[PlayerPrefs.GetInt("PlayerShip", 0)]; }
public void LoadMisc(WzImage mapImage, Board mapBoard) { // All of the following properties are extremely esoteric features that only appear in a handful of maps. // They are implemented here for the sake of completeness, and being able to repack their maps without corruption. WzImageProperty clock = mapImage["clock"]; WzImageProperty ship = mapImage["shipObj"]; WzImageProperty area = mapImage["area"]; WzImageProperty healer = mapImage["healer"]; WzImageProperty pulley = mapImage["pulley"]; WzImageProperty BuffZone = mapImage["BuffZone"]; WzImageProperty swimArea = mapImage["swimArea"]; if (clock != null) { Clock clockInstance = new Clock(mapBoard, new Rectangle(InfoTool.GetInt(clock["x"]), InfoTool.GetInt(clock["y"]), InfoTool.GetInt(clock["width"]), InfoTool.GetInt(clock["height"]))); mapBoard.BoardItems.Add(clockInstance, false); } if (ship != null) { string objPath = InfoTool.GetString(ship["shipObj"]); string[] objPathParts = objPath.Split("/".ToCharArray()); string oS = WzInfoTools.RemoveExtension(objPathParts[objPathParts.Length - 4]); string l0 = objPathParts[objPathParts.Length - 3]; string l1 = objPathParts[objPathParts.Length - 2]; string l2 = objPathParts[objPathParts.Length - 1]; ObjectInfo objInfo = ObjectInfo.Get(oS, l0, l1, l2); ShipObject shipInstance = new ShipObject(objInfo, mapBoard, InfoTool.GetInt(ship["x"]), InfoTool.GetInt(ship["y"]), InfoTool.GetOptionalInt(ship["z"]), InfoTool.GetOptionalInt(ship["x0"]), InfoTool.GetInt(ship["tMove"]), InfoTool.GetInt(ship["shipKind"]), InfoTool.GetBool(ship["f"])); mapBoard.BoardItems.Add(shipInstance, false); } if (area != null) { foreach (WzImageProperty prop in area.WzProperties) { int x1 = InfoTool.GetInt(prop["x1"]); int x2 = InfoTool.GetInt(prop["x2"]); int y1 = InfoTool.GetInt(prop["y1"]); int y2 = InfoTool.GetInt(prop["y2"]); Area currArea = new Area(mapBoard, new Rectangle(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1)), prop.Name); mapBoard.BoardItems.Add(currArea, false); } } if (healer != null) { string objPath = InfoTool.GetString(healer["healer"]); string[] objPathParts = objPath.Split("/".ToCharArray()); string oS = WzInfoTools.RemoveExtension(objPathParts[objPathParts.Length - 4]); string l0 = objPathParts[objPathParts.Length - 3]; string l1 = objPathParts[objPathParts.Length - 2]; string l2 = objPathParts[objPathParts.Length - 1]; ObjectInfo objInfo = ObjectInfo.Get(oS, l0, l1, l2); Healer healerInstance = new Healer(objInfo, mapBoard, InfoTool.GetInt(healer["x"]), InfoTool.GetInt(healer["yMin"]), InfoTool.GetInt(healer["yMax"]), InfoTool.GetInt(healer["healMin"]), InfoTool.GetInt(healer["healMax"]), InfoTool.GetInt(healer["fall"]), InfoTool.GetInt(healer["rise"])); mapBoard.BoardItems.Add(healerInstance, false); } if (pulley != null) { string objPath = InfoTool.GetString(pulley["pulley"]); string[] objPathParts = objPath.Split("/".ToCharArray()); string oS = WzInfoTools.RemoveExtension(objPathParts[objPathParts.Length - 4]); string l0 = objPathParts[objPathParts.Length - 3]; string l1 = objPathParts[objPathParts.Length - 2]; string l2 = objPathParts[objPathParts.Length - 1]; ObjectInfo objInfo = ObjectInfo.Get(oS, l0, l1, l2); Pulley pulleyInstance = new Pulley(objInfo, mapBoard, InfoTool.GetInt(pulley["x"]), InfoTool.GetInt(pulley["y"])); mapBoard.BoardItems.Add(pulleyInstance, false); } if (BuffZone != null) { foreach (WzImageProperty zone in BuffZone.WzProperties) { int x1 = InfoTool.GetInt(zone["x1"]); int x2 = InfoTool.GetInt(zone["x2"]); int y1 = InfoTool.GetInt(zone["y1"]); int y2 = InfoTool.GetInt(zone["y2"]); int id = InfoTool.GetInt(zone["ItemID"]); int interval = InfoTool.GetInt(zone["Interval"]); int duration = InfoTool.GetInt(zone["Duration"]); BuffZone currZone = new BuffZone(mapBoard, new Rectangle(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1)), id, interval, duration, zone.Name); mapBoard.BoardItems.Add(currZone, false); } } if (swimArea != null) { foreach (WzImageProperty prop in swimArea.WzProperties) { int x1 = InfoTool.GetInt(prop["x1"]); int x2 = InfoTool.GetInt(prop["x2"]); int y1 = InfoTool.GetInt(prop["y1"]); int y2 = InfoTool.GetInt(prop["y2"]); SwimArea currArea = new SwimArea(mapBoard, new Rectangle(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs(x2 - x1), Math.Abs(y2 - y1)), prop.Name); mapBoard.BoardItems.Add(currArea, false); } } // Some misc items are not implemented here; these are copied byte-to-byte from the original. See VerifyMapPropsKnown for details. }
public void initializeShip(EnumShipType shipType, Vector3 vectorPosition) { ship = new ShipObject(shipType, vectorPosition); }
public void Init(ShipObject shipObject) { shipObject.OnStateChanged += Refresh; }