예제 #1
0
    public static CanAddr convertLatAddrToCanAddr(LatAddr lAddr)
    {
        CanAddr result = new CanAddr();
        LatAddr tmp = new LatAddr(lAddr);

        byte curTup = 0x00;
        int i = 0;

        while ((tmp.A != tmp.B || tmp.A != tmp.C) && (i < Config.TREE_DEPTH)) {
            curTup = (byte) ((tmp.A + (2 * tmp.B) + (4 * tmp.C)) % 7);
            curTup &= TUPLE_MASK;

            result.setTuple(curTup, i);

            tmp.A = tmp.A - ((curTup >> 0) & 0x01);
            tmp.B = tmp.B - ((curTup >> 1) & 0x01);
            tmp.C = tmp.C - ((curTup >> 2) & 0x01);

            int a = tmp.A;
            int b = tmp.B;
            int c = tmp.C;

            tmp.A = ((4*a)+b+(2*c))/7;
            tmp.B = ((2*a)+(4*b)+c)/7;
            tmp.C = (a+(2*b)+(4*c))/7;

            i++;
        }

        return result;
    }
예제 #2
0
	/* ******************
	 * 	TREEOBJ MEMBERS
	 * ******************/
	
	public override Tile getTile (CanAddr cAddr) {
		int childIndex = (int) cAddr.getTuple(this.aggLev - 1);

		if (children[childIndex] == null) {
			if (this.aggLev == 1) {
				children[childIndex] = new Tile (this, childIndex);
			}
			else { children[childIndex] = new Node(this, childIndex); }
		}
		return children[childIndex].getTile(cAddr);
	}
예제 #3
0
    // Use this for initialization
    void Start()
    {
        Tile t = SpaceTree.getTile(new CanAddr());
        t.curTemp = 300;

        //SpaceTree.setState(new CanAddr(), (byte) 0x02);

        CanAddr cAddr = new CanAddr();
        cAddr.setTuple (3, 3);

        //SpaceTree.setState(cAddr, 0x04);

        this.StartCoroutine(SimUpdate(0.1f));
    }
예제 #4
0
	public override void updateProperties (CanAddr cAddr) {
		
		int childIndex = (int) cAddr.getTuple(this.aggLev - 1);

		if (this.children [childIndex] != null) {
			this.children [childIndex].updateProperties (cAddr);
		}

		/*
		for (int i = 0; i < NUM_CHILDREN; i++) {
			if (children[i] != null) {
				children[i].updateProperties(cAddr);
			}
		}
		*/
	}
예제 #5
0
	public override void RegisterController (CanAddr cAddr, TileTypeController tTCont) {
		int childIndex = (int) cAddr.getTuple(this.aggLev - 1);

		if (children[childIndex] == null) {
			if (this.aggLev == 1) {
				this.children[childIndex] = new Tile (this, childIndex);
				this.children[childIndex].RegisterController(cAddr, tTCont);
			}
			else {
				this.children[childIndex] = new Node (this, childIndex);
				this.children[childIndex].RegisterController(cAddr, tTCont);
			}
		}
		else {
			children[childIndex].RegisterController(cAddr, tTCont);
		}
	}
예제 #6
0
	public override void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) {
		int childIndex = (int) cAddr.getTuple(this.aggLev - 1);

		if (children[childIndex] == null) {
			if (this.aggLev == 1) {
				this.children[childIndex] = new Tile (this, childIndex);
				this.children[childIndex].setState(cAddr, tileType, growthLevel);
			}
			else {
				this.children[childIndex] = new Node (this, childIndex);
				this.children[childIndex].setState(cAddr, tileType, growthLevel);
			}
		}
		else {
			children[childIndex].setState(cAddr, tileType, growthLevel);
		}
	}
예제 #7
0
파일: Node.cs 프로젝트: AShirtz/WildFireSim
    public override void setState(CanAddr cAddr, byte state)
    {
        int childIndex = (int) cAddr.getTuple(this.aggLev - 1);

        if (children[childIndex] == null) {
            if (this.aggLev == 1) {
                this.childState[childIndex] = state;
            }
            else {
                this.children[childIndex] = new Node (this, childIndex);
                this.children[childIndex].inheritState (this.childState[childIndex]);
                this.children[childIndex].setState(cAddr, state);
            }
        }
        else {
            children[childIndex].setState(cAddr, state);
        }
    }
예제 #8
0
	// TODO: ordering check
	public static LatAddr convertCanAddrToLatAddr (CanAddr cAddr) {
		LatAddr result = new LatAddr();
		LatAddr tmp = new LatAddr();

		for (int i = 0; i < Config.TREE_DEPTH; i++) {
			byte curTup = cAddr.getTuple(i);
			tmp.A = (curTup >> 0) & 0x01;
			tmp.B = (curTup >> 1) & 0x01;
			tmp.C = (curTup >> 2) & 0x01;

			for (int j = i; j > 0; j--) {
				BasisVectors.applyBMatrixToLatAddr(tmp);
			}

			result.A += tmp.A;
			result.B += tmp.B;
			result.C += tmp.C;
		}

		result.cleanUpLatAddr();
		return result;
	}
예제 #9
0
	public abstract void updateProperties (CanAddr cAddr);
예제 #10
0
 // Shallow Copy Constructor
 public CanAddr(CanAddr cAddr)
 {
     this.val = cAddr.val;
 }
예제 #11
0
	public override void RegisterController (CanAddr cAddr, TileTypeController tTCont) {
		this.tileCont = tTCont;
	}
예제 #12
0
	public override void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) {
		if (tileType == TileTypeController.TileType.TILE_BLANK 		||
		    tileType == TileTypeController.TileType.TILE_FLOWERS	||
		    tileType == TileTypeController.TileType.TILE_WEEDS 		||
		    tileType == TileTypeController.TileType.TILE_VINE 		||
		    tileType == TileTypeController.TileType.TILE_TREE) { 
			this.isActiveType = true;
		} else {
			this.isActiveType = false;
		}

		if (tileType != TileTypeController.TileType.TILE_VINE && this.tileType == TileTypeController.TileType.TILE_VINE) {
			this.tileType = tileType;
			this.presentVine.killChildren();
			this.presentVine = null;
		}

		if (this.tileType != TileTypeController.TileType.TILE_VINE && tileType == TileTypeController.TileType.TILE_VINE) {
			this.presentVine = new Vine ();
			this.presentVine.owningTile = this;
		}

		this.tileType = tileType;
		this.growthLevel = growthLevel;

		this.growthState = Tile.getGrowthStateForLevel (this.growthLevel);
		this.fillOutRef ();

		this.UpdateTileViz (this.tileCont);
	}
예제 #13
0
 public abstract void setState(CanAddr cAddr, byte state);
예제 #14
0
	public static Vector3 GridToWorld (CanAddr addr) {
		Vector2 tmp = LatAddr.convertLatAddrToVector (CanAddr.convertCanAddrToLatAddr(addr));
		Vector3 result = new Vector3 (tmp.y, 0, tmp.x);
		return (result * Config.WorldToGridScale);
	}
예제 #15
0
파일: Tile.cs 프로젝트: AShirtz/WildFireSim
 public override void setState(CanAddr cAddr, byte state)
 {
     this.state = state;
     this.prnt.notifyStateChange(this.addr.getTuple(this.aggLev), this.state);
 }
예제 #16
0
	public Tile getTile (CanAddr cAddr) {
		if (rootNode == null) { rootNode = new Node(); }
		return rootNode.getTile(cAddr);
	}
예제 #17
0
	public StateChangeEvent (CanAddr cAddr, byte state) {
		this.tileAddr = cAddr;
		this.state = state;
	}
예제 #18
0
	public override void updateProperties (CanAddr cAddr) {
		if (!this.isActiveType) {
			return;
		}
		this.updateGrowth ();
		this.AffectNeighbors ();
	}
예제 #19
0
	public void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) {
		if (rootNode == null) { rootNode = new Node(); }
		rootNode.setState(cAddr, tileType, growthLevel);
	}
예제 #20
0
	public abstract void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel);
예제 #21
0
파일: Tile.cs 프로젝트: AShirtz/WildFireSim
 /* ******************
  * 	TREEOBJ MEMBERS
  * ******************/
 public override Tile getTile(CanAddr cAddr)
 {
     return this;
 }
예제 #22
0
	public abstract void RegisterController (CanAddr cAddr, TileTypeController tTCont);
예제 #23
0
 public abstract Tile getTile(CanAddr cAddr);
예제 #24
0
 public static void setState(CanAddr cAddr, byte state)
 {
     if (rootNode == null) { rootNode = new Node(); }
     rootNode.setState(cAddr, state);
 }