public RobotLocator(InternalMap map, RTSWorld world) { this.world = world; this.map = map; currentDirection = map.RobotId == TwoPlayersId.Left ? Direction.Right : Direction.Left; realRobotAngle = currentDirection.ToAngle(); expectedRobotAngle = realRobotAngle; }
public override void Update(World rawWorld) { RTSWorld world = rawWorld as RTSWorld; if (!this.m_HasSpawned) { // Set to neutral by default. Team teamInstance = world.Teams.DefaultIfEmpty(null).First(v => (v.SynchronisationData.PlayerID == this.m_PlayerID)); if (teamInstance == null) { throw new ProtogameException("Unable to find team instance with player ID '" + this.m_PlayerID + "'."); } // Find unit factory. foreach (Type t in AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes())) { if (typeof(IUnitFactory).IsAssignableFrom(t) && !t.IsInterface) { IUnitFactory factory = t.GetConstructor(Type.EmptyTypes).Invoke(null) as IUnitFactory; if (factory.CanCreate(this.m_UnitName)) { this.m_Unit = factory.Create(world, this.Level, teamInstance, this.m_UnitName, this.m_Attributes); this.m_Unit.X = this.X; this.m_Unit.Y = this.Y; this.Level.Entities.Add(this.m_Unit); this.m_HasSpawned = true; if (this.m_SynchronisationName != null) { this.m_Unit.SetSynchronisationName(this.m_SynchronisationName); this.m_Unit.ForceSynchronisation(); } return; } } } throw new ProtogameException("Unable to find unit factory that handles unit name '" + this.m_UnitName + "'."); } base.Update(world); }