Exemple #1
0
    void AddShit( BuilderGridTile tile, int category, int index )
    {
        if( category > 0 ) {

            if( tile.currentObject != null ) {
                RemoveShit( tile );
            }

            tile.currentObject = (Transform)Instantiate( GetPrefab( category, index ), tile.transform.position, Quaternion.identity );
            objectRecords.Add( Factory.BuildingObjectRecord( tile, category, index ) );

        } else {

            RemoveShit( tile );

        }
    }
Exemple #2
0
    void SetFloor( BuilderGridTile tile, int index )
    {
        if( tile.currentFloor != null ) {
            Destroy( tile.currentFloor.gameObject );
            tile.currentFloor = null;
        }

        tile.currentFloor = (Transform)Instantiate( floors[index], tile.transform.position, floors[index].rotation );
        tileFloors[ tile ] = index;
    }
Exemple #3
0
 public static BuildingObjectRecord BuildingObjectRecord( BuilderGridTile tile, int category, int index )
 {
     BuildingObjectRecord o = new BuildingObjectRecord {x = tile.x , y = tile.y , c = category , i = index};
     return o;
 }
Exemple #4
0
    void RemoveShit( BuilderGridTile tile )
    {
        objectRecords.RemoveAll( rec => rec.x == tile.x && rec.y == tile.y );

        if( tile.currentObject == null ) return;

        Destroy( tile.currentObject.gameObject );
        tile.currentObject = null;
    }
Exemple #5
0
    void OnTileMouseOver( BuilderGridTile tile )
    {
        if( Input.GetMouseButton( 0 ) ) {
            DoAction( tile, 0 );
        } else
        if( Input.GetMouseButton( 1 ) ) {
            DoAction( tile, 1 );
        } else if( Input.GetMouseButton( 2 ) ) {
            DoAction( tile , 2 );
        } else {

            const float DIST_MAX = 5;
            float dist;
            foreach( BuilderGridTile t in tiles ) {

                dist = Vector3.Distance( t.transform.position , tile.transform.position );

                if( dist >= DIST_MAX ) {
                    t.marker.renderer.enabled = false;
                    continue;
                }

                if( t == tile ) {
                    //t.marker.localScale = Vector3.one * 1.5f;
                    t.marker.localScale = Vector3.one;
                    continue;
                }

                t.marker.renderer.enabled = true;
                //t.marker.localScale = Vector3.one * ( 1 - ( dist / DIST_MAX ) );
                t.marker.localScale = Vector3.one * ( 1 - ( dist / DIST_MAX ) ) / 2;

            }

        }
    }
Exemple #6
0
 void OnTileMouseOut( BuilderGridTile tile )
 {
     foreach( BuilderGridTile t in tiles ) {
     }
 }
Exemple #7
0
 void OnTileClick( BuilderGridTile tile, int button )
 {
     DoAction( tile , button );
 }
Exemple #8
0
 //|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|
 //|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|
 void DoAction( BuilderGridTile tile, int action )
 {
     switch( action ) {
         case 0: AddShit( tile, currentCategory, currentIndex );
             break;
         case 1: RemoveShit( tile );
             break;
         case 2:
             SetFloor( tile, currentFloorIndex );
             break;
         default:
             return;
     }
 }