Inheritance: MonoBehaviour
Beispiel #1
0
    private static SpawnPoint parseSpawnPoint(XMLNode node)
    {
        SpawnPoint result;

        result = new SpawnPoint((float.Parse(node.attributes["x"]) + 8f), -(float.Parse(node.attributes["y"]) - 8f));
        return result;
    }
Beispiel #2
0
 public void SetUp(SpawnPoint _goal,BoxType _type)
 {
     m_Goal=_goal;
     m_Type=_type;
     transform.position=_goal.transform.position;
     //TODO: update sprite
 }
Beispiel #3
0
		protected internal override void SetupNPC(NPCEntry entry, SpawnPoint spawnPoint)
		{
			base.SetupNPC(entry, spawnPoint);

			NPCFlags = NPCFlags.SpellClick;
			SetupSeats();
		}
 static void RenderSpawnGizmo(SpawnPoint spawnPoint, GizmoType gizmoType)
 {
     // Draw the icon
     string iconName = spawnPoint.gizmoIcon;
     if (string.IsNullOrEmpty(iconName)) { iconName = "EnemySpawn"; }
     Gizmos.DrawIcon (spawnPoint.transform.position, iconName, true);
 }
    public void Parse(Level Level, List list)
    {
        this.Level = Level;

        Properties props = new Properties(list);
        props.Get("name", ref Name);
        props.Get("music", ref Music);
        props.Get("gravity", ref Gravity);

        LispIterator iter = new LispIterator(list);
        while(iter.MoveNext()) {
            switch(iter.Key) {
                case "spawnpoint":
                    SpawnPoint SpawnPoint = new SpawnPoint();
                    SpawnPoint.Parse(iter.List);
                    SpawnPoints.Add(SpawnPoint.Name, SpawnPoint);
                    break;
                default:
                    GameObject Object = ParseObject(iter.Key, iter.List);
                    if(Object != null)
                        AddObject(Object);
                    break;
            }
        }
    }
	public static SpawnPoint getRandomSpawnPoint(SpawnPoint[] points, int teamId = TeamMember.TeamFFA, bool ungaurded = false) 
	{
		// If FFA just give a spot, but check ungaurded if desired
		if (teamId == TeamMember.TeamFFA) { 
			if (ungaurded) {
				SpawnPoint openPoint = getUngaurdedSpawn (points,teamId);
				if (openPoint)
					return openPoint;
			}
			return points [Random.Range (0, points.Length)];
		}

		// Get friendly points
		SpawnPoint[] allowedPoints = getTeamSpawnPoints (points, teamId);
		if (allowedPoints.Length == 0)
			return null;

		// check if ungaured is required
		if (ungaurded) {
			SpawnPoint openPoint = getUngaurdedSpawn (allowedPoints, teamId);
			if (openPoint)
				return openPoint;
		}
		
		return allowedPoints [Random.Range (0, allowedPoints.Length)];
	}
 //Recycle the Spawn point, make sure to send the box reference to a player before recycle the spawnpoint, otherwise you will lose the box reference
 public void RecycleSpawnPoint(SpawnPoint _spawnPoint)
 {
     _spawnPoint.m_Type=SpawnPoint.PointType.None;
     _spawnPoint.m_BoxRef=null;
     m_Spawners.Add(_spawnPoint);
     m_BusySpawners.Remove(_spawnPoint);
 }
	public void Init( MortarSettings settings, Vector3 startPos, SpawnPoint endPos, SpiderTank spiderTank )
	{
		_spiderTank = spiderTank;
		_spawn = endPos;
		_spawn.available = false;

		base.Init( settings, startPos );
	}
Beispiel #9
0
		public SpawnFigurine(SpawnPoint spawnPoint)
			: base(spawnPoint.SpawnEntry.Entry)
		{
			m_SpawnPoint = spawnPoint;
			m_position = spawnPoint.SpawnEntry.Position;

			GossipMenu = m_SpawnPoint.GossipMenu;
			NPCFlags = NPCFlags.Gossip;
		}
Beispiel #10
0
		public WaypointFigurine(SpawnPoint spawnPoint, WaypointEntry wp)
			: base(spawnPoint.SpawnEntry.Entry)
		{	
			m_SpawnPoint = spawnPoint;
			m_Waypoint = wp;
			m_position = wp.Position;

			GossipMenu = m_SpawnPoint.GossipMenu;
			NPCFlags = NPCFlags.Gossip;
		}
Beispiel #11
0
	public static SpawnPoint[] getTeamSpawnPoints(SpawnPoint[] allPoints, int teamId)
	{
		// If not then we need to find points with our team
		System.Collections.Generic.List<SpawnPoint> allowedPoints = new System.Collections.Generic.List<SpawnPoint>();
		for (int i = 0; i < allPoints.Length; i++) {
			if (allPoints[i].teamId == teamId)
				allowedPoints.Add(allPoints[i]);
		}
		return allowedPoints.ToArray ();
	}
Beispiel #12
0
	//TODO ungaurded currently checks for any one, even those on the same team. This should only get enemies
	public static SpawnPoint getUngaurdedSpawn(SpawnPoint[] points, int teamId = TeamMember.TeamFFA)
	{
		// Look for ungaurded points
		for (int i = 0; i < points.Length; i++) {
			if ((teamId == TeamMember.TeamFFA || points[i].teamId == teamId) // If on our team, or team FFA
				&& Physics2D.OverlapCircleAll (points [i].transform.position, points [i].collider.radius).Length > 0) { // and nobody is close by
				return points [i];
			}
		}
		return null;
	}
    void Awake()
    {
        //this sets all of the variables that need to be set at the beginning of the game

                //this finds the point (transform) that you need to fire bullets from
                bulletSpawn = transform.FindChild ("firePoint");
                sp = SpawnPoint.FindObjectOfType<SpawnPoint> ();
                //this loads in a prefab from the "Resources/<filepath>" directory in the assets folder
                bulletPrefab = Resources.Load<GameObject> ("Prefabs/bullet");
                //this gets the SpriteRenderer Component that is required to swap out sprites
                sprRend = GetComponent<SpriteRenderer> ();
    }
 public static Vector3 GetSpawnPosition(SpawnPoint spawnPoint, bool addOffset = false, float yOffset = -0.010f)
 {
     if (All.ContainsKey(spawnPoint)) {
         Vector3 position = All[spawnPoint].getPositon();
         if (addOffset) {
             position.y += yOffset;
         }
         return position;
     } else {
         return Global.ZERO_VECTOR;
     }
 }
Beispiel #15
0
 private void LookForSpawnPoint()
 {
     foreach (SpawnPoint spawnPoint in FindObjectsOfType<SpawnPoint>())
     {
         if (spawnPoint.position == playerInfo.position)
         {
             this.spawnPoint = spawnPoint;
             spawnPoint.Assign();
             break;
         }
     }
 }
Beispiel #16
0
		protected internal override void SetupNPC(NPCEntry entry, SpawnPoint spawnPoint)
		{
			base.SetupNPC(entry, spawnPoint);

			NPCFlags = NPCFlags.SpellClick;
			SetupSeats();

			AddMessage(() =>
			{
				// Set Level/Scale ingame:
				var level = entry.GetRandomLevel();
				Level = level;
			});
		}
    public bool RemoveTarget(SpawnPoint sp)
    {
        for(int i = 0; i < m_maxRotators; i++)
        {
            if(m_Rotators[i].SpawnPointReference != sp) continue;

            m_Rotators[i].RemoveTarget();

            m_availableRotators++;

            return true;
        }

        return false;
    }
    public GameObject SpawnNPC(SpawnPoint spawnPoint,
	                      Emotion emotion,
	                      string phrase,
	                      NPCController.CollidedWithPlayerAction collidedListener)
    {
        GameObject npcObject = spawnNPC(spawnPoint);
        NPCController npc = npcObject.GetComponent<NPCController>();
        npc.Emotion = emotion;
        if (emotion == Emotion.Mad) {
            npc.SetConflictPhrase(phrase);
        } else {
            npc.Phrase = phrase;
        }
        npc.OnCollidedWithPlayer += collidedListener;
        return npcObject;
    }
    public bool AssignTarget(Transform t, SpawnPoint sp)
    {
        if(m_availableRotators < 1) return false;

        for(int i = 0; i < m_maxRotators; i++)
        {
            if(m_Rotators[i].HasTarget) continue;

            m_Rotators[i].AssignTarget(t, sp);

            m_availableRotators--;
            return true;
        }

        return false;
    }
    /// <summary>
    /// Initialises a new sector with some default values.
    /// </summary>
    /// <param name="Name">Name of new sector.</param>
    /// <returns>The created sector.</returns>
    public static Sector CreateSector(string Name)
    {
        Sector sector = new Sector();
        sector.Name = Name;

        Tilemap tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.ZPos = -100;
        tilemap.Name = "Background";
        sector.Add(tilemap);

        tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.ZPos = 0;
        tilemap.Solid = true;
        tilemap.Name = "Interactive";
        sector.Add(tilemap);

        tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.ZPos = 100;
        tilemap.Name = "Foreground";
        sector.Add(tilemap);

        SpawnPoint spawnpoint = new SpawnPoint();
        spawnpoint.X = 96;
        spawnpoint.Y = 96;
        spawnpoint.Name = "main";
        sector.Add(spawnpoint);

        Camera camera = new Camera();
        sector.Add(camera);

        Background background = new Background();
        background.Image = "images/background/BlueRock_Forest/blue-middle.jpg";
        background.ImageTop = "images/background/BlueRock_Forest/blue-top.jpg";
        background.ImageBottom = "images/background/BlueRock_Forest/blue-bottom.jpg";
        sector.Add(background);

        return sector;
    }
Beispiel #21
0
        public Goblin(GameScreen screen, SpawnPoint spawn)
            : base(screen, COLLISION_WIDTH, COLLISION_HEIGHT)
        {
            MaxSpeed = PATROL_SPEED;
            MaxAirSpeed = 9;
            JumpHeight = 50;
            LongJumpBonus = 15;
            MovementAccel = 10;
            AirAccel = 2;

            //set scale
            Scale = 1.0f;

            Zindex = 0.4f;

            loadSprite("Animations/goblin_placeholder");

            Position = UnitConverter.ToSimUnits(spawn.Position);
            Post = Position;

            if (spawn.Properties.ContainsKey("PatrolRadius"))
                PatrolRadius = float.Parse(spawn.Properties["PatrolRadius"]);

            if (spawn.Properties.ContainsKey("MaxRange"))
                MaxRange = float.Parse(spawn.Properties["MaxRange"]);

            if (spawn.Properties.ContainsKey("waitTimeBetweenPatrols"))
                MaxRange = float.Parse(spawn.Properties["waitTimeBetweenPatrols"]);

            if (spawn.Properties.ContainsKey("PostX") && spawn.Properties.ContainsKey("PostY"))
            {
                Post = new Vector2(float.Parse(spawn.Properties["PostX"]),
                    float.Parse(spawn.Properties["PostY"]));
            }

            state = EnemyState.PATROLING;
        }
Beispiel #22
0
    /// <summary>
    /// Initializes a new sector with some default values.
    /// </summary>
    /// <param name="Name">Name of new sector.</param>
    /// <returns>The created <see cref="Sector"/> object.</returns>
    public static Sector CreateSector(string Name)
    {
        Sector sector = new Sector();
        sector.Name = Name;

        Tilemap tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.Layer = -100;
        tilemap.Name = "Background";
        sector.Add(tilemap, true);

        tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.Layer = 0;
        tilemap.Solid = true;
        tilemap.Name = "Interactive";
        sector.Add(tilemap, true);

        tilemap = new Tilemap();
        tilemap.Resize(100, 35, 0);
        tilemap.Layer = 100;
        tilemap.Name = "Foreground";
        sector.Add(tilemap, true);

        SpawnPoint spawnpoint = new SpawnPoint();
        spawnpoint.X = 96;
        spawnpoint.Y = 96;
        spawnpoint.Name = "main";
        sector.Add(spawnpoint, true);

        Camera camera = new Camera();
        sector.Add(camera, true);

        sector.FinishRead(); //let sector detect it's dimensions

        return sector;
    }
 void setNPCReferences(NPCController npc, SpawnPoint spawnPoint)
 {
     npc.SetSpawnPoint(spawnPoint);
     subscribeToNPCEvents(npc);
 }
Beispiel #24
0
    private void Awake()
    {
        SpawnPoint spawn = FindObjectOfType <SpawnPoint>();

        spawnPoint = spawn.transform;
    }
Beispiel #25
0
    public bool SetConnections()
    {
        Collider2D [] cols = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), 1.0f);
        RoadPiece     rp   = null;

        foreach (Collider2D cd in cols)
        {
            RoadPiece trp = cd.GetComponent <RoadPiece> ();
            if (trp != null)
            {
                rp = trp;
            }
        }

        if (rp == null)
        {
            return(true);
        }

        WaypointOrientation oppositeOrientation = WaypointOrientation.Bottom;

        switch (m_orientation)
        {
        case WaypointOrientation.Bottom:
            oppositeOrientation = WaypointOrientation.Top;
            break;

        case WaypointOrientation.Left:
            oppositeOrientation = WaypointOrientation.Right;
            break;

        case WaypointOrientation.Right:
            oppositeOrientation = WaypointOrientation.Left;
            break;

        case WaypointOrientation.Top:
            oppositeOrientation = WaypointOrientation.Bottom;
            break;
        }

        //TODO: fix this to accomodate placing pieces with multiple connections

        SpawnPoint sp = rp.GetSpawnPoint(oppositeOrientation);

        if (sp == null)
        {
            return(false);
        }
        if (sp.IsLinked())
        {
            return(true);
        }
        Waypoint[] targetInput;
        targetInput = sp.getInput();
        Waypoint[] targetOutput;
        targetOutput = sp.getOutput();


        foreach (Waypoint wp in m_output)
        {
            wp.SetNext(targetInput);
        }

        foreach (Waypoint wp in targetOutput)
        {
            wp.SetNext(m_input);
        }
        Link(sp);
        sp.Link(this);

        return(true);
    }
Beispiel #26
0
        public void TestLoadOarRegionSettings()
        {
            TestHelpers.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            MemoryStream     archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            RegionSettings rs = new RegionSettings();

            rs.AgentLimit          = 17;
            rs.AllowDamage         = true;
            rs.AllowLandJoinDivide = true;
            rs.AllowLandResell     = true;
            rs.BlockFly            = true;
            rs.BlockShowInSearch   = true;
            rs.BlockTerraform      = true;
            rs.DisableCollisions   = true;
            rs.DisablePhysics      = true;
            rs.DisableScripts      = true;
            rs.Elevation1NW        = 15.9;
            rs.Elevation1NE        = 45.3;
            rs.Elevation1SE        = 49;
            rs.Elevation1SW        = 1.9;
            rs.Elevation2NW        = 4.5;
            rs.Elevation2NE        = 19.2;
            rs.Elevation2SE        = 9.2;
            rs.Elevation2SW        = 2.1;
            rs.FixedSun            = true;
            rs.SunPosition         = 12.0;
            rs.ObjectBonus         = 1.4;
            rs.RestrictPushing     = true;
            rs.TerrainLowerLimit   = 0.4;
            rs.TerrainRaiseLimit   = 17.9;
            rs.TerrainTexture1     = UUID.Parse("00000000-0000-0000-0000-000000000020");
            rs.TerrainTexture2     = UUID.Parse("00000000-0000-0000-0000-000000000040");
            rs.TerrainTexture3     = UUID.Parse("00000000-0000-0000-0000-000000000060");
            rs.TerrainTexture4     = UUID.Parse("00000000-0000-0000-0000-000000000080");
            rs.UseEstateSun        = true;
            rs.WaterHeight         = 23;
            rs.TelehubObject       = UUID.Parse("00000000-0000-0000-0000-111111111111");
            rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33"));

            tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs));

            tar.Close();

            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            lock (this)
            {
                m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
                m_archiverModule.DearchiveRegion(archiveReadStream);
            }

            Assert.That(m_lastErrorMessage, Is.Null);
            RegionSettings loadedRs = m_scene.RegionInfo.RegionSettings;

            Assert.That(loadedRs.AgentLimit, Is.EqualTo(17));
            Assert.That(loadedRs.AllowDamage, Is.True);
            Assert.That(loadedRs.AllowLandJoinDivide, Is.True);
            Assert.That(loadedRs.AllowLandResell, Is.True);
            Assert.That(loadedRs.BlockFly, Is.True);
            Assert.That(loadedRs.BlockShowInSearch, Is.True);
            Assert.That(loadedRs.BlockTerraform, Is.True);
            Assert.That(loadedRs.DisableCollisions, Is.True);
            Assert.That(loadedRs.DisablePhysics, Is.True);
            Assert.That(loadedRs.DisableScripts, Is.True);
            Assert.That(loadedRs.Elevation1NW, Is.EqualTo(15.9));
            Assert.That(loadedRs.Elevation1NE, Is.EqualTo(45.3));
            Assert.That(loadedRs.Elevation1SE, Is.EqualTo(49));
            Assert.That(loadedRs.Elevation1SW, Is.EqualTo(1.9));
            Assert.That(loadedRs.Elevation2NW, Is.EqualTo(4.5));
            Assert.That(loadedRs.Elevation2NE, Is.EqualTo(19.2));
            Assert.That(loadedRs.Elevation2SE, Is.EqualTo(9.2));
            Assert.That(loadedRs.Elevation2SW, Is.EqualTo(2.1));
            Assert.That(loadedRs.FixedSun, Is.True);
            Assert.AreEqual(12.0, loadedRs.SunPosition);
            Assert.That(loadedRs.ObjectBonus, Is.EqualTo(1.4));
            Assert.That(loadedRs.RestrictPushing, Is.True);
            Assert.That(loadedRs.TerrainLowerLimit, Is.EqualTo(0.4));
            Assert.That(loadedRs.TerrainRaiseLimit, Is.EqualTo(17.9));
            Assert.That(loadedRs.TerrainTexture1, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000020")));
            Assert.That(loadedRs.TerrainTexture2, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000040")));
            Assert.That(loadedRs.TerrainTexture3, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000060")));
            Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080")));
            Assert.That(loadedRs.UseEstateSun, Is.True);
            Assert.That(loadedRs.WaterHeight, Is.EqualTo(23));
            Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID
            Assert.AreEqual(0, loadedRs.SpawnPoints().Count);
        }
Beispiel #27
0
    /// <summary>
    /// Spawns a ghost for the indicated mind's body and transfers the connection's control to it.
    /// </summary>
    /// <param name="conn"></param>
    /// <param name="oldBody"></param>
    /// <param name="characterSettings"></param>
    /// <param name="occupation"></param>
    /// <returns></returns>
    public static void ServerSpawnGhost(Mind forMind)
    {
        if (forMind == null)
        {
            Logger.LogError("Mind was null for ServerSpawnGhost", Category.Ghosts);
            return;
        }
        //determine where to spawn the ghost
        var body = forMind.GetCurrentMob();

        if (body == null)
        {
            Logger.LogError("Body was null for ServerSpawnGhost", Category.Ghosts);
            return;
        }

        var settings     = body.GetComponent <PlayerScript>().characterSettings;
        var connection   = body.GetComponent <NetworkIdentity>().connectionToClient;
        var registerTile = body.GetComponent <RegisterTile>();

        if (registerTile == null)
        {
            Logger.LogErrorFormat("Cannot spawn ghost for body {0} because it has no registerTile", Category.Ghosts,
                                  body.name);
            return;
        }

        Vector3Int spawnPosition = TransformState.HiddenPos;
        var        objBeh        = body.GetComponent <ObjectBehaviour>();

        if (objBeh != null)
        {
            spawnPosition = objBeh.AssumedWorldPositionServer();
        }

        if (spawnPosition == TransformState.HiddenPos)
        {
            //spawn ghost at occupation location if we can't determine where their body is
            Transform spawnTransform = SpawnPoint.GetRandomPointForJob(forMind.occupation.JobType, true);
            if (spawnTransform == null)
            {
                Logger.LogErrorFormat("Unable to determine spawn position for occupation {1}. Cannot spawn ghost.", Category.Ghosts,
                                      forMind.occupation.DisplayName);
                return;
            }

            spawnPosition = spawnTransform.transform.position.CutToInt();
        }

        var matrixInfo      = MatrixManager.AtPoint(spawnPosition, true);
        var parentNetId     = matrixInfo.NetID;
        var parentTransform = matrixInfo.Objects;

        //using parentTransform.rotation rather than Quaternion.identity because objects should always
        //be upright w.r.t.  localRotation, NOT world rotation
        var ghost = UnityEngine.Object.Instantiate(CustomNetworkManager.Instance.ghostPrefab, spawnPosition, parentTransform.rotation,
                                                   parentTransform);

        ghost.GetComponent <PlayerScript>().registerTile.ServerSetNetworkedMatrixNetID(parentNetId);

        forMind.Ghosting(ghost);

        ServerTransferPlayer(connection, ghost, body, Event.GhostSpawned, settings);


        //fire all hooks
        var info = SpawnInfo.Ghost(forMind.occupation, settings, CustomNetworkManager.Instance.ghostPrefab,
                                   SpawnDestination.At(spawnPosition, parentTransform));

        Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, ghost));

        if (PlayerList.Instance.IsAdmin(forMind.ghost.connectedPlayer))
        {
            var adminItemStorage = AdminManager.Instance.GetItemSlotStorage(forMind.ghost.connectedPlayer);
            adminItemStorage.ServerAddObserverPlayer(ghost);
            ghost.GetComponent <GhostSprites>().SetAdminGhost();
        }
    }
Beispiel #28
0
    protected override void OnDeathActions()
    {
        if (CustomNetworkManager.Instance._isServer)
        {
            PlayerNetworkActions pna = gameObject.GetComponent <PlayerNetworkActions>();
            PlayerMove           pm  = gameObject.GetComponent <PlayerMove>();

            ConnectedPlayer player = PlayerList.Instance.Get(gameObject);

            string killerName = "Stressful work";
            if (LastDamagedBy != null)
            {
                killerName = PlayerList.Instance.Get(LastDamagedBy).Name;
            }

            if (killerName == player.Name)
            {
                PostToChatMessage.Send(player.Name + " commited suicide", ChatChannel.System);                 //Killfeed
            }
            else if (killerName.EndsWith(player.Name))
            {
                // chain reactions
                PostToChatMessage.Send(
                    player.Name + " screwed himself up with some help (" + killerName + ")",
                    ChatChannel.System);                     //Killfeed
            }
            else
            {
                PlayerList.Instance.UpdateKillScore(LastDamagedBy, gameObject);

                //string departmentKillText = "";
                if (LastDamagedBy != null)
                {
                    JobDepartment killerDepartment =
                        SpawnPoint.GetJobDepartment(LastDamagedBy.GetComponent <PlayerScript>().JobType);
                    JobDepartment victimDepartment =
                        SpawnPoint.GetJobDepartment(gameObject.GetComponent <PlayerScript>().JobType);

                    //departmentKillText = "";
                    //if (killerDepartment == victimDepartment)
                    //{
                    //	departmentKillText = ", losing " + killerDepartment.GetDescription() +
                    //	                     " 1 point for team killing!";
                    //}
                    //else
                    //{
                    //	departmentKillText = ", 1 point to " + killerDepartment.GetDescription() + "!";
                    //}
                }

                //TDM demo killfeed
                //PostToChatMessage.Send(killerName + " has killed " + player.Name + departmentKillText,
                //ChatChannel.System);

                //Combat demo killfeed - Also can be used in nuke ops
                //PostToChatMessage.Send(killerName + " has killed " + gameObject.name, ChatChannel.System);
            }
            pna.DropItem("rightHand");
            pna.DropItem("leftHand");

            if (isServer)
            {
                EffectsFactory.Instance.BloodSplat(transform.position, BloodSplatSize.large);
            }

            pna.RpcSpawnGhost();
            pm.isGhost    = true;
            pm.allowInput = true;
            RpcPassBullets(gameObject);
            PlayerDeathMessage.Send(gameObject);

            //FIXME Remove for next demo
            pna.RespawnPlayer(10);
        }
    }
Beispiel #29
0
 void Awake()
 {
     instance = this;
 }
Beispiel #30
0
 public void AddWall(SpawnPoint s)
 {
     Obstacles.Add(s);
 }
 void Start()
 {
     SpawnPoint = GameObject.FindObjectOfType <SpawnPoint>();
     CreatePlayer();
 }
Beispiel #32
0
        static void DrawSpawnPointGizmo(SpawnPoint spawnPoint, GizmoType gizmoType)
        {
            var transform = spawnPoint.transform;

            Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale);

            Gizmos.color = spawnPoint.GizmoColor;
            var position = Vector3.zero;

            if (spawnPoint.Shape == SpawnPoint.SpawnShape.Point || spawnPoint.Shape == SpawnPoint.SpawnShape.Sphere)
            {
                var size = spawnPoint.Shape == SpawnPoint.SpawnShape.Sphere ? spawnPoint.Size : 0.2f;
                Gizmos.DrawSphere(position, size);

                // Draw the outline when the component is selected.
                if (MathUtility.InLayerMask((int)GizmoType.Selected, (int)gizmoType))
                {
                    Gizmos.color = InspectorUtility.GetContrastColor(spawnPoint.GizmoColor);
                    Gizmos.DrawWireSphere(position, size);
                }
            }
            else if (spawnPoint.Shape == SpawnPoint.SpawnShape.Box)
            {
                var size = Vector3.zero;
                size.x    = size.z = spawnPoint.Size;
                size.y    = spawnPoint.GroundSnapHeight;
                position += spawnPoint.transform.up * size.y / 2;
                Gizmos.DrawCube(position, size);

                // Draw the outline when the component is selected.
                if (MathUtility.InLayerMask((int)GizmoType.Selected, (int)gizmoType))
                {
                    Gizmos.color = InspectorUtility.GetContrastColor(spawnPoint.GizmoColor);
                    Gizmos.DrawWireCube(position, size);
                }
            }

            if (MathUtility.InLayerMask((int)GizmoType.Selected, (int)gizmoType))
            {
                // The Gizmo class cannot draw a wire disk.
                Handles.color = InspectorUtility.GetContrastColor(spawnPoint.GizmoColor);
                Handles.DrawWireDisc(spawnPoint.transform.position, spawnPoint.transform.up, 1);

                // Draw directional arrows when selected.
                var rad = spawnPoint.Size > 0 ? spawnPoint.Size : 1;
                if (spawnPoint.RandomDirection)
                {
                    // Draw four big arrows, relative to the spawnpoint and perpendicular to each other.
                    Gizmos.DrawLine((Vector3.back * 2) * rad, (Vector3.forward * 2) * rad);
                    Gizmos.DrawLine((Vector3.left * 2) * rad, (Vector3.right * 2) * rad);
                    Gizmos.DrawLine((Vector3.forward * 2) * rad, (Vector3.forward * 1.5f * rad) + (Vector3.left * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.forward * 2) * rad, (Vector3.forward * 1.5f * rad) + (Vector3.right * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.back * 2) * rad, (Vector3.back * 1.5f * rad) + (Vector3.left * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.back * 2) * rad, (Vector3.back * 1.5f * rad) + (Vector3.right * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.left * 2) * rad, (Vector3.left * 1.5f * rad) + (Vector3.forward * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.left * 2) * rad, (Vector3.left * 1.5f * rad) + (Vector3.back * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.right * 2) * rad, (Vector3.right * 1.5f * rad) + (Vector3.forward * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.right * 2) * rad, (Vector3.right * 1.5f * rad) + (Vector3.back * 0.5f) * rad);
                }
                else
                {
                    // Draw a single big arrow pointing in the spawnpoint's forward direction.
                    Gizmos.DrawLine(Vector3.zero, (Vector3.forward * 2) * rad);
                    Gizmos.DrawLine((Vector3.forward * 2) * rad, (Vector3.forward * 1.5f * rad) + (Vector3.left * 0.5f) * rad);
                    Gizmos.DrawLine((Vector3.forward * 2) * rad, (Vector3.forward * 1.5f * rad) + (Vector3.right * 0.5f) * rad);
                }
            }
        }
Beispiel #33
0
 public void Link(SpawnPoint target)
 {
     m_linked = target;
     m_tunnelSpriteRenderer.enabled = false;
 }
Beispiel #34
0
    public List <GameObject> AvailablePieceThatFits()
    {
        Collider2D [] cols = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), 1.0f);
        // if there's an intersection of a piece that fits, return that piece
        SpawnPoint[] spawnPoints = new SpawnPoint[cols.Length];

        List <GameObject> workingPieces;

        int index = 0;

        foreach (Collider2D c in cols)
        {
            SpawnPoint sp = c.GetComponent <SpawnPoint> ();
            if (sp == null)
            {
                return(null);
            }
            spawnPoints [index] = sp;
            index++;
        }

        List <GameObject> AvailablePieces = new List <GameObject>();

        foreach (GameObject go in GetViableRoadPieces())
        {
            AvailablePieces.Add(go);
        }

        foreach (SpawnPoint sp in spawnPoints)
        {
            GameObject[] viablePieces = sp.GetViableRoadPieces();

            List <GameObject> toRemove = new List <GameObject> ();

            foreach (GameObject go in AvailablePieces)
            {
                bool contained = false;

                foreach (GameObject vp in viablePieces)
                {
                    if (vp == go)
                    {
                        contained = true;
                    }
                }

                if (contained == false)
                {
                    toRemove.Add(go);
                }
            }

            foreach (GameObject go in toRemove)
            {
                AvailablePieces.Remove(go);
            }
        }

        if (AvailablePieces.Count == 0)
        {
            return(null);
        }
        else
        {
            return(AvailablePieces);
        }
    }
Beispiel #35
0
 public void Unlink()
 {
     m_linked = null;
     m_tunnelSpriteRenderer.enabled = true;
 }
    GameObject spawnNPC(SpawnPoint spawnPoint)
    {
        GameObject npc = (GameObject) Instantiate (
            NPCPrefab,
            SpawnPointController.GetSpawnPosition(spawnPoint, true),
            Quaternion.identity);

        setNPCReferences(
            npc.GetComponent<NPCController>(),
            spawnPoint);

        return npc;
    }
Beispiel #37
0
 public override string GetText(GossipConversation convo)
 {
     return(SpawnPoint.ToString());
 }
Beispiel #38
0
 public abstract GameObject SpawnInWorld(SpawnPoint spawnPoint);
Beispiel #39
0
    /// <summary>
    /// Spawns a new player character and transfers the connection's control into the new body.
    /// If existingMind is null, creates the new mind and assigns it to the new body.
    ///
    /// Fires server and client side player spawn hooks.
    /// </summary>
    /// <param name="connection">connection to give control to the new player character</param>
    /// <param name="occupation">occupation of the new player character</param>
    /// <param name="characterSettings">settings of the new player character</param>
    /// <param name="existingMind">existing mind to transfer to the new player, if null new mind will be created
    /// and assigned to the new player character</param>
    /// <param name="spawnPos">world position to spawn at</param>
    /// <param name="spawnItems">If spawning a player, should the player spawn without the defined initial equipment for their occupation?</param>
    /// <param name="willDestroyOldBody">if true, indicates the old body is going to be destroyed rather than pooled,
    /// thus we shouldn't send any network message which reference's the old body's ID since it won't exist.</param>
    ///
    /// <returns>the spawned object</returns>
    private static GameObject ServerSpawnInternal(NetworkConnection connection, Occupation occupation, CharacterSettings characterSettings,
                                                  Mind existingMind, Vector3Int?spawnPos = null, bool spawnItems = true, bool willDestroyOldBody = false, bool showBanner = true)
    {
        //determine where to spawn them
        if (spawnPos == null)
        {
            Transform spawnTransform;
            //Spawn normal location for special jobs or if less than 2 minutes passed
            if (GameManager.Instance.stationTime < ARRIVALS_SPAWN_TIME || occupation.LateSpawnIsArrivals == false)
            {
                spawnTransform = SpawnPoint.GetRandomPointForJob(occupation.JobType);
            }
            else
            {
                spawnTransform = SpawnPoint.GetRandomPointForLateSpawn();
                //Fallback to assistant spawn location if none found for late join
                if (spawnTransform == null && occupation.JobType != JobType.NULL)
                {
                    spawnTransform = SpawnPoint.GetRandomPointForJob(JobType.ASSISTANT);
                }
            }

            if (spawnTransform == null)
            {
                Logger.LogErrorFormat(
                    "Unable to determine spawn position for connection {0} occupation {1}. Cannot spawn player.",
                    Category.EntitySpawn,
                    connection.address, occupation.DisplayName);
                return(null);
            }

            spawnPos = spawnTransform.transform.position.CutToInt();
        }

        //create the player object
        var newPlayer       = ServerCreatePlayer(spawnPos.GetValueOrDefault(), occupation.SpecialPlayerPrefab);
        var newPlayerScript = newPlayer.GetComponent <PlayerScript>();

        //get the old body if they have one.
        var oldBody = existingMind?.GetCurrentMob();

        //transfer control to the player object
        ServerTransferPlayer(connection, newPlayer, oldBody, Event.PlayerSpawned, characterSettings, willDestroyOldBody);

        if (existingMind == null)
        {
            //create the mind of the player
            Mind.Create(newPlayer, occupation);
        }
        else
        {
            //transfer the mind to the new body
            existingMind.SetNewBody(newPlayerScript);
        }


        var ps = newPlayer.GetComponent <PlayerScript>();
        var connectedPlayer = PlayerList.Instance.Get(connection);

        connectedPlayer.Name = ps.playerName;
        connectedPlayer.Job  = ps.mind.occupation.JobType;
        UpdateConnectedPlayersMessage.Send();

        //fire all hooks
        var info = SpawnInfo.Player(occupation, characterSettings, CustomNetworkManager.Instance.humanPlayerPrefab,
                                    SpawnDestination.At(spawnPos), spawnItems: spawnItems);

        Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, newPlayer));

        if (occupation != null && showBanner)
        {
            SpawnBannerMessage.Send(
                newPlayer,
                occupation.DisplayName,
                occupation.SpawnSound.AssetAddress,
                occupation.TextColor,
                occupation.BackgroundColor,
                occupation.PlaySound);
        }

        newPlayer.GetComponent <DynamicItemStorage>()?.SetUpOccupation(occupation);

        return(newPlayer);
    }
    public void Respawn()
    {
        var foundSpawn = SpawnPoint.GetSpawnPoint("SpawnPointDefault");

        Respawn(foundSpawn);
    }
Beispiel #41
0
    GameObject readXmlNode(XmlNode xmlNode, GameObject parent, string fileName)
    {
        GameObject go = new GameObject(xmlNode.Name);

        if (parent != null)
        {
            go.transform.parent = parent.transform;
        }

        if (xmlNode.NodeType == XmlNodeType.Comment)
        {
            CommentElement comment = go.AddComponent <CommentElement>();
            go.transform.parent = parent.transform;

            comment.comment = xmlNode.InnerText;
        }
        else if (xmlNode.Name == "vehicle")
        {
            Vehicle tag = go.AddComponent <Vehicle>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.sound        = readString(xmlNode, "sound");
            tag.spring       = readFloat(xmlNode, "spring");
            tag.acceleration = readFloat(xmlNode, "acceleration");
            tag.antiroll     = readFloat(xmlNode, "antiroll");
            tag.damping      = readFloat(xmlNode, "damping");
            tag.friction     = readFloat(xmlNode, "friction");
            tag.difflock     = readFloat(xmlNode, "difflock");
            tag.steerassist  = readFloat(xmlNode, "steerassist");
            tag.topspeed     = readFloat(xmlNode, "topspeed");
            tag.driven       = readBool(xmlNode, "driven", false);
            tag.antispin     = readFloat(xmlNode, "antispin");
            tag.soundVolume  = readFloat(xmlNode, "soundvolume");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "wheel")
        {
            Wheel tag = go.AddComponent <Wheel>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.steer  = readFloat(xmlNode, "steer");
            tag.drive  = readFloat(xmlNode, "drive");
            tag.travel = readVec2(xmlNode, "travel");
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "spawnpoint")
        {
            SpawnPoint tag = go.AddComponent <SpawnPoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "location")
        {
            Location tag = go.AddComponent <Location>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "group")
        {
            Group tag = go.AddComponent <Group>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "rope")
        {
            Rope tag = go.AddComponent <Rope>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.strength = readFloat(xmlNode, "strength");
            tag.slack    = readFloat(xmlNode, "slack");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "screen")
        {
            Screen tag = go.AddComponent <Screen>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.size        = readVec2(xmlNode, "size");
            tag.isEnabled   = readBool(xmlNode, "enabled", false);
            tag.interactive = readBool(xmlNode, "interactive", false);
            tag.emissive    = readFloat(xmlNode, "emissive");
            tag.color       = readColor(xmlNode, "color");
            tag.resolution  = readVec2(xmlNode, "resolution");
            tag.bulge       = readVec2(xmlNode, "bulge");
            tag.script      = readString(xmlNode, "script");
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vox")
        {
            Vox tag = go.AddComponent <Vox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            tag.file      = readString(xmlNode, "file").Replace("LEVEL", getLevelFolder(fileName));;
            tag.voxObject = readString(xmlNode, "object");
            tag.dynamic   = readBool(xmlNode, "prop", false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            tag.Reload();

            if (tag.scale > 0)
            {
                go.transform.localScale *= tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "joint")
        {
            TeardownJoint tag = go.AddComponent <TeardownJoint>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.type        = (TeardownJoint.Type)Enum.Parse(typeof(TeardownJoint.Type), readString(xmlNode, "type", "ball"), false);
            tag.size        = readFloat(xmlNode, "size");
            tag.rotspring   = readFloat(xmlNode, "rotspring");
            tag.rotstrength = readFloat(xmlNode, "rotstrength");
            tag.limits      = readVec2(xmlNode, "limits");

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "voxbox")
        {
            VoxBox tag = go.AddComponent <VoxBox>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.color   = readColor(xmlNode, "color");
            tag.dynamic = readBool(xmlNode, "prop", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;

            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.parent        = go.transform;
            cube.transform.localPosition = new Vector3(0.5f, 0.5f, -0.5f);
            cube.transform.localRotation = Quaternion.identity;
            cube.GetComponent <MeshRenderer>().sharedMaterial = new Material(Shader.Find("Standard"));
            go.transform.localScale = tag.size / 10;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "body")
        {
            Body tag = go.AddComponent <Body>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.dynamic = readBool(xmlNode, "dynamic", false);
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "water")
        {
            go.name = "<" + xmlNode.Name + ">";
            Water tag = go.AddComponent <Water>();
            go.transform.parent = parent.transform;

            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "environment")
        {
            TeardownEnvironment tag = go.AddComponent <TeardownEnvironment>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.skyboxrot     = readFloat(xmlNode, "skyboxrot");
            tag.sunBrightness = readFloat(xmlNode, "sunBrightness");
            tag.sunFogScale   = readFloat(xmlNode, "sunFogScale");
            tag.sunDir        = readVec3(xmlNode, "sunDir");
            tag.sunColorTint  = readColor(xmlNode, "sunColorTint");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "scene")
        {
            Scene tag = go.AddComponent <Scene>();

            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.shadowVolume = readVec3(xmlNode, "shadowVolume");
            tag.version      = readInt(xmlNode, "version");

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "boundary")
        {
            Boundary tag = go.AddComponent <Boundary>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;
            go.name             = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "script")
        {
            Script tag = go.AddComponent <Script>();
            attachGeneralProperties(tag, xmlNode);
            go.transform.parent = parent.transform;

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "instance")
        {
            Instance tag = go.AddComponent <Instance>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);

            tag.file = readString(xmlNode, "file");
            go.name  = "<" + xmlNode.Name + " " + tag.teardownName + " " + tag.file + ">";

            if (!fileName.Contains("create") && tag.file.StartsWith("LEVEL"))
            {
                Debug.LogError("Your source file has no create folder in its path but an instance is referencing the level folder. Cannot import!");
            }
            else if (!tag.file.StartsWith("LEVEL"))
            {
                GameObject xmlRoot = readXML(tag.file);
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            else
            {
                GameObject xmlRoot = readXML(tag.file.Replace("LEVEL", getLevelFolder(fileName)));
                xmlRoot.GetComponentInChildren <Prefab>().gameObject.transform.transform.parent = go.transform;
                DestroyImmediate(xmlRoot);
            }
            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "prefab")
        {
            Prefab tag = go.AddComponent <Prefab>();
            go.transform.parent = parent.transform;

            attachGameObjectProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "vertex")
        {
            Vertex tag = go.AddComponent <Vertex>();
            go.transform.parent = parent.transform;
            attachGeneralProperties(tag, xmlNode);
            tag.pos = readVec2(xmlNode, "pos");

            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";
            go.transform.localPosition = new Vector3(tag.pos.x, 0, tag.pos.y);

            addToParent(parent, tag);
        }
        else if (xmlNode.Name == "light")
        {
            Light tag = go.AddComponent <Light>();
            go.transform.parent = parent.transform;

            attachGeneralProperties(tag, xmlNode);
            attachTransformProperties(tag, xmlNode);
            go.name = "<" + xmlNode.Name + " " + tag.teardownName + ">";

            tag.penumbra   = readFloat(xmlNode, "penumbra");
            tag.unshadowed = readFloat(xmlNode, "unshadowed");
            tag.angle      = readFloat(xmlNode, "angle");
            tag.glare      = readFloat(xmlNode, "glare");
            tag.color      = readColor(xmlNode, "color");
            tag.type       = (Light.Type)Enum.Parse(typeof(Light.Type), readString(xmlNode, "type", "area"), false);

            go.transform.localRotation = Quaternion.Euler(tag.rotation);
            go.transform.localPosition = tag.position;
            if (tag.scale > 0)
            {
                go.transform.localScale = go.transform.localScale * tag.scale;
            }
            addToParent(parent, tag);
        }

        foreach (XmlNode child in xmlNode.ChildNodes)
        {
            GameObject childGameObject = readXmlNode(child, go, fileName);
        }

        return(go);
    }
Beispiel #42
0
        public static void Generate(frmMace frmLogForm, string strUserCityName,
                                    bool booIncludeFarms, bool booIncludeMoat, bool booIncludeWalls,
                                    bool booIncludeDrawbridges, bool booIncludeGuardTowers, bool booIncludeBuildings,
                                    bool booIncludePaths, bool booIncludeMineshaft, bool booIncludeItemsInChests,
                                    bool booIncludeValuableBlocks, bool booIncludeGhostdancerSpawners,
                                    string strCitySize, string strMoatType, string strCityEmblem,
                                    string strOutsideLights, string strTowerAddition, string strWallMaterial,
                                    string strCitySeed, string strWorldSeed, bool booExportSchematic)
        {
            #region seed the random number generators
            int intCitySeed, intWorldSeed;
            Random randSeeds = new Random();
            if (strCitySeed.Length == 0)
            {
                intCitySeed = randSeeds.Next();
                frmLogForm.UpdateLog("Random city seed: " + intCitySeed);
            }
            else
            {
                intCitySeed = JavaStringHashCode(strCitySeed);
                frmLogForm.UpdateLog("Random city seed: " + strCitySeed);
            }
            if (strWorldSeed.Length == 0)
            {
                intWorldSeed = randSeeds.Next();
                frmLogForm.UpdateLog("Random world seed: " + intWorldSeed);
            }
            else
            {
                intWorldSeed = JavaStringHashCode(strWorldSeed);
                frmLogForm.UpdateLog("Random world seed: " + strWorldSeed);
            }
            RandomHelper.SetSeed(intCitySeed);
            #endregion

            #region create minecraft world directory from a random unused city name
            string strFolder = String.Empty, strCityName = String.Empty;

            strUserCityName = SafeFilename(strUserCityName);
            if (strUserCityName.ToLower().Trim().Length == 0)
            {
                strUserCityName = "random";
            }

            if (strUserCityName.ToLower().Trim() != "random")
            {
                if (Directory.Exists(Utils.GetMinecraftSavesDirectory(strUserCityName)))
                {

                    if (MessageBox.Show("A world called \"" + strUserCityName + "\" already exists. " +
                                    "Would you like to use a random name instead?", "World already exists",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        frmLogForm.UpdateLog("Cancelled, because a world with this name already exists.");
                        return;
                    }
                }
                else
                {
                    strCityName = strUserCityName;
                    strFolder = Utils.GetMinecraftSavesDirectory(strCityName);
                }
            }
            if (strCityName.Length == 0)
            {
                string strStart, strEnd;
                do
                {
                    strStart = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityAdj.txt"));
                    strEnd = RandomHelper.RandomFileLine(Path.Combine("Resources", "CityNoun.txt"));
                    strCityName = "City of " + strStart + strEnd;
                    strFolder = Utils.GetMinecraftSavesDirectory(strCityName);
                } while (strStart.ToLower().Trim() == strEnd.ToLower().Trim() || Directory.Exists(strFolder) || (strStart + strEnd).Length > 14);
            }
            Directory.CreateDirectory(strFolder);
            RandomHelper.SetSeed(intCitySeed);
            #endregion

            #region get handles to world, chunk manager and block manager
            BetaWorld worldDest = BetaWorld.Create(@strFolder);
            BetaChunkManager cmDest = worldDest.GetChunkManager();
            BlockManager bmDest = worldDest.GetBlockManager();
            bmDest.AutoLight = false;
            #endregion

            #region determine block sizes
            // first we set the city size by chunks
            int intCitySize = 12;
            switch (strCitySize)
            {
                case "Random":
                    intCitySize = RandomHelper.Next(8, 16);
                    break;
                case "Very small":
                    intCitySize = 2;
                    break;
                case "Small":
                    intCitySize = 4;
                    break;
                case "Medium":
                    intCitySize = 8;
                    break;
                case "Large":
                    intCitySize = 16;
                    break;
                case "Very large":
                    intCitySize = 32;
                    break;
                default:
                    Debug.Fail("Invalid switch result");
                    break;
            }
            // then we multiply by 16, because that's the x and z of a chunk
            intCitySize *= 16;
            int intFarmLength = booIncludeFarms ? 32 : 8;
            int intMapLength = intCitySize + (intFarmLength * 2);
            #endregion

            #region setup classes
            BlockShapes.SetupClass(bmDest, intMapLength);
            BlockHelper.SetupClass(bmDest, intMapLength);
            if (!SourceWorld.SetupClass(worldDest, booIncludeItemsInChests, booIncludeGhostdancerSpawners))
            {
                return;
            }
            NoticeBoard.SetupClass(intCitySeed, intWorldSeed);
            #endregion

            #region determine random options
            // ensure selected options take priority, but don't set things on fire
            if (strTowerAddition == "Random")
            {
                strTowerAddition = RandomHelper.RandomString("Fire beacon", "Flag");
            }
            if (strWallMaterial.StartsWith("Wood"))
            {
                if (strMoatType == "Lava" || strMoatType == "Fire" || strMoatType == "Random")
                {
                    strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water");
                }
                strOutsideLights = "Torches";
            }
            if (strWallMaterial == "Random")
            {
                if (strMoatType == "Lava" || strMoatType == "Fire" || strOutsideLights == "Fire")
                {
                    strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone", "Stone");
                }
                else
                {
                    strWallMaterial = RandomHelper.RandomString("Brick", "Cobblestone", "Sandstone",
                                                                "Stone", "Wood Planks");
                    if (strWallMaterial.StartsWith("Wood"))
                    {
                        if (strMoatType == "Random")
                        {
                            strMoatType = RandomHelper.RandomString("Drop to Bedrock", "Cactus", "Water");
                        }
                        strOutsideLights = "Torches";
                    }
                }
            }
            if (strOutsideLights == "Random")
            {
                strOutsideLights = RandomHelper.RandomString("Fire", "Torches");
            }
            if (strMoatType == "Random")
            {
                int intRand = RandomHelper.Next(100);
                if (intRand >= 90)
                {
                    strMoatType = "Drop to Bedrock";
                }
                else if (intRand >= 80)
                {
                    strMoatType = "Cactus";
                }
                else if (intRand >= 50)
                {
                    strMoatType = "Lava";
                }
                else if (intRand >= 40)
                {
                    strMoatType = "Fire";
                }
                else
                {
                    strMoatType = "Water";
                }
            }

            int intWallMaterial = BlockType.STONE;
            switch (strWallMaterial)
            {
                case "Brick":
                    intWallMaterial = BlockType.BRICK_BLOCK;
                    break;
                case "Cobblestone":
                    intWallMaterial = BlockType.COBBLESTONE;
                    break;
                case "Sandstone":
                    intWallMaterial = BlockType.SANDSTONE;
                    break;
                case "Stone":
                    intWallMaterial = BlockType.STONE;
                    break;
                case "Wood Planks":
                    intWallMaterial = BlockType.WOOD_PLANK;
                    break;
                case "Wood Logs":
                    intWallMaterial = BlockType.WOOD;
                    break;
                case "Bedrock":
                    intWallMaterial = BlockType.BEDROCK;
                    break;
                case "Mossy Cobblestone":
                    intWallMaterial = BlockType.MOSS_STONE;
                    break;
                case "Netherrack":
                    intWallMaterial = BlockType.NETHERRACK;
                    break;
                case "Glass":
                    intWallMaterial = BlockType.GLASS;
                    break;
                case "Ice":
                    intWallMaterial = BlockType.ICE;
                    break;
                case "Snow":
                    intWallMaterial = BlockType.SNOW_BLOCK;
                    break;
                case "Glowstone":
                    intWallMaterial = BlockType.GLOWSTONE_BLOCK;
                    break;
                case "Dirt":
                    intWallMaterial = BlockType.DIRT;
                    break;
                case "Obsidian":
                    intWallMaterial = BlockType.OBSIDIAN;
                    break;
                case "Jack-o-Lantern":
                    intWallMaterial = BlockType.JACK_O_LANTERN;
                    break;
                case "Soul sand":
                    intWallMaterial = BlockType.SOUL_SAND;
                    break;
                case "Gold":
                    intWallMaterial = BlockType.GOLD_BLOCK;
                    break;
                case "Diamond":
                    intWallMaterial = BlockType.DIAMOND_BLOCK;
                    break;
                case "Stone brick - 1.8!":
                    intWallMaterial = BlockType.STONE_BRICK;
                    break;
                default:
                    Debug.Fail("Invalid switch result");
                    break;
            }
            #endregion

            #region make the city
            frmLogForm.UpdateLog("Creating underground terrain");
            Chunks.CreateInitialChunks(cmDest, intMapLength / 16, frmLogForm);
            frmLogForm.UpdateProgress(25);

            Buildings.structPoint spMineshaftEntrance = new Buildings.structPoint();

            if (booIncludeWalls)
            {
                frmLogForm.UpdateLog("Creating city walls");
                Walls.MakeWalls(worldDest, intFarmLength, intMapLength, strCityEmblem, strOutsideLights, intWallMaterial);
            }
            frmLogForm.UpdateProgress(34);
            if (booIncludeBuildings || booIncludePaths)
            {
                frmLogForm.UpdateLog("Creating inner-city paths");
                int[,] intArea = Paths.MakePaths(worldDest, bmDest, intFarmLength, intMapLength, strCitySize,
                                                 booIncludeMineshaft);
                frmLogForm.UpdateProgress(36);
                if (booIncludeBuildings)
                {
                    frmLogForm.UpdateLog("Creating buildings");
                    spMineshaftEntrance = Buildings.MakeInsideCity(bmDest, worldDest, intArea, intFarmLength, intMapLength, booIncludePaths);
                    frmLogForm.UpdateProgress(45);
                    if (booIncludeMineshaft)
                    {
                        frmLogForm.UpdateLog("Creating mineshaft");
                        Mineshaft.MakeMineshaft(worldDest, bmDest, intFarmLength, intMapLength, spMineshaftEntrance);
                    }
                }
            }
            frmLogForm.UpdateProgress(51);

            if (booIncludeMoat)
            {
                frmLogForm.UpdateLog("Creating moat");
                Moat.MakeMoat(intFarmLength, intMapLength, strMoatType, booIncludeGuardTowers);
            }
            frmLogForm.UpdateProgress(52);

            if (booIncludeDrawbridges)
            {
                frmLogForm.UpdateLog("Creating drawbridges");
                Drawbridge.MakeDrawbridges(bmDest, intFarmLength, intMapLength, booIncludeMoat,
                                           booIncludeWalls, booIncludeItemsInChests, intWallMaterial, strMoatType, strCityName);
            }
            frmLogForm.UpdateProgress(53);

            if (booIncludeGuardTowers)
            {
                frmLogForm.UpdateLog("Creating guard towers");
                GuardTowers.MakeGuardTowers(bmDest, intFarmLength, intMapLength, booIncludeWalls,
                                            strOutsideLights, strTowerAddition, booIncludeItemsInChests, intWallMaterial);
            }
            frmLogForm.UpdateProgress(54);

            if (booIncludeFarms)
            {
                frmLogForm.UpdateLog("Creating farms");
                Farms.MakeFarms(worldDest, bmDest, intFarmLength, intMapLength);
            }
            frmLogForm.UpdateProgress(58);

            if (!booIncludeValuableBlocks)
            {
                cmDest.Save();
                worldDest.Save();
                Chunks.ReplaceValuableBlocks(worldDest, bmDest, intMapLength, intWallMaterial);
            }
            frmLogForm.UpdateProgress(60);
            Chunks.PositionRails(worldDest, bmDest, intMapLength);
            frmLogForm.UpdateProgress(62);
            #endregion

            #region world settings
            // spawn looking at one of the city entrances
            if (booIncludeFarms)
            {
                SpawnPoint spLevel = new SpawnPoint(7, 11, 13);
                worldDest.Level.Spawn = spLevel;
                worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength - (intFarmLength - 10));
            }
            else
            {
                worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength - (intFarmLength - 7));
            }
            // spawn in the middle of the city
            //#if DEBUG
            //worldDest.Level.Spawn = new SpawnPoint(intMapLength / 2, 64, intMapLength / 2);
            //#endif
            if (strWorldSeed.Length > 0)
            {
                worldDest.Level.RandomSeed = intWorldSeed;
            }

            #if RELEASE
            worldDest.Level.Time = RandomHelper.Next(24000);

            if (RandomHelper.NextDouble() < 0.15)
            {
                worldDest.Level.IsRaining = true;
                // one-quarter to three-quarters of a day
                worldDest.Level.RainTime = RandomHelper.Next(6000, 18000);
                if (RandomHelper.NextDouble() < 0.25)
                {
                    worldDest.Level.IsThundering = true;
                    worldDest.Level.ThunderTime = worldDest.Level.RainTime;
                }
            }
            #endif
            #endregion

            #if DEBUG
            MakeHelperChest(bmDest, worldDest.Level.Spawn.X + 2, worldDest.Level.Spawn.Y, worldDest.Level.Spawn.Z + 2);
            #endif

            frmLogForm.UpdateLog("Creating lighting data");
            Chunks.ResetLighting(worldDest, cmDest, frmLogForm, (int)Math.Pow(intMapLength / 16, 2));

            worldDest.Level.LevelName = strCityName;
            worldDest.Save();

            if (booExportSchematic)
            {
                frmLogForm.UpdateLog("Creating schematic");
                AlphaBlockCollection abcExport = new AlphaBlockCollection(intMapLength, 128, intMapLength);
                for (int x = 0; x < intMapLength; x++)
                {
                    for (int z = 0; z < intMapLength; z++)
                    {
                        for (int y = 0; y < 128; y++)
                        {
                            abcExport.SetBlock(x, y, z, bmDest.GetBlock(x, y, z));
                        }
                    }
                }
                Schematic CitySchematic = new Schematic(intMapLength, 128, intMapLength);
                CitySchematic.Blocks = abcExport;
                CitySchematic.Export(Utils.GetMinecraftSavesDirectory(strCityName) + "\\" + strCityName + ".schematic");
            }

            frmLogForm.UpdateLog("\r\nCreated the " + strCityName + "!");
            frmLogForm.UpdateLog("It'll be at the end of your MineCraft world list.");
        }
Beispiel #43
0
        public Task <CharacterCreationResult> CreateHumanPlayerCharacterAsync(CharCreationInfo creationInfo)
        {
            if (creationInfo == null)
            {
                throw new ArgumentNullException(nameof(creationInfo));
            }

            return(_CharacterService.CheckCharacterExistsAsync(creationInfo.Name).ContinueWith <CharacterCreationResult>(task =>
            {
                //Validate the creation info because it comes directly from the client(we do not trust the client).
                if (!creationInfo.Validate(out string invalidProperty, out object value))
                {
                    _Log.Warn($"Character creation failed due to invalid {nameof(CharCreationInfo)}, invalid attribute is '{invalidProperty}' with value '{value}'");
                    return new CharacterCreationFailed(CharacterCreationFailure.InvalidCreationInfo);
                }

                //Check whether the name can be used for a character.
                if (!_NameValidator.IsValid(creationInfo.Name))
                {
                    return (CharacterCreationResult) new CharacterCreationFailed(CharacterCreationFailure.NameIsInvalid);
                }

                //The character does already exist.
                if (task.Result)
                {
                    return (CharacterCreationResult) new CharacterCreationFailed(CharacterCreationFailure
                                                                                 .AlreadyExists);
                }

                //Create the new character
                try
                {
                    using (CharacterManagementContext db = _ContextFactory.Create())
                    {
                        SpawnPoint spawn = _SpawnPointProvider.GetSpawnPoint();

                        //Add the character
                        var characterEntity = new CharacterEntity
                        {
                            CharacterName = creationInfo.Name,
                            PositionX = spawn.Point.X,
                            PositionY = spawn.Point.Y,
                            PositionZ = spawn.Point.Z,
                            Rotation = spawn.Rotation.Yaw,
                            WorldName = spawn.World.Path,
                            TemplateName = _CharacterTemplateSelector.GetTemplate(creationInfo)
                        };
                        db.Characters.Add(characterEntity);

                        //Add the visuals of the character.
                        var customVisuals = new CharacterCustomVisualsEntity
                        {
                            OwnerCharacter = characterEntity,
                            BodyMesh = creationInfo.BodyMesh,
                            BodyTex = creationInfo.BodyTex,
                            HeadMesh = creationInfo.HeadMesh,
                            HeadTex = creationInfo.HeadTex,
                            Voice = creationInfo.Voice,
                            Fatness = creationInfo.Fatness,
                            BodyWidth = creationInfo.BodyWidth
                        };
                        db.CustomVisuals.Add(customVisuals);

                        //Save the changes.
                        db.SaveChanges();


                        Character character = _CharacterBuilder.HumanCharacterFromEntities(characterEntity, customVisuals);

                        //Invoke the character creation event(later so we can inform the client first)
                        _Dispatcher.EnqueueAction(() =>
                        {
                            _CharacterService.OnCharacterCreated(new CharacterCreatedArgs(character));
                        });

                        //Return information about successful character creation.
                        return new CharacterCreationSuccess(character);
                    }
                }
                catch (Exception e)
                {
                    throw new DatabaseRequestException("Something went wrong while adding the new character to the database.", e);
                }
            }));
        }
Beispiel #44
0
    public RoadPiece PlacePiece(RoadPiece previous)
    {
        if (m_OriginalViableRoadPieces == null)
        {
            m_OriginalViableRoadPieces = m_viableRoadPieces;
        }

        m_viableRoadPieces = m_OriginalViableRoadPieces;
        List <GameObject> instantiables = AvailablePieceThatFits();

        if (instantiables != null)
        {
            bool pieceNotPlaced = true;
            while (pieceNotPlaced && instantiables.Count > 0)
            {
                //TODO, prevent double selection
                int        choice = Random.Range(0, instantiables.Count);
                GameObject go     = GameObject.Instantiate(instantiables[choice]);
                instantiables.RemoveAt(choice);

                go.transform.position = transform.position;

                WaypointOrientation oppositeOrientation = WaypointOrientation.Bottom;
                switch (m_orientation)
                {
                case WaypointOrientation.Bottom:
                    oppositeOrientation = WaypointOrientation.Top;
                    break;

                case WaypointOrientation.Left:
                    oppositeOrientation = WaypointOrientation.Right;
                    break;

                case WaypointOrientation.Right:
                    oppositeOrientation = WaypointOrientation.Left;
                    break;

                case WaypointOrientation.Top:
                    oppositeOrientation = WaypointOrientation.Bottom;
                    break;
                }

                //TODO: fix this to accomodate placing pieces with multiple connections

                RoadPiece  rp = go.GetComponent <RoadPiece> ();
                SpawnPoint sp = rp.GetSpawnPoint(oppositeOrientation);
                //TODO: link up all of the road pieces

                Waypoint[] targetInput;
                targetInput = sp.getInput();
                Waypoint[] targetOutput;
                targetOutput = sp.getOutput();
                Link(sp);
                sp.Link(this);


                foreach (Waypoint wp in m_output)
                {
                    wp.SetNext(targetInput);
                }

                foreach (Waypoint wp in targetOutput)
                {
                    wp.SetNext(m_input);
                }
                go.GetComponent <RoadPiece> ().Instantiate(previous);

                bool works = true;

                foreach (SpawnPoint targetSpawnPoints in rp.SpawnPoints())
                {
                    if (targetSpawnPoints.IsColliding())
                    {
                        if (targetSpawnPoints.SetConnections() == false)
                        {
                            works = false;
                        }
                    }
                }

                if (ZoneCheck(rp) == false)
                {
                    works = false;
                }

                if (works == false)
                {
                    rp.KillMe();
                }
                else
                {
                    pieceNotPlaced = false;
                    return(rp);
                }
            }
            return(null);
        }
        else
        {
            return(null);
        }
    }
Beispiel #45
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     spawnPoint = spawnObject.GetComponentInChildren<SpawnPoint>();
     spawnPoint.enabled = true; 
 }
                private Var1Scenario(int index)
                {
                    CalloutMessage    = "Murder Investigation";
                    MurderDescription = "[NOT IMPLEMENTED]";
                    switch (index)
                    {
                    default:
                    case 0:
                        CalloutPosition = new Vector3(115.6685f, 290.0636f, 109.974f);

                        VictimSpawnPoint        = new SpawnPoint(new Vector3(115.6685f, 290.0636f, 109.974f), 1.790135f);
                        VictimFootageSpawnPoint = new SpawnPoint(new Vector3(116.59f, 291.90f, 109.97f), 158.63f);
                        VictimPedModel          = new Model[] { "s_f_y_hooker_01", "a_f_y_business_01", "a_f_y_business_02", "a_f_y_business_03", "a_f_y_business_04" }.GetRandomElement();

                        MurdererSpawnPoint        = new SpawnPoint(new Vector3(138.2685f, 299.19f, 110.87f), 255.76f);
                        MurdererFootageSpawnPoint = new SpawnPoint(new Vector3(106.91f, 297.36f, 109.99f), 249.91f);
                        MurdererPedModel          = new Model[] { "s_m_y_chef_01", "s_m_y_garbage", "s_m_y_robber_01" }.GetRandomElement();
                        if (MurdererPedModel == new Model("s_m_y_chef_01"))
                        {
                            MurderDescription = "Suspect wears a chef uniform";
                        }
                        else if (MurdererPedModel == new Model("s_m_y_garbage"))
                        {
                            MurderDescription = "Suspect wears a garbage collector uniform";
                        }
                        else if (MurdererPedModel == new Model("s_m_y_robber_01"))
                        {
                            //MurderDescription = "Suspect wears s_m_y_robber_01";
                        }

                        CCTVCameraModelPositionRotation = new Tuple <Model, Vector3, Rotator>(3940745496, new Vector3(102.5212f, 281.4584f, 114.698f), new Rotator(0f, 0f, 156.0005f));
                        KnifeModelPositionRotation      = new Tuple <Model, Vector3, Rotator>(3776622480, new Vector3(122.5029f, 301.3399f, 111.14f), new Rotator(90.91142f, 31.9574f, 58.76347f));
                        break;

                    case 1:
                        CalloutPosition = new Vector3(181.4932f, 304.668f, 105.3759f);

                        VictimSpawnPoint        = new SpawnPoint(new Vector3(181.4932f, 304.668f, 105.3759f), 96.78967f);
                        VictimFootageSpawnPoint = new SpawnPoint(new Vector3(181.4932f, 304.668f, 105.3759f), 96.78967f);
                        VictimPedModel          = new Model[] { "s_f_y_hooker_01", "a_f_y_business_01", "a_f_y_business_02", "a_f_y_business_03", "a_f_y_business_04" }.GetRandomElement();

                        MurdererSpawnPoint        = new SpawnPoint(new Vector3(199.1882f, 292.4081f, 105.6103f), -115.9992f);
                        MurdererFootageSpawnPoint = new SpawnPoint(new Vector3(199.1882f, 292.4081f, 105.6103f), -115.9992f);
                        MurdererPedModel          = new Model[] { "s_m_y_chef_01", "s_m_y_garbage", "s_m_y_robber_01" }.GetRandomElement();
                        if (MurdererPedModel == new Model("s_m_y_chef_01"))
                        {
                            MurderDescription = "Suspect wears a chef uniform";
                        }
                        else if (MurdererPedModel == new Model("s_m_y_garbage"))
                        {
                            MurderDescription = "Suspect wears a garbage collector uniform";
                        }
                        else if (MurdererPedModel == new Model("s_m_y_robber_01"))
                        {
                            //MurderDescription = "Suspect wears s_m_y_robber_01";
                        }

                        CCTVCameraModelPositionRotation = new Tuple <Model, Vector3, Rotator>(3940745496, new Vector3(197.3559f, 296.6242f, 110.2151f), new Rotator(0f, 0f, -87.99941f));
                        KnifeModelPositionRotation      = new Tuple <Model, Vector3, Rotator>(3776622480, new Vector3(195.9491f, 291.6119f, 104.6099f), new Rotator(-87.93718f, -7.711276f, 19.59351f));
                        break;
                    }
                }
Beispiel #47
0
	// Use this for initialization
	void Start () {
		spawnPoint = GetComponentInChildren<SpawnPoint>();
		soundManager = FindObjectOfType(typeof(SoundManager)) as SoundManager;
	}
    /// <summary>
    /// Test için paylaşımlı spawn noktalarından en uygun olanını seçer.
    /// Test oyuncusunun pozisyonunu seçilen spawn noktasına atar.
    /// </summary>
    public void TestGetSpawnPoint()
    {
        SpawnPoint spawnPoint = GetSharedSpawnPoint(PlayerToBeSpawned.PlayerTeamValue);

        PlayerToBeSpawned.Transform.position = spawnPoint.PointTransform.position;
    }
Beispiel #49
0
        /// <summary>
        /// Method to load a map
        /// </summary>
        /// <param name="filename">file name of map</param>
        /// <param name="contentMgr">content manager instance</param>
        /// <param name="gfxDevice">graphics device instance</param>
        public static void loadMap(String filename, ContentManager contentMgr, GraphicsDevice gfxDevice)
        {
            XmlReader reader = XmlReader.Create(filename);
            XPathDocument docNav = new XPathDocument(reader);
            XPathNavigator nav = docNav.CreateNavigator();
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(nav.NameTable);
            XPathNodeIterator iter;
            XPathNavigator mapIter = nav.SelectSingleNode("/Map");
            mapRadius = Convert.ToSingle(mapIter.GetAttribute("mapRadius", nsmanager.DefaultNamespace));

            XPathNavigator skyboxIter = nav.SelectSingleNode("/Map/Skybox");
            String texName = skyboxIter.GetAttribute("texture", nsmanager.DefaultNamespace);
            skyBoxRepeat = Convert.ToSingle(skyboxIter.GetAttribute("repeat", nsmanager.DefaultNamespace));
            SetUpSkyBox(gfxDevice, contentMgr, texName, Convert.ToString(skyBoxRepeat));
            //Now read in path nodes:
            iter = nav.Select("/Map/Marker[@className!='SpawnPoint' and @className!='PlayerSpawnPoint']");
            while (iter.MoveNext())
            {
                Node n = new Node();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Read spawnpoints:
            iter = nav.Select("/Map/Marker[@className='SpawnPoint']");
            while (iter.MoveNext())
            {
                SpawnPoint n = new SpawnPoint();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Read player spawnpoints:
            iter = nav.Select("/Map/Marker[@className='PlayerSpawnPoint']");
            while (iter.MoveNext())
            {
                SpawnPoint n = new PlayerSpawnPoint();
                readMarkerData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
                content.Add(n.id, n);
            }
            //Now read other content:
            iter = nav.Select("/Map/ContentItem");
            while (iter.MoveNext())
            {
                Drawer n = new Drawer(false);
                n.contentLoader = contentMgr;
                readObjectData(contentMgr, reader, docNav, nav, nsmanager, iter, n);
            }
            List<Edge> edgeList = new List<Edge>();
            List<float> edgeDistances = new List<float>();
            iter = nav.Select("/Map/PathEdge");
            while (iter.MoveNext())
            {
                float weight = Convert.ToSingle(iter.Current.GetAttribute("weight", nsmanager.DefaultNamespace));
                float distance = Convert.ToSingle(iter.Current.GetAttribute("distance", nsmanager.DefaultNamespace));
                String firstId = iter.Current.SelectSingleNode("firstNodeId").Value;
                String secondId = iter.Current.SelectSingleNode("secondNodeId").Value;
                Node first = null, second = null;
                foreach (Object item in content.Values)
                    if (item is Node)
                    {
                        if ((item as Marker).id == firstId)
                            first = item as Node;
                        else if ((item as Marker).id == secondId)
                            second = item as Node;
                        if (first != null && second != null)
                            break;
                    }
                edgeList.Add(new Edge(first, second, weight));
                edgeDistances.Add(distance);
            }
            //Connect nodes:
            for (int i = 0; i < edgeList.Count; i++)
            {
                Edge item = edgeList.ElementAt(i);
                float distance = edgeDistances.ElementAt(i);
                item.node1.connectToNode(item.node2, item.weight, distance);
            }
            reader.Close();
        }
 /// <summary>
 /// Move to last point
 /// </summary>
 public void Retreat()
 {
     spawn = spawn.retreatPoint;
 }
 /// <summary>
 /// Move to next point
 /// </summary>
 public void Advance()
 {
     spawn = spawn.advancePoint;
 }
 public void setSpawnPoint(SpawnPoint point)
 {
     selected = point;
 }
 void handleNPCOffscreen(GameObject npc, SpawnPoint spawnPoint)
 {
     spawnPools[(int) spawnPoint].Enqueue(npc);
 }
Beispiel #54
0
 public EnemySpawnInfo(float spawnTime, SpawnPoint spawnPoint, Enemy enemy)
 {
     SpawnTime  = spawnTime;
     SpawnPoint = spawnPoint;
     Enemy      = enemy;
 }
    void setNPCStartPosition(NPCController npc, SpawnPoint spawnPoint)
    {
        npc.transform.position =
            SpawnPointController.GetSpawnPosition(spawnPoint, true);

        npc.moveAcrossScreenToLeft();
    }
        static void Postfix(RoomManager __instance, CharacterState characterState, SpawnPoint prevPoint, SpawnPoint newPoint)
        {
            List <CharacterState> chars = new List <CharacterState>();

            try
            {
                characterState.GetCharacterManager().AddCharactersInTowerToList(chars);
                foreach (var unit in chars)
                {
                    CustomTriggerManager.QueueTrigger(OnSpawnChange.OnSpawnChangeCharTrigger, unit);
                }
            }
            catch (System.Exception)
            {
                Trainworks.Trainworks.Log(BepInEx.Logging.LogLevel.All, "OnSpawnPointChange Preview has crashed, bypassing.");
            }
        }
 GameObject spawnNPCFromPool(SpawnPoint spawnPoint)
 {
     Queue<GameObject> spawnPool = spawnPools[(int) spawnPoint];
     if (spawnPool.Count > 0) {
         return spawnPool.Dequeue();
     } else {
         return spawnNPC(spawnPoint);
     }
 }
Beispiel #58
0
 // Spawn Points
 public void DieAndGoToSpawnPoint(SpawnPoint spawnPoint)
 {
     this.transform.position = spawnPoint.transform.position;
     movementComponent.StopAllMovement();
 }
 static void Postfix(CardEffectState effectState, List <CharacterState> targets, SpawnPoint dropLocation, SubtypeData targetSubtype)
 {
     if (BossTargetIgnoreFix.targetIgnoreBosses && effectState.GetTargetMode() == TargetMode.DropTargetCharacter && dropLocation != null)
     {
         CharacterState characterState = dropLocation.GetCharacterState();
         if (characterState.IsMiniboss() || characterState.IsOuterTrainBoss())
         {
             targets.Clear();
             // lastTargetedCharacters.Clear();
         }
     }
 }
Beispiel #60
0
 public void SpawnPlayer(SpawnPoint spawnPoint)
 {
     Player.transform.position = spawnPoint.transform.position;
 }