コード例 #1
0
ファイル: Projectile.cs プロジェクト: elegios/MShip2
    void OnTriggerEnter(Collider collider)
    {
        if (!Network.isServer)
        {
            return;
        }

        Debug.Break();
        Debug.DrawRay(transform.position, rigidbody.velocity - collider.transform.root.rigidbody.velocity);

        networkView.RPC("NetDestroyThis", RPCMode.All);
        GameObject  other         = collider.gameObject;
        StationLink linkToDestroy = other.GetComponent <StationLink>();

        if (linkToDestroy == null)
        {
            if (other.GetComponent <RemoteStationLink>() != null)
            {
                linkToDestroy = other.GetComponent <RemoteStationLink>().link;
            }
        }
        if (linkToDestroy != null)
        {
            linkToDestroy.DoDestroy(transform.position, (rigidbody.velocity - other.transform.root.rigidbody.velocity) * rigidbody.mass);
        }
        else
        {
            print("collided with something else, destroying self anyway");
        }
    }
コード例 #2
0
        private void AddNewLink(Station stationOrigin, Station stationDestination)
        {
            var newLink = new StationLink {
                Origin = stationOrigin, Destination = stationDestination
            };

            if (_stationLinks.Any(sl => sl.IsLinkRepeated(newLink)))
            {
                return;
            }
            _stationLinks.Add(newLink);
        }
コード例 #3
0
ファイル: StationLink.cs プロジェクト: elegios/MShip2
    public void SetParent(StationLink parent)
    {
        if (!Network.isServer)
        {
            print("This function should only be called on the server");
            return;
        }

        if (parent != null)
        {
            networkView.RPC("NetDestroy", RPCMode.AllBuffered, buildBoards[buildBoards.Length - 1].networkView.viewID);
            this.parent = parent;
        }
    }
コード例 #4
0
ファイル: StationLink.cs プロジェクト: elegios/MShip2
    //Must be called from code that is run for all players
    public void ChildAdded(GameObject buildBoard, StationLink child)
    {
        int i = 0;

        while (i < buildBoards.Length && buildBoards[i] != buildBoard)
        {
            i++;
        }
        if (i == buildBoards.Length)
        {
            print("Couldn't find the buildboard that built the child");
            return;
        }

        children[i] = child;
        child.GetComponent <Mass>().TransferMassTo(transform.root.rigidbody);
        Destroy(buildBoards[i]);
    }
コード例 #5
0
        private List <StationLink> GenerateVirtualLinks(List <StationLink> invalidDestinationLinks, List <StationLink> invalidOriginLinks)
        {
            List <StationLink> virtualLinks = new List <StationLink>();

            foreach (StationLink invalidDestinationLink in invalidDestinationLinks)
            {
                Station origin = invalidDestinationLink.Origin;
                foreach (StationLink invalidOriginLink in invalidOriginLinks)
                {
                    Station     destination = invalidOriginLink.Destination;
                    StationLink virtualLink = new StationLink {
                        Origin = origin, Destination = destination
                    };
                    virtualLinks.Add(virtualLink);
                }
            }
            return(virtualLinks);
        }
コード例 #6
0
ファイル: BuildBoard.cs プロジェクト: elegios/MShip2
    void DoBuild(NetworkViewID thingID)
    {
        Transform thing = NetworkView.Find(thingID).transform;

        thing.position = buildPoint.position;
        thing.rotation = buildPoint.rotation;
        thing.parent   = transform.parent;

        StationLink stationLink = thing.transform.Find("StationPart").GetComponent <StationLink>();

        if (Network.isServer)
        {
            stationLink.SetParent(transform.parent.GetComponent <StationLink>());
        }
        transform.parent.GetComponent <StationLink>().ChildAdded(gameObject, stationLink);

        DoActivate(false);
    }
コード例 #7
0
ファイル: StationLink.cs プロジェクト: elegios/MShip2
    void ChildWillBeDestroyed(StationLink child, Vector3 position, Vector3 impulse)
    {
        int i = 0;

        while (i < childPoints.Length && children[i] != child)
        {
            i++;
        }
        if (i == childPoints.Length)
        {
            print("Couldn't find the child that will supposedly be destroyed");
            return;
        }

        networkView.RPC("Push", RPCMode.All, position, impulse);

        GameObject board = (GameObject)Network.Instantiate(buildBoardPrefab, Vector3.zero, Quaternion.identity, 0);

        networkView.RPC("SetupBuildBoard", RPCMode.AllBuffered, i, board.networkView.viewID);
    }