Example #1
0
    bool isAvailable(Boardcordinates source, Boardcordinates check, bool sourceState)
    {
        bool OkFlag = true;

        if (source.inRange(check))
        {
            OkFlag = false;
        }
        if (sourceState == isHoriontal)
        {
            if (isHoriontal)
            {
                if (source.x + 0.25f == check.x - 1.25f || source.z - 0.25f == check.x + 1.25f)
                {
                    OkFlag = false;
                }
            }
            else
            {
                if (source.z + 0.25f == check.z - 1.25f || source.z - 0.25f == check.z + 1.25f)
                {
                    OkFlag = false;
                }
            }
        }

        return(true);
    }
Example #2
0
    bool toAlignmentVertc()
    {
        float           x    = this.transform.position.x;
        float           z    = this.transform.position.z;
        bool            flag = true;
        int             i;
        int             j     = 0;
        Boardcordinates point = new Boardcordinates(x, z);

        for (i = 0; i < 8 && flag; i++)
        {
            for (j = 0; j < 8; j++)
            {
                if ((z > BoardBuilder.Positions[j, i].z && z < BoardBuilder.Positions[j + 1, i].z) &&
                    (BoardBuilder.Positions[j, i].inRange(point) || BoardBuilder.Positions[j + 1, i].inRange(point)))
                {
                    flag = !flag;
                    break;
                }
            }
        }

        if (!flag)
        {
            z = (BoardBuilder.Positions[j, i].z + BoardBuilder.Positions[j + 1, i].z) / 2.0f;
            if (x >= BoardBuilder.Positions[j, i].x)
            {
                x = BoardBuilder.Positions[j, i].x + 0.750f;
            }
            else
            {
                x = BoardBuilder.Positions[j, i].x - 0.750f;
            }
            this.transform.position = new Vector3(x, 1.0f, z);
        }
        else
        {
            used = !used;
        }

        return(!flag);
    }
Example #3
0
    //public Rigidbody[,] Positions;
    // Use this for initialization
    void Start()
    {
        //Positions = new Rigidbody[9, 9];
        PositionsTag  = new string[9, 9];
        Positions     = new Boardcordinates[9, 9];
        TakenSpots    = new Boardcordinates[20];
        areHorizontal = new bool[20];
        float z = -6.0f;
        float x;
        int   counter = 1;

        // Positions
        for (int i = 0; i < 9; i++)
        {
            x = -6.0f;
            for (int j = 0; j < 9; j++)
            {
                Instantiate(pos);
                pos.transform.position = new Vector3(x, 0.5f, z);
                pos.tag             = counter.ToString();
                PositionsTag [i, j] = counter.ToString();
                Positions [i, j]    = new Boardcordinates(x, z);
                counter++;
                x += 1.5f;
            }
            z += 1.5f;
        }

        z = -7.5f;
        x = -8.25f;
        // Blocks
        for (int i = 0; i < 11; i++)
        {
            Instantiate(block);
            block.transform.position = new Vector3(x, 0.5f, z);
            z += 1.5f;
        }
        z = -7.5f;
        x = 8.25f;
        for (int i = 0; i < 11; i++)
        {
            Instantiate(block);
            block.transform.position = new Vector3(x, 0.5f, z);
            z += 1.5f;
        }

        // Borders
        Instantiate(Border);
        Border.transform.position = new Vector3(-6.75f, 0.5f, 0.0f);
        Instantiate(Border);
        Border.transform.position = new Vector3(6.75f, 0.5f, 0.0f);

        z = -7.0f;
        for (int i = 0; i < 10; i++)
        {
            Instantiate(wall);
            wall.transform.position = new Vector3(x, 1.0f, z);
            wall.freezeRotation     = true;
            wall.tag = "Player1";
            z       += 1.5f;
        }

        // Walls
        x = -8.25f;
        z = -7.0f;
        for (int i = 0; i < 10; i++)
        {
            Instantiate(wall);
            wall.freezeRotation     = true;
            wall.transform.position = new Vector3(x, 1.0f, z);
            wall.tag = "Player2";
            z       += 1.5f;
        }
    }
Example #4
0
    public bool inRange(Boardcordinates a)
    {
        float result = Mathf.Pow(a.x - this.x, 2.0f) + Mathf.Pow(a.z - this.z, 2.0f);

        return(Mathf.Sqrt(result) <= 1.0f);
    }