Ejemplo n.º 1
0
    /// <summary>
    /// Finds all the RadialBuyMenuButtons attached to children and stores
    /// the reference in the approriate slot.
    /// </summary>
    private void GetChildButtons()
    {
        GameObject tempChild;


        // Loop through childNames for each name
        for (int i = 0; i < childNames.Length; i++)
        {
            if (transform.Find(childNames[i]) == null)
            {
                // Ignore this one
                continue;
            }
            tempChild = (transform.Find(childNames [i])).gameObject;

            if (tempChild != null)
            {
                // This child exists! Set the correct *Button
                RadialBuyMenuButton tempButt = tempChild.GetComponent <RadialBuyMenuButton>();
                // Sanity check
                if (tempButt == null)
                {
                    // ignore
                    continue;
                }
                switch (i)
                {
                case 0:
                    topButton = tempButt;
                    break;

                case 1:
                    rightButton = tempButt;
                    break;

                case 2:
                    bottomButton = tempButt;
                    break;

                case 3:
                    leftButton = tempButt;
                    break;
                }

                // Now assign the UnitInfo's
                tempButt.AssignUnit(teamBuyList [i]);
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        // Are we still holding down the mouse button?
        if (Input.GetMouseButton(0))
        {
            // What's the change in the mouse position between frames?
            Vector2 mouseDelta = (Vector2)(Input.mousePosition) - oldMousePos;
            oldMousePos = Input.mousePosition;

            // Add the change
            curGesture += mouseDelta;

            // Is the gesture big enough to make a change?
            if (curGesture.magnitude > gestureMagnitude)
            {
                // Update the selection
                UpdateSelection();
            }

            return;
        }
        // We're not holding down a button, close up shop
        // Revert back to the old timeScale
        Time.timeScale = oldTimeScale;

        // Make the cursor visible
        Cursor.visible = true;

        // Tell the spawner what unit we're trying to spawn
        RadialBuyMenuButton selected = EventSystem.current.currentSelectedGameObject.GetComponent <RadialBuyMenuButton> ();

        // Make sure our selection is valid
        if (selected != null)
        {
            UnitInfo spawnThis = selected.getUnit();
            teamTeamSpawnerSpawner.SpawnUnit(SpawnThere, spawnThis);
        }


        // Finally, destroy the object if we're done
        Destroy(gameObject);
    }