Esempio n. 1
0
 public void CreateFactory(Factory fact, mapPiece land)
 {
     land.AddFactory(fact, clientName);
     UpdateServerMapPiece(land.DataInfo());
 }
Esempio n. 2
0
 public void SetCurrentMapPiece(mapPiece land)
 {
     currentLand = land;
 }
Esempio n. 3
0
    private void CreateMapPartExtras(GameObject go)
    {
        //    Debug.Log("Made map part extras");
        mapPiece mapPart = go.GetComponent <mapPiece>();

        if (mapPart.getResourceCount() > 0)
        {
            GameObject factory = Instantiate(factoryPrefab, go.transform) as GameObject;
        }
        // Create algorithm to find out which factory piece to use.
        bool hasRight  = mapPart.rightStrength() > 0;
        bool hasTop    = mapPart.topStrength() > 0;
        bool hasLeft   = mapPart.leftStrength() > 0;
        bool hasBottom = mapPart.bottomStrength() > 0;

        if (!(hasRight || hasTop || hasLeft || hasBottom))
        {
            return;
        }

        int frontNum = 0;
        int rot      = 0;

        if (hasRight)
        {
            frontNum++;
        }
        if (hasTop)
        {
            frontNum++;
        }
        if (hasLeft)
        {
            frontNum++;
        }
        if (hasBottom)
        {
            frontNum++;
        }
        if (frontNum == 1)
        {
            frontNum = 0;
        }
        if (frontNum == 2 && ((hasRight && hasLeft) || (hasTop && hasBottom)))
        {
            frontNum--;
        }
        if (frontNum == 1 && (hasTop && hasBottom))
        {
            rot = 1;
        }
        if (frontNum == 2)
        {
            if (!hasTop)
            {
                rot += 2;
                if (hasRight)
                {
                    rot++;
                }
            }
            else
            {
                if (!hasRight)
                {
                    rot++;
                }
            }
        }
        if (frontNum == 3)
        {
            if (!hasRight)
            {
                rot++;
            }
            if (!hasTop)
            {
                rot += 2;
            }
            if (hasLeft)
            {
                rot += 3;
            }
        }
        if (!clientName.Equals(mapPart.getOwner())) // is Enemy
        {
            frontNum += 5;
        }

        SetImage(go, frontlines[frontNum], rot);
    }