Example #1
0
    private GameObject CreateSectorsConnection(GameObject Sector1, GameObject Sector2)
    {
        Vector2 distance = new Vector2(Sector1.transform.position.x - Sector2.transform.position.x, Sector1.transform.position.y - Sector2.transform.position.y);
        distance.Normalize();

        float x = Sector1.transform.position.x - (distance.x * 5.5f);
        float y = Sector1.transform.position.y - distance.y * 2f;

        GameObject conn1 = Instantiate(ConnectionPoint, new Vector3(x, y, 0), new Quaternion(0, 0, 0, 0), Sector1.transform);
        Sector1.GetComponent<SpaceSystem>().PlanetsList.Add(conn1);

        x = Sector2.transform.position.x + (distance.x * 5.5f);
        y = Sector2.transform.position.y + distance.y * 2f;

        GameObject conn2 = Instantiate(ConnectionPoint, new Vector3(x, y, 0), new Quaternion(0, 0, 0, 0), Sector2.transform);
        Sector2.GetComponent<SpaceSystem>().PlanetsList.Add(conn2);

        if (UseDatabase)
        {
            // utwórz punkt w bazie danych
            db.CreateSectorConnection(Sector1, Sector2);
        }
        GameObject conection = CreateConnection(conn1, conn2, Sector1, Sector2);
        //Sector1.GetComponent<SpaceSystem>().ConnectionsList.Add(conection);
        //Sector2.GetComponent<SpaceSystem>().ConnectionsList.Add(conection);
        return conection;
    }