Esempio n. 1
0
    public List <IndexGroup> SelectableTrianglesOfaGridPiece(GridPiece tempMapPiece)
    {
        List <IndexGroup> groupHolder = new List <IndexGroup> ();

        for (int i = 0; i < 6; i++)
        {
            float angle = (45f + 60f * i);
            int   xMultiplierForSecondAndThirdAreas = ((angle / 90f > 1) && (angle / 90f < 4)) ? -1 : +1;
            int   yMultiplierForThirdAndFourthAreas = (angle / 90f > 2) ? -1 : +1;
            float xOfVector = Mathf.Sin(angle) * xMultiplierForSecondAndThirdAreas / 2f;
            //The y-axis of this direction is the sinus of this angle
            float yOfVector = Mathf.Cos(angle) * yMultiplierForThirdAndFourthAreas / 2f;

            IndexGroup group = GameSkeleton.gridSystem.GiveClosestIndexesOfAGridPieceInGridSystem(tempMapPiece, tempMapPiece.transform.position + new Vector3(xOfVector, yOfVector, 0f), 2);
            if (!group.IsHolderContainsThisList(groupHolder))
            {
                groupHolder.Add(group);
                if (!group.IsHolderContainsThisList(EverySelectableTriangleInGridSystem))
                {
                    EverySelectableTriangleInGridSystem.Add(group);
                }
            }
        }
        return(groupHolder);
    }