/// <summary> /// set pieces at destinationation cell and clear source cell /// </summary> /// <param name="game"></param> /// <returns></returns> public bool Complete(Game game) { DestinationCell.SetPiece(Piece); //destination cell is set with the piece SourceCell.SetPiece(null); game.Movements.Push(this); // add to movement stack in the game to keep track of all the movements return(true); }
public bool Equals(Synapse obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (InputIndex != obj.InputIndex) { return(false); } // // Synapses are equal if they belong to the same segment. if (this.SegmentIndex != ((Synapse)obj).SegmentIndex) { return(false); } if (SourceCell == null) { if (obj.SourceCell != null) { return(false); } } else if (!SourceCell.Equals(obj.SourceCell)) { return(false); } if (SynapseIndex != obj.SynapseIndex) { return(false); } if (Permanence != obj.Permanence) { return(false); } if (IsDestroyed != obj.IsDestroyed) { return(false); } if (BoxedIndex == null) { if (obj.BoxedIndex != null) { return(false); } } return(true); }
public override int GetHashCode() { int prime = 31; int result = 1; result = prime * result + InputIndex; result = prime * result + ((Segment == null) ? 0 : Segment.GetHashCode()); result = prime * result + ((SourceCell == null) ? 0 : SourceCell.GetHashCode()); result = prime * result + SynapseIndex; return(result); }
/** * {@inheritDoc} */ public override String ToString() { string srcCell = String.Empty; if (SourceCell != null) { srcCell = $"[SrcCell: {SourceCell.ToString()}]"; } return($"Syn: synIndx:{SynapseIndex}, inpIndx:{InputIndex}, perm:{this.Permanence}[{Segment}], {srcCell}"); }
/* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ // @Override public bool Equals(Object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (typeof(Synapse) != obj.GetType()) { return(false); } Synapse other = (Synapse)obj; if (InputIndex != other.InputIndex) { return(false); } if (Segment == null) { if (other.Segment != null) { return(false); } } else if (!Segment.Equals(other.Segment)) { return(false); } if (SourceCell == null) { if (other.SourceCell != null) { return(false); } } else if (!SourceCell.Equals(other.SourceCell)) { return(false); } if (SynapseIndex != other.SynapseIndex) { return(false); } if (Permanence != other.Permanence) { return(false); } return(true); }
private void OnSourceCellUpdated(SourceCell sourceCell) { Transform sourceTrans = transform.Find(string.Format("{0}", sourceCell.Key)); if (sourceTrans != null) { SourceController sourceCtr = sourceTrans.GetComponent <SourceController>(); if (sourceCtr != null) { sourceCtr.UpdateSource(sourceCell); } } }
public bool Equals(Synapse obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (InputIndex != obj.InputIndex) { return(false); } // // Synapses are equal if they belong to the same segment. if (Segment == null && obj.Segment != null) { return(false); } else if (!Segment.Equals(obj.Segment)) { return(false); } if (SourceCell == null) { if (obj.SourceCell != null) { return(false); } } else if (!SourceCell.Equals(obj.SourceCell)) { return(false); } if (SynapseIndex != obj.SynapseIndex) { return(false); } if (Permanence != obj.Permanence) { return(false); } return(true); }
public void UpdateSource(SourceCell sourceCell) { Key = sourceCell.Key; Source = sourceCell.Source; if (Source != null) { TargetSprite.color = ShanghaiConfig.Instance.MinistryColours[Source.TargetID]; BountyLabel.text = string.Format("{0}", Source.Bounty); } else { TargetSprite.color = Color.white; BountyLabel.text = ""; } }
/// <summary> /// set piece back to source cell and clear destination cell /// draw an killed piece back /// if king was made during last move make it normal /// </summary> /// <param name="game"></param> /// <returns></returns> public bool Undo(Game game) { SourceCell.SetPiece(Piece); DestinationCell.SetPiece(null); game.UndoMovements.Push(this); if (KilledPiece != null) { game.board.content[KilledPiece.Y, KilledPiece.X].SetPiece(KilledPiece); game.board.content[KilledPiece.Y, KilledPiece.X].UnSelect(); } if (isKing) { Piece.MakeNormal(); } return(true); }
public void Test_AntennaPortsConfigureTransform() { Mapper.Initialize(cfg => { var coreMap = cfg.CreateMap(typeof (SourceCell), typeof (Cell)); coreMap.ForMember("AntennaPorts", map => map.ResolveUsing(typeof (AntennaPortsConfigureTransform)).FromMember("TransmitReceive")); }); var source = new SourceCell { TransmitReceive = "2T2R" }; var dest = source.MapTo<Cell>(); Assert.AreEqual(dest.AntennaPorts, AntennaPortsConfigure.Antenna2T2R); }