//F272_xxxx_SENSOR_TriggerEffect protected async void TriggerEffect(ILeader theron, ActuatorX actuator, SensorEffect effect) { if (LocalEffect) { TriggerLocalEffect(theron, actuator); } else { MessageAction action; switch (effect) { case SensorEffect.C00_EFFECT_SET: action = MessageAction.Set; break; case SensorEffect.C01_EFFECT_CLEAR: action = MessageAction.Clear; break; case SensorEffect.C02_EFFECT_TOGGLE: action = MessageAction.Toggle; break; default: throw new ArgumentOutOfRangeException(nameof(effect), effect, null); } //TODO send B,A,TargetCell only to wall tiles, floor tiles has set this flag NORTHWEST //TODO time delay await Task.Delay(A.Value); await Task.Delay(TimeDelay); TargetTile.AcceptMessageBase(new Message(action, Specifier)); } }
/** * */ public bool CanMoveTo() { //Setting up variables------------ int ii = 0; bool CanMove = false; this.TargetTile = this.curTile; //Finding the tile to land on by iterating thu the urTile "linkedList" while (this.TargetTile.nextTile.Length != 0 && ii < MoveDistance) { this.TargetTile = TargetTile.GetNext(Owner.ID); ii++; } //If ii does not equal the move distance then the piece does not move if (ii == MoveDistance) { if (this.TargetTile.CanOccupy) { if (TargetTile.CurrentPiece == null || TargetTile.CurrentPiece.Owner != this.Owner) { CanMove = true; } } } return(CanMove); }
// Start is called before the first frame update public void Start() { cm = GameObject.FindGameObjectWithTag("GameController").GetComponent <CameraManager>(); player = GameObject.FindGameObjectWithTag("Player"); playerC = player.GetComponent <Character>(); HeartOfDungeon = GameObject.Find("Dungeon Heart"); //init shop _trapTypeDisplay.Add(GameObject.Find("SpawnSelection")); _trapTypeDisplay.Add(GameObject.Find("HoleSelection")); _trapTypeDisplay.Add(GameObject.Find("ArrowsSelection")); _trapTypeDisplay.Add(GameObject.Find("MudSelection")); //_trapTypeDisplay.Add(GameObject.Find("GoldSelection")); _trapTypeDisplay[0].GetComponent <Button>().onClick.AddListener(SetSpawner); _trapTypeDisplay[1].GetComponent <Button>().onClick.AddListener(SetHole); _trapTypeDisplay[2].GetComponent <Button>().onClick.AddListener(SetArrows); _trapTypeDisplay[3].GetComponent <Button>().onClick.AddListener(SetMud); //_trapTypeDisplay[3].GetComponent<Button>().onClick.AddListener(SetGoldDisplay); tileSelectedDisplay = GameObject.Find("Selection").GetComponent<RectTransform>(); _trapDescription = GameObject.Find("TrapDescription").GetComponent <Text>(); spawnerDescription = "Invocator Gate\n\nInvoke a gobelin every 5 seconds to kill adventurers (10 max)\n\nCost: 70 golds"; holeTrapDescription = "Hole\n\nKill 1 adventurer if we walk on it (1 use)\n\nCost: 25 gold"; arrowTrapDescription = "Arrows Wall\n\nSend arrows when an adventurer come in front of them\nCost: 110 golds"; mudTrapDescription = "Mud\n\nSlow down heroes during a few seconds\n\nCost: 50"; //goldPileDescription = "Gold Pile\n\nPut an amount of gold somewhere, it will allow you to accumulate more gold, you can take it back when needed.\nAdventurers will go take in in priority"; _trapDescription.text = spawnerDescription; tileSelected = GameObject.Find("TargetTile").GetComponent <TargetTile>(); tileSelectedDisplay = GameObject.Find("Selection").GetComponent <RectTransform>(); shopPanel = GameObject.Find("Shop"); trapPlaced = new List <GameObject>(); shopText = GameObject.FindGameObjectWithTag("ShopText"); UpgradeShop = GameObject.Find("UpgradeShop"); UpgradeShop.SetActive(false); ShopClose(); healTimer = 0f; }
public override void Undo() { if (executed) { TargetTile.DetachPiece(); SelectedTile.AttachPiece(Piece, PieceHasMoved); executed = false; } }
public override void Execute() { if (!executed) { SelectedTile.DetachPiece(); TargetTile.AttachPiece(Piece, true); executed = true; } }
public override void Undo() { if (executed) { TargetTile.DetachPiece(); SelectedTile.AttachPiece(Piece, PieceHasMoved); if (Piece is IEnPassantable) { IEnPassantable enPassantablePiece = Piece as IEnPassantable; enPassantablePiece.CurrentlyEnPassantable = false; } executed = false; } }
public override void Execute() { if (!executed) { SelectedTile.DetachPiece(); TargetTile.AttachPiece(Piece, true); if (Piece is IEnPassantable) { IEnPassantable enPassantablePiece = Piece as IEnPassantable; enPassantablePiece.CurrentlyEnPassantable = true; } executed = true; } }
public override void Fire() { base.Fire(); TargetTile.TargetingSetActive(this.TowerKind, true); throwSimulator.Shoot(this.transform, this.transform.position, this.TargetTile.transform.position, 10f, 5f, () => { TargetTile.TargetingSetActive(this.TowerKind, false); Effect.gameObject.SetActive(true); Effect.transform.position = new Vector3(transform.position.x, 1f, transform.position.z); Effect.Play(); Hit(); EventManager.Instance.emit(EVENT_TYPE.TILE_HIT, this, TargetTile); StartCoroutine("PositionReset"); }); }
public override void Fire() { base.Fire(); TargetTile.TargetingSetActive(this.TowerKind, true); throwSimulator.Shoot(this.transform, this.transform.position, this.TargetTile.transform.position, 10f, 5f, () => { Effect.gameObject.SetActive(true); TargetTile.TargetingSetActive(this.TowerKind, false); Effect.transform.position = new Vector3(transform.position.x, 1f, transform.position.z); Effect.Play(); if (dotObject) { dotObject.SetActive(true); } Hit(); StartCoroutine("OneSecTimer"); }); }
IEnumerator OneSecTimer() { yield return(new WaitForSeconds(0.5f)); if (demageTime > dotDamageTime) { demageTime = 0; if (dotObject) { dotObject.SetActive(false); } StartCoroutine("PositionReset"); StopCoroutine("OneSecTimer"); yield return(null); } demageTime++; if (TargetTile.tileData.tileState == TileState.BUILDING) { TargetTile.TileHurt(Damage); } EventManager.Instance.emit(EVENT_TYPE.TILE_HIT, this, TargetTile); StartCoroutine("OneSecTimer"); }
public virtual OrderInvalidReason Validate() { OrderInvalidReason r; if (_OddsCalculations.Count == 0) { if (TargetTile.Units.Count() == 0) { return(OrderInvalidReason.TARGET_EMPTY); } return(TargetTile.Units.First().CanBeAttackedBy(Army, AttackMethod)); } if (Army.HasAttackedTile(TargetTile)) { return(OrderInvalidReason.TARGET_ALREADY_ATTACKED); } foreach (SingleAttackOrder order in _Attackers) { r = order.Validate(); if (r != OrderInvalidReason.NONE) { return(r); } } r = TargetTile.CanBeAttacked(AttackMethod); if (r != OrderInvalidReason.NONE) { return(r); } if (_Attackers.Select(i => i.AttackTile).Distinct().Count() > 1) { return(OrderInvalidReason.ILLEGAL); } return(OrderInvalidReason.NONE); }
public LightHitInfo[] LightBouncePositions(Vector2Int startPosition, Vector2Int aimingDirection, TileColor lightColor) { if (aimingDirection == Vector2Int.zero) { //If there is no direction then it can go no where, so lets just stop it here otherwise it will be stuck in a infinite loop LightHitInfo[] tempArray = { new LightHitInfo(startPosition, Vector2Int.zero) }; return(tempArray); } BaseTile NextPosition = GridArray[startPosition.x][startPosition.y]; List <LightHitInfo> ReflectPositions = new List <LightHitInfo>(); //A Temporary List for checking the satelite Positions hit, so it doesn't get stuck in a loop List <Vector2Int> TilesHit = new List <Vector2Int>(); Vector2Int LastKnownHeading = aimingDirection; Vector2Int nullPosition = new Vector2Int(-1, -1); //Set First Position ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(startPosition); //Try to get to the next position, so we aren't just checking the position we started from already Vector2Int tempPosition = NextPosition.arrayPosition + LastKnownHeading; if (tempPosition.x < Width && tempPosition.x >= 0 && tempPosition.y < Height && tempPosition.y >= 0) { NextPosition = GridArray[tempPosition.x][tempPosition.y]; } else { //Position is out of the array break here NextPosition = null; } while (NextPosition != null) { //Look into the next Position tempPosition = nullPosition; //Check if this Position is a Satalite switch (NextPosition.tileType) { case BaseTile.TileTypes.Satalite: //This is a satalite, this will update our heading LastKnownHeading = NextPosition.GetComponent <Satellite>().ReflectDirection; if (TilesHit.Contains(NextPosition.arrayPosition)) { //Stop this here, since we are going to end up going in a loop ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); //Is this needed? NextPosition = null; break; } else { ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); } break; case BaseTile.TileTypes.LightTarget: TargetTile tempTarget = NextPosition.GetComponent <TargetTile>(); if (lightColor == tempTarget.TargetColour) { ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); //Is this needed? NextPosition = null; break; } else { //Not Reached our Target } break; case BaseTile.TileTypes.CombineSatellite: //Check if we are searching for our selves if (NextPosition.arrayPosition == startPosition) { break; } //End the Light position for this colour ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); NextPosition = null; break; case BaseTile.TileTypes.LightGate: //Check if the light can pass through the gate LightGate tempGate = NextPosition.GetComponent <LightGate>(); if (tempGate.CanPass(LastKnownHeading, lightColor)) { ReflectPositions.Add(new LightHitInfo(NextPosition.arrayPosition, WorldOffset)); } else { ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); NextPosition = null; } break; //If the Tile hit ends here and DOES contain ITileHit interface case BaseTile.TileTypes.SatelliteSplitter: case BaseTile.TileTypes.LightTrigger: case BaseTile.TileTypes.LightFilter: //Not matter what happens, the light beam should end here ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); NextPosition = null; break; //If the tile hits an end point but DOES NOT contain the ITileHit interface case BaseTile.TileTypes.Asteroid: //End Here, Hit an Asteroid ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); TilesHit.Add(NextPosition.arrayPosition); //Is this needed? NextPosition = null; break; } if (NextPosition == null) { break; } //Basic Tile, Keep Heading in Direction and Till we reach the end tempPosition = NextPosition.arrayPosition + LastKnownHeading; //Checking this is within the size of the array, and has been assigned if (tempPosition.x < Width && tempPosition.x >= 0 && tempPosition.y < Height && tempPosition.y >= 0) { NextPosition = GridArray[tempPosition.x][tempPosition.y]; } else { ReflectPositions.Add(new LightHitInfo(NextPosition, WorldOffset)); //Reached End NextPosition = null; break; } } return(ReflectPositions.ToArray()); }