示例#1
0
    //Build ship
    void Build()
    {
        regenerate = false;
        //TODO: help why please god
        SetTerrainAffectorOff();

        Erase();

        //Points
        points = new Point[edge.Length + 1];
        //Center
        points[0] = ObjectManager.AddPoint(spawnPosition, module.pointMass, altColor, gameObject);

        for (int i = 1; i < edge.Length + 2; ++i)
        {
            //Edge
            if (i < edge.Length + 1)
            {
                points[i] = ObjectManager.AddPoint(spawnPosition + vertexOffset(edge[i - 1]), module.pointMass, color, gameObject);
                edge[i - 1].pointIndex = i;
                //Oars
                if (edge[i - 1].leftOar || edge[i - 1].rightOar)
                {
                    points[i].AddOar(edge[i - 1].leftOar);
                }
            }
            //
            center.invisible = true;

            //Links
            if (i > 1)
            {
                Point start = points[i - 1], end = points[((i - 1) % edge.Length) + 1];
                start.AddLink(end, Vector2.Distance(start.position, end.position), module.stiffness, module.damping, color);
                //Framework
                end = center;
                end.AddLink(start, Vector2.Distance(start.position, end.position), module.stiffness, module.damping, altColor, false); //
            }
        }
        //Cannon
        center.AddCannon(color);
        center.cannon.ship = this.GetComponent <ShipRevamped>();
        this.cannon        = center.cannon;
        //Deck
        center.AddDeck();
    }
示例#2
0
    //Build breakable
    void Build()
    {
        Clear();

        //Points
        points = new Point[edge.Length + 1];
        //Center
        points[0] = ObjectManager.AddPoint(spawnPosition, module.pointMass, altColor, gameObject);

        if (generateVertices)
        {
            for (int i = 0; i < sides; i++)
            {
                Vertex v = new Vertex();
                v.x          = (radius * Mathf.Cos(2 * Mathf.PI * i / sides + (theta * (Mathf.PI / 180))));
                v.y          = (radius * Mathf.Sin(2 * Mathf.PI * i / sides + (theta * (Mathf.PI / 180))));
                v.pointIndex = i + 1;
                edge [i]     = v;
            }
        }

        for (int i = 1; i < edge.Length + 2; ++i)
        {
            //Vertices
            if (i < edge.Length + 1)
            {
                points[i] = ObjectManager.AddPoint(spawnPosition + vertexOffset(edge[i - 1]), module.pointMass, color, gameObject);
                edge[i - 1].pointIndex = i;
            }
            //Links
            if (i > 1)
            {
                Point start = points[i - 1], end = points[((i - 1) % edge.Length) + 1];
                start.AddLink(end, Vector2.Distance(start.position, end.position), module.stiffness, module.damping, color);
                //Framework
                end = center;
                end.AddLink(start, Vector2.Distance(start.position, end.position), module.stiffness, module.damping, altColor);
            }
        }
    }