public void OnTangibleAdded(Tangible t) { Debug.Log("Tangible added: " + t.Id); var e = GetExampleTangible(t.Id); e.Update(t, _offset); }
/// <summary> /// Add unique damage behaviour here /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void doDamage(Tangible target, GameTime gameTime) { explosionEngine.createSmallExplosion(position); assets.explosionsSFX[9].Play(); assets.explosionsSFX[10].Play(); base.doDamage(target, gameTime); }
public void OnTangibleAdded(Tangible t) { TangibleData tangible = GetTangibleWithId(t.Id); tangible.GameObject.GetComponent <SpawnTangibleCollider>().puckIndex = t.PatternId; Debug.Log(tangible.GameObject.GetComponent <SpawnTangibleCollider>().puckIndex); tangible.Update(t, _offset); }
public void OnTangibleUpdated(Tangible t) { //Debug.Log("Tangible Updated: " + t.Id); TangibleData tangible = GetTangibleWithId(t.Id); tangible.Update(t, _offset); //Debug.Log(tangible.Transform.position); }
/// <summary> /// Deal damage and destroy the projectile. /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void collide(Tangible target, GameTime gameTime) { if (target != owner) { doDamage(target, gameTime); destroy(); } }
public void AddTangible(Tangible t) { if (_tangibles != null && !_tangibles.Contains(t)) { _tangibles.Add(t); _sim.InvokeUpdate(); } }
public void OnTangibleUpdated(Tangible t) { ExampleTangibleData e; if (_tangibleMap.TryGetValue(t.Id, out e)) { e.Update(t, _offset); } }
public void ActivateTangible() { Debug.Log("Activate Tangible"); _tangible = GetTangible(); _simView.AddTangible(_tangible); OnButtonBg.color = SelectedButtonColor; OnLabel.color = SelectedTextColor; OffButtonBg.color = UnselectedButtonColor; OffLabel.color = UnselectedTextColor; }
public void OnTangibleRemoved(Tangible t) { Debug.Log("Tangible Removed: " + t.Id); TangibleData tangible = GetTangibleWithId(t.Id); //replaced destroy for setting tangible collider activity tangible.GameObject.GetComponent <SpawnTangibleCollider>().puck.gameObject.SetActive(false); //Debug.Log(tangible.GameObject + "onRemoved"); ReturnTangible(t.Id); }
public void RemoveTangible(Tangible t) { if (_tangibles != null && _tangibles.Contains(t)) { _tangibles.Remove(t); if (_tangibles.Count <= 0) { _sim.InvokeUpdate(); } } }
private void narrowCheck(Tangible target, float temp, ref Tangible currentTarget) { Color[] rawData = new Color[target.width * target.height]; target.texture.GetData <Color>(rawData); Color[,] rawDataGrid = new Color[target.width, target.height]; for (int x = 0; x < target.width; ++x) { for (int y = 0; y < target.height; ++y) { rawDataGrid[x, y] = rawData[x + y * target.width]; } } float distanceTo = temp * beamLength; // start checking pixel-by-pixel from this point Vector2 startFrom = new Vector2(beamDirection.X * distanceTo + position.X, beamDirection.Y * distanceTo + position.Y); Vector2 checkV = startFrom; Point check = new Point((int)startFrom.X, (int)startFrom.Y); Rectangle hb = target.getHitBox().getArray(); Vector2 length; length = position - checkV; if (length.Y > 0) { check.Y -= 1; } if (length.X > 0) { check.X -= 1; } // until out of hitbox or beamLength exceeded while (hb.Contains(check)) { Color color = rawDataGrid[Math.Abs(hb.X - check.X), Math.Abs(hb.Y - check.Y)]; // if color is not transparent if (color.A != 0) { distToTarget = length.Length() / beamLength; currentTarget = target; return; } checkV.X += beamDirection.X; checkV.Y += beamDirection.Y; length = position - checkV; if (length.Length() > beamLength) { return; } check.X = (int)checkV.X; check.Y = (int)checkV.Y; } }
public void Update(Tangible t, Vector3 offset) { if (Transform != null) { Transform.localPosition = new Vector3(t.X, t.Y, 0) + offset; Transform.localEulerAngles = new Vector3(0, 0, t.R * Mathf.Rad2Deg); } if (Text != null) { Text.text = string.Format("Tangible {0}\nPattern {1}\nPosition {2:000.0}, {3:000.0}\nRotation {4:000.0}", t.Id, t.PatternId, t.X, t.Y, Mathf.Rad2Deg * t.R); } }
public void DeactivateTangible() { Debug.Log("Deactivate Tangible"); if (_tangible == null) { return; } _simView.RemoveTangible(_tangible); _tangible = null; OnButtonBg.color = UnselectedButtonColor; OnLabel.color = UnselectedTextColor; OffButtonBg.color = SelectedButtonColor; OffLabel.color = SelectedTextColor; }
public Tangible GetTangible() { if (_rectTransform == null) { _rectTransform = GetComponent <RectTransform>(); } var id = _patternIds[_patternIndex]; var tangible = new Tangible { Id = tangibleId++, PatternId = id, Pos = { x = _rectTransform.anchoredPosition.x, y = _rectTransform.anchoredPosition.y }, R = rotateHandle.R * Mathf.Deg2Rad, PointerIds = new[] { 1, 2, 3 } }; return(tangible); }
/// <summary> /// Determine what kind of collision is occuring. /// @Written by Tristan. /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> /// <exception cref="NotImplementedException">A new kind of object that needs handling</exception> public override void collide(Tangible target, GameTime gameTime) { if (target is Projectile) { target.collide(this, gameTime); // the projectile can handle it from here } else if (target is Ship) { game.collisionHandler.shipOnShip(this, (Ship)target, gameTime); } else if (target is Asteroid) { game.collisionHandler.shipOnAsteroid(this, (Asteroid)target, gameTime); } else if (target is Planet) { game.collisionHandler.shipOnPlanet(this, (Planet)target, gameTime); } else { throw new NotImplementedException(); } }
public override void collide(Tangible target, GameTime gameTime) { if (target is Projectile) { target.collide(this, gameTime); } else if (target is Ship) { game.collisionHandler.shipOnPlanet((Ship)target, this, gameTime); } else if (target is Asteroid) { game.collisionHandler.asteroidOnPlanet((Asteroid)target, this, gameTime); } else if (target is Planet) { game.collisionHandler.planetOnPlanet(this, (Planet)target, gameTime); } else { throw new NotImplementedException(); } }
/// <summary> /// Add unique damage behaviour here /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void doDamage(Tangible target, GameTime gameTime) { base.doDamage(target, gameTime); }
public TaxLaw(Tangible Tangible, double Amount) { _Tangible = Tangible; _Amount = Amount; }
/// <summary> /// Add unique damage behaviour here /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void doDamage(Tangible target, GameTime gameTime) { explosionEngine.createBigExplosion(position); base.doDamage(target, gameTime); }
public void OnTangibleRemoved(Tangible t) { Debug.Log("Tangible removed: " + t.Id); ReturnExampleTangible(t.Id); }
public void OnEngineFailedToConnect(Tangible t) { //Debug.Log("failed to connect"); }
/// <summary> /// Add unique collision behaviour here /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void collide(Tangible target, GameTime gameTime) { base.collide(target, gameTime); }
public void update(GameTime gameTime, QuadTree quadTree) { if (!beamOn) { return; } beamQuanta.Clear(); //beamQuantum = new Rectangle((int) position.X, (int) position.Y, 1, 3); beamDirection = new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation)); Ray2 ray = new Ray2(position, beamDirection * beamLength); distToTarget = 1; // find targets within line of fire /*List<Tangible> possibleCollisions = quadTree.retrieveNeighbors(owner);*/ /* This method and may result in missed ships. * A different retriever using a raycast * will likely be necessary. -Tristan-*/ List <Tangible> possibleCollisions = GameplayScreen.targets; Tangible currentTarget = null; foreach (Tangible target in possibleCollisions) { if (target != owner && target.isActive) { if (ray.intersectsToRange(target.getHitBox())) { float temp = ray.getDistance(); if (temp <= distToTarget) { // fine hit detection narrowCheck(target, temp, ref currentTarget); } } } } if (currentTarget != null) { doDamage(currentTarget, gameTime); } frameIndex = startQuanta; for (int i = 0; i < beamLength * distToTarget; ++i) { beamQuanta.Add(getNextQuanta()); if (++frameIndex > 4) { frameIndex = 0; } } if (--startQuanta < 0) { startQuanta = 4; } beamOn = false; }
public void doDamage(Tangible target, GameTime gameTime) { target.takeDamage(weaponDamage, gameTime, owner); }
private static void PrintTangibleCommands(Tangible tangible) { Console.WriteLine($"{tangible} has {tangible.Commands.Count()} commands."); foreach (var command in tangible.Commands) { Console.WriteLine($"{command} is owned by {command.Owner}."); } }
/// <summary> /// Add unique damage behaviour here /// </summary> /// <param name="target"></param> /// <param name="gameTime"></param> public override void doDamage(Tangible target, GameTime gameTime) { explosionEngine.createSmallExplosion(position); base.doDamage(target, gameTime); // base calls destroy by default }