Ejemplo n.º 1
0
    //protected = child can access, virtual = child can override if wanted
    protected virtual void powerNeighbour(int dir, int tileIndex)
    {
        //is there a tile there?
        GameObject curTile = GC.tiles[tileIndex];

        if (curTile != null)
        {
            //can it get an input?
            InputBasedTile inputTile = curTile.GetComponent <InputBasedTile>();
            if (inputTile != null)
            {
                //can it get input this way?
                int negDir = negDirection(dir);
                if (inputTile.possibleInputs.Contains(negDir))
                {
                    if (output[dir] == 1)
                    {
                        if (!inputTile.currentInputs.Contains(negDir))
                        {
                            inputTile.currentInputs.Add(negDir);
                        }
                        inputTile.needUpdatePower    = true;
                        inputTile.exludeSendPowerDir = -1;
                    }
                    else
                    {
                        inputTile.currentInputs.Remove(negDir);
                        inputTile.needUpdatePower    = true;
                        inputTile.exludeSendPowerDir = negDir;
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void powerNeighbour(int dir, int tileIndex)
    {
        //do we already get power from this dir?
        //if (!currentInputs.Contains(dir))
        {
            //is there a tile there?
            GameObject curTile = GC.tiles[tileIndex];
            if (curTile != null)
            {
                //can it get an input?
                InputBasedTile inputTile = curTile.GetComponent <InputBasedTile>();
                if (inputTile != null)
                {
                    //can it get input this way?
                    int negDir = negDirection(dir);
                    if (inputTile.possibleInputs.Contains(negDir))
                    {
                        //print("This tile should update: " + inputTile.spotIndex + " -from " + spotIndex);
                        if (output[dir] == 1) //send power
                        {
                            //if (!inputTile.beingPowered)
                            {
                                //print("Updating neighbour! I AM powered, but neighbour isnt");
                                if (!inputTile.currentInputs.Contains(negDir))
                                {
                                    inputTile.currentInputs.Add(negDir);
                                }
                                inputTile.needUpdatePower    = true;
                                inputTile.exludeSendPowerDir = negDir;
                            }
                        }
                        else //if(pokedFromDir != dir)
                        {
                            //if (inputTile.beingPowered)
                            {
                                //print("Updating neighbour! I (" + spotIndex + ") am NOT powered, but neighbour is");
                                inputTile.currentInputs.Remove(negDir);
                                inputTile.needUpdatePower    = true;
                                inputTile.exludeSendPowerDir = negDir;
                            }
                            //inputTile.pokedFromDir = negDir;
                        }

                        /*
                         * else
                         * {
                         *  inputTile.pokedFromDir = -1;
                         *  pokedFromDir = -1;
                         * }*/
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    //public int pokedFromDir = -1;

    protected void checkNeighbour(int dir)  //new
    {
        GameObject go = neighbours[dir];

        if (go != null)
        {
            InputBasedTile inputTile = go.GetComponent <InputBasedTile>();
            if (inputTile != null)
            {
                //print("Updating neighbour: " + inputTile.spotIndex);
                inputTile.needUpdatePower    = true;
                inputTile.exludeSendPowerDir = -1;
            }
        }
    }