コード例 #1
0
    private void CalculateTargetPosition()
    {
        SquareManager squareManager = SquareManager.instance;
        float         reserve       = StickersController.TileSize / 3;

        if (StickersController.Horizontal)
        {
            float minX = squareManager.TilesPositions[0, 0].x - reserve;
            float maxX = squareManager.TilesPositions[0, squareManager.Side - 1].x + reserve;

            if (targetPosition.x < minX)
            {
                targetPosition.x = minX;
            }
            if (targetPosition.x > maxX)
            {
                targetPosition.x = maxX;
            }
        }
        else
        {
            float minY = squareManager.TilesPositions[squareManager.Side - 1, 0].y - reserve;
            float maxY = squareManager.TilesPositions[0, 0].y + reserve;

            if (targetPosition.y < minY)
            {
                targetPosition.y = minY;
            }
            if (targetPosition.y > maxY)
            {
                targetPosition.y = maxY;
            }
        }
    }
コード例 #2
0
    public virtual void Rotate()
    {
        int rotationNum = 50;

        for (int i = 0; i < rotationNum; i++)
        {
            int rotationVar = Side == 3 ? 4 : 6;            // Number of possible rotations
            int rotation    = Random.Range(1, rotationVar + 1);

            switch (rotation)
            {
            case 1: Clockwise();
                break;

            case 2: AntiClockwise();
                break;

            case 3: Row();
                break;

            case 4: Column();
                break;

            case 5:
                LargeClockwise();
                break;

            case 6:
                LargeAntiClockwise();
                break;
            }
        }

        SquareManager.Rotation();
    }
コード例 #3
0
    public override void Rotate()
    {
        int rotationNum = 100;

        for (int i = 0; i < rotationNum; i++)
        {
            bool row      = Random.Range(0, 2) == 1;
            int  position = Random.Range(0, Side);      // Num of row/column to rotate
            int  offset   = Random.Range(1, Side);

            bool emptyCenter = (SquareManager as EmptySquareManager).emptyCenter;
            if (emptyCenter)
            {
                if (position == Side / 2)           // Can't rotate middle column and row
                {
                    continue;
                }
            }
            else
            {
                if (position == 1 || position == Side - 2)
                {
                    continue;
                }
            }

            RotateLine(row, position, offset);
        }

        SquareManager.Rotation();
    }
コード例 #4
0
 void Awake()
 {
     squares  = null;
     maxX     = 0;
     maxY     = 0;
     lg       = GetComponent <LevelGenerator>();
     instance = this;
 }
コード例 #5
0
ファイル: Square.cs プロジェクト: jaynerd8/Unity_RGBPY
    private void Start()
    {
        mainCam       = MainCam.Instance;
        squareManager = SquareManager.Instance;

        // getting spray particle components.
        spray          = transform.GetChild(0).gameObject;
        sprayParticles = spray.GetComponentsInChildren <ParticleSystem> ();
    }
コード例 #6
0
    void Start()
    {
        squareManager = SquareManager.instance;
        gameManager   = GameManager.instance;

        HasAngle     = false;
        AnimationRun = false;
        CanDrag      = true;
        Paused       = false;
    }
コード例 #7
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        SquareManager squareManager = (SquareManager)target;

        if (GUILayout.Button("New Square"))
        {
            squareManager.NewSquare();
        }
    }
コード例 #8
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         if (instance != this)
         {
             Destroy(gameObject);
         }
     }
 }
コード例 #9
0
    public virtual void Rotate()
    {
        int rotationNum = 50;

        for (int i = 0; i < rotationNum; i++)
        {
            bool row      = Random.Range(0, 2) == 1;
            int  position = Random.Range(0, Side);
            int  offset   = Random.Range(1, Side);

            RotateLine(row, position, offset);
        }

        SquareManager.Rotation();
    }
コード例 #10
0
ファイル: ArenaManager.cs プロジェクト: bpinzone/SnakeV2
    public void Cmd_RequestFood()
    {
        int  x     = 1;
        int  y     = 1;
        bool valid = false;

        while (!valid)
        {
            x = Random.Range(1, width - 2);
            y = Random.Range(1, height - 2);
            SquareManager sm = get_SM(x, y);
            valid = sm.isOpen() && x != 3;
        }
        SendFood(x, y);
    }
コード例 #11
0
        public CollisionManager()
        {
            sqrMan = new SquareManager();
            entsqrs = new RecycleArray<EntitySquares>(EntitySquares.CopyMethod, EntitySquares.CreateCopyMethod);
            entsqrs.SetDataMode(false);
            addedEntSqrTemp = new EntitySquares();
            addedECITemp = new EntityCollisionInfo();

            collideAgainstEnts = new List<Entity>();
            collideAgainstBlocks = new List<Block>();

            collideEntsInfo = new RecycleArray<EntityCollisionInfo>(EntityCollisionInfo.CopyMethod, EntityCollisionInfo.CreateCopyMethod);
            collideEntsInfo.SetDataMode(false);
            collideBlocksInfo = new RecycleArray<EntityCollisionInfo>(EntityCollisionInfo.CopyMethod, EntityCollisionInfo.CreateCopyMethod);
            collideBlocksInfo.SetDataMode(false);

            colliderList = new List<Collider>();
        }
コード例 #12
0
 void InitializeBoard()
 {
     BoardStateGO = new GameObject[BoardHeight, BoardWidth];
     for (int y = 0; y < BoardHeight; y++)
     {
         for (int x = 0; x < BoardWidth; x++)
         {
             //reverse y during this so output matches map generator
             int        yReverse   = (BoardHeight - y) - 1;
             GameObject GridSquare = Instantiate(Prefabs[BoardState[yReverse, x]], new Vector3((-4.6f + x) / 2, (-5f + y) / 2, 0f), Quaternion.identity);
             //this eventually needs cleaned up for resizing to board size and resolution
             SquareManager state = GridSquare.GetComponent <SquareManager>();
             state.GameState           = BoardState[yReverse, x];
             state.x                   = x;
             state.y                   = yReverse;
             BoardStateGO[yReverse, x] = GridSquare;
         }
     }
 }
コード例 #13
0
ファイル: ArenaManager.cs プロジェクト: bpinzone/SnakeV2
    public void Cmd_RequestClaim(int player, int x, int y)
    {
        Debug.Log("Player attempting claim " + x.ToString() + " " + y.ToString() + " for player " + player.ToString());

        SquareManager sm = get_SM(x, y);
        PlayerManager pm = players[player].GetComponent <PlayerManager>();

        if (sm.isDeath())
        {
            Debug.Log("Killing player" + player.ToString());
            Debug.Log("Death due to coordinate: " + x.ToString() + " " + y.ToString());
            Debug.Log("Finished setup is: " + finishedSetup.ToString());
            pm.Rpc_Die();
            return;
        }
        if (sm.isFood())
        {
            Debug.Log("Growing");
            pm.Rpc_Grow();
            Cmd_RequestFood();
        }
        SendClaim(player, x, y);
    }
コード例 #14
0
ファイル: SquareManager.cs プロジェクト: jaynerd8/Unity_RGBPY
 private void Awake()
 {
     Instance = this;
     squares  = GetComponentsInChildren <Square> ();
     Init();
 }
コード例 #15
0
ファイル: ArenaManager.cs プロジェクト: bpinzone/SnakeV2
    public void Rpc_ReceiveClaim(int player, Color c, int x, int y, int commandID)
    {
        SquareManager squareManager = get_SM(x, y);

        squareManager.makeClaim(player, c, commandID);
    }
コード例 #16
0
ファイル: ArenaManager.cs プロジェクト: bpinzone/SnakeV2
    public void Rpc_ReceiveFood(int x, int y, int commandID)
    {
        SquareManager squareManager = get_SM(x, y);

        squareManager.makeFood(commandID);
    }
コード例 #17
0
ファイル: ArenaManager.cs プロジェクト: bpinzone/SnakeV2
    // ==== HELPERS ===========
    private SquareManager get_SM(int x, int y)
    {
        SquareManager sm = squareData[x, y].square.GetComponent <SquareManager>();

        return(sm);
    }