コード例 #1
0
    override public void UpdateGridValue(GridBehaviour obj)
    {
        int divideAmt = 0;
        int curAmt    = 0;

        foreach (GameObject go in obj.couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();
            if (!lc.inUse)
            {
                continue;
            }

            if (!lc.isInput)
            {
                ++divideAmt;
            }
            else if (lc.isInput)
            {
                curAmt = lc.currentLine.value;
            }
        }

        // Check to avoid division by 0
        if (divideAmt > 0)
        {
            obj.data = new GridData(curAmt / divideAmt);
        }
        else
        {
            obj.data = new GridData(curAmt);
        }
    }
コード例 #2
0
 public BruschInfo(int xPos, int yPos, GridBehaviour grid, Color currentColor)
 {
     this.xPos         = xPos;
     this.yPos         = yPos;
     this.grid         = grid;
     this.currentColor = currentColor;
 }
コード例 #3
0
 void Awake()
 {
     grid     = GetComponentInParent <GridBehaviour> ();
     animator = GetComponent <Animator> ();
     x        = transform.position.x;
     y        = transform.position.y;
 }
コード例 #4
0
    override public void UpdateGridValue(GridBehaviour obj)
    {
        int minusFrom = 0;
        int minusAmt  = 0;

        foreach (GameObject go in obj.couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();
            if (!lc.inUse || !lc.isInput)
            {
                continue;
            }

            if (lc.currentLine.value > minusFrom)
            {
                minusAmt += minusFrom;
                minusFrom = lc.currentLine.value;
            }
            else
            {
                minusAmt += lc.currentLine.value;
            }
        }

        // Final minus amount cant go lower than 0
        int newVal = Mathf.Max(minusFrom - minusAmt, 0);

        obj.data = new GridData(newVal);
    }
コード例 #5
0
    void Start()
    {
        geometryBehaviour   = GameObject.Find("/3D/Geometry").GetComponent <GeometryBehaviour>();
        navigationBehaviour = GameObject.Find("/3D/Navigation").GetComponent <NavigationBehaviour>();
        gridBehaviour       = GameObject.Find("/3D/Grid").GetComponent <GridBehaviour>();
        coordinateBehaviour = GameObject.Find("/3D/Coordinate").GetComponent <CoordinateBehaviour>();

        geoCamera = GameObject.Find("/3D/GeoCamera").GetComponent <GeoCamera>();
        navCamera = GameObject.Find("/3D/NavCamera").GetComponent <NavCamera>();

        InitTouchSystem();
        InitView();
        InitUI();

        geoCamera.InitDefault();

        stateController = GetComponent <StateController>();
        stateController.Init(geoUI.statePanel);

        toolController = GetComponent <ToolController>();
        toolController.Init(geoUI.toolPanel);

        recognizeController = GetComponent <RecognizeController>();
        recognizeController.Init(geoUI.writingPanel);

        ClearGeometry();
    }
コード例 #6
0
    // Trace to the originating start block to set their used flag
    public void TraceToStartBlock()
    {
        foreach (GameObject couplerObj in couplers)
        {
            LineCoupler coupler = couplerObj.GetComponent <LineCoupler>();
            if (!coupler.inUse || !coupler.isInput)
            {
                continue;
            }

            // Take current line's starting couplers
            GridBehaviour originBlock = coupler.currentLine.lineCouplers[0].currentBlock.GetComponent <GridBehaviour>();

            // if it is a start block, set flag
            if (originBlock.overrideBlock == BLOCK.START)
            {
                originBlock.GetComponent <StartBlockScript>().SetInUse(true);
            }
            else
            {
                // if not then call trace to start block on that block
                originBlock.TraceToStartBlock();
            }
        }
    }
コード例 #7
0
    bool CheckGridForLegalBlock(GameObject gridObj)
    {
        if (gridObj == null)
        {
            return(false);
        }
        LineController lineC = gridObj.GetComponent <LineController>();
        GridBehaviour  gridB = gridObj.GetComponent <GridBehaviour>();

        return(lineC.currentLine == null && gridB.currentBlockType.blockType == BLOCK.EMPTY);
    }
コード例 #8
0
    public void MoveToPosition(GridBehaviour grid, Vector3 point)
    {
        Node boardNode = grid.NodeFromWorldPosition(point);

        pointer.transform.position = new Vector3(boardNode.worldPosition.x, boardNode.worldPosition.y + grid.pointerPosition, boardNode.worldPosition.z);
        _pointerAnimator.SetTrigger("Clicked");
        _character.Move(pointer.transform.position);

        // trigger event
        GameEvents.LevelEvents.Moved.SafeInvoke();
    }
コード例 #9
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            _grid = (GridBehaviour)target;

            if (GUILayout.Button("View Grid"))
            {
                _grid.DestroyTempPanelsInEditor();
                _grid.CreateGrid();
            }
        }
コード例 #10
0
ファイル: MasterBehaviour.cs プロジェクト: ldmcdona/TestGame
    void Start()
    {
        once   = true;
        outB.x = -26;
        outB.y = 12;
        outB.z = 0;

        turn            = 1;
        selected_ship   = null;
        selected_planet = null;

        spaces       = new Space[61];
        ships        = new ShipBehaviour[5];
        texts        = new TextBehaviour[5];
        planets      = new Planet[3];
        fleet        = new EnShip[2];
        productions  = new GameObject[3];
        prod_choices = new Dropdown[3];
        ddvalues     = new int[3];

        getShips();

        grid = transform.GetChild(1).gameObject.GetComponent <GridBehaviour>();

        et1 = transform.GetChild(2).gameObject.GetComponent <EndTurn>();

        getTexts();

        getPlanets();

        getDDMenus();

        getSpaces();

        highlight = transform.GetChild(6).gameObject;

        enSpawner = transform.GetChild(7).gameObject.GetComponent <Hostile>();

        arena = transform.GetChild(8).gameObject.GetComponent <BattleEnviro>();

        bank = transform.GetChild(9).gameObject.GetComponent <Resources>();

        cam = transform.GetChild(10).gameObject;

        ships[0].setPrev(spaces[1]);
        ships[1].setPrev(spaces[40]);
        planets[0].movement(spaces[11]);
        planets[1].movement(spaces[23]);
        planets[2].movement(spaces[58]);

        Select();
    }
コード例 #11
0
    void spawn(GameObject prefab)
    {
        // will try to find a random position 10 times that it can spawn the item in
        // Otherwise it will return and not spawn the item

        GridBehaviour gridPrefab = prefab.GetComponent <GridBehaviour> ();

        // try this ten times
        for (int i = 0; i < 10; i++)
        {
            // choose the random cell
            int  potential = UnityEngine.Random.Range(0, gameSize);
            bool good      = true;

            // check if those cells are good
            for (int x = 0; x < gridPrefab.size; x++)
            {
                // not enough space anyways
                if (potential + x > gameSize - 1)
                {
                    good = false;
                    break;
                }

                // There is enough space, lets see if it works!
                if (cells [potential + x].occupied)
                {
                    good = false;
                    break;
                }
            }

            if (good)
            {
                // spawn
                GameObject spawned = Instantiate(prefab);

                for (int x = 0; x < gridPrefab.size; x++)
                {
                    cells [potential + x].occupied = true;
                    cells [potential + x].setObject(spawned.GetComponent <GridBehaviour>());
                }

                spawned.transform.position  = transform.position;
                spawned.transform.position += new Vector3(potential, 0, 0);
                spawned.GetComponent <GridBehaviour> ().xPos = potential;
                // Debug.Log ("RETURN");
                return;
            }
        }
    }
コード例 #12
0
    bool CheckLegalConnect()
    {
        bool success = true;
        Line curLine = lineMan.currentLineBeingDrawn;

        if (curLine == currentLine)
        {
            return(false);
        }

        GridBehaviour gridB = GetComponentInParent <GridBehaviour>();

        if (!curLine.CanConnect() ||
            curLine.lineCouplers.Contains(this) ||
            gridB.currentBlockType.blockType == BLOCK.START ||
            gridB.IsLineExisting(curLine))
        {
            success = false;
        }
        else
        {
            List <LineController> linePath = curLine.linePath;
            int[] thisCoord = gridB.coordinates;
            int[] prevCoord;

            if (curLine.linePath.Count == 0)
            {
                prevCoord = curLine.lineCouplers[0].GetComponentInParent <GridBehaviour>().coordinates;
            }
            else
            {
                prevCoord = linePath[linePath.Count - 1].GetComponentInParent <GridBehaviour>().coordinates;
            }

            int xDiff = Mathf.Abs(thisCoord[0] - prevCoord[0]);
            int yDiff = Mathf.Abs(thisCoord[1] - prevCoord[1]);

            if (!CheckLegalDirection(xDiff, yDiff))
            {
                success = false;
            }
        }

        if (!success)
        {
            gridMan.UpdateIllegalBlock(transform.position);
        }

        return(success);
    }
コード例 #13
0
    override public void UpdateGridValue(GridBehaviour obj)
    {
        int finalVal = 0;

        foreach (GameObject go in obj.couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();
            if (!lc.inUse || !lc.isInput)
            {
                continue;
            }

            finalVal += lc.currentLine.value;
        }
        obj.data = new GridData(finalVal);
    }
コード例 #14
0
    //Initialize Grid
    void Awake()
    {
        //Set Singleton
        instance = this;

        //Settings
        draw_debug = true;
        grid_width = Mathf.RoundToInt(grid_size.x / node_dia);
        grid_hight = Mathf.RoundToInt(grid_size.y / node_dia);
        grid       = new Node[grid_width, grid_hight];

        createGrid();
        if (node_outline != 0)
        {
            filterGrid();
        }
    }
コード例 #15
0
    //private Color lineCol;

    // Use this for initialization
    void Start()
    {
        inUse        = false;
        isInput      = false;
        currentLine  = null;
        currentBlock = GetComponentsInParent <Transform>()[1].gameObject;

        lineMan = GameObject.Find("LineManager").GetComponent <LineManager>();
        gridMan = GameObject.Find("GridManager").GetComponent <GridManager>();
        gridB   = GetComponentInParent <GridBehaviour>();

        // Set animation data
        couplerParticles = GetComponentInChildren <ParticleSystem>();
        //UpdateCouplerColor();
        var psMain = couplerParticles.main;

        psMain.startSize = transform.localScale.x * 2.75f;
    }
コード例 #16
0
    override public void UpdateGridValue(GridBehaviour obj)
    {
        // Look for input lines
        foreach (GameObject go in obj.couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();
            if (!lc.inUse || !lc.isInput)
            {
                continue;
            }
            obj.data = new GridData(lc.currentLine.value);
            obj.GetComponent <EndBlockScript>().UpdateEndStatus(obj.data.value);
            return;
        }

        // If no input was found
        obj.GetComponent <EndBlockScript>().SetNoInput();
    }
コード例 #17
0
    void GenerateBlocks(NodeBlock[] blocks, GameObject obj, List <GameObject> objs)
    {
        GridManager gridMan       = GetComponent <GridManager>();
        Vector2     gridBlockSize = gridMan.gridBlockSize;
        float       spacing       = gridMan.spacing;
        int         halfGridX     = gridMan.gridSizeX / 2;
        int         halfGridY     = gridMan.gridSizeY / 2;
        int         xOffset       = gridMan.gridSizeX % 2;
        int         yOffset       = gridMan.gridSizeY % 2;
        float       posOffsetX    = xOffset == 0 ? gridBlockSize.x : 0;
        float       posOffsetY    = yOffset == 0 ? gridBlockSize.y : 0;

        for (int i = 0; i < blocks.Length; ++i)
        {
            Vector3 instPos = new Vector3((-halfGridX + blocks[i].pos.x) * (gridBlockSize.x + spacing) + posOffsetX,
                                          (-halfGridY + blocks[i].pos.y) * (gridBlockSize.y + spacing) + posOffsetY, 0.0f);
            instPos += transform.position; // Add position of obj to offset entire grid

            GameObject curGridBlock = Instantiate(obj, instPos, Quaternion.identity);
            curGridBlock.transform.localScale = new Vector3(gridBlockSize.x, gridBlockSize.y, 1.0f);

            // Add grid coordinates
            curGridBlock.GetComponent <GridBehaviour>().coordinates = new int[2] {
                (int)blocks[i].pos.x, (int)blocks[i].pos.y
            };

            // Update GameManager
            if ((int)blocks[i].pos.x >= 0 && (int)blocks[i].pos.x < gridMan.gridSizeX &&
                (int)blocks[i].pos.y >= 0 && (int)blocks[i].pos.y < gridMan.gridSizeY)
            {
                GameManager.Instance.grid[(int)blocks[i].pos.x][(int)blocks[i].pos.y] = curGridBlock;
            }

            GridBehaviour gridScript = curGridBlock.GetComponent <GridBehaviour>();
            if (gridScript)
            {
                gridScript.SetValue(blocks[i].value, true);
            }

            // Initialize list of blocks
            objs.Add(curGridBlock);
        }
    }
コード例 #18
0
    override public void UpdateGridValue(GridBehaviour obj)
    {
        bool anyInput = false;
        int  finalVal = 1;

        foreach (GameObject go in obj.couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();
            if (!lc.inUse || !lc.isInput)
            {
                continue;
            }
            anyInput = true;

            finalVal *= lc.currentLine.value;
        }

        // Set the value to 0 if there are no inputs
        if (anyInput == false)
        {
            finalVal = 0;
        }
        obj.data = new GridData(finalVal);
    }
コード例 #19
0
    // Start is called before the first frame update
    void Start()
    {
        pLog     = new List <Planet> {
        };
        turn     = 1;
        view     = true;
        autoS    = false;
        outB.x   = 13.6f;
        outB.y   = 23f;
        outB.z   = -1f;
        normal.x = 8f;
        normal.y = 25.3f;
        normal.z = market.z = solar.z = -10f;
        market.x = -175f;
        market.y = solar.y = 32f;
        solar.x  = -358.2f;

        grid      = transform.GetChild(0).gameObject.GetComponent <GridBehaviour>();
        highlight = transform.GetChild(1).gameObject;
        inv       = transform.GetChild(2).gameObject.GetComponent <Resources>();

        UIs = new GameObject[6]; //In order these are: SideBar, SBCanvas, ScanUI, MarketUI, SolarUI, EndUI

        UIs[0]   = transform.GetChild(3).gameObject;
        UIs[1]   = transform.GetChild(4).gameObject;
        sideText = UIs[1].transform.GetChild(0).gameObject.GetComponent <Text>();
        turnText = UIs[1].transform.GetChild(1).gameObject.GetComponent <Text>();
        UIs[2]   = transform.GetChild(5).gameObject;
        UIs[2].SetActive(false);
        temp       = UIs[2].transform.GetChild(0).gameObject;
        scanButton = temp.GetComponent <Button>();
        scanButton.onClick.AddListener(scan);
        cam          = transform.GetChild(6).gameObject;
        temp         = cam.transform.GetChild(0).gameObject;
        topText      = temp.transform.GetChild(0).gameObject.GetComponent <Text>();
        upkeepText   = temp.transform.GetChild(1).gameObject.GetComponent <Text>();
        UIs[3]       = cam.transform.GetChild(2).gameObject;
        temp         = UIs[3].transform.GetChild(0).gameObject;
        marketButton = temp.GetComponent <Button>();
        marketButton.onClick.AddListener(marketView);
        temp        = temp.transform.GetChild(0).gameObject;
        MBtx        = temp.GetComponent <Text>();
        UIs[4]      = cam.transform.GetChild(3).gameObject;
        temp        = UIs[4].transform.GetChild(0).gameObject;
        solarButton = temp.GetComponent <Button>();
        solarButton.onClick.AddListener(solarView);
        temp = temp.transform.GetChild(0).gameObject;
        SVtx = temp.GetComponent <Text>();
        UIs[4].SetActive(false);

        //Alright, this is setting up listeners for the market.
        temp = transform.GetChild(7).gameObject;      //Market
        temp = temp.transform.GetChild(1).gameObject; //Canvas
        temp = temp.transform.GetChild(0).gameObject; //Buy
        for (int i = 0; i < 5; i++)
        {
            GameObject temp2;
            temp2 = temp.transform.GetChild(i).gameObject;
            btemp = temp2.GetComponent <Button>();
            btemp.onClick.AddListener(delegate { transaction(temp2.name); });
        }
        temp = transform.GetChild(7).gameObject;      //Market
        temp = temp.transform.GetChild(1).gameObject; //Canvas
        temp = temp.transform.GetChild(1).gameObject; //Sell
        for (int i = 0; i < 8; i++)
        {
            GameObject temp2;
            temp2 = temp.transform.GetChild(i).gameObject;
            btemp = temp2.GetComponent <Button>();
            btemp.onClick.AddListener(delegate { transaction(temp2.name); });
        }

        temp  = transform.GetChild(7).gameObject;      //Market
        temp  = temp.transform.GetChild(1).gameObject; //Canvas
        btemp = temp.transform.GetChild(2).gameObject.GetComponent <Button>();
        btemp.onClick.AddListener(cashOut);
        btemp = temp.transform.GetChild(3).gameObject.GetComponent <Button>();
        btemp.onClick.AddListener(AutoSell);

        col = transform.GetChild(8).gameObject.GetComponent <Colonizer>();

        UIs[5]     = temp = transform.GetChild(9).gameObject;
        turnButton = temp.transform.GetChild(0).gameObject.GetComponent <Button>();
        turnButton.onClick.AddListener(endTurn);
    }
コード例 #20
0
 void Awake()
 {
     gridManager = FindObjectOfType <GridBehaviour>();
     speed       = 15;
 }
コード例 #21
0
 private void Awake()
 {
     requestManager = GetComponent <PathRequestManager>();
     grid           = GetComponent <GridBehaviour>();
 }
コード例 #22
0
ファイル: GridBehaviour.cs プロジェクト: YanJardim/GGJ-2016
    void Awake()
    {
        instance = this;

    }
コード例 #23
0
 //Initialize Singleton Grid
 void Awake()
 {
     grid = GridBehaviour.instance;
 }
コード例 #24
0
ファイル: Colonizer.cs プロジェクト: ldmcdona/ColonyCorp
    public void colonize(Resources inv, Planet selected, Text top, GameObject display, GridBehaviour grid, int a, int b, List <Planet> pLog, Display bob)
    {
        GameObject     cbuObj, canv, buildObj; //spare;
        Text           buttonText, infoText;   //costText, modText; //modText isn't used yet because colony level doesn't affect upkeep yet.
        Dropdown       pdd;
        SpriteRenderer psr;

        canv = display.transform.GetChild(0).gameObject;
        psr  = display.transform.GetChild(1).gameObject.GetComponent <SpriteRenderer>();

        infoText = canv.transform.GetChild(2).gameObject.GetComponent <Text>();
        //costText = canv.transform.GetChild(3).gameObject.GetComponent<Text>();
        cbuObj   = canv.transform.GetChild(3).gameObject;
        buildObj = canv.transform.GetChild(0).gameObject;

        //spare = canv.transform.GetChild(7).gameObject;
        //modText = spare.transform.GetChild(5).gameObject.GetComponent<Text>(); //Eventually want this to be done for-loop style like in Master.

        buttonText = cbuObj.transform.GetChild(0).gameObject.GetComponent <Text>();
        pdd        = buildObj.transform.GetChild(1).gameObject.GetComponent <Dropdown>();

        if (!selected.colony)
        {
            if (inv.canAfford(selected.getCost()))
            {
                selected.colony = true;
                grid.distances(a, b);
                inv.Spend(selected.getCost());
                selected.levelUp();
                top.text = inv.getInfo();
                //setDD(selected, pdd);
                Color tempC = new Color(0.3f, 0.1f, 0.1f);
                selected.pColor = tempC;
                psr.color       = tempC;
                buttonText.text = "Upgrade";
                buildObj.SetActive(true); //here
                //costText.text = selected.getCostDisplay();
                pLog.Add(selected);
                bob.neoGenesis(selected.getProd(), 1);
                bob.genesis(selected.getUpke(), 2);
                if (!selected.maxed)
                {
                    bob.genesis(selected.getCost(), 3);
                }
                int[] toll;
                toll = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 100 };
                bob.buildingGenesis(toll);
            }
        }
        else
        {
            if (inv.canAfford(selected.getCost()))
            {
                inv.Spend(selected.getCost());
                selected.levelUp();
                top.text = inv.getInfo();
                int[] upkeep = selected.getUpke();
                //modText.text = "$: " + upkeep[5];
                infoText.text = selected.getInfo();
                Color tempC = new Color(0.3f, (0.1f * selected.level), 0.1f);
                selected.pColor = tempC;
                psr.color       = tempC;
                //setDD(selected, pdd);
                //costText.text = selected.getCostDisplay();
                if (selected.maxed)
                {
                    cbuObj.SetActive(false);
                    //costText.text = "Colony Level Maxed";
                }
                bob.neoGenesis(selected.getProd(), 1);
                bob.genesis(selected.getUpke(), 2);
                if (!selected.maxed)
                {
                    bob.genesis(selected.getCost(), 3);
                }
            }
        }
    }
コード例 #25
0
 public void setObject(GridBehaviour obj)
 {
     this.obj = obj;
 }
コード例 #26
0
 void Awake()
 {
     CurrentColor  = Color.white;
     grid          = FindObjectOfType <GridBehaviour>();
     currentBrusch = new StandardBrusch();
 }
コード例 #27
0
 void Start()
 {
     grid = FindObjectOfType <GridBehaviour>();
 }
コード例 #28
0
 override public void UpdateGridValue(GridBehaviour obj)
 {
 }
コード例 #29
0
 virtual public void UpdateGridValue(GridBehaviour obj)
 {
 }
コード例 #30
0
 void SetGrid()
 {
     grid = (GridBehaviour)FindObjectOfType(typeof(GridBehaviour));
 }